From: terencehill Date: Wed, 16 Feb 2011 22:57:32 +0000 (+0100) Subject: Use an offset to draw the Clear button so that it can be better placed based on the... X-Git-Tag: xonotic-v0.7.0~55^2~13^2~9 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=ef06098372dc7668713a8a72da22ccf0dc42b023;p=xonotic%2Fxonotic-data.pk3dir.git Use an offset to draw the Clear button so that it can be better placed based on the inputbox right border For luminos skin use a copy of the Close button and set the proper offset (previously the image itself had the offset) Add Clear buttons to the other 2 skins (a copy of the Close button for Xaw and the middle part of a checkbox for Default skin, this one not very nice tbh) --- diff --git a/gfx/menu/default/clearbutton_c.tga b/gfx/menu/default/clearbutton_c.tga new file mode 100644 index 0000000000..26bc0effef Binary files /dev/null and b/gfx/menu/default/clearbutton_c.tga differ diff --git a/gfx/menu/default/clearbutton_f.tga b/gfx/menu/default/clearbutton_f.tga new file mode 100644 index 0000000000..e857381452 Binary files /dev/null and b/gfx/menu/default/clearbutton_f.tga differ diff --git a/gfx/menu/default/clearbutton_n.tga b/gfx/menu/default/clearbutton_n.tga new file mode 100644 index 0000000000..26bc0effef Binary files /dev/null and b/gfx/menu/default/clearbutton_n.tga differ diff --git a/gfx/menu/default/skinvalues.txt b/gfx/menu/default/skinvalues.txt index b2b0a97008..4a1a934b93 100755 --- a/gfx/menu/default/skinvalues.txt +++ b/gfx/menu/default/skinvalues.txt @@ -183,6 +183,7 @@ COLOR_DIALOG_CVARS '1 0 0' COLOR_INPUTBOX_N '1 1 1' COLOR_INPUTBOX_F '1 1 1' MARGIN_INPUTBOX_CHARS 1 +OFFSET_CLEARBUTTON -0.5 // item: key grabber COLOR_KEYGRABBER_TITLES '1 1 1' diff --git a/gfx/menu/luminos/clearbutton_c.tga b/gfx/menu/luminos/clearbutton_c.tga index df5b64cb6c..3de1ccb804 100644 Binary files a/gfx/menu/luminos/clearbutton_c.tga and b/gfx/menu/luminos/clearbutton_c.tga differ diff --git a/gfx/menu/luminos/clearbutton_f.tga b/gfx/menu/luminos/clearbutton_f.tga index 1ef420399e..be0939c067 100644 Binary files a/gfx/menu/luminos/clearbutton_f.tga and b/gfx/menu/luminos/clearbutton_f.tga differ diff --git a/gfx/menu/luminos/clearbutton_n.tga b/gfx/menu/luminos/clearbutton_n.tga index 201645b976..57d76c47e1 100644 Binary files a/gfx/menu/luminos/clearbutton_n.tga and b/gfx/menu/luminos/clearbutton_n.tga differ diff --git a/gfx/menu/luminos/skinvalues.txt b/gfx/menu/luminos/skinvalues.txt index 21944b67a8..82d188cb62 100755 --- a/gfx/menu/luminos/skinvalues.txt +++ b/gfx/menu/luminos/skinvalues.txt @@ -183,6 +183,7 @@ COLOR_DIALOG_CVARS '1 0 0' COLOR_INPUTBOX_N '1 1 1' COLOR_INPUTBOX_F '1 1 1' MARGIN_INPUTBOX_CHARS 1 +OFFSET_CLEARBUTTON -0.3 // item: key grabber COLOR_KEYGRABBER_TITLES '1 1 1' diff --git a/gfx/menu/xaw/clearbutton_c.tga b/gfx/menu/xaw/clearbutton_c.tga new file mode 100644 index 0000000000..d8bfea5adb Binary files /dev/null and b/gfx/menu/xaw/clearbutton_c.tga differ diff --git a/gfx/menu/xaw/clearbutton_f.tga b/gfx/menu/xaw/clearbutton_f.tga new file mode 100644 index 0000000000..338ac1f586 Binary files /dev/null and b/gfx/menu/xaw/clearbutton_f.tga differ diff --git a/gfx/menu/xaw/clearbutton_n.tga b/gfx/menu/xaw/clearbutton_n.tga new file mode 100644 index 0000000000..60ee8c8d10 Binary files /dev/null and b/gfx/menu/xaw/clearbutton_n.tga differ diff --git a/gfx/menu/xaw/skinvalues.txt b/gfx/menu/xaw/skinvalues.txt index eae123ce79..217e8c9561 100644 --- a/gfx/menu/xaw/skinvalues.txt +++ b/gfx/menu/xaw/skinvalues.txt @@ -123,6 +123,7 @@ HEIGHT_DIALOGBORDER 1 COLOR_INPUTBOX_N '1 1 1' COLOR_INPUTBOX_F '1 1 1' MARGIN_INPUTBOX_CHARS 1 +OFFSET_CLEARBUTTON 0 // item: key grabber COLOR_KEYGRABBER_TITLES '1 1 1' diff --git a/qcsrc/menu/item/inputbox.c b/qcsrc/menu/item/inputbox.c index b44db7c42a..67ac8e9957 100644 --- a/qcsrc/menu/item/inputbox.c +++ b/qcsrc/menu/item/inputbox.c @@ -32,6 +32,7 @@ CLASS(InputBox) EXTENDS(Label) ATTRIB(InputBox, enableClearButton, float, 1) ATTRIB(InputBox, clearButton, entity, NULL) ATTRIB(InputBox, cb_size, vector, '0 0 0') + ATTRIB(InputBox, cb_offset, float, SKINOFFSET_CLEARBUTTON) // bound to range -1, 0 ATTRIB(InputBox, cb_pressed, float, 0) ATTRIB(InputBox, cb_focused, float, 0) ATTRIB(InputBox, cb_src, string, SKINGFX_CLEARBUTTON) @@ -52,7 +53,8 @@ void InputBox_resizeNotify(entity me, vector relOrigin, vector relSize, vector a if (me.enableClearButton) { me.cb_size = eX * (absSize_y / absSize_x) + eY; - me.keepspaceRight = me.keepspaceRight + me.cb_size_x; + me.cb_offset = bound(-1, me.cb_offset, 0) * me.cb_size_x; // bound to range -1, 0 + me.keepspaceRight = me.keepspaceRight - me.cb_offset + me.cb_size_x; } } @@ -70,8 +72,8 @@ void InputBox_Clear_Click(entity btn, entity me) float over_ClearButton(entity me, vector pos) { - if (pos_x >= 1 - me.cb_size_x) - if (pos_x < 1) + if (pos_x >= 1 + me.cb_offset - me.cb_size_x) + if (pos_x < 1 + me.cb_offset) if (pos_y >= 0) if (pos_y < me.cb_size_y) return 1; @@ -368,11 +370,11 @@ void InputBox_draw(entity me) if (me.text != "") { if(me.focused && me.cb_pressed) - draw_Picture('1 1 0' - me.cb_size, strcat(me.cb_src, "_c"), me.cb_size, '1 1 1', 1); + draw_Picture('1 1 0' + eX * me.cb_offset - me.cb_size, strcat(me.cb_src, "_c"), me.cb_size, '1 1 1', 1); else if(me.focused && me.cb_focused) - draw_Picture('1 1 0' - me.cb_size, strcat(me.cb_src, "_f"), me.cb_size, '1 1 1', 1); + draw_Picture('1 1 0' + eX * me.cb_offset - me.cb_size, strcat(me.cb_src, "_f"), me.cb_size, '1 1 1', 1); else - draw_Picture('1 1 0' - me.cb_size, strcat(me.cb_src, "_n"), me.cb_size, '1 1 1', 1); + draw_Picture('1 1 0' + eX * me.cb_offset - me.cb_size, strcat(me.cb_src, "_n"), me.cb_size, '1 1 1', 1); } } diff --git a/qcsrc/menu/skin-customizables.inc b/qcsrc/menu/skin-customizables.inc index a4a4f9e80e..2cb85a7a0f 100644 --- a/qcsrc/menu/skin-customizables.inc +++ b/qcsrc/menu/skin-customizables.inc @@ -160,6 +160,7 @@ SKINBEGIN SKINVECTOR(COLOR_INPUTBOX_N, '1 1 1'); SKINVECTOR(COLOR_INPUTBOX_F, '1 1 1'); SKINSTRING(GFX_CLEARBUTTON, "clearbutton"); + SKINFLOAT(OFFSET_CLEARBUTTON, 0); SKINFLOAT(MARGIN_INPUTBOX_CHARS, 1); // item: key grabber