添加注释
This commit is contained in:
parent
bbfe5ab665
commit
791fca9282
@ -78,12 +78,12 @@ int main(int argc, char* argv[]) {
|
||||
(text_block)
|
||||
);
|
||||
|
||||
// const auto button2 = mnew(mbutton)
|
||||
// mslot(mbutton)
|
||||
// .visibility(visibility_t::visible)
|
||||
// [
|
||||
// text_block2
|
||||
// ];
|
||||
const auto button2 = std::make_shared<mbutton>();
|
||||
button2->push_slot(
|
||||
mslot(mbutton)
|
||||
.visibility(visibility_t::visible)
|
||||
(text_block2)
|
||||
);
|
||||
|
||||
const auto& window = mwindow::create({ 800, 600 }, L"Hello, World!");
|
||||
window->set_content(
|
||||
|
@ -6,6 +6,11 @@
|
||||
#include "widget_new.h"
|
||||
#include "compound_widget/mbutton.h"
|
||||
|
||||
/**
|
||||
* @struct mwidget_decl
|
||||
* @tparam WidgetType 要创建的组件类型
|
||||
* @brief 组件布局声明结构体, 用于创建和管理组件实例
|
||||
*/
|
||||
template<typename WidgetType>
|
||||
struct mwidget_decl {
|
||||
mwidget_decl() {
|
||||
@ -30,5 +35,41 @@ struct mwidget_decl {
|
||||
std::shared_ptr<WidgetType> widget_;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief 创建一个新的组件插槽
|
||||
* @param type 组件类型
|
||||
* @code
|
||||
// 创建一个组件插槽
|
||||
mslot(mv_box)
|
||||
// 使用方式如下
|
||||
auto button = std::make_shared<mbutton>();
|
||||
button->push_slot(
|
||||
mslot(mbutton)
|
||||
.margin({10})
|
||||
.visibility(visibility_t::visible)
|
||||
(text_block)
|
||||
);
|
||||
* @endcode
|
||||
*/
|
||||
#define mslot(type) type::slot_type()
|
||||
|
||||
/**
|
||||
* @param type 组件类型
|
||||
* @code
|
||||
// 创建一个新的组件实例
|
||||
mnew(mv_box)
|
||||
[
|
||||
// 第一个子组件
|
||||
mslot(mv_box)
|
||||
.h_alignment(horizontal_alignment_t::center)
|
||||
.v_alignment(vertical_alignment_t::center)
|
||||
(child_widget),
|
||||
|
||||
// 第二个子组件
|
||||
mslot(mv_box)
|
||||
(child_widget2)
|
||||
];
|
||||
* @endcode
|
||||
* @note 对于简单的创建控件也可以不使用mnew方式,而是使用std::make_shared<type>(),然后使用布局容器的成员函数来管理布局,具体可以看mcompound_widget和mpanel_widget
|
||||
*/
|
||||
#define mnew(type, ...) mwidget_decl<type>(__VA_ARGS__)
|
||||
|
Loading…
x
Reference in New Issue
Block a user