From 6fe3d23dfeef9335eef3e925704658afe0b2d92e Mon Sep 17 00:00:00 2001 From: Tanasart Date: Sun, 24 Mar 2024 12:44:34 +0700 Subject: [PATCH] - Improve slider, vector, range widgets. --- fonts/_f_sdf/_f_sdf.old.png | Bin 82361 -> 82361 bytes fonts/_f_sdf/_f_sdf.png | Bin 82361 -> 82361 bytes fonts/_f_sdf_medium/_f_sdf_medium.old.png | Bin 59906 -> 59906 bytes fonts/_f_sdf_medium/_f_sdf_medium.png | Bin 59906 -> 59906 bytes .../o_dialog_image_array_edit/Create_0.gml | 4 +- scripts/areaBox/areaBox.gml | 83 ++++++++++++------ scripts/matrixGrid/matrixGrid.gml | 12 ++- scripts/nodeValue_drawer/nodeValue_drawer.gml | 11 ++- scripts/quarternionBox/quarternionBox.gml | 12 ++- scripts/rangeBox/rangeBox.gml | 30 ++++--- scripts/transformBox/transformBox.gml | 39 +++++--- scripts/vectorBox/vectorBox.gml | 24 ++--- scripts/vectorRangeBox/vectorRangeBox.gml | 80 +++++++++++------ 13 files changed, 190 insertions(+), 105 deletions(-) diff --git a/fonts/_f_sdf/_f_sdf.old.png b/fonts/_f_sdf/_f_sdf.old.png index b1db5d8ef5c16ab32d8b84038538e3286f74b22d..15da3544183b0357064d060b668fefd9aa407f3f 100644 GIT binary patch delta 87 zcmdnl%(}CgwP6dRxuc-5m655Hsj0Ssft7*5E5iwsr+YXuDxeC_&e71HUg^lFEQ_N0 TOeNbP0l+XkKGD{c8 delta 87 zcmdnl%(}CgwP6dRxuc+=m7%effrYk#ft7)Q`LYCuXJQomPJu5 T`0i*V0}yz+`njxgN@xNAD}NXi diff --git a/fonts/_f_sdf/_f_sdf.png b/fonts/_f_sdf/_f_sdf.png index 15da3544183b0357064d060b668fefd9aa407f3f..3b77f12d616539a2bdd2a404871490f2fa98a5f1 100644 GIT binary patch delta 87 zcmdnl%(}CgwP6dRxuc+|m7%$np{cfkft7(laOd}q=^l=Z3aG+LSNu(;S2{8(%c7_* TJ(%~J0SG)@{an^LB{Ts5KSdZ$ delta 87 zcmdnl%(}CgwP6dRxuc-5m655Hsj0Ssft7*5E5iwsr+YXuDxeC_&e71HUg^lFEQ_N0 TOeNbP0l+XkKGD{c8 diff --git a/fonts/_f_sdf_medium/_f_sdf_medium.old.png b/fonts/_f_sdf_medium/_f_sdf_medium.old.png index f8490660cfe7ccd9d006e6f4af2e667c0a88554b..fcaf06e27e06c98989961d98755d252cc8d04dd9 100644 GIT binary patch delta 83 zcmZp=!rXL)c|*fXL1QZ;Q!7(bZ36=<1A|wF6DCid_)-B?basx0{^Ub1m1R-Xo~h*g PzyJiEu6{1-oD!MYTw PWB>wBS3j3^P6}9 diff --git a/fonts/_f_sdf_medium/_f_sdf_medium.png b/fonts/_f_sdf_medium/_f_sdf_medium.png index fcaf06e27e06c98989961d98755d252cc8d04dd9..9044032b04ce76e01e7736abbc736618be180dc6 100644 GIT binary patch delta 83 zcmZp=!rXL)c|*fXK~pP3b1OqLZ36=<1B0Z*x1y6LzEnUJ6}AaoIr-2_Wmy!pE}A7} P3_#%N>gTe~DWM4fVWJqz delta 83 zcmZp=!rXL)c|*fXL1QZ;Q!7(bZ36=<1A|wF6DCid_)-B?basx0{^Ub1m1R-Xo~h*g PzyJiEu6{1-oD!M= 2) { - var ww = _w / 2; - for(var i = 0; i < 2; i++) { - tb[i].setFocusHover(active, hover); + + } else if(is_array(_data) && array_length(_data) >= 2) { + draw_sprite_stretched_ext(THEME.textbox, 3, _x, _y, _w, _h, c_white, 1); + draw_sprite_stretched_ext(THEME.textbox, 0, _x, _y, _w, _h, c_white, 0.5 + 0.5 * interactable); + + var ww = _w / 2; + for(var i = 0; i < 2; i++) { + tb[i].setFocusHover(active, hover); - var bx = _x + ww * i; - tb[i].draw(bx + ui(44), _y, ww - ui(44), _h, _data[i], _m); - - draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text_sub); - draw_text(bx + ui(8), _y + _h / 2, label[i]); - } + var bx = _x + ww * i; + tb[i].draw(bx, _y, ww, _h, _data[i], _m); } } diff --git a/scripts/transformBox/transformBox.gml b/scripts/transformBox/transformBox.gml index f269ff03b..15d56a451 100644 --- a/scripts/transformBox/transformBox.gml +++ b/scripts/transformBox/transformBox.gml @@ -53,36 +53,55 @@ function transformBox(_onModify) : widget() constructor { if(is_array(_data[0])) return 0; rot.setFocusHover(active, hover); - for(var i = 0; i < array_length(_data); i++) + for(var i = 0; i < array_length(_data); i++) { tb[i].setFocusHover(active, hover); + tb[i].hide = true; + } - var tbh = TEXTBOX_HEIGHT; var lbw = ui(80); + var tbw = (_w - lbw) / 2; + var tbh = TEXTBOX_HEIGHT; draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text_inner); draw_text_add(_x, _y + tbh / 2, __txt("Position")); - var tbw = (_w - lbw) / 2 - ui(4); - tb[TRANSFORM.pos_x].draw(_x + lbw, _y, tbw, tbh, _data[TRANSFORM.pos_x], _m); - tb[TRANSFORM.pos_y].draw(_x + lbw + ui(8) + tbw, _y, tbw, tbh, _data[TRANSFORM.pos_y], _m); + draw_sprite_stretched_ext(THEME.textbox, 3, _x + lbw, _y, _w - lbw, tbh, c_white, 1); + draw_sprite_stretched_ext(THEME.textbox, 0, _x + lbw, _y, _w - lbw, tbh, c_white, 0.5 + 0.5 * interactable); + + draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text_sub); + draw_set_alpha(0.5); + draw_text_add(_x + lbw + ui(8), _y + tbh / 2, "x"); + draw_text_add(_x + lbw + tbw + ui(8), _y + tbh / 2, "y"); + draw_set_alpha(1); + + tb[TRANSFORM.pos_x].draw(_x + lbw, _y, tbw, tbh, _data[TRANSFORM.pos_x], _m); + tb[TRANSFORM.pos_y].draw(_x + lbw + tbw, _y, tbw, tbh, _data[TRANSFORM.pos_y], _m); _y += ui(40); rot.draw(_x, _y, _w, _data[TRANSFORM.rot], _m); - //draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text_inner); - //draw_text_add(_x + ui(8), _y + tbh / 2, "Rotation"); - _y += ui(72); draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text_inner); draw_text_add(_x, _y + tbh / 2, __txt("Scale")); - var tbw = array_length(_data) > 4? (_w - lbw) / 2 - ui(4) : _w - lbw; + draw_sprite_stretched_ext(THEME.textbox, 3, _x + lbw, _y, _w - lbw, tbh, c_white, 1); + draw_sprite_stretched_ext(THEME.textbox, 0, _x + lbw, _y, _w - lbw, tbh, c_white, 0.5 + 0.5 * interactable); + tbw = array_length(_data) > 4? (_w - lbw) / 2 : _w - lbw; + + if(array_length(_data) > 4) { + draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text_sub); + draw_set_alpha(0.5); + draw_text_add(_x + lbw + ui(8), _y + tbh / 2, "x"); + draw_text_add(_x + lbw + tbw + ui(8), _y + tbh / 2, "y"); + draw_set_alpha(1); + } + tb[TRANSFORM.sca_x].draw(_x + lbw, _y, tbw, tbh, _data[TRANSFORM.sca_x], _m); if(array_length(_data) > 4) - tb[TRANSFORM.sca_y].draw(_x + lbw + ui(8) + tbw, _y, tbw, tbh, _data[TRANSFORM.sca_y], _m); + tb[TRANSFORM.sca_y].draw(_x + lbw + tbw, _y, tbw, tbh, _data[TRANSFORM.sca_y], _m); resetFocus(); diff --git a/scripts/vectorBox/vectorBox.gml b/scripts/vectorBox/vectorBox.gml index 3f398af65..11eb0be17 100644 --- a/scripts/vectorBox/vectorBox.gml +++ b/scripts/vectorBox/vectorBox.gml @@ -126,8 +126,9 @@ function vectorBox(_size, _onModify, _unit = noone) : widget() constructor { if(linkable) { var _icon_blend = linked? COLORS._main_accent : (link_inactive_color == noone? COLORS._main_icon : link_inactive_color); var bx = _x; - var by = _y + _h / 2 - ui(32 / 2); - if(buttonInstant(THEME.button_hide, bx + ui(4), by + ui(4), ui(24), ui(24), _m, active, hover, tooltip, THEME.value_link, linked, _icon_blend) == 2) { + var by = _y + _h / 2 - ui(24 / 2); + + if(buttonInstant(THEME.button_hide, bx, by, ui(24), ui(24), _m, active, hover, tooltip, THEME.value_link, linked, _icon_blend) == 2) { linked = !linked; _display_data.linked = linked; @@ -136,7 +137,7 @@ function vectorBox(_size, _onModify, _unit = noone) : widget() constructor { onModify(1, _data[0]); } } - + _x += ui(28); _w -= ui(28); } @@ -144,20 +145,23 @@ function vectorBox(_size, _onModify, _unit = noone) : widget() constructor { var sz = min(size, array_length(_data)); var ww = per_line? _w : _w / sz; + draw_sprite_stretched_ext(THEME.textbox, 3, _x, _y, _w, _h, c_white, 1); + draw_sprite_stretched_ext(THEME.textbox, 0, _x, _y, _w, _h, c_white, 0.5 + 0.5 * interactable); + for(var i = 0; i < sz; i++) { draw_set_font(f_p0); - var lw = sz > 1? max(ui(24), string_width(axis[i]) + ui(16)) : 0; var bx = per_line? _x : _x + ww * i; var by = per_line? _y + (_h + ui(8)) * i : _y; - tb[i].setFocusHover(active, hover); - tb[i].draw(bx + lw, by, ww - lw, _h, _data[i], _m); + draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text_sub); + draw_set_alpha(0.5); + draw_text_add(bx + ui(8), by + _h / 2, axis[i]); + draw_set_alpha(1); - if(sz > 1) { - draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text_inner); - draw_text_add(bx + ui(8), by + _h / 2, axis[i]); - } + tb[i].setFocusHover(active, hover); + tb[i].hide = true; + tb[i].draw(bx, by, ww, _h, _data[i], _m); } resetFocus(); diff --git a/scripts/vectorRangeBox/vectorRangeBox.gml b/scripts/vectorRangeBox/vectorRangeBox.gml index 980d0df72..5fa1f82e7 100644 --- a/scripts/vectorRangeBox/vectorRangeBox.gml +++ b/scripts/vectorRangeBox/vectorRangeBox.gml @@ -28,35 +28,36 @@ function vectorRangeBox(_size, _type, _onModify, _unit = noone) : widget() const extras = -1; - for(var i = 0; i < size; i++) { + for(var i = 0; i < size; i++) { #region tb[i] = new textBox(_type, onModifySingle[i]); tb[i].slidable = true; - } + tb[i].hide = true; + } #endregion - static setSlideSpeed = function(speed) { + static setSlideSpeed = function(speed) { #region for(var i = 0; i < size; i++) tb[i].setSlidable(speed); - } + } #endregion - static setInteract = function(interactable = noone) { + static setInteract = function(interactable = noone) { #region self.interactable = interactable; var _step = linked? 2 : 1; for( var i = 0; i < size; i += _step ) tb[i].interactable = interactable; - } + } #endregion - static register = function(parent = noone) { + static register = function(parent = noone) { #region var _step = linked? 2 : 1; for( var i = 0; i < size; i += _step ) tb[i].register(parent); - } + } #endregion - static drawParam = function(params) { + static drawParam = function(params) { #region return draw(params.x, params.y, params.w, params.h, params.data, params.display_data, params.m); - } + } #endregion - static draw = function(_x, _y, _w, _h, _data, _display_data, _m) { + static draw = function(_x, _y, _w, _h, _data, _display_data, _m) { #region x = _x; y = _y; w = _w; @@ -68,10 +69,10 @@ function vectorRangeBox(_size, _type, _onModify, _unit = noone) : widget() const var _icon_blend = linked? COLORS._main_accent : COLORS._main_icon; var bx = _x; - var by = _y + _h / 2 - ui(32 / 2); - if(buttonInstant(THEME.button_hide, bx + ui(4), by + ui(4), ui(24), ui(24), _m, active, hover, tooltip, THEME.value_link, linked, _icon_blend) == 2) { + var by = _y + _h / 2 - ui(24 / 2); + if(buttonInstant(THEME.button_hide, bx, by, ui(24), ui(24), _m, active, hover, tooltip, THEME.value_link, linked, _icon_blend) == 2) { linked = !linked; - _display_data.linked = linked; + _display_data.linked = linked; if(linked) { for(var i = 0; i < size; i += 2) { @@ -84,26 +85,47 @@ function vectorRangeBox(_size, _type, _onModify, _unit = noone) : widget() const _x += ui(28); _w -= ui(28); - var _step = linked? 2 : 1; - var ww = _w / size * 2; + var ww = _w / 2; - for(var i = 0; i < size; i += _step) { - tb[i].setFocusHover(active, hover); + if(linked) { + draw_sprite_stretched_ext(THEME.textbox, 3, _x, _y, _w, _h, c_white, 1); + draw_sprite_stretched_ext(THEME.textbox, 0, _x, _y, _w, _h, c_white, 0.5 + 0.5 * interactable); + + for( var i = 0; i < 2; i++ ) { + var bx = _x + ww * i; + var by = _y; + + draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text_sub); + draw_set_alpha(0.5); + draw_text_add(bx + ui(8), by + _h / 2, axis[i]); + draw_set_alpha(1); + + tb[i * 2].setFocusHover(active, hover); + tb[i * 2].draw(bx, by, ww, _h, _data[i * 2], _m); + } + } else { + for( var j = 0; j < 2; j++ ) { + var by = _y + (_h + ui(4)) * j; + + draw_sprite_stretched_ext(THEME.textbox, 3, _x, by, _w, _h, c_white, 1); + draw_sprite_stretched_ext(THEME.textbox, 0, _x, by, _w, _h, c_white, 0.5 + 0.5 * interactable); - var bx = _x + ww * floor(i / 2); - var by = _y + i % 2 * (_h + ui(4)); - var _ww = ui(32 + 32 * !linked); - tb[i].draw(bx + _ww, by, ww - _ww, _h, _data[i], _m); - - draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text_inner); - - var _label = linked? axis[floor(i / 2)] - : (i % 2? __txt("Max") : __txt("Min")) + " " + axis[floor(i / 2)]; - draw_text(bx + ui(8), by + _h / 2, _label); + draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text_sub); + draw_set_alpha(0.5); + draw_text_add(_x + ui(8), by + _h / 2, axis[j]); + draw_set_alpha(1); + + for( var i = 0; i < 2; i++ ) { + var bx = _x + ww * i; + + tb[j * 2 + i].setFocusHover(active, hover); + tb[j * 2 + i].draw(bx, by, ww, _h, _data[j * 2 + i], _m); + } + } } resetFocus(); return h; - } + } #endregion } \ No newline at end of file