checkpoint: fixing ux with window frame bar

This commit is contained in:
2026-03-13 13:13:35 -04:00
parent c76aba64e4
commit ca01397885
9 changed files with 226 additions and 89 deletions

View File

@@ -367,38 +367,58 @@ class App:
except Exception as e:
self.ai_status = f"error: {e}"
imgui.end_menu()
# Draw right-aligned window controls directly in the menu bar
try:
import ctypes
ctypes.pythonapi.PyCapsule_GetPointer.restype = ctypes.c_void_p
ctypes.pythonapi.PyCapsule_GetPointer.argtypes = [ctypes.py_object, ctypes.c_char_p]
hwnd_capsule = imgui.get_main_viewport().platform_handle_raw
hwnd = ctypes.pythonapi.PyCapsule_GetPointer(hwnd_capsule, b"nb_handle")
except Exception:
hwnd = 0
if hwnd:
btn_w = 40
display_w = imgui.get_io().display_size.x
right_x = display_w - (btn_w * 3)
# Drag area check using an explicit invisible button spanning the empty space
curr_x = imgui.get_cursor_pos_x()
drag_w = right_x - curr_x
if drag_w > 0:
imgui.invisible_button("##drag_area", (drag_w, 0))
if imgui.is_item_hovered() and imgui.is_mouse_clicked(0):
win32gui.ReleaseCapture()
win32gui.SendMessage(hwnd, win32con.WM_NCLBUTTONDOWN, win32con.HTCAPTION, 0)
imgui.push_style_color(imgui.Col_.button, vec4(0, 0, 0, 0))
try:
is_max = win32gui.GetWindowPlacement(hwnd)[1] == win32con.SW_SHOWMAXIMIZED
except Exception:
is_max = False
imgui.set_cursor_pos_x(right_x)
if imgui.button("_", (btn_w, 0)):
win32gui.ShowWindow(hwnd, win32con.SW_MINIMIZE)
imgui.set_cursor_pos_x(right_x + btn_w)
if imgui.button("[=]" if is_max else "[]", (btn_w, 0)):
win32gui.ShowWindow(hwnd, win32con.SW_RESTORE if is_max else win32con.SW_MAXIMIZE)
imgui.set_cursor_pos_x(right_x + btn_w * 2)
imgui.push_style_color(imgui.Col_.button_hovered, vec4(200, 50, 50, 255))
if imgui.button("X", (btn_w, 0)):
win32gui.PostMessage(hwnd, win32con.WM_CLOSE, 0, 0)
imgui.pop_style_color()
imgui.pop_style_color()
def _render_custom_title_bar(self) -> None:
hwnd = imgui.get_main_viewport().platform_handle
if not hwnd: return
bar_height = 30
imgui.set_next_window_pos((0, 0))
imgui.set_next_window_size((imgui.get_io().display_size.x, bar_height))
flags = (imgui.WindowFlags_.no_title_bar | imgui.WindowFlags_.no_resize |
imgui.WindowFlags_.no_move | imgui.WindowFlags_.no_scrollbar |
imgui.WindowFlags_.no_saved_settings | imgui.WindowFlags_.no_bring_to_front_on_focus)
imgui.push_style_var(imgui.StyleVar_.window_rounding, 0)
imgui.push_style_var(imgui.StyleVar_.window_border_size, 0)
imgui.push_style_var(imgui.StyleVar_.window_padding, (10, 5))
if imgui.begin("##custom_title_bar", None, flags):
imgui.text("manual slop")
if imgui.is_window_hovered() and imgui.is_mouse_dragging(0):
win32gui.ReleaseCapture()
win32gui.SendMessage(hwnd, win32con.WM_NCLBUTTONDOWN, win32con.HTCAPTION, 0)
btn_w = 40
spacing = imgui.get_style().item_spacing.x
right_x = imgui.get_window_width() - (btn_w * 3 + spacing * 2 + 10)
imgui.same_line(right_x)
if imgui.button("_", (btn_w, 20)):
win32gui.ShowWindow(hwnd, win32con.SW_MINIMIZE)
imgui.same_line()
if imgui.button("[]", (btn_w, 20)):
win32gui.ShowWindow(hwnd, win32con.SW_MAXIMIZE)
imgui.same_line()
if imgui.button("X", (btn_w, 20)):
win32gui.PostMessage(hwnd, win32con.WM_CLOSE, 0, 0)
imgui.end()
imgui.pop_style_var(3)
# Obsolete, removed since it renders behind the full screen dock space.
# Controls are now embedded in _show_menus.
pass
def _render_shader_live_editor(self) -> None:
if self.show_windows.get('Shader Editor', False):