mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-09-14 00:11:01 +03:00
Synchronize custom-scrollbar cursor geometry after relayout
This commit is contained in:
@@ -1173,7 +1173,7 @@ class _ImagePaintState extends State<ImagePaint> {
|
||||
child: child);
|
||||
});
|
||||
if (c.imageOverflow.isTrue && c.scrollStyle != ScrollStyle.scrollauto) {
|
||||
_syncEdgeScrollAfterLayout(c);
|
||||
_syncScrollAfterLayout(c);
|
||||
final paintWidth = c.getDisplayWidth() * s;
|
||||
final paintHeight = c.getDisplayHeight() * s;
|
||||
final paintSize = Size(paintWidth, paintHeight);
|
||||
@@ -1218,13 +1218,15 @@ class _ImagePaintState extends State<ImagePaint> {
|
||||
}
|
||||
}
|
||||
|
||||
void _syncEdgeScrollAfterLayout(CanvasModel canvas) {
|
||||
if (canvas.scrollStyle != ScrollStyle.scrolledge) return;
|
||||
void _syncScrollAfterLayout(CanvasModel canvas) {
|
||||
// Custom scrollbars also paint from scroll fractions; preserve Original's path.
|
||||
if (canvas.scrollStyle != ScrollStyle.scrolledge &&
|
||||
canvas.viewStyle.style != kRemoteViewStyleCustom) return;
|
||||
final renderedScroll = (canvas.scrollX, canvas.scrollY);
|
||||
// Relayout can clamp or detach scroll positions without a scroll event.
|
||||
SchedulerBinding.instance.addPostFrameCallback((_) {
|
||||
if (!mounted) return;
|
||||
canvas.updateEdgeScrollAfterLayout(renderedScroll);
|
||||
canvas.updateScrollAfterLayout(renderedScroll);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -2702,7 +2702,7 @@ class CanvasModel with ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void updateEdgeScrollAfterLayout((double, double) renderedScroll) {
|
||||
void updateScrollAfterLayout((double, double) renderedScroll) {
|
||||
updateScrollPercent();
|
||||
// A delayed refresh may already have changed the model without repainting.
|
||||
if (renderedScroll != (_scrollX, _scrollY)) {
|
||||
|
||||
@@ -47,7 +47,7 @@ class _Texture extends Fake implements TextureModel {
|
||||
}
|
||||
|
||||
class _ScrollCanvas extends CanvasModel {
|
||||
_ScrollCanvas(FFI ffi, String style)
|
||||
_ScrollCanvas(FFI ffi, String style, this.scrollStyle)
|
||||
: viewStyle = ViewStyle(
|
||||
style: style,
|
||||
width: _viewport.width,
|
||||
@@ -69,7 +69,7 @@ class _ScrollCanvas extends CanvasModel {
|
||||
@override
|
||||
double get y => (size.height - getDisplayHeight() * scale) / 2;
|
||||
@override
|
||||
ScrollStyle get scrollStyle => ScrollStyle.scrolledge;
|
||||
final ScrollStyle scrollStyle;
|
||||
@override
|
||||
final ViewStyle viewStyle;
|
||||
|
||||
@@ -100,10 +100,10 @@ class _Cursor extends CursorModel {
|
||||
|
||||
class _FFI extends Fake implements FFI {
|
||||
_FFI(ui.Image frame, ui.Image cursor,
|
||||
{required bool texture, required String style, required Offset position})
|
||||
{required bool texture, required (String, ScrollStyle) style, required Offset position})
|
||||
: ffiModel = _Peer(frame) {
|
||||
imageModel = _Image(this, frame, texture);
|
||||
canvasModel = _ScrollCanvas(this, style);
|
||||
canvasModel = _ScrollCanvas(this, style.$1, style.$2);
|
||||
cursorModel = _Cursor(this, cursor, position);
|
||||
}
|
||||
@override
|
||||
@@ -131,7 +131,9 @@ class _Draw extends Fake implements Canvas {
|
||||
}
|
||||
|
||||
void main() {
|
||||
for (final style in [kRemoteViewStyleOriginal, kRemoteViewStyleCustom]) {
|
||||
for (final style in [(kRemoteViewStyleOriginal, ScrollStyle.scrolledge),
|
||||
(kRemoteViewStyleCustom, ScrollStyle.scrolledge),
|
||||
(kRemoteViewStyleCustom, ScrollStyle.scrollbar)]) {
|
||||
for (final texture in [false, true]) {
|
||||
for (final (frame, dpr) in [
|
||||
(const Size(199, 320), 1.0),
|
||||
@@ -140,13 +142,13 @@ void main() {
|
||||
(const Size(400, 158), 1.0),
|
||||
]) {
|
||||
testWidgets(
|
||||
'ScrollEdge $style texture=$texture frame=$frame DPR=$dpr',
|
||||
'Scroll $style texture=$texture frame=$frame DPR=$dpr',
|
||||
(tester) => tester
|
||||
.runAsync(() => _check(tester, (style, texture, frame, dpr))));
|
||||
}
|
||||
for (final refreshBeforeLayout in [true, false]) {
|
||||
testWidgets(
|
||||
'ScrollEdge relayout $style texture=$texture early=$refreshBeforeLayout',
|
||||
'Scroll relayout $style texture=$texture early=$refreshBeforeLayout',
|
||||
(tester) => tester.runAsync(() =>
|
||||
_checkRelayout(tester, (style, texture, refreshBeforeLayout))));
|
||||
}
|
||||
@@ -155,7 +157,7 @@ void main() {
|
||||
}
|
||||
|
||||
Future<void> _check(
|
||||
WidgetTester tester, (String, bool, Size, double) testCase) async {
|
||||
WidgetTester tester, ((String, ScrollStyle), bool, Size, double) testCase) async {
|
||||
final (style, texture, frame, dpr) = testCase;
|
||||
tester.view.devicePixelRatio = dpr;
|
||||
tester.view.physicalSize = _viewport * dpr;
|
||||
@@ -195,7 +197,7 @@ Future<void> _check(
|
||||
}
|
||||
|
||||
Future<void> _checkRelayout(
|
||||
WidgetTester tester, (String, bool, bool) testCase) async {
|
||||
WidgetTester tester, ((String, ScrollStyle), bool, bool) testCase) async {
|
||||
final (style, texture, refreshBeforeLayout) = testCase;
|
||||
tester.view.devicePixelRatio = 1;
|
||||
tester.view.physicalSize = _viewport;
|
||||
|
||||
Reference in New Issue
Block a user