From bf9f438d0f3067cb5f0b6e63670d9585ef034901 Mon Sep 17 00:00:00 2001 From: Vadim Lopatin Date: Fri, 27 Mar 2015 14:08:40 +0300 Subject: [PATCH] fix layout problems --- examples/example1/example1.visualdproj | 2 +- src/dlangui/core/events.d | 7 +++++++ src/dlangui/platforms/windows/winapp.d | 10 ++++++++++ src/dlangui/widgets/layouts.d | 22 +++++++++++----------- 4 files changed, 29 insertions(+), 12 deletions(-) diff --git a/examples/example1/example1.visualdproj b/examples/example1/example1.visualdproj index 9d810003..5430f72a 100644 --- a/examples/example1/example1.visualdproj +++ b/examples/example1/example1.visualdproj @@ -72,7 +72,7 @@ 0 0 - Unicode USE_FREETYPE USE_SDL USE_OPENGL + Unicode USE_FREETYPE USE_OPENGL 0 3 0 diff --git a/src/dlangui/core/events.d b/src/dlangui/core/events.d index 7fc8cf20..2bec74b0 100644 --- a/src/dlangui/core/events.d +++ b/src/dlangui/core/events.d @@ -505,6 +505,13 @@ struct ButtonDetails { static final long DOUBLE_CLICK_THRESHOLD_MS = 200; + + void reset() { + _downTs = _upTs = 0; + _downFlags = 0; + _downX = _downY = 0; + } + /// update for button down void down(short x, short y, ushort flags) { //Log.d("Button down ", x, ",", y, " _downTs=", _downTs, " _upTs=", _upTs); diff --git a/src/dlangui/platforms/windows/winapp.d b/src/dlangui/platforms/windows/winapp.d index 8f7036ec..f9575aaf 100644 --- a/src/dlangui/platforms/windows/winapp.d +++ b/src/dlangui/platforms/windows/winapp.d @@ -556,6 +556,15 @@ class Win32Window : Window { protected ButtonDetails _mbutton; protected ButtonDetails _rbutton; + private void updateButtonsState(uint flags) { + if (!(flags & MK_LBUTTON) && _lbutton.isDown) + _lbutton.reset(); + if (!(flags & MK_MBUTTON) && _mbutton.isDown) + _mbutton.reset(); + if (!(flags & MK_RBUTTON) && _rbutton.isDown) + _rbutton.reset(); + } + private bool _mouseTracking; private bool onMouse(uint message, uint flags, short x, short y) { debug(DebugMouseEvents) Log.d("Win32 Mouse Message ", message, " flags=", flags, " x=", x, " y=", y); @@ -566,6 +575,7 @@ class Win32Window : Window { switch (message) { case WM_MOUSEMOVE: action = MouseAction.Move; + updateButtonsState(flags); break; case WM_LBUTTONDOWN: action = MouseAction.ButtonDown; diff --git a/src/dlangui/widgets/layouts.d b/src/dlangui/widgets/layouts.d index 82cbecab..f0628c40 100644 --- a/src/dlangui/widgets/layouts.d +++ b/src/dlangui/widgets/layouts.d @@ -413,6 +413,17 @@ class ResizerWidget : Widget { if (event.action == MouseAction.FocusOut && _dragging) { return true; } + if ((event.action == MouseAction.ButtonUp && event.button == MouseButton.Left) || (!event.lbutton.isDown && _dragging)) { + resetState(State.Pressed); + if (_dragging) { + //sendScrollEvent(ScrollAction.SliderReleased, _position); + _dragging = false; + if (resizeListener.assigned) { + resizeListener(this, ResizerEventType.EndDragging, _orientation == Orientation.Vertical ? event.y : event.x); + } + } + return true; + } if (event.action == MouseAction.Move && _dragging) { int delta = _orientation == Orientation.Vertical ? event.y - _dragStart.y : event.x - _dragStart.x; if (resizeListener.assigned) { @@ -459,17 +470,6 @@ class ResizerWidget : Widget { //onIndicatorDragging(_dragStartPosition, position); return true; } - if (event.action == MouseAction.ButtonUp && event.button == MouseButton.Left) { - resetState(State.Pressed); - if (_dragging) { - //sendScrollEvent(ScrollAction.SliderReleased, _position); - _dragging = false; - if (resizeListener.assigned) { - resizeListener(this, ResizerEventType.EndDragging, _orientation == Orientation.Vertical ? event.y : event.x); - } - } - return true; - } if (event.action == MouseAction.Move && trackHover) { if (!(state & State.Hovered)) { Log.d("Hover ", id);