声明式UI框架
通过它可以使开发者基于完全原生的 C++ 以声明式的方式编写 UI 界面程序
声明式 UI 代码使用示例
#include <widget/UI.h>
#include <Application.h>
#include <Window.h>
int main() {
.name = "MainWindow",
.title =
L"Grace UI Test",
.rect =
iRect{0, 0, 800, 600},
.name = "MainLayout",
.rect =
iRect{0, 0, 800, 600},
.parent = it,
});
it.setGridSize(3,3);
it.setPadding(20);
it.setSpace(10);
.name = "Button1",
.parent = it,
it.onClicked.connect([] {
std::cout << "Button1 clicked" << std::endl;
});
}
};
.name = "Button2",
.parent = it,
it.onClicked.connect([] {
std::cout << "Button2 clicked" << std::endl;
});
}
};
.name = "Button3",
.parent = it,
it.onClicked.connect([] {
std::cout << "Button3 clicked" << std::endl;
});
}
};
.name = "Slider1",
.parent = it,
it.setRange(0, 100, 0.6f);
it.setValue(50);
it.onValueChanged.connect([](float value) {
std::cout << "Slider1 value changed to " << value << std::endl;
});
}
};
}
};
}
};
return app.run();
}
const iRect & rect() const
定义 GraphInterface.cpp:40
constexpr Size< T > & size()
矩形大小
定义 Rect.hpp:82
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
GraceFt库的命名空间
定义 _private.inl:64