- [Graph Panel] Fix node name label height not scale with UI scale.

This commit is contained in:
Tanasart 2024-07-17 14:36:03 +07:00
parent 07d18167bc
commit c677d84243
6 changed files with 54 additions and 34 deletions

View file

@ -42,26 +42,25 @@ function curveBox(_onModify) : widget() constructor {
static get_x = function(val) { return cw * (val - minx) / (maxx - minx); } static get_x = function(val) { return cw * (val - minx) / (maxx - minx); }
static get_y = function(val) { return ch * (1 - (val - miny) / (maxy - miny)); } static get_y = function(val) { return ch * (1 - (val - miny) / (maxy - miny)); }
static register = function() {} static setInteract = function(interactable = noone) {
static setInteract = function(interactable = noone) { #region
self.interactable = interactable; self.interactable = interactable;
tb_shift.setInteract(interactable); tb_shift.setInteract(interactable);
tb_scale.setInteract(interactable); tb_scale.setInteract(interactable);
} #endregion }
static register = function(parent = noone) { static register = function(parent = noone) {
self.parent = parent;
tb_shift.register(parent); tb_shift.register(parent);
tb_scale.register(parent); tb_scale.register(parent);
} }
static isHovering = function() { #region static isHovering = function() {
if(tb_shift.isHovering()) return true; if(tb_shift.isHovering()) return true;
if(tb_scale.isHovering()) return true; if(tb_scale.isHovering()) return true;
return hovering; return hovering;
} #endregion }
static drawParam = function(params) { static drawParam = function(params) {
rx = params.rx; rx = params.rx;
@ -109,6 +108,7 @@ function curveBox(_onModify) : widget() constructor {
curve_surface = surface_verify(curve_surface, cw, ch); curve_surface = surface_verify(curve_surface, cw, ch);
if(node_dragging != -1) { #region editing if(node_dragging != -1) { #region editing
if(parent) parent.pen_scroll_lock = true;
show_coord = true; show_coord = true;
_data = array_clone(_data); _data = array_clone(_data);
@ -540,8 +540,8 @@ function curveBox(_onModify) : widget() constructor {
return h; return h;
} }
static clone = function() { #region static clone = function() {
var cln = new curveBox(onModify); var cln = new curveBox(onModify);
return cln; return cln;
} #endregion }
} }

View file

@ -95,7 +95,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
x = _x; x = _x;
y = _y; y = _y;
name_height = 16; name_height = ui(16);
w = 128; w = 128;
h = 128; h = 128;
min_w = w; min_w = w;

View file

@ -98,6 +98,10 @@ function Panel_Animation() : PanelContent() constructor {
timeline_preview = noone; timeline_preview = noone;
timeline_contents = []; timeline_contents = [];
scroll_s = sprite_get_width(THEME.ui_scrollbar);
scroll_w = scroll_s;
#endregion #endregion
#region ---- keyframes ---- #region ---- keyframes ----
@ -1750,7 +1754,7 @@ function Panel_Animation() : PanelContent() constructor {
#region scroll #region scroll
dope_sheet_y = lerp_float(dope_sheet_y, dope_sheet_y_to, 4); dope_sheet_y = lerp_float(dope_sheet_y, dope_sheet_y_to, 4);
if(pHOVER && point_in_rectangle(mx, my, ui(8), ui(8), bar_x, ui(8) + dope_sheet_h)) { if(pHOVER && point_in_rectangle(mx, my, ui(8), ui(8), bar_x, ui(8) + dope_sheet_h)) {
if(mouse_wheel_down()) dope_sheet_y_to = clamp(dope_sheet_y_to - ui(32) * SCROLL_SPEED, -dope_sheet_y_max, 0); if(mouse_wheel_down()) dope_sheet_y_to = clamp(dope_sheet_y_to - ui(32) * SCROLL_SPEED, -dope_sheet_y_max, 0);
if(mouse_wheel_up()) dope_sheet_y_to = clamp(dope_sheet_y_to + ui(32) * SCROLL_SPEED, -dope_sheet_y_max, 0); if(mouse_wheel_up()) dope_sheet_y_to = clamp(dope_sheet_y_to + ui(32) * SCROLL_SPEED, -dope_sheet_y_max, 0);
@ -1765,9 +1769,9 @@ function Panel_Animation() : PanelContent() constructor {
var scr_scale_s = scr_s * scr_size; var scr_scale_s = scr_s * scr_size;
var scr_prog_s = scr_prog * (scr_s - scr_scale_s); var scr_prog_s = scr_prog * (scr_s - scr_scale_s);
var scr_w = ui(sprite_get_width(THEME.ui_scrollbar)); var scr_w = scroll_w;
var scr_h = scr_s; var scr_h = scr_s;
var s_bar_w = ui(sprite_get_width(THEME.ui_scrollbar)); var s_bar_w = scroll_w;
var s_bar_h = scr_scale_s; var s_bar_h = scr_scale_s;
var s_bar_x = scr_x; var s_bar_x = scr_x;
var s_bar_y = scr_y + scr_prog_s; var s_bar_y = scr_y + scr_prog_s;
@ -1786,6 +1790,9 @@ function Panel_Animation() : PanelContent() constructor {
} else { } else {
draw_sprite_stretched_ext(THEME.ui_scrollbar, 0, s_bar_x, s_bar_y, s_bar_w, s_bar_h, COLORS.scrollbar_idle, 1); draw_sprite_stretched_ext(THEME.ui_scrollbar, 0, s_bar_x, s_bar_y, s_bar_w, s_bar_h, COLORS.scrollbar_idle, 1);
} }
var _p = PEN_USE && (is_scrolling || point_in_rectangle(mx, my, scr_x - ui(2), scr_y - ui(2), scr_x + scr_w + ui(2), scr_y + scr_h + ui(2)));
scroll_w = lerp_float(scroll_w, _p? 12 : scroll_s, 5);
#endregion #endregion
surface_set_target(dope_sheet_surface); surface_set_target(dope_sheet_surface);

View file

@ -28,6 +28,10 @@ function scrollPane(_w, _h, ondraw) : widget() constructor {
pen_scroll_my = 0; pen_scroll_my = 0;
pen_scroll_sy = 0; pen_scroll_sy = 0;
pen_scroll_py = 0; pen_scroll_py = 0;
pen_scroll_lock = false;
scroll_s = sprite_get_width(THEME.ui_scrollbar);
scroll_w = scroll_s;
static resize = function(_w, _h) { static resize = function(_w, _h) {
w = _w; w = _w;
@ -41,26 +45,25 @@ function scrollPane(_w, _h, ondraw) : widget() constructor {
scroll_y_to = clamp(_scroll_y, -content_h, 0); scroll_y_to = clamp(_scroll_y, -content_h, 0);
} }
static draw = function(x, y, _mx = mouse_mx - x, _my = mouse_my - y) { static draw = function(x, y, mx = mouse_mx - x, my = mouse_my - y) {
self.x = x; self.x = x;
self.y = y; self.y = y;
var mx = _mx, my = _my; hover &= point_in_rectangle( mx, my, 0, 0, surface_w, surface_h);
hover &= point_in_rectangle(mx, my, 0, 0, surface_w, surface_h);
hover &= pen_scrolling != 2; hover &= pen_scrolling != 2;
surface = surface_verify(surface, surface_w, surface_h); surface = surface_verify(surface, surface_w, surface_h);
surface_set_target(surface); surface_set_target(surface);
draw_clear(COLORS.panel_bg_clear); draw_clear(COLORS.panel_bg_clear);
var hh = drawFunc(scroll_y, [mx, my], [x, y]); var hh = drawFunc(scroll_y, [ mx, my ], [ x, y ]);
content_h = max(0, hh - surface_h); content_h = max(0, hh - surface_h);
surface_reset_target(); surface_reset_target();
var sc = is_scroll; var sc = is_scroll;
is_scroll = hh > surface_h; is_scroll = hh > surface_h;
if(sc != is_scroll) if(sc != is_scroll) resize(w, h);
resize(w, h);
//// Scrolling
scroll_y_to = clamp(scroll_y_to, -content_h, 0); scroll_y_to = clamp(scroll_y_to, -content_h, 0);
scroll_y_raw = lerp_float(scroll_y_raw, scroll_y_to, 4); scroll_y_raw = lerp_float(scroll_y_raw, scroll_y_to, 4);
@ -71,13 +74,12 @@ function scrollPane(_w, _h, ondraw) : widget() constructor {
if(mouse_wheel_down()) scroll_y_to -= scroll_step * SCROLL_SPEED; if(mouse_wheel_down()) scroll_y_to -= scroll_step * SCROLL_SPEED;
if(mouse_wheel_up()) scroll_y_to += scroll_step * SCROLL_SPEED; if(mouse_wheel_up()) scroll_y_to += scroll_step * SCROLL_SPEED;
} }
scroll_lock = false;
// if(pen_scroll_lock) pen_scrolling = 0;
if(hover && PEN_USE && mouse_press(mb_left)) { // else if(hover && PEN_USE && mouse_press(mb_left)) {
pen_scrolling = 1; // pen_scrolling = 1;
pen_scroll_my = 0; // pen_scroll_my = 0;
} // }
if(pen_scrolling == 1) { if(pen_scrolling == 1) {
pen_scroll_my += PEN_Y_DELTA; pen_scroll_my += PEN_Y_DELTA;
@ -99,32 +101,37 @@ function scrollPane(_w, _h, ondraw) : widget() constructor {
} }
if(show_scroll && (abs(content_h) > 0 || always_scroll)) { if(show_scroll && (abs(content_h) > 0 || always_scroll)) {
var scr_w = sprite_get_width(THEME.ui_scrollbar); var _p = PEN_USE && (is_scrolling || point_in_rectangle(x + mx, y + my, x + w - scroll_w - 2, y, x + w, y + surface_h));
draw_scroll(x + w - scr_w, y + ui(6), true, surface_h - ui(12), -scroll_y / content_h, surface_h / (surface_h + content_h), scroll_w = lerp_float(scroll_w, _p? 12 : scroll_s, 5);
COLORS.scrollbar_bg, COLORS.scrollbar_idle, COLORS.scrollbar_hover, x + _mx, y + _my);
draw_scroll(x + w - scroll_w, y + ui(6), true, surface_h - ui(12), -scroll_y / content_h, surface_h / (surface_h + content_h),
COLORS.scrollbar_bg, COLORS.scrollbar_idle, COLORS.scrollbar_hover, x + mx, y + my, scroll_w);
} }
scroll_lock = false;
pen_scroll_lock = false;
} }
static draw_scroll = function(scr_x, scr_y, is_vert, scr_s, scr_prog, scr_ratio, bg_col, bar_col, bar_hcol, mx, my) { static draw_scroll = function(scr_x, scr_y, is_vert, scr_s, scr_prog, scr_ratio, bg_col, bar_col, bar_hcol, mx, my, bar_spr_w) {
var scr_scale_s = scr_s * scr_ratio; var scr_scale_s = scr_s * scr_ratio;
var scr_prog_s = scr_prog * (scr_s - scr_scale_s); var scr_prog_s = scr_prog * (scr_s - scr_scale_s);
var scr_w, scr_h, bar_w, bar_h, bar_x, bar_y; var scr_w, scr_h, bar_w, bar_h, bar_x, bar_y;
if(is_vert) { if(is_vert) {
scr_w = ui(sprite_get_width(THEME.ui_scrollbar)); scr_w = bar_spr_w;
scr_h = scr_s; scr_h = scr_s;
bar_w = ui(sprite_get_width(THEME.ui_scrollbar)); bar_w = bar_spr_w;
bar_h = scr_scale_s; bar_h = scr_scale_s;
bar_x = scr_x; bar_x = scr_x;
bar_y = scr_y + scr_prog_s; bar_y = scr_y + scr_prog_s;
} else { } else {
scr_w = scr_s; scr_w = scr_s;
scr_h = ui(sprite_get_width(THEME.ui_scrollbar)); scr_h = bar_spr_w;
bar_w = scr_scale_s; bar_w = scr_scale_s;
bar_h = ui(sprite_get_width(THEME.ui_scrollbar)); bar_h = bar_spr_w;
bar_x = scr_x + scr_prog_s; bar_x = scr_x + scr_prog_s;
bar_y = scr_y; bar_y = scr_y;

View file

@ -718,12 +718,16 @@ function textArea(_input, _onModify) : textInput(_input, _onModify) constructor
if(target != undefined) { if(target != undefined) {
if(!click_block) { if(!click_block) {
if(mouse_press(mb_left, active) && HOVER != o_dialog_textbox_autocomplete.id) { if(mouse_press(mb_left, active) && HOVER != o_dialog_textbox_autocomplete.id) {
if(parent) parent.pen_scroll_lock = true;
cursor_select = target; cursor_select = target;
cursor = target; cursor = target;
o_dialog_textbox_autocomplete.deactivate(self); o_dialog_textbox_autocomplete.deactivate(self);
} else if(mouse_click(mb_left, active))
} else if(mouse_click(mb_left, active)) {
if(parent) parent.pen_scroll_lock = true;
cursor = target; cursor = target;
}
} }
} }
@ -993,6 +997,7 @@ function textArea(_input, _onModify) : textInput(_input, _onModify) constructor
var bar_y = scr_y + (scr_h - bar_h) * abs(text_y / text_y_max); var bar_y = scr_y + (scr_h - bar_h) * abs(text_y / text_y_max);
if(text_scrolling) { if(text_scrolling) {
if(parent) parent.pen_scroll_lock = true;
text_y_to = text_scroll_sy - (_m[1] - text_scroll_my) / bar_h * scr_h; text_y_to = text_scroll_sy - (_m[1] - text_scroll_my) / bar_h * scr_h;
text_y_to = clamp(text_y_to, -text_y_max, 0); text_y_to = clamp(text_y_to, -text_y_max, 0);

View file

@ -502,6 +502,7 @@ function textBox(_input, _onModify) : textInput(_input, _onModify) constructor {
var hoverRect = point_in_rectangle(_m[0], _m[1], _x, _y, _x + _w, _y + _h); var hoverRect = point_in_rectangle(_m[0], _m[1], _x, _y, _x + _w, _y + _h);
if(sliding > 0) { #region slide if(sliding > 0) { #region slide
if(parent) parent.pen_scroll_lock = true;
slide_delta += PEN_USE? PEN_X_DELTA : window_mouse_get_delta_x(); slide_delta += PEN_USE? PEN_X_DELTA : window_mouse_get_delta_x();
slide_delta += PEN_USE? PEN_Y_DELTA : window_mouse_get_delta_y(); slide_delta += PEN_USE? PEN_Y_DELTA : window_mouse_get_delta_y();