diff --git a/imgui.ini b/imgui.ini index 5760f2f1..0bde0223 100644 --- a/imgui.ini +++ b/imgui.ini @@ -24,26 +24,26 @@ Size=832,45 Collapsed=0 [Window][工具栏] -Pos=354,20 -Size=1334,32 +Pos=318,20 +Size=1809,32 Collapsed=0 DockId=0x0000000D,0 [Window][场景树] Pos=0,20 -Size=352,748 +Size=322,995 Collapsed=0 DockId=0x00000007,0 [Window][属性面板] -Pos=1690,20 -Size=358,748 +Pos=2129,20 +Size=431,995 Collapsed=0 DockId=0x00000002,0 [Window][控制台] -Pos=1690,20 -Size=358,748 +Pos=2129,20 +Size=431,995 Collapsed=0 DockId=0x00000002,1 @@ -60,7 +60,7 @@ Collapsed=0 [Window][WindowOverViewport_11111111] Pos=0,20 -Size=2048,1084 +Size=2560,1331 Collapsed=0 [Window][测试窗口1] @@ -84,12 +84,12 @@ Size=400,300 Collapsed=0 [Window][选择路径] -Pos=660,254 +Pos=980,425 Size=600,500 Collapsed=0 [Window][打开项目] -Pos=710,304 +Pos=1030,475 Size=500,400 Collapsed=0 @@ -99,8 +99,8 @@ Size=600,500 Collapsed=0 [Window][资源管理器] -Pos=0,770 -Size=2048,334 +Pos=0,1017 +Size=2560,334 Collapsed=0 DockId=0x00000006,0 @@ -207,18 +207,18 @@ Collapsed=0 DockId=0x00000002,2 [Window][项目另存为] -Pos=794,432 +Pos=1050,555 Size=460,240 Collapsed=0 [Docking][Data] -DockSpace ID=0x08BD597D Window=0x1BBC0F80 Pos=0,20 Size=2048,1084 Split=Y +DockSpace ID=0x08BD597D Window=0x1BBC0F80 Pos=0,20 Size=2560,1331 Split=Y DockNode ID=0x00000005 Parent=0x08BD597D SizeRef=2560,995 Split=X - DockNode ID=0x00000007 Parent=0x00000005 SizeRef=352,1084 Selected=0xE0015051 - DockNode ID=0x00000008 Parent=0x00000005 SizeRef=2206,1084 Split=X - DockNode ID=0x00000001 Parent=0x00000008 SizeRef=1846,989 Split=Y - DockNode ID=0x0000000D Parent=0x00000001 SizeRef=1318,32 HiddenTabBar=1 Selected=0x43A39006 + DockNode ID=0x00000007 Parent=0x00000005 SizeRef=322,1084 Selected=0xE0015051 + DockNode ID=0x00000008 Parent=0x00000005 SizeRef=1724,1084 Split=X + DockNode ID=0x00000001 Parent=0x00000008 SizeRef=1291,989 Split=Y + DockNode ID=0x0000000D Parent=0x00000001 SizeRef=1318,32 Selected=0x43A39006 DockNode ID=0x0000000E Parent=0x00000001 SizeRef=1318,961 CentralNode=1 - DockNode ID=0x00000002 Parent=0x00000008 SizeRef=358,989 Selected=0x5DB6FF37 + DockNode ID=0x00000002 Parent=0x00000008 SizeRef=431,989 Selected=0x5428E753 DockNode ID=0x00000006 Parent=0x08BD597D SizeRef=2560,334 Selected=0x3A2E05C3 diff --git a/ui/panels/editor_panels_top.py b/ui/panels/editor_panels_top.py index 0e40fb59..ea0aa4e7 100644 --- a/ui/panels/editor_panels_top.py +++ b/ui/panels/editor_panels_top.py @@ -3,6 +3,82 @@ from imgui_bundle import imgui, imgui_ctx class EditorPanelsTopMixin: """Auto-split mixin from editor_panels.py.""" + @staticmethod + def _draw_toolbar_text_button(label, active=False, tooltip=None, enabled=True): + """Draw a text-only toolbar action with no filled background.""" + text_color = (0.84, 0.87, 0.91, 1.0) + hover_color = (0.96, 0.98, 1.0, 1.0) + active_color = (0.24, 0.58, 1.0, 1.0) + disabled_color = (0.45, 0.48, 0.53, 0.75) + + if not enabled: + current_color = disabled_color + elif active: + current_color = active_color + else: + current_color = text_color + + imgui.push_style_color(imgui.Col_.button, (0.0, 0.0, 0.0, 0.0)) + imgui.push_style_color(imgui.Col_.button_hovered, (0.0, 0.0, 0.0, 0.0)) + imgui.push_style_color(imgui.Col_.button_active, (0.0, 0.0, 0.0, 0.0)) + imgui.push_style_color(imgui.Col_.border, (0.0, 0.0, 0.0, 0.0)) + imgui.push_style_color(imgui.Col_.text, current_color) + imgui.push_style_var(imgui.StyleVar_.frame_padding, (6.0, 4.0)) + imgui.push_style_var(imgui.StyleVar_.frame_border_size, 0.0) + imgui.push_style_var(imgui.StyleVar_.frame_rounding, 0.0) + + if not enabled: + imgui.begin_disabled() + clicked = imgui.button(label) + hovered = imgui.is_item_hovered() + if not enabled: + imgui.end_disabled() + + if active: + min_pos = imgui.get_item_rect_min() + max_pos = imgui.get_item_rect_max() + draw_list = imgui.get_window_draw_list() + accent = imgui.color_convert_float4_to_u32(active_color) + draw_list.add_line( + (min_pos.x + 1.0, max_pos.y + 1.0), + (max_pos.x - 1.0, max_pos.y + 1.0), + accent, + 3.0, + ) + elif hovered and enabled: + min_pos = imgui.get_item_rect_min() + max_pos = imgui.get_item_rect_max() + draw_list = imgui.get_window_draw_list() + hover_u32 = imgui.color_convert_float4_to_u32((hover_color[0], hover_color[1], hover_color[2], 0.75)) + draw_list.add_line( + (min_pos.x + 2.0, max_pos.y + 1.0), + (max_pos.x - 2.0, max_pos.y + 1.0), + hover_u32, + 1.0, + ) + + if tooltip and hovered: + imgui.set_tooltip(tooltip) + + imgui.pop_style_var(3) + imgui.pop_style_color(5) + return clicked + + @staticmethod + def _draw_toolbar_text_chip(label, active=False): + """Draw a text-only status label without a background block.""" + base_color = (0.72, 0.75, 0.8, 0.92) + active_color = (0.88, 0.91, 0.96, 1.0) + imgui.push_style_color(imgui.Col_.text, active_color if active else base_color) + imgui.text_unformatted(label) + imgui.pop_style_color() + + @staticmethod + def _draw_toolbar_divider(): + imgui.push_style_color(imgui.Col_.text, (0.38, 0.41, 0.46, 0.85)) + imgui.text_unformatted("|") + imgui.pop_style_color() + @staticmethod def _truncate_toolbar_text(text, limit=20): text = text or "" @@ -280,16 +356,48 @@ class EditorPanelsTopMixin: def draw_toolbar(self): """绘制工具栏""" - # 工具栏可以保持无标题栏,但允许移动和调整大小 - flags = self.app.style_manager.get_window_flags("toolbar") - - with self.app.style_manager.begin_styled_window("工具栏", self.app.showToolbar, flags) as (_, opened): + viewport = imgui.get_main_viewport() + menu_bar_height = imgui.get_frame_height() + toolbar_y = viewport.pos.y + menu_bar_height + 6.0 + toolbar_x = viewport.pos.x + 8.0 + + scene_tree_rect = getattr(self.app, "_scene_tree_window_rect", None) + if self.app.is_panel_visible("scene_tree") and scene_tree_rect: + scene_tree_right = float(scene_tree_rect[0]) + float(scene_tree_rect[2]) + toolbar_x = max(toolbar_x, scene_tree_right + 12.0) + + toolbar_width = max(320.0, viewport.pos.x + viewport.size.x - toolbar_x - 12.0) + + imgui.set_next_window_pos((toolbar_x, toolbar_y), imgui.Cond_.always) + imgui.set_next_window_size((toolbar_width, 34.0), imgui.Cond_.always) + imgui.set_next_window_bg_alpha(0.0) + + flags = ( + imgui.WindowFlags_.no_title_bar | + imgui.WindowFlags_.no_resize | + imgui.WindowFlags_.no_move | + imgui.WindowFlags_.no_scrollbar | + imgui.WindowFlags_.no_scroll_with_mouse | + imgui.WindowFlags_.no_saved_settings | + imgui.WindowFlags_.no_collapse | + imgui.WindowFlags_.no_background + ) + + imgui.push_style_color(imgui.Col_.window_bg, (0.0, 0.0, 0.0, 0.0)) + imgui.push_style_color(imgui.Col_.border, (0.0, 0.0, 0.0, 0.0)) + imgui.push_style_var(imgui.StyleVar_.window_padding, (0.0, 2.0)) + imgui.push_style_var(imgui.StyleVar_.window_border_size, 0.0) + imgui.push_style_var(imgui.StyleVar_.window_rounding, 0.0) + + with imgui_ctx.begin("工具栏", self.app.showToolbar, flags) as (_, opened): if not opened: self.app.showToolbar = False + self.app._toolbar_window_rect = None + imgui.pop_style_var(3) + imgui.pop_style_color(2) return self.app.showToolbar = opened - style_manager = self.app.style_manager command_manager = getattr(self.app, "command_manager", None) can_undo = command_manager.can_undo() if command_manager else False can_redo = command_manager.can_redo() if command_manager else False @@ -297,8 +405,7 @@ class EditorPanelsTopMixin: project_name = self._truncate_toolbar_text(self._get_toolbar_project_name(), 18) tool_name = getattr(self.app.tool_manager, "getCurrentTool", lambda: "选择")() - imgui.push_style_var(imgui.StyleVar_.item_spacing, (8.0, 6.0)) - imgui.push_style_var(imgui.StyleVar_.frame_padding, (8.0, 5.0)) + imgui.push_style_var(imgui.StyleVar_.item_spacing, (14.0, 4.0)) tool_buttons = [ ("Q 选择", "选择", self.app.tool_manager.isSelectionTool(), "选择工具 (Q)"), @@ -308,42 +415,51 @@ class EditorPanelsTopMixin: ] for index, (label, tool_id, is_active, tooltip) in enumerate(tool_buttons): - if style_manager.draw_toolbar_button(label, active=is_active, size=(74, 28), tooltip=tooltip): + if self._draw_toolbar_text_button(label, active=is_active, tooltip=tooltip): self.app.tool_manager.setCurrentTool(tool_id) if index != len(tool_buttons) - 1: imgui.same_line() imgui.same_line() - imgui.separator() + self._draw_toolbar_divider() imgui.same_line() - if style_manager.draw_toolbar_button("撤销", size=(56, 28), tooltip="撤销上一步 (Ctrl+Z)", enabled=can_undo): + if self._draw_toolbar_text_button("撤销", tooltip="撤销上一步 (Ctrl+Z)", enabled=can_undo): self.app._on_undo() imgui.same_line() - if style_manager.draw_toolbar_button("重做", size=(56, 28), tooltip="重做上一步 (Ctrl+Y)", enabled=can_redo): + if self._draw_toolbar_text_button("重做", tooltip="重做上一步 (Ctrl+Y)", enabled=can_redo): self.app._on_redo() imgui.same_line() - if style_manager.draw_toolbar_button( + if self._draw_toolbar_text_button( "聚焦", - size=(56, 28), tooltip="聚焦当前选择 (F)", enabled=selection_name != "未选择", ): self.app.onFocusKeyPressed() imgui.same_line() - imgui.separator() + self._draw_toolbar_divider() imgui.same_line() - style_manager.draw_stat_chip(f"项目 {project_name}", tint=(0.12, 0.14, 0.18, 1.0)) + self._draw_toolbar_text_chip(f"项目 {project_name}") imgui.same_line() - style_manager.draw_stat_chip(f"工具 {tool_name}", tint=(0.16, 0.19, 0.24, 1.0)) + self._draw_toolbar_text_chip(f"工具 {tool_name}", active=True) imgui.same_line() - style_manager.draw_stat_chip(f"选择 {selection_name}", tint=(0.18, 0.24, 0.32, 1.0)) + self._draw_toolbar_text_chip(f"选择 {selection_name}") imgui.same_line() - style_manager.draw_stat_chip( + self._draw_toolbar_text_chip( f"历史 {command_manager.get_undo_count() if command_manager else 0}/{command_manager.get_redo_count() if command_manager else 0}", - tint=(0.16, 0.18, 0.2, 1.0), ) - imgui.pop_style_var(2) + window_pos = imgui.get_window_pos() + window_size = imgui.get_window_size() + self.app._toolbar_window_rect = ( + float(window_pos.x), + float(window_pos.y), + float(window_pos.x + window_size.x), + float(window_pos.y + window_size.y), + ) + + imgui.pop_style_var() + imgui.pop_style_var(3) + imgui.pop_style_color(2) diff --git a/新项目_副本/project.json b/新项目_副本/project.json index d053d21e..64e55619 100644 --- a/新项目_副本/project.json +++ b/新项目_副本/project.json @@ -1,7 +1,7 @@ { "name": "新项目_副本", "path": "D:\\IMGUI\\EG\\新项目_副本", - "last_modified": "2026-03-13 16:55:57", + "last_modified": "2026-03-17 16:28:37", "scene_file": "scenes\\scene.bam", "created_at": "2026-03-13 16:55:57", "version": "1.0"