Graphics v0.0.0
A simple abstraction layer for the modern graphics APIs.
载入中...
搜索中...
未找到
Window.h
1// Copyright 2022 ShenMian
2// License(Apache-2.0)
3
4#pragma once
5
6#include "Widget.h"
7
8namespace ui
9{
10
11class Window : public Widget
12{
13public:
14 enum Flag
15 {
16 None = 0,
17 NoTitleBar = 1 << 0, // 禁用标题栏
18 NoResize = 1 << 1, // 禁止用户通过拖拽右下角调整大小
19 NoMove = 1 << 2, // 禁止用户移动窗口
20 NoScrollbar = 1 << 3, // 禁用滚动条 (窗口依然可以通过鼠标或编程的方式滚动)
21 NoScrollWithMouse = 1 << 4, // 禁止用户使用鼠标滚轮垂直滚动. On child window, mouse wheel will be forwarded to
22 // the parent unless NoScrollbar is also set.
23 NoCollapse =
24 1 << 5, // 禁止用户通过双击折叠窗口. Also referred to as Window Menu Button (e.g. within a docking node).
25 AlwaysAutoResize = 1 << 6, // Resize every window to its content every frame
26 NoBackground = 1 << 7, // 禁用背景色(WindowBg, 等.)和外边框的绘制. 类似使用 SetNextWindowBgAlpha(0.0f).
27 NoSavedSettings = 1 << 8, // 不从 .ini 文件中导入/导出配置
28 NoMouseInputs = 1 << 9, // Disable catching mouse, hovering test with pass through.
29 MenuBar = 1 << 10, // Has a menu-bar
30 HorizontalScrollbar =
31 1 << 11, // 允许水平滚动条显示(默认关). You may use SetNextWindowContentSize(ImVec2(width,0.0f)); prior to
32 // calling Begin() to specify width. Read code in imgui_demo in the "Horizontal Scrolling" section.
33 NoFocusOnAppearing = 1 << 12, // Disable taking focus when transitioning from hidden to visible state
34 NoBringToFrontOnFocus = 1 << 13, // Disable bringing window to front when taking focus (e.g. clicking on it or
35 // programmatically giving it focus)
36 AlwaysVerticalScrollbar = 1 << 14, // 总是显示垂直滚动条 (即使 ContentSize.y < Size.y)
37 AlwaysHorizontalScrollbar = 1 << 15, // 总是显示水平滚动条 (即使 ContentSize.x < Size.x)
38 AlwaysUseWindowPadding = 1 << 16, // Ensure child windows without border uses style.WindowPadding (ignored by
39 // default for non-bordered child windows, because more convenient)
40 NoNavInputs = 1 << 18, // No gamepad/keyboard navigation within the window
41 NoNavFocus =
42 1 << 19, // No focusing toward this window with gamepad/keyboard navigation (e.g. skipped by CTRL+TAB)
43 UnsavedDocument =
44 1 << 20, // 在标题旁显示一个点. When used in a tab/docking context, tab is selected when clicking the X +
45 // closure is not assumed (will wait for user to stop submitting the tab). Otherwise closure is
46 // assumed when pressing the X, so if you keep submitting the tab may reappear at end of tab bar.
47 NoDocking = 1 << 21, // 禁用该窗口的停靠
48
49 NoNav = NoNavInputs | NoNavFocus,
50 NoDecoration = NoTitleBar | NoResize | NoScrollbar | NoCollapse,
51 NoInputs = NoMouseInputs | NoNavInputs | NoNavFocus,
52 };
53
54 Window(const std::string& label, Flag flags = Flag::None);
55
56 void add(Widget& widget);
57
58 void clear();
59
60 void update() override;
61
62 std::function<void(Window&)> hover;
63
64private:
65 Flag flags_;
66 std::vector<Widget*> widgets_;
67};
68
69} // namespace ui
Definition: Widget.h:14
Definition: Window.h:12