Xonotic
listbox.qh
Go to the documentation of this file.
1 #pragma once
2 
3 #include "../item.qh"
5  METHOD(ListBox, resizeNotify, void(entity, vector, vector, vector, vector));
6  METHOD(ListBox, configureListBox, void(entity, float, float));
7  METHOD(ListBox, draw, void(entity));
8  METHOD(ListBox, keyDown, float(entity, float, float, float));
9  METHOD(ListBox, mouseMove, float(entity, vector));
10  METHOD(ListBox, mousePress, bool(ListBox this, vector pos));
11  METHOD(ListBox, mouseDrag, float(entity, vector));
12  METHOD(ListBox, mouseRelease, float(entity, vector));
13  METHOD(ListBox, focusLeave, void(entity));
14  ATTRIB(ListBox, focusable, float, 1);
15  ATTRIB(ListBox, focusedItem, int, -1);
16  ATTRIB(ListBox, focusedItemAlpha, float, 0.3);
17  METHOD(ListBox, setFocusedItem, void(entity, int));
18  ATTRIB(ListBox, mouseMoveOffset, float, -1); // let know where the cursor is when the list scrolls without moving the cursor
19  ATTRIB(ListBox, allowFocusSound, float, 1);
20  ATTRIB(ListBox, selectedItem, int, 0);
21  ATTRIB(ListBox, size, vector, '0 0 0');
22  ATTRIB(ListBox, origin, vector, '0 0 0');
23  ATTRIB(ListBox, scrollPos, float, 0); // measured in window heights, fixed when needed
24  ATTRIB(ListBox, scrollPosTarget, float, 0);
25  METHOD(ListBox, isScrolling, bool(entity));
26  ATTRIB(ListBox, needScrollToItem, float, -1);
27  METHOD(ListBox, scrollToItem, void(entity, int));
28  ATTRIB(ListBox, previousValue, float, 0);
29  ATTRIB(ListBox, pressed, float, 0); // 0 = normal, 1 = scrollbar dragging, 2 = item dragging, 3 = released
30  ATTRIB(ListBox, pressOffset, float, 0);
31 
32  METHOD(ListBox, updateControlTopBottom, void(entity));
33  ATTRIB(ListBox, controlTop, float, 0);
34  ATTRIB(ListBox, controlBottom, float, 0);
35  ATTRIB(ListBox, controlWidth, float, 0);
36  ATTRIB(ListBox, dragScrollPos, vector, '0 0 0');
37  ATTRIB(ListBox, selectionDoesntMatter, bool, false); // improves scrolling by keys for lists that don't need to show an active selection
38 
39  ATTRIB(ListBox, src, string); // scrollbar
40  ATTRIB(ListBox, color, vector, '1 1 1');
41  ATTRIB(ListBox, color2, vector, '1 1 1');
42  ATTRIB(ListBox, colorC, vector, '1 1 1');
43  ATTRIB(ListBox, colorF, vector, '1 1 1');
44  ATTRIB(ListBox, tolerance, vector, '0 0 0'); // drag tolerance
45  ATTRIB(ListBox, scrollbarWidth, float, 0); // pixels
46  ATTRIB(ListBox, nItems, float, 42); // FIXME: why?!?
47  ATTRIB(ListBox, itemHeight, float, 0);
48  ATTRIB(ListBox, itemAbsSize, vector, '0 0 0');
49  ATTRIB(ListBox, colorBG, vector, '0 0 0');
50  ATTRIB(ListBox, alphaBG, float, 0);
51 
52  ATTRIB(ListBox, lastClickedItem, float, -1);
53  ATTRIB(ListBox, lastClickedTime, float, 0);
54 
55  METHOD(ListBox, drawListBoxItem, void(entity, int, vector, bool, bool)); // item number, width/height, isSelected, isFocused
56  METHOD(ListBox, clickListBoxItem, void(entity, float, vector)); // item number, relative clickpos
57  METHOD(ListBox, doubleClickListBoxItem, void(entity, float, vector)); // item number, relative clickpos
58  METHOD(ListBox, setSelected, void(entity, float));
59  METHOD(ListBox, focusedItemChangeNotify, void(entity));
60 
61  METHOD(ListBox, getLastFullyVisibleItemAtScrollPos, float(entity, float));
62  METHOD(ListBox, getFirstFullyVisibleItemAtScrollPos, float(entity, float));
63 
64  // NOTE: override these four methods if you want variable sized list items
65  METHOD(ListBox, getTotalHeight, float(entity));
66  METHOD(ListBox, getItemAtPos, float(entity, float));
67  METHOD(ListBox, getItemStart, float(entity, float));
68  METHOD(ListBox, getItemHeight, float(entity, float));
69  // NOTE: if getItemAt* are overridden, it may make sense to cache the
70  // start and height of the last item returned by getItemAtPos and fast
71  // track returning their properties for getItemStart and getItemHeight.
72  // The "hot" code path calls getItemAtPos first, then will query
73  // getItemStart and getItemHeight on it soon.
74  // When overriding, the following consistency rules must hold:
75  // getTotalHeight() == SUM(getItemHeight(i), i, 0, me.nItems-1)
76  // getItemStart(i+1) == getItemStart(i) + getItemHeight(i)
77  // for 0 <= i < me.nItems-1
78  // getItemStart(0) == 0
79  // getItemStart(getItemAtPos(p)) <= p
80  // if p >= 0
81  // getItemAtPos(p) == 0
82  // if p < 0
83  // getItemStart(getItemAtPos(p)) + getItemHeight(getItemAtPos(p)) > p
84  // if p < getTotalHeigt()
85  // getItemAtPos(p) == me.nItems - 1
86  // if p >= getTotalHeight()
vector color
CLASS(Object) Object
Definition: oo.qh:318
entity() spawn
origin
Definition: ent_cs.qc:114
#define METHOD(cname, name, prototype)
Definition: oo.qh:257
vector size
Definition: csprogsdefs.qc:114
#define ATTRIB(...)
Definition: oo.qh:136
Definition: item.qh:8
vector(float skel, float bonenum) _skel_get_boneabs_hidden
vector colorC
Definition: borderimage.qh:25
#define ENDCLASS(cname)
Definition: oo.qh:269
bool pressed
Definition: picker.qc:3
vector colorF
Definition: borderimage.qh:25