Pixel-Composer/scripts/buttonGradient/buttonGradient.gml

34 lines
946 B
Text
Raw Normal View History

2022-01-13 05:24:03 +01:00
function buttonGradient(_onApply) {
return new buttonGradientClass(_onApply);
}
function buttonGradientClass(_onApply) constructor {
active = false;
hover = false;
onApply = _onApply;
2022-01-24 02:21:25 +01:00
static draw = function(_x, _y, _w, _h, _gradient, _data, _m) {
2022-01-13 05:24:03 +01:00
var click = false;
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.button, 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
var dialog = dialogCall(o_dialog_gradient, WIN_W / 2, WIN_H / 2);
dialog.setGradient(_gradient, _data);
dialog.onApply = onApply;
click = true;
}
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.button, 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.button, 0, _x, _y, _w, _h);
2022-01-13 05:24:03 +01:00
}
2022-11-03 11:44:49 +01:00
draw_gradient(_x + ui(6), _y + ui(6), _w - ui(12), _h - ui(12), _gradient, _data[| 0]);
2022-01-13 05:24:03 +01:00
hover = false;
active = false;
return click;
}
}