X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fmenu%2Fxonotic%2Fscrollpanel.qc;fp=qcsrc%2Fmenu%2Fxonotic%2Fscrollpanel.qc;h=4543f0bc48e011f16f801ca69761c4c36746b374;hb=be37ea91fb3bbd1a6fa4f0b70b32d1ea95343ad4;hp=0000000000000000000000000000000000000000;hpb=c1afbb3db4d2b8f1ca73b331ebe00cd276a99f1b;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/menu/xonotic/scrollpanel.qc b/qcsrc/menu/xonotic/scrollpanel.qc new file mode 100644 index 0000000000..4543f0bc48 --- /dev/null +++ b/qcsrc/menu/xonotic/scrollpanel.qc @@ -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(mouseFunc) \ +METHOD(XonoticScrollPanel, mouseFunc, bool(XonoticScrollPanel this, vector pos)) \ +{ \ + SUPER(XonoticScrollPanel).mouseFunc(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.mouseFunc(p, globalToBox(pos, o, s)); \ +} +X(mouseMove) +X(mousePress) +X(mouseDrag) +X(mouseRelease) +#undef X + +#define X(keyFunc) \ +METHOD(XonoticScrollPanel, keyFunc, bool(XonoticScrollPanel this, int key, int ascii, bool shift)) \ +{ \ + XonoticTab p = this.currentPanel; \ + return p.keyFunc(p, key, ascii, shift) || SUPER(XonoticScrollPanel).keyFunc(this, key, ascii, shift); \ +} +X(keyDown) +X(keyUp) +#undef X