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);
selecting = -1;
menu_id = "";
alarm[0] = -1;
menu = 1;
font = f_p2;
hght = line_get_height(font, 10);
tooltips = [];
show_icon = false;
context = noone;
submenu = noone;
submenuIt = noone;
parentPanel = noone;
menu_id = "";
alarm[0] = -1;
menu = 1;
font = f_p2;
hght = line_get_height(font, 10);
tooltips = [];
show_icon = false;
context = noone;
submenu = noone;
submenuIt = noone;
_hovering_ch = true;
init_press_l = MOUSE_POOL.lpress;
@ -83,8 +84,7 @@ event_inherited();
dialog_h += hght;
}
if(show_icon)
dialog_w += ui(32);
dialog_w += show_icon * ui(32);
var _mon = winMan_getData();
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);
for(var i = 0; i < array_length(menu); i++) {
for( var i = 0, n = array_length(menu); i < n; i++ ) {
var _menuItem = menu[i];
if(is_string(_menuItem)) {
@ -64,6 +64,7 @@ DIALOG_WINCLEAR1
if(_hovering_ch && is_instanceof(_menuItem, MenuItem)) {
if(_menuItem.active && _lclick) {
var _par = _menuItem.params;
var _p = _par != noone;
if(_menuItem.isShelf) {
FOCUS_CONTENT = context;
@ -92,21 +93,13 @@ DIALOG_WINCLEAR1
submenuIt = _menuItem;
}
} else if(remove_parents) {
FOCUS_CONTENT = context;
if(_par == noone) _menuItem.func();
else _menuItem.func(_par);
to_del = o_dialog_menubox;
} else {
FOCUS_CONTENT = context;
if(_par == noone) _menuItem.func();
else _menuItem.func(_par);
if(_p) _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)
draw_sprite_ui_uniform(_spr, _ind, _bx, _by,, _clr);
if(_str != "")
draw_text(_bx, _by, _str);
if(_spr != noone) draw_sprite_ui_uniform(_spr, _ind, _bx, _by, 1, _clr);
if(_str != "") draw_text(_bx, _by, _str);
}
} else {
@ -214,7 +204,9 @@ DIALOG_WINCLEAR1
var sca = array_safe_get_fast(_menuItem.spr, 2, 0.8);
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);
gpu_set_tex_filter(false);
}
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 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) {
setContent(panel.content);
childs = panel.childs;
@ -79,36 +115,20 @@ function Panel(_parent, _x, _y, _w, _h) constructor {
refreshSize();
}
function resetMask() {
var tab = array_length(content) > 1;
tx = x; ty = y + tab * tab_height;
tw = w; th = h - tab * tab_height;
function refresh() {
resetMask();
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();
array_foreach(content, function(c) /*=>*/ { c.refresh(); });
array_foreach(childs, function(c) /*=>*/ { c.refresh(); });
}
////- Sizing
function setPadding(padding) {
self.padding = padding;
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) {
x += dx;
y += dy;
@ -147,8 +167,7 @@ function Panel(_parent, _x, _y, _w, _h) constructor {
return childs[ind].resizable(dw, dh, oppose);
}
function refreshSize(recur = true) { //refresh content surface after resize
//__debug_counter("refresh size");
function refreshSize(recur = true) { // refresh content surface after resize
var tab = array_length(content) > 1;
tx = x; ty = y + tab * tab_height;
tw = w; th = h - tab * tab_height;
@ -219,26 +238,6 @@ function Panel(_parent, _x, _y, _w, _h) constructor {
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) {
if(abs(_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];
}
////- Step
function stepBegin() {
var con = getContent();
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();
}
////- 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() {
if(hasContent()) { drawPanel(); return; }
if(hasContent()) { drawContent(); return; }
if(array_empty(childs)) return;
@ -448,6 +466,7 @@ function Panel(_parent, _x, _y, _w, _h) constructor {
continue;
var p = ui(6 - 1);
switch(_panel.anchor) {
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))
@ -637,24 +656,7 @@ function Panel(_parent, _x, _y, _w, _h) constructor {
draw_surface(tab_surface, tsx, tsy);
}
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 drawPanel() {
function drawContent() {
if(w <= ui(16)) return;
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(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) {
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) {
extract();
panel_mouse = 0;
} else if(mouse_press(mb_right)) {
var menu = array_clone(border_rb_menu);
if(instanceof(getContent()) == "Panel_Menu")
@ -749,6 +753,8 @@ function Panel(_parent, _x, _y, _w, _h) constructor {
con.drawGUI();
}
////- Actions
function extract() {
var con = getContent();
con.dragSurface = surface_clone(content_surface);

View file

@ -248,7 +248,7 @@ function connectionParameter() constructor {
}
}
////- Graph
////- Graph
function Panel_Graph(project = PROJECT) : PanelContent() constructor {
title = __txt("Graph");
@ -1131,9 +1131,9 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
draw_set_alpha(1);
}
function drawViewControl() { //
function drawViewController() { //
if(h < ui(96)) return;
view_hovering = false;
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_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() { //
@ -2617,7 +2621,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
drawToolBar();
drawMinimap();
drawViewControl();
drawViewController();
if(pFOCUS && !view_hovering) array_foreach(nodes_selecting, function(node) { node.focusStep(); });
@ -3502,7 +3506,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
initSize();
}
////- File
////- File
function load_file_path(path, _x = undefined, _y = undefined) {
if(!is_array(path)) path = [ path ];

View file

@ -1603,8 +1603,9 @@ function Panel_Preview() : PanelContent() constructor {
var _view_x = show_view_control == 1?
tool_side_draw_l * toolbar_width + ui(8) :
w - tool_side_draw_r * toolbar_width - 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;
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_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) {