]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'master' into TimePath/scrollpanel
authorterencehill <piuntn@gmail.com>
Sun, 18 Feb 2018 12:43:39 +0000 (13:43 +0100)
committerterencehill <piuntn@gmail.com>
Sun, 18 Feb 2018 12:43:39 +0000 (13:43 +0100)
32 files changed:
qcsrc/menu/draw.qc
qcsrc/menu/item.qc
qcsrc/menu/item.qh
qcsrc/menu/item/button.qc
qcsrc/menu/item/button.qh
qcsrc/menu/item/container.qc
qcsrc/menu/item/container.qh
qcsrc/menu/item/image.qc
qcsrc/menu/item/inputbox.qc
qcsrc/menu/item/inputbox.qh
qcsrc/menu/item/inputcontainer.qc
qcsrc/menu/item/inputcontainer.qh
qcsrc/menu/item/listbox.qc
qcsrc/menu/item/listbox.qh
qcsrc/menu/item/nexposee.qc
qcsrc/menu/item/nexposee.qh
qcsrc/menu/item/slider.qc
qcsrc/menu/item/slider.qh
qcsrc/menu/xonotic/_mod.inc
qcsrc/menu/xonotic/_mod.qh
qcsrc/menu/xonotic/colorpicker.qc
qcsrc/menu/xonotic/colorpicker.qh
qcsrc/menu/xonotic/colorpicker_string.qc
qcsrc/menu/xonotic/colorpicker_string.qh
qcsrc/menu/xonotic/dialog_settings_game.qc
qcsrc/menu/xonotic/dialog_settings_game.qh
qcsrc/menu/xonotic/picker.qc
qcsrc/menu/xonotic/picker.qh
qcsrc/menu/xonotic/screenshotimage.qc
qcsrc/menu/xonotic/screenshotimage.qh
qcsrc/menu/xonotic/scrollpanel.qc [new file with mode: 0644]
qcsrc/menu/xonotic/scrollpanel.qh [new file with mode: 0644]

index 01184a4bf5d026e2c5c0580c8ef625e07610772a..ae6967e367565fc02c38f08f57c77ac0ccca706d 100644 (file)
@@ -312,32 +312,55 @@ float draw_CondensedFontFactor(string theText, float ICanHasKallerz, vector Size
        return 1.0;
 }
 
-float draw_clipSet;
+IntrusiveList draw_clip;
+STATIC_INIT(draw_clip) { draw_clip = IL_NEW(); }
+CLASS(ClipFrame, Object)
+       ATTRIB(ClipFrame, clip_shift, vector, '0 0 0');
+       ATTRIB(ClipFrame, clip_scale, vector, '0 0 0');
+ENDCLASS(ClipFrame)
+
+void _draw_SetClip(vector o, vector s)
+{
+       ClipFrame prev = IL_PEEK(draw_clip);
+       if (prev) {
+               o.x = bound(prev.clip_shift.x, o.x, prev.clip_shift.x + prev.clip_scale.x);
+               o.y = bound(prev.clip_shift.y, o.y, prev.clip_shift.y + prev.clip_scale.y);
+               s.x = bound(0, s.x, prev.clip_scale.x - (o.x - prev.clip_shift.x));
+               s.y = bound(0, s.y, prev.clip_scale.y - (o.y - prev.clip_shift.y));
+       }
+       ClipFrame e = NEW(ClipFrame);
+       e.clip_shift = o;
+       e.clip_scale = s;
+       IL_PUSH(draw_clip, e);
+       drawsetcliparea(o.x, o.y, s.x, s.y);
+}
+
 void draw_SetClip()
 {
-       if(draw_clipSet)
-               error("Already clipping, no stack implemented here, sorry");
-       drawsetcliparea(draw_shift.x, draw_shift.y, draw_scale.x, draw_scale.y);
-       draw_clipSet = 1;
+       _draw_SetClip(draw_shift, draw_scale);
 }
 
 void draw_SetClipRect(vector theOrigin, vector theScale)
 {
-       vector o, s;
-       if(draw_clipSet)
-               error("Already clipping, no stack implemented here, sorry");
-       o = boxToGlobal(theOrigin, draw_shift, draw_scale);
-       s = boxToGlobalSize(theScale, draw_scale);
-       drawsetcliparea(o.x, o.y, s.x, s.y);
-       draw_clipSet = 1;
+       _draw_SetClip(
+               boxToGlobal(theOrigin, draw_shift, draw_scale),
+               boxToGlobalSize(theScale, draw_scale)
+       );
 }
 
 void draw_ClearClip()
 {
-       if(!draw_clipSet)
-               error("Not clipping, can't clear it then");
+       if (IL_EMPTY(draw_clip)) {
+               LOG_FATAL("Not clipping, can't clear it then");
+       }
+       entity currentSettings = IL_PEEK(draw_clip);
+       IL_REMOVE(draw_clip, currentSettings);
+       delete(currentSettings);
        drawresetcliparea();
-       draw_clipSet = 0;
+       ClipFrame e = IL_PEEK(draw_clip);
+       if (e) {
+               drawsetcliparea(e.clip_shift.x, e.clip_shift.y, e.clip_scale.x, e.clip_scale.y);
+       }
 }
 
 string draw_TextShortenToWidth(string theText, float maxWidth, float ICanHasKallerz, vector SizeThxBye)
index 1d31e95a9c7d5c513ea9f2766da4c574a1d7eca3..a5c7cfa8544c70219099a4a12079b7a87dd5a408 100644 (file)
@@ -74,9 +74,9 @@
                return 0;  // unhandled
        }
 
-       METHOD(Item, mousePress, float(Item this, vector pos))
+       METHOD(Item, mousePress, bool(Item this, vector pos))
        {
-               return 0;  // unhandled
+               return false;  // unhandled
        }
 
        METHOD(Item, mouseDrag, float(Item this, vector pos))
index a5df526806e851e7777f0e6792de627881a46145..6cee17b3fdd5f9ccd24a66d078f040aaee9110a2 100644 (file)
@@ -10,7 +10,7 @@ CLASS(Item, Object)
        METHOD(Item, keyDown, float(Item, float, float, float));
        METHOD(Item, keyUp, float(Item, float, float, float));
        METHOD(Item, mouseMove, float(Item, vector));
-       METHOD(Item, mousePress, float(Item, vector));
+       METHOD(Item, mousePress, bool(Item this, vector pos));
        METHOD(Item, mouseDrag, float(Item, vector));
        METHOD(Item, mouseRelease, float(Item, vector));
        METHOD(Item, focusEnter, void(Item));
index 8299a6859f539c097404e15184437e0903b44c4f..77e4ccad264fee8f912abdb8573ba154af71289c 100644 (file)
                if (pos.y >= 1) me.pressed = 0;
                return 1;
        }
-       float Button_mousePress(entity me, vector pos)
+       METHOD(Button, mousePress, bool(Button this, vector pos))
        {
-               me.mouseDrag(me, pos);  // verify coordinates
-               return 1;
+               this.mouseDrag(this, pos);  // verify coordinates
+               return true;
        }
        float Button_mouseRelease(entity me, vector pos)
        {
index 1a164245c8f269368067b3b43c4ae6f92fd9066f..2077da70071c5b680c55e6ac83b10838b83bf2a4 100644 (file)
@@ -9,7 +9,7 @@ CLASS(Button, Label)
        METHOD(Button, showNotify, void(entity));
        METHOD(Button, resizeNotify, void(entity, vector, vector, vector, vector));
        METHOD(Button, keyDown, float(entity, float, float, float));
-       METHOD(Button, mousePress, float(entity, vector));
+       METHOD(Button, mousePress, bool(Button this, vector pos));
        METHOD(Button, mouseDrag, float(entity, vector));
        METHOD(Button, mouseRelease, float(entity, vector));
        METHOD(Button, playClickSound, void(entity));
index 56535bf71c18f5ddd24202dc534642568948c1c2..04e1bc6f7cf20f754a88741cbe9ed003e42495a9 100644 (file)
                }
                return 0;
        }
-       float Container_mousePress(entity me, vector pos)
+       METHOD(Container, mousePress, bool(Container this, vector pos))
        {
-               entity f;
-               float r;
-               f = me.focusedChild;
+               entity f = this.focusedChild;
                if (f)
                {
-                       me.enterSubitem(me, f);
-                       r = f.mousePress(f, globalToBox(pos, f.Container_origin, f.Container_size));
-                       me.leaveSubitem(me);
+                       this.enterSubitem(this, f);
+                       bool r = f.mousePress(f, globalToBox(pos, f.Container_origin, f.Container_size));
+                       this.leaveSubitem(this);
                        return r;
                }
-               return 0;
+               return false;
        }
        float Container_mouseDrag(entity me, vector pos)
        {
index 8273f5ddde38a43ec3e153d3a5f02247f452a775..b73752685030a8ef57277ddaf3a3b7b7279f26f1 100644 (file)
@@ -7,7 +7,7 @@ CLASS(Container, Item)
        METHOD(Container, keyUp, float(entity, float, float, float));
        METHOD(Container, keyDown, float(entity, float, float, float));
        METHOD(Container, mouseMove, float(entity, vector));
-       METHOD(Container, mousePress, float(entity, vector));
+       METHOD(Container, mousePress, bool(Container this, vector pos));
        METHOD(Container, mouseDrag, float(entity, vector));
        METHOD(Container, mouseRelease, float(entity, vector));
        METHOD(Container, focusLeave, void(entity));
index 59405ec169f15448df4e7f028c67b8e43ef56c0b..73b302c4a7716a6e7f7b363b030a3d46ff7058a8 100644 (file)
 
        void Image_draw(entity me)
        {
-               if (me.imgSize.x > 1 || me.imgSize.y > 1) draw_SetClip();
+               bool willClip = me.imgSize.x > 1 || me.imgSize.y > 1;
+               if (willClip) draw_SetClip();
                draw_Picture(me.imgOrigin, me.src, me.imgSize, me.color, 1);
-               if (me.imgSize.x > 1 || me.imgSize.y > 1) draw_ClearClip();
+               if (willClip) draw_ClearClip();
                SUPER(Image).draw(me);
        }
        void Image_updateAspect(entity me)
index 6f7ed9f24309b7d7556d5d594144acf642198a83..a418dc2ce0fffa7b761fff860ebe8f950dbb09bf 100644 (file)
                return 1;
        }
 
-       float InputBox_mousePress(entity me, vector pos)
+       METHOD(InputBox, mousePress, bool(InputBox this, vector pos))
        {
-               if (me.enableClearButton)
-                       if (over_ClearButton(me, pos))
+               if (this.enableClearButton)
+                       if (over_ClearButton(this, pos))
                        {
-                               me.cb_pressed = 1;
-                               return 1;
+                               this.cb_pressed = 1;
+                               return true;
                        }
-               me.dragScrollTimer = time;
-               me.pressed = 1;
-               return InputBox_mouseDrag(me, pos);
+               this.dragScrollTimer = time;
+               this.pressed = 1;
+               return InputBox_mouseDrag(this, pos);
        }
 
        float InputBox_mouseRelease(entity me, vector pos)
index e3eede653b9c0c297bf698b36ed1b4108ae5035b..5b0c28f9e454d49eb6990e9cd694abe845f8e4dd 100644 (file)
@@ -9,7 +9,7 @@ CLASS(InputBox, Label)
        METHOD(InputBox, keyDown, float(entity, float, float, float));
        METHOD(InputBox, mouseMove, float(entity, vector));
        METHOD(InputBox, mouseRelease, float(entity, vector));
-       METHOD(InputBox, mousePress, float(entity, vector));
+       METHOD(InputBox, mousePress, bool(InputBox this, vector pos));
        METHOD(InputBox, mouseDrag, float(entity, vector));
        METHOD(InputBox, showNotify, void(entity));
        METHOD(InputBox, resizeNotify, void(entity, vector, vector, vector, vector));
index 37c46240f77fdcd8bf704b1b6d999aaa3de5e254..641e47745a11f804e6ed47e4567ac2673ba539c7 100644 (file)
                if (pos.x >= 0 && pos.y >= 0 && pos.x < 1 && pos.y < 1) return 1;
                return 0;
        }
-       float InputContainer_mousePress(entity me, vector pos)
+       METHOD(InputContainer, mousePress, bool(InputContainer this, vector pos))
        {
-               me.mouseFocusedChild = NULL;  // force focusing
-               if (me._changeFocusXY(me, pos))
-                       if (SUPER(InputContainer).mousePress(me, pos)) return 1;
-               if (pos.x >= 0 && pos.y >= 0 && pos.x < 1 && pos.y < 1) return 1;
-               return 0;
+               this.mouseFocusedChild = NULL;  // force focusing
+               if (this._changeFocusXY(this, pos))
+                       if (SUPER(InputContainer).mousePress(this, pos)) return true;
+               if (pos.x >= 0 && pos.y >= 0 && pos.x < 1 && pos.y < 1) return true;
+               return false;
        }
        float InputContainer_mouseRelease(entity me, vector pos)
        {
index 9ae4a537506bcad1a54fb7721b7816dd74685d35..8ded2e657bcba13f3a7f594c078d6dafceee4043 100644 (file)
@@ -4,7 +4,7 @@
 CLASS(InputContainer, Container)
        METHOD(InputContainer, keyDown, float(entity, float, float, float));
        METHOD(InputContainer, mouseMove, float(entity, vector));
-       METHOD(InputContainer, mousePress, float(entity, vector));
+       METHOD(InputContainer, mousePress, bool(InputContainer this, vector pos));
        METHOD(InputContainer, mouseRelease, float(entity, vector));
        METHOD(InputContainer, mouseDrag, float(entity, vector));
        METHOD(InputContainer, focusLeave, void(entity));
index aa10c20b3b0f6d04bac8d5810e8b53b74bb799f2..07385e91e68ac0dde198ac54ce2377ecbadaf6b6 100644 (file)
                }
                return 1;
        }
-       float ListBox_mousePress(entity me, vector pos)
+       METHOD(ListBox, mousePress, bool(ListBox this, vector pos))
        {
-               if (pos.x < 0) return 0;
-               if (pos.y < 0) return 0;
-               if (pos.x >= 1) return 0;
-               if (pos.y >= 1) return 0;
-               me.dragScrollPos = pos;
-               me.updateControlTopBottom(me);
-               if (pos.x >= 1 - me.controlWidth)
+               if (pos.x < 0) return false;
+               if (pos.y < 0) return false;
+               if (pos.x >= 1) return false;
+               if (pos.y >= 1) return false;
+               this.dragScrollPos = pos;
+               this.updateControlTopBottom(this);
+               if (pos.x >= 1 - this.controlWidth)
                {
-                       // if hit, set me.pressed, otherwise scroll by one page
-                       if (pos.y < me.controlTop)
+                       // if hit, set this.pressed, otherwise scroll by one page
+                       if (pos.y < this.controlTop)
                        {
                                // page up
-                               me.scrollPosTarget = max(me.scrollPosTarget - 1, 0);
+                               this.scrollPosTarget = max(this.scrollPosTarget - 1, 0);
                        }
-                       else if (pos.y > me.controlBottom)
+                       else if (pos.y > this.controlBottom)
                        {
                                // page down
-                               me.scrollPosTarget = min(me.scrollPosTarget + 1, me.getTotalHeight(me) - 1);
+                               this.scrollPosTarget = min(this.scrollPosTarget + 1, this.getTotalHeight(this) - 1);
                        }
                        else
                        {
-                               me.pressed = 1;
-                               me.pressOffset = pos.y;
-                               me.previousValue = me.scrollPos;
+                               this.pressed = 1;
+                               this.pressOffset = pos.y;
+                               this.previousValue = this.scrollPos;
                        }
                }
                else
                {
                        // continue doing that while dragging (even when dragging outside). When releasing, forward the click to the then selected item.
-                       me.pressed = 2;
+                       this.pressed = 2;
                        // an item has been clicked. Select it, ...
-                       me.setSelected(me, me.getItemAtPos(me, me.scrollPos + pos.y));
-                       me.setFocusedItem(me, me.selectedItem);
+                       this.setSelected(this, this.getItemAtPos(this, this.scrollPos + pos.y));
+                       this.setFocusedItem(this, this.selectedItem);
                }
-               return 1;
+               return true;
        }
        void ListBox_setFocusedItem(entity me, int item)
        {
        AUTOCVAR(menu_scroll_averaging_time_pressed, float, 0.06, "smooth scroll averaging time when dragging the scrollbar");
        void ListBox_draw(entity me)
        {
-               float i;
-               vector absSize, fillSize = '0 0 0';
-               vector oldshift, oldscale;
+               vector fillSize = '0 0 0';
 
                // we can't do this in mouseMove as the list can scroll without moving the cursor
                if (me.mouseMoveOffset != -1) me.setFocusedItem(me, me.getItemAtPos(me, me.scrollPos + me.mouseMoveOffset));
                        }
                }
                draw_SetClip();
-               oldshift = draw_shift;
-               oldscale = draw_scale;
+               vector oldshift = draw_shift;
+               vector oldscale = draw_scale;
 
-               i = me.getItemAtPos(me, me.scrollPos);
-               float j = me.getItemStart(me, i) - me.scrollPos;
-               for ( ; i < me.nItems && j < 1; ++i)
+               int i = me.getItemAtPos(me, me.scrollPos);
+               float y = me.getItemStart(me, i) - me.scrollPos;
+               for ( ; i < me.nItems && y < 1; ++i)
                {
-                       draw_shift = boxToGlobal(eY * j, oldshift, oldscale);
+                       draw_shift = boxToGlobal(eY * y, oldshift, oldscale);
                        vector relSize = eX * (1 - me.controlWidth) + eY * me.getItemHeight(me, i);
-                       absSize = boxToGlobalSize(relSize, me.size);
+                       vector absSize = boxToGlobalSize(relSize, me.size);
                        draw_scale = boxToGlobalSize(relSize, oldscale);
                        me.drawListBoxItem(me, i, absSize, (me.selectedItem == i), (me.focusedItem == i));
-                       j += relSize.y;
+                       y += relSize.y;
                }
                draw_ClearClip();
 
index 56fda91cc15d82e163e362e9a250c38a8c1bb525..b3f5164a4d0937f769a55c68fb9cfbf474b07a99 100644 (file)
@@ -7,7 +7,7 @@ CLASS(ListBox, Item)
        METHOD(ListBox, draw, void(entity));
        METHOD(ListBox, keyDown, float(entity, float, float, float));
        METHOD(ListBox, mouseMove, float(entity, vector));
-       METHOD(ListBox, mousePress, float(entity, vector));
+       METHOD(ListBox, mousePress, bool(ListBox this, vector pos));
        METHOD(ListBox, mouseDrag, float(entity, vector));
        METHOD(ListBox, mouseRelease, float(entity, vector));
        METHOD(ListBox, focusLeave, void(entity));
index c0f18cf859476eff528f0f9a9ebb10a1eee3acdd..d42fceb533a787a35a340eaa517aa964e1843247 100644 (file)
@@ -154,35 +154,35 @@ LABEL(have_overlap)
                SUPER(Nexposee).draw(me);
        }
 
-       float Nexposee_mousePress(entity me, vector pos)
+       METHOD(Nexposee, mousePress, bool(Nexposee this, vector pos))
        {
-               if (me.animationState == 0)
+               if (this.animationState == 0)
                {
-                       me.mouseFocusedChild = NULL;
-                       Nexposee_mouseMove(me, pos);
-                       if (me.mouseFocusedChild)
+                       this.mouseFocusedChild = NULL;
+                       Nexposee_mouseMove(this, pos);
+                       if (this.mouseFocusedChild)
                        {
                                m_play_click_sound(MENU_SOUND_OPEN);
-                               me.animationState = 1;
-                               SUPER(Nexposee).setFocus(me, NULL);
+                               this.animationState = 1;
+                               SUPER(Nexposee).setFocus(this, NULL);
                        }
                        else
                        {
-                               me.close(me);
+                               this.close(this);
                        }
-                       return 1;
+                       return true;
                }
-               else if (me.animationState == 2)
+               else if (this.animationState == 2)
                {
-                       if (!(SUPER(Nexposee).mousePress(me, pos)))
+                       if (!(SUPER(Nexposee).mousePress(this, pos)))
                        {
                                m_play_click_sound(MENU_SOUND_CLOSE);
-                               me.animationState = 3;
-                               SUPER(Nexposee).setFocus(me, NULL);
+                               this.animationState = 3;
+                               SUPER(Nexposee).setFocus(this, NULL);
                        }
-                       return 1;
+                       return true;
                }
-               return 0;
+               return false;
        }
 
        float Nexposee_mouseRelease(entity me, vector pos)
index 4159648f974207260d502ab8efb4ad90907258f4..440413b5e59616332194103a7c6f1b30cb8f0649 100644 (file)
@@ -5,7 +5,7 @@ CLASS(Nexposee, Container)
        METHOD(Nexposee, draw, void(entity));
        METHOD(Nexposee, keyDown, float(entity, float, float, float));
        METHOD(Nexposee, keyUp, float(entity, float, float, float));
-       METHOD(Nexposee, mousePress, float(entity, vector));
+       METHOD(Nexposee, mousePress, bool(Nexposee this, vector pos));
        METHOD(Nexposee, mouseMove, float(entity, vector));
        METHOD(Nexposee, mouseRelease, float(entity, vector));
        METHOD(Nexposee, mouseDrag, float(entity, vector));
index 2e89bb68ee21e7356dcc906653a73c9a35b385c1..b569c3b0c4c228bec7d158f558129e21fded4f7c 100644 (file)
 
                return 1;
        }
-       float Slider_mousePress(entity me, vector pos)
+       METHOD(Slider, mousePress, bool(Slider this, vector pos))
        {
                float controlCenter;
-               if (me.disabled) return 0;
-               if (pos.x < 0) return 0;
-               if (pos.y < 0) return 0;
-               if (pos.x >= 1 - me.textSpace) return 0;
-               if (pos.y >= 1) return 0;
-               controlCenter = (me.value - me.valueMin) / (me.valueMax - me.valueMin) * (1 - me.textSpace - me.controlWidth) + 0.5 * me.controlWidth;
-               if (fabs(pos.x - controlCenter) <= 0.5 * me.controlWidth)
+               if (this.disabled) return false;
+               if (pos.x < 0) return false;
+               if (pos.y < 0) return false;
+               if (pos.x >= 1 - this.textSpace) return false;
+               if (pos.y >= 1) return false;
+               controlCenter = (this.value - this.valueMin) / (this.valueMax - this.valueMin) * (1 - this.textSpace - this.controlWidth) + 0.5 * this.controlWidth;
+               if (fabs(pos.x - controlCenter) <= 0.5 * this.controlWidth)
                {
-                       me.pressed = 1;
-                       me.pressOffset = pos.x - controlCenter;
-                       me.previousValue = me.value;
-                       // me.mouseDrag(me, pos);
+                       this.pressed = 1;
+                       this.pressOffset = pos.x - controlCenter;
+                       this.previousValue = this.value;
+                       // this.mouseDrag(this, pos);
                }
                else
                {
                        float clickValue, pageValue, inRange;
-                       clickValue = median(0, (pos.x - me.pressOffset - 0.5 * me.controlWidth) / (1 - me.textSpace - me.controlWidth), 1) * (me.valueMax - me.valueMin) + me.valueMin;
-                       inRange = (almost_in_bounds(me.valueMin, me.value, me.valueMax));
+                       clickValue = median(0, (pos.x - this.pressOffset - 0.5 * this.controlWidth) / (1 - this.textSpace - this.controlWidth), 1) * (this.valueMax - this.valueMin) + this.valueMin;
+                       inRange = (almost_in_bounds(this.valueMin, this.value, this.valueMax));
                        if (pos.x < controlCenter)
                        {
-                               pageValue = me.value - me.valuePageStep;
-                               if (me.valueStep) clickValue = floor(clickValue / me.valueStep) * me.valueStep;
+                               pageValue = this.value - this.valuePageStep;
+                               if (this.valueStep) clickValue = floor(clickValue / this.valueStep) * this.valueStep;
                                pageValue = max(pageValue, clickValue);
                        }
                        else
                        {
-                               pageValue = me.value + me.valuePageStep;
-                               if (me.valueStep) clickValue = ceil(clickValue / me.valueStep) * me.valueStep;
+                               pageValue = this.value + this.valuePageStep;
+                               if (this.valueStep) clickValue = ceil(clickValue / this.valueStep) * this.valueStep;
                                pageValue = min(pageValue, clickValue);
                        }
-                       if (inRange) me.setValue(me, median(me.valueMin, pageValue, me.valueMax));
-                       else me.setValue(me, me.valueMax);
-                       if(me.applyButton)
-                               me.applyButton.disabled = false;
+                       if (inRange) this.setValue(this, median(this.valueMin, pageValue, this.valueMax));
+                       else this.setValue(this, this.valueMax);
+                       if(this.applyButton)
+                               this.applyButton.disabled = false;
                        if (pageValue == clickValue)
                        {
-                               controlCenter = (me.value - me.valueMin) / (me.valueMax - me.valueMin) * (1 - me.textSpace - me.controlWidth) + 0.5 * me.controlWidth;
-                               me.pressed = 1;
-                               me.pressOffset = pos.x - controlCenter;
-                               me.previousValue = me.value;
-                               // me.mouseDrag(me, pos);
+                               controlCenter = (this.value - this.valueMin) / (this.valueMax - this.valueMin) * (1 - this.textSpace - this.controlWidth) + 0.5 * this.controlWidth;
+                               this.pressed = 1;
+                               this.pressOffset = pos.x - controlCenter;
+                               this.previousValue = this.value;
+                               // this.mouseDrag(this, pos);
                        }
                }
-               return 1;
+               return true;
        }
        float Slider_mouseRelease(entity me, vector pos)
        {
index 3b7327788c0d130afb230471b076b8b8262587e9..c798aae338dcc5771ca8edcc51cfa9401e66522b 100644 (file)
@@ -10,7 +10,7 @@ CLASS(Slider, Label)
        METHOD(Slider, draw, void(entity));
        METHOD(Slider, keyDown, float(entity, float, float, float));
        METHOD(Slider, keyUp, float(entity, float, float, float));
-       METHOD(Slider, mousePress, float(entity, vector));
+       METHOD(Slider, mousePress, bool(Slider this, vector pos));
        METHOD(Slider, mouseDrag, float(entity, vector));
        METHOD(Slider, mouseRelease, float(entity, vector));
        METHOD(Slider, valueToText, string(entity, float));
index 577c8225803461225c818ce07f6cf396d1806f10..fd83718283928e45f0c77ad9d3af81cc62ad88d1 100644 (file)
@@ -98,6 +98,7 @@
 #include <menu/xonotic/rootdialog.qc>
 #include <menu/xonotic/screenshotimage.qc>
 #include <menu/xonotic/screenshotlist.qc>
+#include <menu/xonotic/scrollpanel.qc>
 #include <menu/xonotic/serverlist.qc>
 #include <menu/xonotic/skinlist.qc>
 #include <menu/xonotic/slider.qc>
index b6e34eff247606d774eb1d321fe9f7539071d3ff..f1644a2f5cfc0bb76657141f15d34dea80b340a8 100644 (file)
@@ -98,6 +98,7 @@
 #include <menu/xonotic/rootdialog.qh>
 #include <menu/xonotic/screenshotimage.qh>
 #include <menu/xonotic/screenshotlist.qh>
+#include <menu/xonotic/scrollpanel.qh>
 #include <menu/xonotic/serverlist.qh>
 #include <menu/xonotic/skinlist.qh>
 #include <menu/xonotic/slider.qh>
index 357276e16adf3794334eb7d640089b78350504ca..d8aedf69512a7349910fb0a0c6ba06e0009b6059 100644 (file)
@@ -16,10 +16,10 @@ void XonoticColorpicker_configureXonoticColorpicker(entity me, entity theTextbox
        me.configureImage(me, me.image);
 }
 
-float XonoticColorpicker_mousePress(entity me, vector coords)
+METHOD(XonoticColorpicker, mousePress, bool(XonoticColorpicker this, vector pos))
 {
-       me.mouseDrag(me, coords);
-       return 1;
+       this.mouseDrag(this, pos);
+       return true;
 }
 
 // must match hslimage.c
index b1c9d1e80ae566dd5a5dcddc8fb569f46bb3f3b3..149357dd9f2695065045d97edd6fb27be5b0d2ff 100644 (file)
@@ -3,7 +3,7 @@
 #include "../item/image.qh"
 CLASS(XonoticColorpicker, Image)
        METHOD(XonoticColorpicker, configureXonoticColorpicker, void(entity, entity));
-       METHOD(XonoticColorpicker, mousePress, float(entity, vector));
+       METHOD(XonoticColorpicker, mousePress, bool(XonoticColorpicker this, vector pos));
        METHOD(XonoticColorpicker, mouseRelease, float(entity, vector));
        METHOD(XonoticColorpicker, mouseDrag, float(entity, vector));
        ATTRIB(XonoticColorpicker, controlledTextbox, entity);
index 200204c00d131cc9fb3e62615215fd74a6577b1f..5a44e58830862c9e668185b3f21bda1bffadd076 100644 (file)
@@ -50,10 +50,10 @@ void XonoticColorpickerString_saveCvars(entity me)
                cvar_set(me.cvarName, sprintf("%v", hslimage_color(me.prevcoords, me.imagemargin)));
 }
 
-float XonoticColorpickerString_mousePress(entity me, vector coords)
+METHOD(XonoticColorpickerString, mousePress, bool(XonoticColorpickerString this, vector pos))
 {
-       me.mouseDrag(me, coords);
-       return 1;
+       this.mouseDrag(this, pos);
+       return true;
 }
 
 float XonoticColorpickerString_mouseDrag(entity me, vector coords)
index e990234b3f0a24779b9e3b40da6850b31299cd82..aa4a10c93a7d45a9583f4c8b57f671d135f20b81 100644 (file)
@@ -5,7 +5,7 @@
 #include "../item/image.qh"
 CLASS(XonoticColorpickerString, Image)
        METHOD(XonoticColorpickerString, configureXonoticColorpickerString, void(entity, string, string));
-       METHOD(XonoticColorpickerString, mousePress, float(entity, vector));
+       METHOD(XonoticColorpickerString, mousePress, bool(XonoticColorpickerString this, vector pos));
        METHOD(XonoticColorpickerString, mouseRelease, float(entity, vector));
        METHOD(XonoticColorpickerString, mouseDrag, float(entity, vector));
 
index d2ce368d1d0b225452230bfef96ff4770f540890..87134cb7812c15635247ec2799c21abf88c8a27e 100644 (file)
@@ -94,7 +94,9 @@ CONSTRUCTOR(XonoticRegisteredSettingsList, DataSource _source) {
 
 METHOD(XonoticGameSettingsTab, topicChangeNotify, void(entity, entity this))
 {
-    entity c = this.currentPanel;
+    entity s = this.currentPanel;
+    s.viewportHeight = 15.5;
+    entity c = s.currentPanel;
     entity removing = this.currentItem;
     DataSource data = this.topicList.source;
     entity adding = data.getEntry(data, this.topicList.selectedItem, func_null);
@@ -107,6 +109,7 @@ METHOD(XonoticGameSettingsTab, topicChangeNotify, void(entity, entity this))
         this.currentItem = adding;
         adding.resizeNotify(adding, '0 0 0', c.size, '0 0 0', c.size);
         c.addItem(c, adding, '0 0 0', '1 1 0', 1);
+               s.resizeNotify(s, '0 0 0', s.size, '0 0 0', s.size);
     }
 }
 METHOD(XonoticGameSettingsTab, fill, void(entity this))
index b9231642b18e9b016afb5277531a6e15fe1bea84..c9617f582f55fa01e9caefeb624cdbc54e9ae180 100644 (file)
@@ -32,13 +32,14 @@ CLASS(XonoticRegisteredSettingsList, XonoticListBox)
 ENDCLASS(XonoticRegisteredSettingsList)
 
 #include "tab.qh"
+#include "scrollpanel.qh"
 CLASS(XonoticGameSettingsTab, XonoticTab)
        ATTRIB(XonoticGameSettingsTab, intendedWidth, float, 0.9);
        ATTRIB(XonoticGameSettingsTab, rows, float, 15.5);
        ATTRIB(XonoticGameSettingsTab, columns, float, 6.5);
        ATTRIB(XonoticGameSettingsTab, source, DataSource, NEW(SettingSource));
        ATTRIB(XonoticGameSettingsTab, topicList, entity, NEW(XonoticRegisteredSettingsList, this.source));
-       ATTRIB(XonoticGameSettingsTab, currentPanel, entity, NEW(XonoticTab));
+       ATTRIB(XonoticGameSettingsTab, currentPanel, entity, NEW(XonoticScrollPanel));
        ATTRIB(XonoticGameSettingsTab, currentItem, entity);
        METHOD(XonoticGameSettingsTab, topicChangeNotify, void(entity, entity this));
        METHOD(XonoticGameSettingsTab, fill, void(entity this));
index db302e9a8ca11b435bd9e6b2e7c006fcc05268b8..527697683218d87a2550f862ddd36b2a3dd67299 100644 (file)
@@ -39,17 +39,17 @@ float XonoticPicker_mouseDrag(entity me, vector coords)
        return me.mouseMove(me, coords);
 }
 
-float XonoticPicker_mousePress(entity me, vector coords)
+METHOD(XonoticPicker, mousePress, bool(XonoticPicker this, vector pos))
 {
-       me.mouseMove(me, coords);
+       this.mouseMove(this, pos);
 
-       if(me.focusedCell.x >= 0)
+       if(this.focusedCell.x >= 0)
        {
-               me.pressed = 1;
-               me.pressedCell = me.focusedCell;
+               this.pressed = 1;
+               this.pressedCell = this.focusedCell;
        }
 
-       return 1;
+       return true;
 }
 
 float XonoticPicker_mouseRelease(entity me, vector coords)
index b8e19cf19ebaedf19a3fcb0f440f877ae3006012..c98e9fc9b6fa8f082a3bd346dad51c48edd36048 100644 (file)
@@ -3,7 +3,7 @@
 #include "../item.qh"
 CLASS(XonoticPicker, Item)
        METHOD(XonoticPicker, configureXonoticPicker, void(entity));
-       METHOD(XonoticPicker, mousePress, float(entity, vector));
+       METHOD(XonoticPicker, mousePress, bool(XonoticPicker this, vector pos));
        METHOD(XonoticPicker, mouseRelease, float(entity, vector));
        METHOD(XonoticPicker, mouseMove, float(entity, vector));
        METHOD(XonoticPicker, mouseDrag, float(entity, vector));
index 42e168b4b58b2617d5978b7bce289bd8ac4a8131..8e8f3ccf738bd4f32de72be843b87510b558d8d8 100644 (file)
@@ -27,9 +27,9 @@ void XonoticScreenshotImage_load(entity me, string theImage)
        me.setZoom(me, 0, 0);
 }
 
-float XonoticScreenshotImage_mousePress(entity me, vector coords)
+METHOD(XonoticScreenshotImage, mousePress, bool(XonoticScreenshotImage this, vector pos))
 {
-       return me.drag_setStartPos(me, coords);
+       return this.drag_setStartPos(this, pos);
 }
 
 float XonoticScreenshotImage_mouseDrag(entity me, vector coords)
index 8920bed287f50fceed2527f56646d36a8599f812..c27a853377ce51eb18270adb6c7197e4811fb2e9 100644 (file)
@@ -6,7 +6,7 @@ CLASS(XonoticScreenshotImage, XonoticImage)
        METHOD(XonoticScreenshotImage, load, void(entity, string));
        METHOD(XonoticScreenshotImage, draw, void(entity));
        ATTRIB(XonoticScreenshotImage, focusable, float, 1);  // mousePress and mouseDrag work only if focusable is set
-       METHOD(XonoticScreenshotImage, mousePress, float(entity, vector));
+       METHOD(XonoticScreenshotImage, mousePress, bool(XonoticScreenshotImage this, vector pos));
        METHOD(XonoticScreenshotImage, mouseDrag, float(entity, vector));
        METHOD(XonoticScreenshotImage, mouseMove, float(entity, vector));
        METHOD(XonoticScreenshotImage, resizeNotify, void(entity, vector, vector, vector, vector));
diff --git a/qcsrc/menu/xonotic/scrollpanel.qc b/qcsrc/menu/xonotic/scrollpanel.qc
new file mode 100644 (file)
index 0000000..874a0af
--- /dev/null
@@ -0,0 +1,46 @@
+#include "scrollpanel.qh"
+
+METHOD(XonoticScrollPanel, drawListBoxItem, void(XonoticScrollPanel this, int i, vector absSize, bool isSelected, bool isFocused))
+{
+       XonoticTab p = this.currentPanel;
+       p.draw(p);
+}
+
+METHOD(XonoticScrollPanel, resizeNotify, void(XonoticScrollPanel this, vector relOrigin, vector relSize, vector absOrigin, vector absSize))
+{
+       SUPER(XonoticScrollPanel).resizeNotify(this, relOrigin, relSize, absOrigin, absSize);
+       this.scrollToItem(this, 0);
+       XonoticTab p = this.currentPanel;
+       float m = p.firstChild.rows / this.viewportHeight;
+       this.itemHeight = m;
+       relSize.y *= m;
+       absSize.y *= m;
+       p.resizeNotify(p, relOrigin, relSize, absOrigin, absSize);
+}
+
+#define X(x) \
+METHOD(XonoticScrollPanel, x, bool(XonoticScrollPanel this, vector pos)) \
+{ \
+       SUPER(XonoticScrollPanel).x(this, pos); \
+       XonoticTab p = this.currentPanel; \
+       this.setFocus(this, p); \
+       \
+       vector o = -eY * this.scrollPos; \
+       vector s = eX * (1 - this.controlWidth) + eY * this.itemHeight; \
+       return p.x(p, globalToBox(pos, o, s)); \
+}
+X(mouseMove)
+X(mousePress)
+X(mouseDrag)
+X(mouseRelease)
+#undef X
+
+#define X(x) \
+METHOD(XonoticScrollPanel, x, bool(XonoticScrollPanel this, int key, int ascii, bool shift)) \
+{ \
+       XonoticTab p = this.currentPanel; \
+       return p.x(p, key, ascii, shift) || SUPER(XonoticScrollPanel).x(this, key, ascii, shift); \
+}
+X(keyDown)
+X(keyUp)
+#undef X
diff --git a/qcsrc/menu/xonotic/scrollpanel.qh b/qcsrc/menu/xonotic/scrollpanel.qh
new file mode 100644 (file)
index 0000000..f675e86
--- /dev/null
@@ -0,0 +1,24 @@
+#pragma once
+
+#include "listbox.qh"
+#include "tab.qh"
+CLASS(XonoticScrollPanel, XonoticListBox)
+       /** container for single child panel */
+       ATTRIB(XonoticScrollPanel, currentPanel, entity, NEW(XonoticTab));
+       ATTRIB(XonoticScrollPanel, nItems, int, 1);
+       ATTRIB(XonoticScrollPanel, selectionDoesntMatter, bool, true);
+       ATTRIB(XonoticScrollPanel, itemHeight, float, 1);
+       /** number of rows to show at once */
+       ATTRIB(XonoticScrollPanel, viewportHeight, float, 12);
+       ATTRIB(XonoticScrollPanel, alphaBG, float, 0);
+
+       METHOD(XonoticScrollPanel, getItemAtPos, float(XonoticScrollPanel this, float pos)) { return 0; }
+       METHOD(XonoticScrollPanel, getItemHeight, float(XonoticScrollPanel this, int i)) { return this.itemHeight; }
+       METHOD(XonoticScrollPanel, getItemStart, float(XonoticScrollPanel this, int i)) { return 0; }
+       METHOD(XonoticScrollPanel, getTotalHeight, float(XonoticScrollPanel this)) { return this.itemHeight; }
+       METHOD(XonoticScrollPanel, setFocus, void(XonoticScrollPanel this, entity other)) { Container_setFocus(this, other); }
+       METHOD(XonoticScrollPanel, setSelected, void(XonoticScrollPanel this, int i)) { }
+
+       METHOD(XonoticScrollPanel, drawListBoxItem, void(XonoticScrollPanel this, int i, vector absSize, bool isSelected, bool isFocused));
+       METHOD(XonoticScrollPanel, resizeNotify, void(XonoticScrollPanel this, vector relOrigin, vector relSize, vector absOrigin, vector absSize));
+ENDCLASS(XonoticScrollPanel)