flutter_desktop: scroll, mid commit

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou
2022-08-11 00:12:47 +08:00
parent 33f5d9a4f3
commit 4e4f837160
4 changed files with 262 additions and 189 deletions

View File

@@ -432,22 +432,27 @@ class ImageModel with ChangeNotifier {
}
}
enum ScrollStyle {
scrollbar,
scrollmouse,
}
class CanvasModel with ChangeNotifier {
double _x = 0;
double _y = 0;
double _scale = 1.0;
double _tabBarHeight = 0.0;
String id = ""; // TODO multi canvas model
ScrollStyle _scrollStyle = ScrollStyle.scrollbar;
WeakReference<FFI> parent;
CanvasModel(this.parent);
double get x => _x;
double get y => _y;
double get scale => _scale;
ScrollStyle get scrollStyle => _scrollStyle;
set tabBarHeight(double h) => _tabBarHeight = h;
double get tabBarHeight => _tabBarHeight;
@@ -497,6 +502,16 @@ class CanvasModel with ChangeNotifier {
notifyListeners();
}
void updateScrollStyle() async {
final s = await bind.getSessionOption(id: id, arg: 'scroll-style');
if (s == 'scrollmouse') {
_scrollStyle = ScrollStyle.scrollmouse;
} else {
_scrollStyle = ScrollStyle.scrollbar;
}
notifyListeners();
}
void update(double x, double y, double scale) {
_x = x;
_y = y;