From 054f1cb29dd9b992163b2abcc464a17075d83873 Mon Sep 17 00:00:00 2001 From: Rejean Loyer Date: Thu, 2 Jun 2016 05:07:35 -0400 Subject: [PATCH] ecere/gui/controls/Stacker, ide: implement hover scroll for Stacker. make use of it in the ide. --- ecere/src/gui/controls/SelectorBar.ec | 1 + ecere/src/gui/controls/Stacker.ec | 32 +++++++++++++++++++++++++++++++- ide/src/ProjectSettings.ec | 10 ++++++++-- ide/src/dialogs/GlobalSettingsDialog.ec | 5 ++++- 4 files changed, 44 insertions(+), 4 deletions(-) diff --git a/ecere/src/gui/controls/SelectorBar.ec b/ecere/src/gui/controls/SelectorBar.ec index 4c3ad08..ded05d8 100644 --- a/ecere/src/gui/controls/SelectorBar.ec +++ b/ecere/src/gui/controls/SelectorBar.ec @@ -140,6 +140,7 @@ public: public class SelectorButton : Button { bevelOver = true, isRadio = true, bitmap = null, minClientSize = { 44, 22 }; isRemote = true; + clickThrough = true; public: Window focusHolder; diff --git a/ecere/src/gui/controls/Stacker.ec b/ecere/src/gui/controls/Stacker.ec index 900e412..e4137fc 100644 --- a/ecere/src/gui/controls/Stacker.ec +++ b/ecere/src/gui/controls/Stacker.ec @@ -16,7 +16,7 @@ static define stackerScrolling = 16; class StackerBits { - bool reverse:1, scrollable:1, flipSpring:1, autoSize:1, endButtons:1; + bool reverse:1, scrollable:1, flipSpring:1, autoSize:1, endButtons:1, hoverScroll:1; // internals bool holdChildMonitoring:1; @@ -83,6 +83,11 @@ public: } get { return bits.endButtons; } }; + property bool hoverScroll + { + set { bits.hoverScroll = value; } + get { return bits.hoverScroll; } + }; private: StackerBits bits; @@ -117,6 +122,7 @@ private: RepButton left { nonClient = true, parent = this, visible = false, bevelOver = true, keyRepeat = true, opacity = 0; delay0 = 0.1; + clickThrough = true; bool NotifyClicked(Button button, int x, int y, Modifiers mods) { @@ -138,6 +144,7 @@ private: RepButton right { nonClient = true, parent = this, visible = false, bevelOver = true, keyRepeat = true, opacity = 0; delay0 = 0.1; + clickThrough = true; bool NotifyClicked(Button button, int x, int y, Modifiers mods) { @@ -256,6 +263,29 @@ private: direction = vertical; endButtons = true; + bool OnMouseMove(int x, int y, Modifiers mods) + { + int limit = direction == vertical ? size.h : size.w; + int length = direction == vertical ? scrollArea.h : scrollArea.w; + if(bits.hoverScroll/* && needScrollers*/ && length > limit) + { + int pos = direction == vertical ? y : x; + if(pos > 0) + { + int endZoneSize = (bits.endButtons ? left.size.w : 0) + 16; + //float ratio = (float)pos / (float)limit; + float ratio = (float)(Min(Max(endZoneSize, pos), limit - endZoneSize) - endZoneSize) / (float)(limit - endZoneSize * 2); + int offset = (int)(ratio * (length - limit)); + if(direction == vertical) + scroll.y = offset; + else + scroll.x = offset; + size = size; // TRIGGER SCROLLING UPDATE (Currently required since we aren't using Window scrollbars) + } + } + return true; + } + void OnChildAddedOrRemoved(Window child, bool removed) { if(!child.nonClient) diff --git a/ide/src/ProjectSettings.ec b/ide/src/ProjectSettings.ec index f47b3ab..c83f7d7 100644 --- a/ide/src/ProjectSettings.ec +++ b/ide/src/ProjectSettings.ec @@ -1322,7 +1322,10 @@ class BuildTab : Tab { this, text = $"Configurations: ", anchor = { left = 98, top = 8, right = 54 }; size = { 0, 26 }; opacity = 0; - direction = horizontal, scrollable = true; + direction = horizontal; + scrollable = true; + endButtons = false; + hoverScroll = true; bool OnKeyDown(Key key, unichar ch) { @@ -1468,7 +1471,10 @@ class BuildTab : Tab { this, text = $"Platforms: ", anchor = { left = 64, top = 38, right = 54 }; size = { 0, 26 }; opacity = 0; - direction = horizontal, scrollable = true; + direction = horizontal; + scrollable = true; + endButtons = false; + hoverScroll = true; bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct) { diff --git a/ide/src/dialogs/GlobalSettingsDialog.ec b/ide/src/dialogs/GlobalSettingsDialog.ec index 01782aa..cc389a5 100644 --- a/ide/src/dialogs/GlobalSettingsDialog.ec +++ b/ide/src/dialogs/GlobalSettingsDialog.ec @@ -278,7 +278,10 @@ class CompilersTab : GlobalSettingsSubTab { this, text = $"Compiler Configurations:", anchor = { left = 148, top = 38, right = 99 }; size = { 0, 26 }; opacity = 0; - direction = horizontal, scrollable = true; + direction = horizontal; + scrollable = true; + endButtons = false; + hoverScroll = true; bool OnKeyDown(Key key, unichar ch) { -- 1.8.3.1