Pixel-Composer/scripts/rangeBox/rangeBox.gml

44 lines
1.1 KiB
Plaintext
Raw Normal View History

2022-01-13 05:24:03 +01:00
function rangeBox(_type, _onModify) constructor {
onModify = _onModify;
hover = false;
active = false;
label = [ "min", "max" ];
onModifySingle[0] = function(val) { onModify(0, toNumber(val)); }
onModifySingle[1] = function(val) { onModify(1, toNumber(val)); }
extras = -1;
for(var i = 0; i < 2; i++) {
tb[i] = new textBox(_type, onModifySingle[i]);
tb[i].slidable = true;
}
2022-01-24 02:21:25 +01:00
static draw = function(_x, _y, _w, _h, _data, _m) {
2022-12-23 04:45:52 +01:00
if(extras != -1 && is_struct(extras) && instanceof(extras) == "buttonClass") {
2022-01-13 05:24:03 +01:00
extras.hover = hover;
extras.active = active;
2022-11-18 03:20:31 +01:00
extras.draw(_x + _w - ui(32), _y + _h / 2 - ui(32 / 2), ui(32), ui(32), _m, THEME.button_hide);
2022-11-03 11:44:49 +01:00
_w -= ui(40);
2022-01-13 05:24:03 +01:00
}
if(is_array(_data) && array_length(_data) >= 2) {
var ww = _w / 2;
for(var i = 0; i < 2; i++) {
tb[i].hover = hover;
tb[i].active = active;
var bx = _x + ww * i;
2022-11-03 11:44:49 +01:00
tb[i].draw(bx + ui(44), _y, ww - ui(44), _h, _data[i], _m);
2022-01-13 05:24:03 +01:00
2022-11-18 03:20:31 +01:00
draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text_sub);
2022-11-03 11:44:49 +01:00
draw_text(bx + ui(8), _y + _h / 2, label[i]);
2022-01-13 05:24:03 +01:00
}
}
hover = false;
active = false;
}
}