mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2025-01-11 23:06:51 +01:00
- [Gradient] Fix freeze when resize the panel is too small.
This commit is contained in:
parent
24e33606f5
commit
a344f1643f
3 changed files with 134 additions and 142 deletions
|
@ -141,7 +141,7 @@ function gradientObject(color = c_black) constructor {
|
||||||
surface_set_target(surf);
|
surface_set_target(surf);
|
||||||
DRAW_CLEAR
|
DRAW_CLEAR
|
||||||
var _gh = aa? _h - ui(8) : _h;
|
var _gh = aa? _h - ui(8) : _h;
|
||||||
draw_sprite_stretched_ext(THEME.gradient_mask, 0, 0, 0, _w, _gh, c_white, _a)
|
draw_sprite_stretched_ext(THEME.ui_panel_bg, 4, 0, 0, _w, _gh, c_white, _a)
|
||||||
|
|
||||||
if(len) {
|
if(len) {
|
||||||
BLEND_MULTIPLY
|
BLEND_MULTIPLY
|
||||||
|
@ -159,7 +159,7 @@ function gradientObject(color = c_black) constructor {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(aa) {
|
if(aa) {
|
||||||
draw_sprite_stretched_ext(THEME.gradient_mask, 0, 0, _h - ui(6), _w, ui(6), c_white, _a)
|
draw_sprite_stretched_ext(THEME.ui_panel_bg, 4, 0, _h - ui(6), _w, ui(6), c_white, _a)
|
||||||
|
|
||||||
BLEND_MULTIPLY
|
BLEND_MULTIPLY
|
||||||
|
|
||||||
|
|
|
@ -1,31 +1,24 @@
|
||||||
function Panel_Gradient() : PanelContent() constructor {
|
function Panel_Gradient() : PanelContent() constructor {
|
||||||
title = __txt("Gradients");
|
title = __txt("Gradients");
|
||||||
showHeader = false;
|
padding = 8;
|
||||||
title_height = 64;
|
|
||||||
padding = 20;
|
|
||||||
|
|
||||||
w = ui(320);
|
w = ui(320);
|
||||||
h = ui(480);
|
h = ui(480);
|
||||||
|
|
||||||
function onResize() {
|
function onResize() { sp_gradient.resize(w - ui(padding + padding), h - ui(padding + padding)); }
|
||||||
PANEL_PADDING
|
|
||||||
|
|
||||||
sp_gradient.resize(w - ui(padding + padding), h - ui(title_height + padding));
|
sp_gradient = new scrollPane(w - ui(padding + padding), h - ui(padding + padding), function(_y, _m) {
|
||||||
}
|
|
||||||
|
|
||||||
sp_gradient = new scrollPane(w - ui(padding + padding), h - ui(title_height + padding), function(_y, _m) {
|
|
||||||
draw_clear_alpha(COLORS.panel_bg_clear, 0);
|
draw_clear_alpha(COLORS.panel_bg_clear, 0);
|
||||||
var ww = sp_gradient.surface_w;
|
var ww = sp_gradient.surface_w;
|
||||||
var hh = 0;
|
var hh = 0;
|
||||||
|
|
||||||
var amo = array_length(GRADIENTS);
|
var amo = array_length(GRADIENTS);
|
||||||
var col = floor(ww / ui(160));
|
var col = max(1, floor(ww / ui(160)));
|
||||||
var row = ceil(amo / col);
|
var row = ceil(amo / col);
|
||||||
|
|
||||||
|
var pd = ui(6);
|
||||||
var gw = (ww + ui(8)) / col;
|
var gw = (ww + ui(8)) / col;
|
||||||
var gh = ui(16);
|
var hg = ui(26);
|
||||||
|
|
||||||
var hg = ui(24 + 8) + gh;
|
|
||||||
var yy = _y;
|
var yy = _y;
|
||||||
|
|
||||||
for(var i = 0; i < row; i++) {
|
for(var i = 0; i < row; i++) {
|
||||||
|
@ -33,30 +26,36 @@ function Panel_Gradient() : PanelContent() constructor {
|
||||||
var ind = i * col + j;
|
var ind = i * col + j;
|
||||||
if(ind >= amo) break;
|
if(ind >= amo) break;
|
||||||
|
|
||||||
|
var gww = gw - ui(8);
|
||||||
var xx = j * gw;
|
var xx = j * gw;
|
||||||
var preset = GRADIENTS[ind];
|
var preset = GRADIENTS[ind];
|
||||||
var isHover = pHOVER && point_in_rectangle(_m[0], _m[1], xx, max(0, yy), xx + gw - ui(8), min(sp_gradient.h, yy + hg));
|
var isHover = pHOVER && point_in_rectangle(_m[0], _m[1], xx, max(0, yy), xx + gww, min(sp_gradient.h, yy + hg));
|
||||||
|
|
||||||
draw_sprite_stretched(THEME.ui_panel_bg, 3, xx, yy, gw - ui(8), hg);
|
draw_sprite_stretched(THEME.ui_panel_bg, 3, xx, yy, gww, hg);
|
||||||
|
|
||||||
|
preset.gradient.draw(xx, yy, gww, hg);
|
||||||
|
draw_set_text(f_p2, fa_left, fa_center, c_white);
|
||||||
|
|
||||||
|
if(_color_get_light(preset.gradient.keys[0].value) > 0.5) {
|
||||||
|
draw_set_color(c_black);
|
||||||
|
draw_text(xx + pd, yy + hg / 2, preset.name);
|
||||||
|
} else
|
||||||
|
draw_text_add(xx + pd, yy + hg / 2, preset.name);
|
||||||
|
|
||||||
|
draw_sprite_stretched_add(THEME.ui_panel_fg, 1, xx, yy, gww, hg, c_white, 0.3);
|
||||||
if(isHover) {
|
if(isHover) {
|
||||||
sp_gradient.hover_content = true;
|
sp_gradient.hover_content = true;
|
||||||
draw_sprite_stretched_ext(THEME.node_active, 1, xx, yy, gw - ui(8), hg, COLORS._main_accent, 1);
|
draw_sprite_stretched_ext(THEME.ui_panel_fg, 1, xx, yy, gww, hg, COLORS._main_accent, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
draw_set_text(f_p2, fa_left, fa_top, COLORS._main_text_sub);
|
|
||||||
draw_text(xx + ui(10), yy + ui(2), preset.name);
|
|
||||||
preset.gradient.draw(xx + ui(10), yy + ui(24), gw - ui(28), gh);
|
|
||||||
|
|
||||||
if(isHover && mouse_press(mb_left, pFOCUS)) {
|
if(isHover && mouse_press(mb_left, pFOCUS)) {
|
||||||
DRAGGING = {
|
DRAGGING = { type: "Gradient", data: preset.gradient }
|
||||||
type: "Gradient",
|
|
||||||
data: preset.gradient
|
|
||||||
}
|
|
||||||
MESSAGE = DRAGGING;
|
MESSAGE = DRAGGING;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
yy += hg + ui(8);
|
|
||||||
hh += hg + ui(8);
|
yy += hg + ui(6);
|
||||||
|
hh += hg + ui(6);
|
||||||
}
|
}
|
||||||
|
|
||||||
return hh;
|
return hh;
|
||||||
|
@ -64,23 +63,21 @@ function Panel_Gradient() : PanelContent() constructor {
|
||||||
|
|
||||||
function drawContent(panel) {
|
function drawContent(panel) {
|
||||||
draw_clear_alpha(COLORS.panel_bg_clear, 0);
|
draw_clear_alpha(COLORS.panel_bg_clear, 0);
|
||||||
PANEL_PADDING
|
|
||||||
PANEL_TITLE
|
|
||||||
|
|
||||||
var px = ui(padding);
|
var px = ui(padding);
|
||||||
var py = ui(title_height);
|
var py = ui(padding);
|
||||||
var pw = w - ui(padding + padding);
|
var pw = w - ui(padding + padding);
|
||||||
var ph = h - ui(title_height + padding);
|
var ph = h - ui(padding + padding);
|
||||||
|
|
||||||
draw_sprite_stretched(THEME.ui_panel_bg, 1, px - ui(8), py - ui(8), pw + ui(16), ph + ui(16));
|
draw_sprite_stretched(THEME.ui_panel_bg, 1, px - ui(8), py - ui(8), pw + ui(16), ph + ui(16));
|
||||||
|
|
||||||
sp_gradient.setFocusHover(pFOCUS, pHOVER);
|
sp_gradient.setFocusHover(pFOCUS, pHOVER);
|
||||||
sp_gradient.draw(px, py, mx - px, my - py);
|
sp_gradient.draw(px, py, mx - px, my - py);
|
||||||
|
|
||||||
var bx = w - ui(32 + 16);
|
// var bx = w - ui(32 + 16);
|
||||||
var by = title_height / 2 - ui(16 + !in_dialog * 2);
|
// var by = padding / 2 - ui(16 + !in_dialog * 2);
|
||||||
|
|
||||||
if(buttonInstant(THEME.button_hide, bx, by, ui(32), ui(32), [mx, my], pFOCUS, pHOVER, __txt("Refresh"), THEME.refresh_icon, 1, COLORS._main_icon) == 2)
|
// if(buttonInstant(THEME.button_hide, bx, by, ui(32), ui(32), [mx, my], pFOCUS, pHOVER, __txt("Refresh"), THEME.refresh_icon, 1, COLORS._main_icon) == 2)
|
||||||
__initGradient();
|
// __initGradient();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,8 +1,6 @@
|
||||||
function Panel_Tunnels() : PanelContent() constructor {
|
function Panel_Tunnels() : PanelContent() constructor {
|
||||||
title = __txt("Tunnels");
|
title = __txt("Tunnels");
|
||||||
showHeader = false;
|
padding = 8;
|
||||||
title_height = 64;
|
|
||||||
padding = 20;
|
|
||||||
|
|
||||||
#region data
|
#region data
|
||||||
w = ui(320);
|
w = ui(320);
|
||||||
|
@ -37,6 +35,7 @@ function Panel_Tunnels() : PanelContent() constructor {
|
||||||
search_string = string(str);
|
search_string = string(str);
|
||||||
searchNodes();
|
searchNodes();
|
||||||
});
|
});
|
||||||
|
|
||||||
tb_search.align = fa_left;
|
tb_search.align = fa_left;
|
||||||
tb_search.auto_update = true;
|
tb_search.auto_update = true;
|
||||||
tb_search.boxColor = COLORS._main_icon_light;
|
tb_search.boxColor = COLORS._main_icon_light;
|
||||||
|
@ -54,14 +53,9 @@ function Panel_Tunnels() : PanelContent() constructor {
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
function onResize() {
|
function onResize() { sc_tunnel.resize(w - ui(padding + padding), h - ui(padding + padding) - ui(28)); }
|
||||||
PANEL_PADDING
|
|
||||||
|
|
||||||
sc_tunnel.resize(w - ui(padding + padding), h - ui(title_height + padding + 40));
|
sc_tunnel = new scrollPane(w - ui(padding + padding), h - ui(padding + padding) - ui(28), function(_y, _m) {
|
||||||
}
|
|
||||||
|
|
||||||
#region content
|
|
||||||
sc_tunnel = new scrollPane(w - ui(padding + padding), h - ui(title_height + padding + 40), function(_y, _m) {
|
|
||||||
draw_clear_alpha(COLORS.panel_bg_clear, 0);
|
draw_clear_alpha(COLORS.panel_bg_clear, 0);
|
||||||
var _h = 0;
|
var _h = 0;
|
||||||
var ww = sc_tunnel.surface_w;
|
var ww = sc_tunnel.surface_w;
|
||||||
|
@ -84,6 +78,7 @@ function Panel_Tunnels() : PanelContent() constructor {
|
||||||
tunnel_select = tunnel_select == node? noone : node;
|
tunnel_select = tunnel_select == node? noone : node;
|
||||||
} else
|
} else
|
||||||
draw_sprite_stretched_ext(THEME.ui_panel_bg, 0, 0, _y, ww, hg, COLORS._main_icon_light, 1);
|
draw_sprite_stretched_ext(THEME.ui_panel_bg, 0, 0, _y, ww, hg, COLORS._main_icon_light, 1);
|
||||||
|
draw_sprite_stretched_add(THEME.ui_panel_fg, 0, 0, _y, ww, hg, c_white, .3);
|
||||||
|
|
||||||
var key = node.inputs[| 0].getValue(0);
|
var key = node.inputs[| 0].getValue(0);
|
||||||
var bw = ui(28);
|
var bw = ui(28);
|
||||||
|
@ -142,37 +137,37 @@ function Panel_Tunnels() : PanelContent() constructor {
|
||||||
}
|
}
|
||||||
|
|
||||||
return _h;
|
return _h;
|
||||||
})
|
});
|
||||||
#endregion
|
|
||||||
|
|
||||||
function drawContent(panel) {
|
function drawContent(panel) {
|
||||||
draw_clear_alpha(COLORS.panel_bg_clear, 0);
|
draw_clear_alpha(COLORS.panel_bg_clear, 0);
|
||||||
PANEL_PADDING
|
|
||||||
PANEL_TITLE
|
|
||||||
|
|
||||||
scanNodes();
|
scanNodes();
|
||||||
|
|
||||||
var px = ui(padding);
|
var px = ui(padding);
|
||||||
var py = ui(title_height);
|
var py = ui(padding);
|
||||||
var pw = w - ui(padding + padding);
|
var pw = w - ui(padding + padding);
|
||||||
var ph = h - ui(title_height + padding);
|
var ph = h - ui(padding + padding) - ui(28);
|
||||||
|
|
||||||
draw_sprite_stretched(THEME.ui_panel_bg, 1, px - ui(8), py - ui(8), pw + ui(16), ph + ui(16));
|
draw_sprite_stretched(THEME.ui_panel_bg, 1, px - ui(8), py - ui(8), pw + ui(16), ph + ui(16));
|
||||||
if(pFOCUS) WIDGET_CURRENT = tb_search;
|
|
||||||
tb_search.draw(px, py, pw, ui(32), search_string, [mx, my]);
|
tb_search.draw(px, py, pw, ui(32), search_string, [mx, my]);
|
||||||
if(search_string == "")
|
if(search_string == "") tb_search.sprite_index = 1;
|
||||||
tb_search.sprite_index = 1;
|
|
||||||
|
|
||||||
sc_tunnel.setFocusHover(pFOCUS, pHOVER);
|
sc_tunnel.setFocusHover(pFOCUS, pHOVER);
|
||||||
sc_tunnel.draw(px, py + ui(40), mx - px, my - (py + ui(40)));
|
sc_tunnel.draw(px, py + ui(40), mx - px, my - (py + ui(40)));
|
||||||
|
|
||||||
var bx = w - ui(32 + 16);
|
var _add_h = ui(24);
|
||||||
var by = title_height / 2 - ui(16 + !in_dialog * 2);
|
var _bx = 0;
|
||||||
var txt = __txtx("panel_tunnel_create_tunnel", "Create tunnel");
|
var _by = h - _add_h;
|
||||||
|
var _ww = w;
|
||||||
|
var _hov = pHOVER && point_in_rectangle(mx, my, _bx, _by, _bx + _ww, _by + _add_h);
|
||||||
|
|
||||||
if(buttonInstant(THEME.button_hide, bx, by, ui(32), ui(32), [mx, my], pFOCUS, pHOVER, txt, THEME.tunnel, 1, c_white) == 2) {
|
draw_sprite_stretched_ext(THEME.timeline_node, 0, _bx, _by, _ww, _add_h, _hov? COLORS._main_value_positive : COLORS._main_icon, .3 + _hov * .1);
|
||||||
|
draw_sprite_stretched_ext(THEME.timeline_node, 1, _bx, _by, _ww, _add_h, _hov? COLORS._main_value_positive : COLORS._main_icon, .6 + _hov * .25);
|
||||||
|
draw_set_text(f_p2, fa_center, fa_center, _hov? COLORS._main_value_positive : COLORS._main_icon);
|
||||||
|
draw_text_add(_ww / 2, _by + _add_h / 2, __txtx("panel_tunnel_create_tunnel", "Create tunnel"));
|
||||||
|
|
||||||
|
if(mouse_press(mb_left, pFOCUS && _hov))
|
||||||
nodeBuild("Node_Tunnel_In", build_x, build_y);
|
nodeBuild("Node_Tunnel_In", build_x, build_y);
|
||||||
instance_destroy();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue