METHOD(ListBox, configureListBox, void(entity, float, float))
METHOD(ListBox, draw, void(entity))
METHOD(ListBox, keyDown, float(entity, float, float, float))
METHOD(ListBox, configureListBox, void(entity, float, float))
METHOD(ListBox, draw, void(entity))
METHOD(ListBox, keyDown, float(entity, float, float, float))
METHOD(ListBox, mousePress, float(entity, vector))
METHOD(ListBox, mouseDrag, float(entity, vector))
METHOD(ListBox, mouseRelease, float(entity, vector))
METHOD(ListBox, focusLeave, void(entity))
ATTRIB(ListBox, focusable, float, 1)
METHOD(ListBox, mousePress, float(entity, vector))
METHOD(ListBox, mouseDrag, float(entity, vector))
METHOD(ListBox, mouseRelease, float(entity, vector))
METHOD(ListBox, focusLeave, void(entity))
ATTRIB(ListBox, focusable, float, 1)
- ATTRIB(ListBox, selectedItem, float, 0)
+ ATTRIB(ListBox, highlightedItem, int, -1)
+ ATTRIB(ListBox, highlightedItemTime, float, 0)
+ ATTRIB(ListBox, allowFocusSound, float, 1)
+ ATTRIB(ListBox, selectedItem, int, 0)
ATTRIB(ListBox, size, vector, '0 0 0')
ATTRIB(ListBox, origin, vector, '0 0 0')
ATTRIB(ListBox, scrollPos, float, 0) // measured in window heights, fixed when needed
ATTRIB(ListBox, size, vector, '0 0 0')
ATTRIB(ListBox, origin, vector, '0 0 0')
ATTRIB(ListBox, scrollPos, float, 0) // measured in window heights, fixed when needed
ATTRIB(ListBox, lastClickedItem, float, -1)
ATTRIB(ListBox, lastClickedTime, float, 0)
ATTRIB(ListBox, lastClickedItem, float, -1)
ATTRIB(ListBox, lastClickedTime, float, 0)
- METHOD(ListBox, drawListBoxItem, void(entity, float, vector, float)) // item number, width/height, selected
+ METHOD(ListBox, drawListBoxItem, void(entity, int, vector, bool, float)) // item number, width/height, isSelected, highlightedTime
METHOD(ListBox, clickListBoxItem, void(entity, float, vector)) // item number, relative clickpos
METHOD(ListBox, doubleClickListBoxItem, void(entity, float, vector)) // item number, relative clickpos
METHOD(ListBox, setSelected, void(entity, float))
METHOD(ListBox, clickListBoxItem, void(entity, float, vector)) // item number, relative clickpos
METHOD(ListBox, doubleClickListBoxItem, void(entity, float, vector)) // item number, relative clickpos
METHOD(ListBox, setSelected, void(entity, float))
void ListBox_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
{
SUPER(ListBox).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
void ListBox_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
{
SUPER(ListBox).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
{
float i = me.selectedItem;
float a = me.getItemHeight(me, i);
{
float i = me.selectedItem;
float a = me.getItemHeight(me, i);
{
float i = me.selectedItem;
float a = me.getItemHeight(me, i);
{
float i = me.selectedItem;
float a = me.getItemHeight(me, i);
+float ListBox_mouseMove(entity me, 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;
+ if(pos_x < 1 - me.controlWidth)
+ {
+ float x;
+ x = me.highlightedItem;
+ me.highlightedItem = me.getItemAtPos(me, me.scrollPos + pos.y);
+ if(x != me.highlightedItem)
+ me.highlightedItemTime = time;
+ }
+ return 1;
+}
- if(pos_x < 1 - me.controlWidth - me.tolerance_y * me.controlWidth) hit = 0;
- if(pos_y < 0 - me.tolerance_x) hit = 0;
- if(pos_x >= 1 + me.tolerance_y * me.controlWidth) hit = 0;
- if(pos_y >= 1 + me.tolerance_x) hit = 0;
+ if(pos.x < 1 - me.controlWidth - me.tolerance.y * me.controlWidth) hit = 0;
+ if(pos.y < 0 - me.tolerance.x) hit = 0;
+ if(pos.x >= 1 + me.tolerance.y * me.controlWidth) hit = 0;
+ if(pos.y >= 1 + me.tolerance.x) hit = 0;
- if(pos_x < 0) return 0;
- if(pos_y < 0) return 0;
- if(pos_x >= 1) return 0;
- if(pos_y >= 1) return 0;
+ if(pos.x < 0) return 0;
+ if(pos.y < 0) return 0;
+ if(pos.x >= 1) return 0;
+ if(pos.y >= 1) return 0;
{
// page up
me.scrollPos = max(me.scrollPos - 1, 0);
me.setSelected(me, min(me.selectedItem, ListBox_getLastFullyVisibleItemAtScrollPos(me, me.scrollPos)));
}
{
// page up
me.scrollPos = max(me.scrollPos - 1, 0);
me.setSelected(me, min(me.selectedItem, ListBox_getLastFullyVisibleItemAtScrollPos(me, me.scrollPos)));
}
// continue doing that while dragging (even when dragging outside). When releasing, forward the click to the then selected item.
me.pressed = 2;
// an item has been clicked. Select it, ...
// continue doing that while dragging (even when dragging outside). When releasing, forward the click to the then selected item.
me.pressed = 2;
// an item has been clicked. Select it, ...
me.pressed = 3; // do that here, so setSelected can know the mouse has been released
// item dragging mode
// select current one one last time...
me.pressed = 3; // do that here, so setSelected can know the mouse has been released
// item dragging mode
// select current one one last time...
if(me.pressed == 2)
me.mouseDrag(me, me.dragScrollPos); // simulate mouseDrag event
me.updateControlTopBottom(me);
if(me.pressed == 2)
me.mouseDrag(me, me.dragScrollPos); // simulate mouseDrag event
me.updateControlTopBottom(me);
if(me.alphaBG)
draw_Fill('0 0 0', '0 1 0' + fillSize, me.colorBG, me.alphaBG);
if(me.controlWidth)
if(me.alphaBG)
draw_Fill('0 0 0', '0 1 0' + fillSize, me.colorBG, me.alphaBG);
if(me.controlWidth)
float y;
i = me.getItemAtPos(me, me.scrollPos);
y = me.getItemStart(me, i) - me.scrollPos;
float y;
i = me.getItemAtPos(me, me.scrollPos);
y = me.getItemStart(me, i) - me.scrollPos;
{
draw_shift = boxToGlobal(eY * y, oldshift, oldscale);
vector relSize = eX * (1 - me.controlWidth) + eY * me.getItemHeight(me, i);
absSize = boxToGlobalSize(relSize, me.size);
draw_scale = boxToGlobalSize(relSize, oldscale);
{
draw_shift = boxToGlobal(eY * y, oldshift, oldscale);
vector relSize = eX * (1 - me.controlWidth) + eY * me.getItemHeight(me, i);
absSize = boxToGlobalSize(relSize, me.size);
draw_scale = boxToGlobalSize(relSize, oldscale);
- me.drawListBoxItem(me, i, absSize, (me.selectedItem == i));
- y += relSize_y;
+ me.drawListBoxItem(me, i, absSize, (me.selectedItem == i), (me.highlightedItem == i) ? me.highlightedItemTime : 0);
+ y += relSize.y;
-void ListBox_drawListBoxItem(entity me, float i, vector absSize, float selected)
+void ListBox_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, float highlightedTime)
- draw_Text('0 0 0', sprintf(_("Item %d"), i), eX * (8 / absSize_x) + eY * (8 / absSize_y), (selected ? '0 1 0' : '1 1 1'), 1, 0);
+ draw_Text('0 0 0', sprintf(_("Item %d"), i), eX * (8 / absSize.x) + eY * (8 / absSize.y), (isSelected ? '0 1 0' : '1 1 1'), 1, 0);