feat(window): 无边框窗口 + 自定义标题栏组件 - #60
Open
FarnaHerry wants to merge 3 commits into
Open
Conversation
Add a frameless window mode and an idiomatic titlebar component so apps can draw their own window chrome instead of the OS decoration. Window layer (core/window): - WindowCreateRequest.decorated toggles the OS frame (GLFW_DECORATED / SDL_WINDOW_BORDERLESS). - minimizeWindow / maximizeWindow / restoreWindow / isWindowMaximized / requestWindowClose, cross-platform in both backends. - dragWindow() and startWindowResize(edge) synthesize a native move/resize via a per-platform bridge (Win32 WM_NCLBUTTONDOWN / X11 _NET_WM_MOVERESIZE, reporting the cursor's root coordinates so the window doesn't jump). App layer (eui): - DslAppConfig::frameless() toggles the mode; eui/window.h re-exports ResizeEdge. - app::minimizeWindow / maximizeWindow / toggleMaximizeWindow / isWindowMaximized / requestWindowClose / dragWindow / startWindowResize, operating on the running DSL app's window. Component layer (components/titlebar.h): - TitleBarBuilder covers the whole window: a title strip (title + default minimize/maximize/close buttons with a live maximize<->restore icon) plus optional resize handles on the four edges/corners. - content() callback overrides the default layout so callers can fill the strip freely while background drag + resize stay automatic. Also wires libX11 on Linux (both backends) and adds two examples: titlebar_demo (default layout) and titlebar_custom_demo (content callback).
Contributor
Author
|
补充一个 SDL 后端在 Wayland 会话下的已知局限,以及改进方向,供参考: 当前实现的拖动/缩放机制
为什么没用 SDL 的正式 APISDL 有跨平台的
所以若 SDL 后端改用 建议这个改进(获得 Wayland 支持)可作为独立的后续 PR,把「titlebar 组件后端感知」的设计权衡单独讨论。当前 PR 先支持 X11 会话(X11/Wayland 桌面用户绝大多数是 X11 会话或可用 |
eui_neo is static, so its PRIVATE X11 link leaks into the exported link interface as \$<LINK_ONLY:X11::X11>. Consumers of the installed SDK then failed at find_package(eui-neo) because X11::X11 was never declared. Add find_dependency(X11) to the generated config on Linux so the imported target resolves.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概述
新增无边框窗口模式 + 自定义标题栏组件,让应用可以自绘窗口装饰(标题栏、窗口控制按钮、拖动移动、四边缩放),不再局限于操作系统自带的标题栏。
背景与动机
当前 EUI-NEO 只能使用系统原生标题栏,无法实现自定义窗口外观。很多应用场景(编辑器、播放器、客户端工具)需要无边框窗口 + 自绘标题栏来做统一、定制化的 UI。
实现内容
1. 窗口层(core/window)
WindowCreateRequest.decorated:控制是否使用系统边框(GLFWGLFW_DECORATED=OFF/ SDLSDL_WINDOW_BORDERLESS)minimizeWindow/maximizeWindow/restoreWindow/isWindowMaximized/requestWindowClosedragWindow()/startWindowResize(edge):通过平台桥接合成原生移动/缩放(Win32WM_NCLBUTTONDOWN/ X11_NET_WM_MOVERESIZE,正确上报鼠标 root 坐标避免窗口跳到左上角)2. 应用层(eui)
DslAppConfig::frameless(bool):启用无边框eui/window.h导出ResizeEdge枚举app::minimizeWindow / maximizeWindow / toggleMaximizeWindow / isWindowMaximized / requestWindowClose / dragWindow / startWindowResize,作用于当前运行的 DSL 应用窗口3. 组件层(components/titlebar.h)
TitleBarBuilder覆盖整个窗口:顶部标题栏(标题 + 默认最小化/全屏/关闭三按钮,全屏后图标自动切换为还原图标)+ 四边四角 resize 手柄content()回调:完全自定义标题栏内容,背景拖动 / resize 手柄仍自动提供4. 示例
examples/titlebar_demo.cpp:默认布局(左上角标题 + 右上角三按钮)examples/titlebar_custom_demo.cpp:content() 回调自定义(图标 + 标题 + 自定义按钮)平台一致性
_NET_WM_MOVERESIZE是 X11 协议)命名说明
组件命名为
titlebar(对齐现有navbar导航栏的命名风格),类名TitleBarBuilder。如对命名有偏好请告知,改动很小。已知问题
测试验证
KDE Plasma 6 实机验证通过:无边框窗口、拖动移动、四边四角缩放、三按钮(最小化/全屏/关闭、全屏↔还原图标切换)均正常。GLFW + SDL2 两后端均编译通过。