diff --git a/paint/sources/context.ts b/paint/sources/context.ts index 06ddb11d..cfd01b87 100644 --- a/paint/sources/context.ts +++ b/paint/sources/context.ts @@ -642,7 +642,7 @@ function context_is_decal_mask_paint(): bool { function context_is_floating_toolbar(): bool { // Header is off -> floating toolbar - return config_raw.layout[layout_size_t.HEADER] == 0; + return config_raw.layout[layout_size_t.HEADER] == 0 || (!base_view3d_show && ui_view2d_show); } function context_get_area_type(): area_type_t { diff --git a/paint/sources/ui_menubar.ts b/paint/sources/ui_menubar.ts index a205b881..e1695234 100644 --- a/paint/sources/ui_menubar.ts +++ b/paint/sources/ui_menubar.ts @@ -19,6 +19,10 @@ function ui_menubar_init() { } function ui_menu_panel_x(): i32 { + if (!base_view3d_show && ui_view2d_show) { + return 0; + } + let panel_x: i32 = base_x(); if (config_raw.layout[layout_size_t.HEADER] == 1) { let item_w: i32 = ui_toolbar_w(); @@ -142,16 +146,19 @@ function ui_menubar_render_ui() { function ui_menubar_draw_tab_header() { let item_w: i32 = ui_toolbar_w(); - let panel_x: i32 = base_x(); - - let nodesw: i32 = (ui_nodes_show || ui_view2d_show) ? config_raw.layout[layout_size_t.NODES_W] : 0; - let ww: i32 = iron_window_width() - config_raw.layout[layout_size_t.SIDEBAR_W] - ui_menubar_w - nodesw; - panel_x = (base_x() - item_w) + ui_menubar_w; + let nodesw: i32 = (ui_nodes_show || ui_view2d_show) ? config_raw.layout[layout_size_t.NODES_W] : 0; + let ww: i32 = iron_window_width() - config_raw.layout[layout_size_t.SIDEBAR_W] - ui_menubar_w - nodesw; + let panel_x: i32 = (base_x() - item_w) + ui_menubar_w; if (!base_view3d_show) { panel_x += 1; } + if (!base_view3d_show && ui_view2d_show) { + panel_x = ui_menubar_w; + ww -= 100 * UI_SCALE(); + } + if (ui_window(ui_menubar_hwnd, panel_x, 0, ww, ui_header_h)) { if (config_raw.touch_ui) { ui_fill(0, 0, ui._window_w, ui._window_h + 4, ui.ops.theme.SEPARATOR_COL); diff --git a/paint/sources/ui_nodes.ts b/paint/sources/ui_nodes.ts index 1ea90dcc..9cefe79c 100644 --- a/paint/sources/ui_nodes.ts +++ b/paint/sources/ui_nodes.ts @@ -875,6 +875,16 @@ function ui_nodes_render() { } } + if (!base_view3d_show && ui_view2d_show) { + ui_nodes_wx = base_view3d_w(); + ui_nodes_wy = 0; + ui_nodes_ww = config_raw.layout[layout_size_t.NODES_W]; + ui_nodes_wh = sys_h(); + if (config_raw.layout[layout_size_t.HEADER] == 1) { + ui_nodes_wh += ui_header_h * 2; + } + } + if (ui_window(ui_nodes_hwnd, ui_nodes_wx, ui_nodes_wy, ui_nodes_ww, ui_nodes_wh)) { ui_tab(ui_nodes_htab, tr("Nodes"), false, -1, !base_view3d_show); diff --git a/paint/sources/ui_toolbar.ts b/paint/sources/ui_toolbar.ts index 859374e3..d7efbde9 100644 --- a/paint/sources/ui_toolbar.ts +++ b/paint/sources/ui_toolbar.ts @@ -50,7 +50,7 @@ function ui_toolbar_draw_tool(tool: i32, img: gpu_texture_t, icon_accent: i32) { let _y: i32 = ui._y; let visible: bool = true; - if (config_raw.layout[layout_size_t.HEADER] == 0) { + if (context_is_floating_toolbar()) { let statush: i32 = config_raw.layout[layout_size_t.STATUS_H]; let statusy: i32 = iron_window_height() - statush; visible = ui._y + ui._w * 2 < statusy; @@ -63,7 +63,7 @@ function ui_toolbar_draw_tool(tool: i32, img: gpu_texture_t, icon_accent: i32) { context_select_tool(_ui_toolbar_i); }); } - else if (image_state == ui_state_t.RELEASED && config_raw.layout[layout_size_t.HEADER] == 0 && visible) { + else if (image_state == ui_state_t.RELEASED && context_is_floating_toolbar() && visible) { if (ui_toolbar_last_tool == tool) { ui_toolbar_tool_properties_menu(); } @@ -95,7 +95,7 @@ function ui_toolbar_w(screen_size_request: bool = false): i32 { if (screen_size_request && context_is_floating_toolbar()) { return 0; } - if (!base_view3d_show) { + if (!base_view3d_show && !ui_view2d_show) { return 0; } @@ -117,7 +117,11 @@ function ui_toolbar_render_ui() { let h: i32 = iron_window_height() - ui_header_h - config_raw.layout[layout_size_t.STATUS_H]; let _WINDOW_BG_COL: i32 = ui.ops.theme.WINDOW_BG_COL; - if (!base_view3d_show) { + if (!base_view3d_show && !ui_view2d_show) { + return; + } + + if (ui_view2d_show && ui_view2d_type != view_2d_type_t.LAYER) { return; } @@ -126,6 +130,10 @@ function ui_toolbar_render_ui() { y += ui_toolbar_x() + 3 * UI_SCALE(); h = (ui_toolbar_tool_names.length + 1) * (ui_toolbar_w() + 2); ui.ops.theme.WINDOW_BG_COL = ui.ops.theme.SEPARATOR_COL; + + if (!base_view3d_show && ui_view2d_show) { + y += ui_toolbar_w(); + } } if (ui_window(ui_toolbar_handle, x, y, ui_toolbar_w(), h)) { @@ -137,7 +145,7 @@ function ui_toolbar_render_ui() { let icon_accent: i32 = light ? 0xff666666 : -1; // Properties icon - if (config_raw.layout[layout_size_t.HEADER] == 1) { + if (!context_is_floating_toolbar()) { let rect: rect_t = resource_tile50(img, 7, 1); if (ui_sub_image(img, light ? 0xff666666 : ui.ops.theme.BUTTON_COL, -1.0, rect.x, rect.y, rect.w, rect.h) == ui_state_t.RELEASED) { config_raw.layout[layout_size_t.HEADER] = 0; @@ -193,16 +201,21 @@ function ui_toolbar_render_ui() { } function ui_toolbar_tool_properties_menu() { + let y: i32 = ui._y - 2 * UI_SCALE(); + if (!base_view3d_show) { + y += ui_toolbar_w(); + } + ui_menu_draw(function() { ui.changed = false; ui_header_draw_tool_properties(); if (ui.changed || ui.is_typing) { ui_menu_keep_open = true; } - if (ui_button(tr("Pin to Header"), ui_align_t.LEFT)) { + if (base_view3d_show && ui_button(tr("Pin to Header"), ui_align_t.LEFT)) { config_raw.layout[layout_size_t.HEADER] = 1; } - }, math_floor(ui._x + ui._w + 6 * UI_SCALE()), math_floor(ui._y - 2 * UI_SCALE())); + }, ui._x + ui._w + 6 * UI_SCALE(), y); } function ui_toolbar_draw_highlight() { diff --git a/paint/sources/ui_view2d.ts b/paint/sources/ui_view2d.ts index f10cc781..e209ae3f 100644 --- a/paint/sources/ui_view2d.ts +++ b/paint/sources/ui_view2d.ts @@ -107,6 +107,12 @@ function ui_view2d_render() { } } + if (!base_view3d_show && ui_nodes_show) { + ui_view2d_wx = 0; + ui_view2d_ww = base_view3d_w(); + ui_view2d_wh = iron_window_height() - config_raw.layout[layout_size_t.STATUS_H]; + } + if (ui_window(ui_view2d_hwnd, ui_view2d_wx, ui_view2d_wy, ui_view2d_ww, ui_view2d_wh)) { ui_tab(ui_view2d_htab, tr("2D View"), false, -1, !base_view3d_show); @@ -116,11 +122,14 @@ function ui_view2d_render() { } // Grid + // draw_set_color(0xffffffff); + // let step: f32 = ui_nodes_grid_cell_w * ui_view2d_pan_scale; + // let x: f32 = math_fmod(ui_view2d_pan_x, step) - step; + // let y: f32 = math_fmod(ui_view2d_pan_y, step) - step; + // draw_image(ui_view2d_grid, x, y); + draw_set_color(ui.ops.theme.SEPARATOR_COL + 0x00020202); + draw_filled_rect(0, 0, ui_view2d_ww, ui_view2d_wh); draw_set_color(0xffffffff); - let step: f32 = ui_nodes_grid_cell_w * ui_view2d_pan_scale; - let x: f32 = math_fmod(ui_view2d_pan_x, step) - step; - let y: f32 = math_fmod(ui_view2d_pan_y, step) - step; - draw_image(ui_view2d_grid, x, y); // Texture let tex: gpu_texture_t = null;