添加注释

This commit is contained in:
daiqingshuang 2025-04-10 13:47:50 +08:00
parent bbfe5ab665
commit 791fca9282
2 changed files with 47 additions and 6 deletions

View File

@ -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(

View File

@ -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__)