COLOR_INPUTBOX_F '1 1 1'
MARGIN_INPUTBOX_CHARS 1
+// item: clear button
+// uses "clearbutton" images
+OFFSET_CLEARBUTTON -0.3
+COLOR_CLEARBUTTON_N '1 1 1'
+COLOR_CLEARBUTTON_C '1 1 1'
+COLOR_CLEARBUTTON_F '1 1 1'
+
// item: key grabber
COLOR_KEYGRABBER_TITLES '1 1 1'
ALPHA_KEYGRABBER_TITLES 1
COLOR_INPUTBOX_F '1 1 1'
MARGIN_INPUTBOX_CHARS 1
+// item: clear button
+// uses "clearbutton" images
+OFFSET_CLEARBUTTON -0.5
+COLOR_CLEARBUTTON_N '1 1 1'
+COLOR_CLEARBUTTON_C '1 1 1'
+COLOR_CLEARBUTTON_F '1 1 1'
+
// item: key grabber
COLOR_KEYGRABBER_TITLES '1 1 1'
ALPHA_KEYGRABBER_TITLES 1
COLOR_INPUTBOX_F '1 1 1'
MARGIN_INPUTBOX_CHARS 1
+// item: clear button
+// uses "clearbutton" images
+OFFSET_CLEARBUTTON 0
+COLOR_CLEARBUTTON_N '1 1 1'
+COLOR_CLEARBUTTON_C '1 1 1'
+COLOR_CLEARBUTTON_F '1 1 1'
+
// item: key grabber
COLOR_KEYGRABBER_TITLES '1 1 1'
ALPHA_KEYGRABBER_TITLES 1
METHOD(InputBox, setText, void(entity, string))
METHOD(InputBox, enterText, void(entity, string))
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, mouseDrag, float(entity, vector))
METHOD(InputBox, showNotify, void(entity))
+ METHOD(InputBox, resizeNotify, void(entity, vector, vector, vector, vector))
ATTRIB(InputBox, src, string, string_null)
ATTRIB(InputBox, color, vector, '1 1 1')
ATTRIB(InputBox, colorF, vector, '1 1 1')
ATTRIB(InputBox, maxLength, float, 255) // if negative, it counts bytes, not chars
+
+ ATTRIB(InputBox, enableClearButton, float, 1)
+ ATTRIB(InputBox, clearButton, entity, NULL)
+ ATTRIB(InputBox, cb_width, float, 0)
+ ATTRIB(InputBox, cb_pressed, float, 0)
+ ATTRIB(InputBox, cb_focused, float, 0)
+ ATTRIB(InputBox, cb_color, vector, '1 1 1')
+ ATTRIB(InputBox, cb_colorF, vector, '1 1 1')
+ ATTRIB(InputBox, cb_colorC, vector, '1 1 1')
ENDCLASS(InputBox)
void InputBox_Clear_Click(entity btn, entity me);
#endif
me.src = gfx;
me.cursorPos = theCursorPos;
}
+void InputBox_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
+{
+ SUPER(InputBox).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
+ if (me.enableClearButton)
+ {
+ me.cb_width = absSize_y / absSize_x;
+ me.cb_offset = bound(-1, me.cb_offset, 0) * me.cb_width; // bound to range -1, 0
+ me.keepspaceRight = me.keepspaceRight - me.cb_offset + me.cb_width;
+ }
+}
void InputBox_setText(entity me, string txt)
{
me.setText(me, "");
}
+float over_ClearButton(entity me, vector pos)
+{
+ if (pos_x >= 1 + me.cb_offset - me.cb_width)
+ if (pos_x < 1 + me.cb_offset)
+ if (pos_y >= 0)
+ if (pos_y < 1)
+ return 1;
+ return 0;
+}
+
+float InputBox_mouseMove(entity me, vector pos)
+{
+ if (me.enableClearButton)
+ {
+ if (over_ClearButton(me, pos))
+ {
+ me.cb_focused = 1;
+ return 1;
+ }
+ me.cb_focused = 0;
+ }
+ return 1;
+}
+
float InputBox_mouseDrag(entity me, vector pos)
{
float p;
- me.dragScrollPos = pos;
- p = me.scrollPos + pos_x - me.keepspaceLeft;
- me.cursorPos = draw_TextLengthUpToWidth(me.text, p, 0, me.realFontSize);
- me.lastChangeTime = time;
+ if(me.pressed)
+ {
+ me.dragScrollPos = pos;
+ p = me.scrollPos + pos_x - me.keepspaceLeft;
+ me.cursorPos = draw_TextLengthUpToWidth(me.text, p, 0, me.realFontSize);
+ me.lastChangeTime = time;
+ }
+ else if (me.enableClearButton)
+ {
+ if (over_ClearButton(me, pos))
+ {
+ me.cb_pressed = 1;
+ return 1;
+ }
+ }
+ me.cb_pressed = 0;
return 1;
}
float InputBox_mousePress(entity me, vector pos)
{
+ if (me.enableClearButton)
+ if (over_ClearButton(me, pos))
+ {
+ me.cb_pressed = 1;
+ return 1;
+ }
me.dragScrollTimer = time;
me.pressed = 1;
return InputBox_mouseDrag(me, pos);
float InputBox_mouseRelease(entity me, vector pos)
{
+ if(me.cb_pressed)
+ if (over_ClearButton(me, pos))
+ {
+ me.cb_pressed = 0;
+ InputBox_Clear_Click(world, me);
+ return 1;
+ }
+ float r = InputBox_mouseDrag(me, pos);
+ //reset cb_pressed after mouseDrag, mouseDrag could set cb_pressed in this case:
+ //mouse press out of the clear button, drag and then mouse release over the clear button
+ me.cb_pressed = 0;
me.pressed = 0;
- return InputBox_mouseDrag(me, pos);
+ return r;
}
void InputBox_enterText(entity me, string ch)
draw_ClearClip();
+ if (me.enableClearButton)
+ if (me.text != "")
+ {
+ if(me.focused && me.cb_pressed)
+ draw_Picture(eX * (1 + me.cb_offset - me.cb_width), strcat(me.cb_src, "_c"), eX * me.cb_width + eY, me.cb_colorC, 1);
+ else if(me.focused && me.cb_focused)
+ draw_Picture(eX * (1 + me.cb_offset - me.cb_width), strcat(me.cb_src, "_f"), eX * me.cb_width + eY, me.cb_colorF, 1);
+ else
+ draw_Picture(eX * (1 + me.cb_offset - me.cb_width), strcat(me.cb_src, "_n"), eX * me.cb_width + eY, me.cb_color, 1);
+ }
+
// skipping SUPER(InputBox).draw(me);
Item_draw(me);
}
SKINVECTOR(COLOR_INPUTBOX_F, '1 1 1');
SKINFLOAT(MARGIN_INPUTBOX_CHARS, 1);
+ // item: clear button
+ SKINSTRING(GFX_CLEARBUTTON, "clearbutton");
+ SKINFLOAT(OFFSET_CLEARBUTTON, 0);
+ SKINVECTOR(COLOR_CLEARBUTTON_N, '1 1 1');
+ SKINVECTOR(COLOR_CLEARBUTTON_F, '1 1 1');
+ SKINVECTOR(COLOR_CLEARBUTTON_C, '1 1 1');
+
// item: key grabber
SKINVECTOR(COLOR_KEYGRABBER_TITLES, '1 1 1');
SKINFLOAT(ALPHA_KEYGRABBER_TITLES, 1);
}
void XonoticDemoBrowserTab_fill(entity me)
{
- entity e;
- entity btn;
- entity dlist;
+ entity e, dlist;
me.TR(me);
me.TD(me, 1, 4, e = makeXonoticCheckBox(0, "cl_autodemo", _("Automatically record demos while playing")));
me.TR(me);
me.TR(me);
me.TD(me, 1, 0.5, e = makeXonoticTextLabel(0, _("Filter:")));
- me.TD(me, 1, 0.5, btn = makeXonoticButton(_("Clear"), '0 0 0'));
- btn.onClick = InputBox_Clear_Click;
- me.TD(me, 1, 3, e = makeXonoticInputBox(0, string_null));
+ me.TD(me, 1, 3.5, e = makeXonoticInputBox(0, string_null));
dlist = makeXonoticDemoList();
e.onChange = DemoList_Filter_Change;
e.onChangeEntity = dlist;
- btn.onClickEntity = e;
dlist.controlledTextbox = e;
me.TR(me);
}
void XonoticServerListTab_fill(entity me)
{
- entity e, slist, btn;
+ entity e, slist;
slist = makeXonoticServerList();
me.TR(me);
me.TD(me, 1, 0.4, e = makeXonoticTextLabel(0, _("Filter:")));
- me.TD(me, 1, 0.6, btn = makeXonoticButton(_("Clear"), '0 0 0'));
- btn.onClick = InputBox_Clear_Click;
- me.TD(me, 1, me.columns - 0.6 * 4 - 0.4, e = makeXonoticInputBox(0, string_null));
+ me.TD(me, 1, me.columns - 0.6 * 3 - 0.4, e = makeXonoticInputBox(0, string_null));
e.onChange = ServerList_Filter_Change;
e.onChangeEntity = slist;
- btn.onClickEntity = e;
slist.controlledTextbox = e;
me.TD(me, 1, 0.6, e = makeXonoticCheckBox(0, "menu_slist_showempty", ZCTX(_("SRVS^Empty"))));
slist.filterShowEmpty = e.checked;
box.forbiddenCharacters = "\r\n\\\"$"; // don't care, isn't getting saved
box.maxLength = -127; // negative means encoded length in bytes
box.saveImmediately = 1;
+ box.enableClearButton = 0;
label.textEntity = box;
me.TR(me);
me.TD(me, 5, 1, e = makeXonoticColorpicker(box));
me.TDempty(me, 0.2);
me.TD(me, 1, 1.8, e = makeXonoticTextLabel(0, _("Client UDP port:")));
me.TD(me, 1, 1, e = makeXonoticInputBox(0, "cl_port"));
+ e.enableClearButton = 0;
me.TR(me);
me.TR(me);
me.TDempty(me, 0.2);
}
void XonoticCvarsDialog_fill(entity me) // in this dialog, use SKINCOLOR_CVARLIST_CONTROLS to color ALL controls
{
- entity e, cvarlist, btn;
-
+
+ entity e, cvarlist;
+
cvarlist = makeXonoticCvarList();
-
+
cvarlist.color =
cvarlist.colorF =
cvarlist.color2 =
cvarlist.colorC =
SKINCOLOR_CVARLIST_CONTROLS;
-
+
me.TR(me);
me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Cvar filter:")));
- me.TD(me, 1, 0.5, btn = makeXonoticButton(_("Clear"), SKINCOLOR_CVARLIST_CONTROLS));
- me.TD(me, 1, me.columns - 1.5, e = makeXonoticInputBox(0, string_null));
+ me.TD(me, 1, me.columns - 1, e = makeXonoticInputBox(0, string_null));
e.color = SKINCOLOR_CVARLIST_CONTROLS;
e.colorF = SKINCOLOR_CVARLIST_CONTROLS;
+ e.cb_color = SKINCOLOR_CVARLIST_CONTROLS;
+ e.cb_colorC = SKINCOLOR_CVARLIST_CONTROLS;
+ e.cb_colorF = SKINCOLOR_CVARLIST_CONTROLS;
e.onChange = CvarList_Filter_Change;
e.onChangeEntity = cvarlist;
- btn.onClick = InputBox_Clear_Click;
- btn.onClickEntity = e;
cvarlist.controlledTextbox = e; // this COULD also be the Value box, but this leads to accidentally editing stuff
me.TR(me);
me.TD(me, me.rows - me.currentRow - 7, me.columns, cvarlist);
cvarlist.cvarValueBox = e;
e.color = SKINCOLOR_CVARLIST_CONTROLS;
e.colorF = SKINCOLOR_CVARLIST_CONTROLS;
+ e.cb_color = SKINCOLOR_CVARLIST_CONTROLS;
+ e.cb_colorC = SKINCOLOR_CVARLIST_CONTROLS;
+ e.cb_colorF = SKINCOLOR_CVARLIST_CONTROLS;
e.onChange = CvarList_Value_Change;
e.onChangeEntity = cvarlist;
e.onEnter = CvarList_End_Editing;
ATTRIB(XonoticInputBox, alpha, float, SKINALPHA_TEXT)
+ // Clear button attributes
+ ATTRIB(XonoticInputBox, cb_offset, float, SKINOFFSET_CLEARBUTTON) // bound to range -1, 0
+ ATTRIB(XonoticInputBox, cb_src, string, SKINGFX_CLEARBUTTON)
+ ATTRIB(XonoticInputBox, cb_color, vector, SKINCOLOR_CLEARBUTTON_N)
+ ATTRIB(XonoticInputBox, cb_colorF, vector, SKINCOLOR_CLEARBUTTON_F)
+ ATTRIB(XonoticInputBox, cb_colorC, vector, SKINCOLOR_CLEARBUTTON_C)
+
ATTRIB(XonoticInputBox, cvarName, string, string_null)
METHOD(XonoticInputBox, loadCvars, void(entity))
METHOD(XonoticInputBox, saveCvars, void(entity))