Pixel-Composer/scripts/scrollBox/scrollBox.gml

40 lines
1.1 KiB
Plaintext
Raw Normal View History

2022-01-13 05:24:03 +01:00
function scrollBox(_data, _onModify) constructor {
onModify = _onModify;
data_list = _data;
active = false;
hover = false;
open = false;
align = fa_center;
2022-11-18 03:20:31 +01:00
static draw = function(_x, _y, _w, _h, _text, _m = mouse_ui, _rx = 0, _ry = 0) {
2022-01-13 05:24:03 +01:00
if(!open) {
if(hover && point_in_rectangle(_m[0], _m[1], _x, _y, _x + _w, _y + _h)) {
2022-11-18 03:20:31 +01:00
draw_sprite_stretched(THEME.textbox, 1, _x, _y, _w, _h);
2022-12-10 05:06:01 +01:00
if(mouse_press(mb_left, active)) {
2022-01-13 05:24:03 +01:00
open = true;
with(dialogCall(o_dialog_scrollbox, _x + _rx, _y + _ry)) {
scrollbox = other;
dialog_w = _w;
align = other.align;
2022-01-13 05:24:03 +01:00
}
}
2022-12-10 05:06:01 +01:00
if(mouse_click(mb_left, active))
2022-11-18 03:20:31 +01:00
draw_sprite_stretched(THEME.textbox, 2, _x, _y, _w, _h);
2022-01-13 05:24:03 +01:00
} else {
2022-11-18 03:20:31 +01:00
draw_sprite_stretched(THEME.textbox, 0, _x, _y, _w, _h);
2022-01-13 05:24:03 +01:00
}
2022-11-18 03:20:31 +01:00
draw_set_text(f_p0, align, fa_center, COLORS._main_text);
if(align == fa_center)
2022-11-03 11:44:49 +01:00
draw_text(_x + _w / 2, _y + _h / 2 - ui(2), _text);
else if(align == fa_left)
2022-11-03 11:44:49 +01:00
draw_text(_x + ui(8), _y + _h / 2 - ui(2), _text);
2022-11-18 03:20:31 +01:00
draw_sprite_ui_uniform(THEME.scroll_box_arrow, 0, _x + _w - 20, _y + _h / 2, 1, COLORS._main_icon);
2022-01-13 05:24:03 +01:00
}
hover = false;
active = false;
}
}