GraceFt v2.3
开源图形引擎 EGE(Easy Graphics Engine) 的高层封装库
 
载入中...
搜索中...
未找到
GFt::UI 命名空间参考

声明式UI框架 更多...

struct  XBlock
 块声明式UI块 更多...
 
struct  XButton
 按钮声明式UI块 更多...
 
struct  XCheckBox
 复选框声明式UI块 更多...
 
struct  XColumnLayout
 列布局声明式UI块 更多...
 
struct  XGridLayout
 网格布局声明式UI块 更多...
 
struct  XHSlider
 水平滑动条声明式UI块 更多...
 
struct  XLabel
 标签声明式UI块 更多...
 
struct  XMainWindow
 主窗口声明式UI块 更多...
 
struct  XRadioBox
 单选框声明式UI块 更多...
 
struct  XRowLayout
 行布局声明式UI块 更多...
 
struct  XVSlider
 垂直滑动条声明式UI块 更多...
 
struct  XWindow
 窗口声明式UI块 更多...
 

详细描述

声明式UI框架

通过它可以使开发者基于完全原生的 C++ 以声明式的方式编写 UI 界面程序

声明式 UI 代码使用示例
#include <widget/UI.h>
#include <Application.h>
#include <Window.h>
using namespace GFt;
using namespace GFt::UI;
using namespace GFt::Widget;
int main() {
.name = "MainWindow",
.title = L"Grace UI Test",
.rect = iRect{0, 0, 800, 600},
.content = [](MainWindow& it) {
.name = "MainLayout",
.rect = iRect{0, 0, 800, 600},
.parent = it,
.content = [](GridLayout& it) {
Window::onWindowSizeChanged.connect([&it](Window* w) {
it.setSize(w->rect().size());
});
it.setGridSize(3,3);
it.setPadding(20);
it.setSpace(10);
.name = "Button1",
.parent = it,
.content = [](Button& it) {
it.text() = L"Button1";
it.onClicked.connect([] {
std::cout << "Button1 clicked" << std::endl;
});
}
};
it.addItem(BLOCK("Button1"),iRect{0,0,1,2});
.name = "Button2",
.parent = it,
.content = [](Button& it) {
it.text() = L"Button2";
it.onClicked.connect([] {
std::cout << "Button2 clicked" << std::endl;
});
}
};
it.addItem(BLOCK("Button2"),iRect{1,0,1,2});
.name = "Button3",
.parent = it,
.content = [](Button& it) {
it.text() = L"Button3";
it.onClicked.connect([] {
std::cout << "Button3 clicked" << std::endl;
});
}
};
it.addItem(BLOCK("Button3"),iRect{2,0,1,2});
.name = "Slider1",
.parent = it,
.content = [](HSlider& it) {
it.setRange(0, 100, 0.6f);
it.setValue(50);
it.onValueChanged.connect([](float value) {
std::cout << "Slider1 value changed to " << value << std::endl;
});
}
};
it.addItem(BLOCK("Slider1"),iRect{0,2,3,1});
}
};
}
};
Window* window = Window::createWindow(BLOCK("MainWindow"));
Application app{ window };
window->show();
return app.run();
}
应用程序类
定义 Application.h:11
const iRect & rect() const
定义 GraphInterface.cpp:40
网格布局类
定义 GridLayout.h:11
constexpr Size< T > & size()
矩形大小
定义 Rect.hpp:82
按钮控件
定义 Button.h:17
水平滑动条
定义 Slider.h:9
主窗口
定义 MainWindow.h:10
全局窗口对象
定义 Window.h:13
static Window * createWindow(Block *block, bool hide=false)
创建普通窗口
定义 Window.cpp:151
void show()
显示窗口
定义 Window.cpp:40
static Signal< Window * > onWindowSizeChanged
窗口大小改变信号
定义 Window.h:121
#define BLOCK(name)
声明式UI块便利宏
定义 UI.h:254
@ L
L 键
声明式UI框架
定义 UI.h:164
定义式UI库
定义 Button.h:13
GraceFt库的命名空间
定义 _private.inl:64
按钮声明式UI块
定义 UI.h:220
网格布局声明式UI块
定义 UI.h:236
水平滑动条声明式UI块
定义 UI.h:244
主窗口声明式UI块
定义 UI.h:184