refact canvas position and size

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou
2023-02-28 14:50:51 +08:00
parent 6a97608b98
commit 8703d23277
3 changed files with 23 additions and 20 deletions

View File

@@ -459,8 +459,8 @@ class InputModel {
}
evt['type'] = type;
if (isDesktop) {
y = y - stateGlobal.tabBarHeight - stateGlobal.windowBorderWidth.value;
x -= stateGlobal.windowBorderWidth.value;
y -= CanvasModel.topToEdge;
x -= CanvasModel.leftToEdge;
}
final canvasModel = parent.target!.canvasModel;
final nearThr = 3;

View File

@@ -727,19 +727,21 @@ class CanvasModel with ChangeNotifier {
double get scrollX => _scrollX;
double get scrollY => _scrollY;
static double get leftToEdge =>
windowBorderWidth + kDragToResizeAreaPadding.left;
static double get rightToEdge =>
windowBorderWidth + kDragToResizeAreaPadding.right;
static double get topToEdge =>
tabBarHeight + windowBorderWidth + kDragToResizeAreaPadding.top;
static double get bottomToEdge =>
windowBorderWidth + kDragToResizeAreaPadding.bottom;
updateViewStyle() async {
Size getSize() {
final size = MediaQueryData.fromWindow(ui.window).size;
// If minimized, w or h may be negative here.
double w = size.width -
windowBorderWidth * 2 -
kDragToResizeAreaPadding.left -
kDragToResizeAreaPadding.right;
double h = size.height -
tabBarHeight -
windowBorderWidth * 2 -
kDragToResizeAreaPadding.top -
kDragToResizeAreaPadding.bottom;
double w = size.width - leftToEdge - rightToEdge;
double h = size.height - topToEdge - bottomToEdge;
return Size(w < 0 ? 0 : w, h < 0 ? 0 : h);
}
@@ -813,8 +815,8 @@ class CanvasModel with ChangeNotifier {
return parent.target?.ffiModel.display.height ?? defaultHeight;
}
double get windowBorderWidth => stateGlobal.windowBorderWidth.value;
double get tabBarHeight => stateGlobal.tabBarHeight;
static double get windowBorderWidth => stateGlobal.windowBorderWidth.value;
static double get tabBarHeight => stateGlobal.tabBarHeight;
moveDesktopMouse(double x, double y) {
if (size.width == 0 || size.height == 0) {