add hide option in view controller context menu

This commit is contained in:
Tanasart 2024-12-27 11:05:50 +07:00
parent 2af707f36f
commit 21626889d9
5 changed files with 108 additions and 100 deletions

View file

@ -8,16 +8,17 @@ event_inherited();
mouse_init_r_pressed = mouse_click(mb_right); mouse_init_r_pressed = mouse_click(mb_right);
selecting = -1; selecting = -1;
menu_id = ""; parentPanel = noone;
alarm[0] = -1; menu_id = "";
menu = 1; alarm[0] = -1;
font = f_p2; menu = 1;
hght = line_get_height(font, 10); font = f_p2;
tooltips = []; hght = line_get_height(font, 10);
show_icon = false; tooltips = [];
context = noone; show_icon = false;
submenu = noone; context = noone;
submenuIt = noone; submenu = noone;
submenuIt = noone;
_hovering_ch = true; _hovering_ch = true;
init_press_l = MOUSE_POOL.lpress; init_press_l = MOUSE_POOL.lpress;
@ -83,8 +84,7 @@ event_inherited();
dialog_h += hght; dialog_h += hght;
} }
if(show_icon) dialog_w += show_icon * ui(32);
dialog_w += ui(32);
var _mon = winMan_getData(); var _mon = winMan_getData();
var _maxw = PREFERENCES.multi_window? _mon[6] - WIN_X : WIN_W; var _maxw = PREFERENCES.multi_window? _mon[6] - WIN_X : WIN_W;

View file

@ -18,7 +18,7 @@ DIALOG_WINCLEAR1
draw_sprite_stretched(THEME.s_box_r2_clr, 0, dialog_x, dialog_y, dialog_w, dialog_h); draw_sprite_stretched(THEME.s_box_r2_clr, 0, dialog_x, dialog_y, dialog_w, dialog_h);
for(var i = 0; i < array_length(menu); i++) { for( var i = 0, n = array_length(menu); i < n; i++ ) {
var _menuItem = menu[i]; var _menuItem = menu[i];
if(is_string(_menuItem)) { if(is_string(_menuItem)) {
@ -64,6 +64,7 @@ DIALOG_WINCLEAR1
if(_hovering_ch && is_instanceof(_menuItem, MenuItem)) { if(_hovering_ch && is_instanceof(_menuItem, MenuItem)) {
if(_menuItem.active && _lclick) { if(_menuItem.active && _lclick) {
var _par = _menuItem.params; var _par = _menuItem.params;
var _p = _par != noone;
if(_menuItem.isShelf) { if(_menuItem.isShelf) {
FOCUS_CONTENT = context; FOCUS_CONTENT = context;
@ -92,21 +93,13 @@ DIALOG_WINCLEAR1
submenuIt = _menuItem; submenuIt = _menuItem;
} }
} else if(remove_parents) {
FOCUS_CONTENT = context;
if(_par == noone) _menuItem.func();
else _menuItem.func(_par);
to_del = o_dialog_menubox;
} else { } else {
FOCUS_CONTENT = context; FOCUS_CONTENT = context;
if(_par == noone) _menuItem.func(); if(_p) _menuItem.func(_par);
else _menuItem.func(_par); else _menuItem.func();
to_del = self; to_del = remove_parents? o_dialog_menubox : self;
} }
} }
} }
@ -200,11 +193,8 @@ DIALOG_WINCLEAR1
} }
} }
if(_spr != noone) if(_spr != noone) draw_sprite_ui_uniform(_spr, _ind, _bx, _by, 1, _clr);
draw_sprite_ui_uniform(_spr, _ind, _bx, _by,, _clr); if(_str != "") draw_text(_bx, _by, _str);
if(_str != "")
draw_text(_bx, _by, _str);
} }
} else { } else {
@ -214,7 +204,9 @@ DIALOG_WINCLEAR1
var sca = array_safe_get_fast(_menuItem.spr, 2, 0.8); var sca = array_safe_get_fast(_menuItem.spr, 2, 0.8);
var clr = array_safe_get_fast(_menuItem.spr, 3, COLORS._main_icon); var clr = array_safe_get_fast(_menuItem.spr, 3, COLORS._main_icon);
gpu_set_tex_filter(true);
draw_sprite_ui(spr, ind, dialog_x + ui(24), yy + hght / 2, sca, sca, 0, clr, _menuItem.active * 0.5 + 0.25); draw_sprite_ui(spr, ind, dialog_x + ui(24), yy + hght / 2, sca, sca, 0, clr, _menuItem.active * 0.5 + 0.25);
gpu_set_tex_filter(false);
} }
if(_menuItem.toggle != noone) { if(_menuItem.toggle != noone) {

View file

@ -71,6 +71,42 @@ function Panel(_parent, _x, _y, _w, _h) constructor {
static getContent = function() { return array_safe_get_fast(content, content_index, noone); } static getContent = function() { return array_safe_get_fast(content, content_index, noone); }
static hasContent = function() { return bool(array_length(content)); } static hasContent = function() { return bool(array_length(content)); }
////- Content
function setContent(_content = noone, _switch = false) {
array_append(content, _content);
for( var i = 0, n = array_length(content); i < n; i++ )
content[i].onSetPanel(self);
if(_switch) switchContent(_content);
refresh();
}
function switchContent(_content) {
var _ind = array_find(content, _content);
if(_ind == -1) return;
setTab(_ind);
}
function setTab(tabIndex, forceFocus = false) {
if(tabIndex < 0) return;
if(tabIndex >= array_length(content)) return;
if(content_index == tabIndex) {
if(forceFocus) content[tabIndex].onFocusBegin();
return;
}
var prec = array_safe_get_fast(content, content_index);
if(prec) prec.onFocusEnd();
content_index = tabIndex;
var prec = array_safe_get_fast(content, content_index);
if(prec) prec.onFocusBegin();
}
function replacePanel(panel) { function replacePanel(panel) {
setContent(panel.content); setContent(panel.content);
childs = panel.childs; childs = panel.childs;
@ -79,36 +115,20 @@ function Panel(_parent, _x, _y, _w, _h) constructor {
refreshSize(); refreshSize();
} }
function resetMask() { function refresh() {
var tab = array_length(content) > 1; resetMask();
tx = x; ty = y + tab * tab_height;
tw = w; th = h - tab * tab_height;
content_surface = surface_verify(content_surface, tw, th); array_foreach(content, function(c) /*=>*/ { c.refresh(); });
mask_surface = surface_verify(mask_surface, tw, th); array_foreach(childs, function(c) /*=>*/ { c.refresh(); });
surface_set_target(mask_surface); }
draw_clear(c_black);
gpu_set_blendmode(bm_subtract); ////- Sizing
draw_sprite_stretched(THEME.ui_panel_bg, 0, padding, padding, tw - padding * 2, th - padding * 2);
gpu_set_blendmode(bm_normal);
surface_reset_target();
} resetMask();
function setPadding(padding) { function setPadding(padding) {
self.padding = padding; self.padding = padding;
refresh(); refresh();
} }
function refresh() {
resetMask();
for( var i = 0, n = array_length(content); i < n; i++ )
content[i].refresh();
for( var i = 0; i < array_length(childs); i++ )
childs[i].refresh();
}
function move(dx, dy) { function move(dx, dy) {
x += dx; x += dx;
y += dy; y += dy;
@ -147,8 +167,7 @@ function Panel(_parent, _x, _y, _w, _h) constructor {
return childs[ind].resizable(dw, dh, oppose); return childs[ind].resizable(dw, dh, oppose);
} }
function refreshSize(recur = true) { //refresh content surface after resize function refreshSize(recur = true) { // refresh content surface after resize
//__debug_counter("refresh size");
var tab = array_length(content) > 1; var tab = array_length(content) > 1;
tx = x; ty = y + tab * tab_height; tx = x; ty = y + tab * tab_height;
tw = w; th = h - tab * tab_height; tw = w; th = h - tab * tab_height;
@ -219,26 +238,6 @@ function Panel(_parent, _x, _y, _w, _h) constructor {
refreshSize(false); refreshSize(false);
} }
function setContent(_content = noone, _switch = false) {
if(is_array(_content))
content = array_append(content, _content);
else
array_push(content, _content);
for( var i = 0, n = array_length(content); i < n; i++ )
content[i].onSetPanel(self);
if(_switch) setTab(array_find(content, _content));
refresh();
}
function switchContent(_content) {
var _ind = array_find(content, _content);
if(_ind == -1) return;
setTab(_ind);
}
function split_h(_w) { function split_h(_w) {
if(abs(_w) > w) { if(abs(_w) > w) {
print($"Error: Split panel larger than size w ({_w} > {w})"); print($"Error: Split panel larger than size w ({_w} > {w})");
@ -310,6 +309,8 @@ function Panel(_parent, _x, _y, _w, _h) constructor {
return [_panelT, _panelB]; return [_panelT, _panelB];
} }
////- Step
function stepBegin() { function stepBegin() {
var con = getContent(); var con = getContent();
if(FULL_SCREEN_CONTENT != noone && con == FULL_SCREEN_CONTENT && self != FULL_SCREEN_PARENT) return; if(FULL_SCREEN_CONTENT != noone && con == FULL_SCREEN_CONTENT && self != FULL_SCREEN_PARENT) return;
@ -421,8 +422,25 @@ function Panel(_parent, _x, _y, _w, _h) constructor {
childs[i].step(); childs[i].step();
} }
////- Draw
function resetMask() {
var tab = array_length(content) > 1;
tx = x; ty = y + tab * tab_height;
tw = w; th = h - tab * tab_height;
content_surface = surface_verify(content_surface, tw, th);
mask_surface = surface_verify(mask_surface, tw, th);
surface_set_target(mask_surface);
draw_clear(c_black);
gpu_set_blendmode(bm_subtract);
draw_sprite_stretched(THEME.ui_panel_bg, 0, padding, padding, tw - padding * 2, th - padding * 2);
gpu_set_blendmode(bm_normal);
surface_reset_target();
} resetMask();
static draw = function() { static draw = function() {
if(hasContent()) { drawPanel(); return; } if(hasContent()) { drawContent(); return; }
if(array_empty(childs)) return; if(array_empty(childs)) return;
@ -448,6 +466,7 @@ function Panel(_parent, _x, _y, _w, _h) constructor {
continue; continue;
var p = ui(6 - 1); var p = ui(6 - 1);
switch(_panel.anchor) { switch(_panel.anchor) {
case ANCHOR.left : case ANCHOR.left :
if(!point_in_rectangle(mouse_mx, mouse_my, _panel.x + _panel.w - p, _panel.y, _panel.x + _panel.w + p, _panel.y + _panel.h)) if(!point_in_rectangle(mouse_mx, mouse_my, _panel.x + _panel.w - p, _panel.y, _panel.x + _panel.w + p, _panel.y + _panel.h))
@ -637,24 +656,7 @@ function Panel(_parent, _x, _y, _w, _h) constructor {
draw_surface(tab_surface, tsx, tsy); draw_surface(tab_surface, tsx, tsy);
} }
function setTab(tabIndex, forceFocus = false) { function drawContent() {
if(tabIndex < 0) return;
if(tabIndex >= array_length(content)) return;
if(content_index == tabIndex) {
if(forceFocus) content[tabIndex].onFocusBegin();
return;
}
var prec = array_safe_get_fast(content, content_index);
if(prec) prec.onFocusEnd();
content_index = tabIndex;
var prec = array_safe_get_fast(content, content_index);
if(prec) prec.onFocusBegin();
}
function drawPanel() {
if(w <= ui(16)) return; if(w <= ui(16)) return;
var tab = array_length(content) > 1; var tab = array_length(content) > 1;
@ -713,7 +715,8 @@ function Panel(_parent, _x, _y, _w, _h) constructor {
if(tab) draw_sprite_bbox(THEME.ui_panel_tab, 3, tab_cover); if(tab) draw_sprite_bbox(THEME.ui_panel_tab, 3, tab_cover);
if(FOCUS == self && parent != noone) { if(FOCUS == self && parent != noone) {
draw_sprite_stretched_ext(THEME.ui_panel, 1, tx + padding, ty + padding, tw - padding * 2, th - padding * 2, PREFERENCES.panel_outline_accent? COLORS._main_accent : COLORS.panel_select_border, 1); var _color = PREFERENCES.panel_outline_accent? COLORS._main_accent : COLORS.panel_select_border;
draw_sprite_stretched_ext(THEME.ui_panel, 1, tx + padding, ty + padding, tw - padding * 2, th - padding * 2, _color, 1);
if(hasContent() && !m_in && m_ot) { if(hasContent() && !m_in && m_ot) {
draw_sprite_stretched_ext(THEME.ui_panel, 1, tx + padding, ty + padding, tw - padding * 2, th - padding * 2, c_white, 0.4); draw_sprite_stretched_ext(THEME.ui_panel, 1, tx + padding, ty + padding, tw - padding * 2, th - padding * 2, c_white, 0.4);
@ -721,6 +724,7 @@ function Panel(_parent, _x, _y, _w, _h) constructor {
if(DOUBLE_CLICK) { if(DOUBLE_CLICK) {
extract(); extract();
panel_mouse = 0; panel_mouse = 0;
} else if(mouse_press(mb_right)) { } else if(mouse_press(mb_right)) {
var menu = array_clone(border_rb_menu); var menu = array_clone(border_rb_menu);
if(instanceof(getContent()) == "Panel_Menu") if(instanceof(getContent()) == "Panel_Menu")
@ -749,6 +753,8 @@ function Panel(_parent, _x, _y, _w, _h) constructor {
con.drawGUI(); con.drawGUI();
} }
////- Actions
function extract() { function extract() {
var con = getContent(); var con = getContent();
con.dragSurface = surface_clone(content_surface); con.dragSurface = surface_clone(content_surface);

View file

@ -248,7 +248,7 @@ function connectionParameter() constructor {
} }
} }
////- Graph ////- Graph
function Panel_Graph(project = PROJECT) : PanelContent() constructor { function Panel_Graph(project = PROJECT) : PanelContent() constructor {
title = __txt("Graph"); title = __txt("Graph");
@ -1131,9 +1131,9 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
draw_set_alpha(1); draw_set_alpha(1);
} }
function drawViewControl() { // function drawViewController() { //
if(h < ui(96)) return; if(h < ui(96)) return;
view_hovering = false; view_hovering = false;
if(!show_view_control) return; if(!show_view_control) return;
@ -1196,6 +1196,10 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
draw_circle_ui(_d3x, _d3y, d3_view_wz, _hv? 0 : 0.04, COLORS._main_icon, 0.3); draw_circle_ui(_d3x, _d3y, d3_view_wz, _hv? 0 : 0.04, COLORS._main_icon, 0.3);
draw_sprite_ui(THEME.view_zoom, 0, _d3x, _d3y, 1, 1, 0, view_zoom_tool? COLORS._main_accent : COLORS._main_icon, 1); draw_sprite_ui(THEME.view_zoom, 0, _d3x, _d3y, 1, 1, 0, view_zoom_tool? COLORS._main_accent : COLORS._main_icon, 1);
if(view_hovering && mouse_press(mb_right, pFOCUS)) {
mouse_on_graph = false;
menuCall("preview_view_controller", [ menuItem("Hide view controllers", function() /*=>*/ { show_view_control = 0; }) ]);
}
} }
function drawBasePreview() { // function drawBasePreview() { //
@ -2617,7 +2621,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
drawToolBar(); drawToolBar();
drawMinimap(); drawMinimap();
drawViewControl(); drawViewController();
if(pFOCUS && !view_hovering) array_foreach(nodes_selecting, function(node) { node.focusStep(); }); if(pFOCUS && !view_hovering) array_foreach(nodes_selecting, function(node) { node.focusStep(); });
@ -3502,7 +3506,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
initSize(); initSize();
} }
////- File ////- File
function load_file_path(path, _x = undefined, _y = undefined) { function load_file_path(path, _x = undefined, _y = undefined) {
if(!is_array(path)) path = [ path ]; if(!is_array(path)) path = [ path ];

View file

@ -1603,8 +1603,9 @@ function Panel_Preview() : PanelContent() constructor {
var _view_x = show_view_control == 1? var _view_x = show_view_control == 1?
tool_side_draw_l * toolbar_width + ui(8) : tool_side_draw_l * toolbar_width + ui(8) :
w - tool_side_draw_r * toolbar_width - ui(8); w - tool_side_draw_r * toolbar_width - ui(8);
var _view_y = topbar_height + ui(8); var _view_y = topbar_height + ui(8);
var _hab = pHOVER && tool_hovering == noone && !view_pan_tool && !view_zoom_tool; var _hab = pHOVER && tool_hovering == noone && !view_pan_tool && !view_zoom_tool;
view_hovering = false; view_hovering = false;
if(d3_active) { if(d3_active) {
@ -1725,6 +1726,11 @@ function Panel_Preview() : PanelContent() constructor {
draw_circle_ui(_d3x, _d3y, d3_view_wz, _hv? 0 : 0.04, COLORS._main_icon, 0.3); draw_circle_ui(_d3x, _d3y, d3_view_wz, _hv? 0 : 0.04, COLORS._main_icon, 0.3);
draw_sprite_ui(THEME.view_zoom, 0, _d3x, _d3y, 1, 1, 0, view_zoom_tool? COLORS._main_accent : COLORS._main_icon, 1); draw_sprite_ui(THEME.view_zoom, 0, _d3x, _d3y, 1, 1, 0, view_zoom_tool? COLORS._main_accent : COLORS._main_icon, 1);
} }
if(view_hovering && mouse_press(mb_right, pFOCUS)) {
mouse_on_preview = false;
menuCall("preview_view_controller", [ menuItem("Hide view controllers", function() /*=>*/ { show_view_control = 0; }) ]);
}
} }
function drawAllNodeGizmo(active) { function drawAllNodeGizmo(active) {