Pixel-Composer/scripts/buttonGradient/buttonGradient.gml

48 lines
1.3 KiB
Text
Raw Normal View History

2022-01-13 05:24:03 +01:00
function buttonGradient(_onApply) {
return new buttonGradientClass(_onApply);
}
2023-01-17 08:11:55 +01:00
function buttonGradientClass(_onApply) : widget() constructor {
2022-01-13 05:24:03 +01:00
onApply = _onApply;
2023-01-17 08:11:55 +01:00
current_gradient = noone;
current_data = noone;
static trigger = function() {
var dialog = dialogCall(o_dialog_gradient, WIN_W / 2, WIN_H / 2);
dialog.setGradient(current_gradient, current_data);
dialog.onApply = onApply;
}
2022-01-24 02:21:25 +01:00
static draw = function(_x, _y, _w, _h, _gradient, _data, _m) {
2023-01-17 08:11:55 +01:00
x = _x;
y = _y;
w = _w;
h = _h;
current_gradient = _gradient;
current_data = _data;
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)) {
2023-01-17 08:11:55 +01:00
trigger();
2022-01-13 05:24:03 +01:00
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);
2023-01-17 08:11:55 +01:00
if(mouse_press(mb_left)) deactivate();
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
2023-01-17 08:11:55 +01:00
if(WIDGET_CURRENT == self)
draw_sprite_stretched(THEME.widget_selecting, 0, _x - ui(3), _y - ui(3), _w + ui(6), _h + ui(6));
resetFocus();
2022-01-13 05:24:03 +01:00
return click;
}
}