mirage/example/src/main.cpp

59 lines
1.6 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <iostream>
#include "mirage.h"
#include "window/mwindow.h"
#include "font/font_system.h"
#include "widget/widget_new.h"
#include "widget/compound_widget/mbutton.h"
#include "widget/leaf_widget/mtext_block.h"
#include "widget/panel_widget/mbox.h"
int main(int argc, char* argv[]) {
mirage_app::get().init();
auto c1 = linear_color::from_string("#FF0000");
auto c2 = linear_color::from_string("rgb(255, 0, 0)");
auto c3 = linear_color::from_string("rgba(255, 0, 0, 255)");
auto& manager = font_manager::instance();
manager.add_font(L"C:/Users/46944/AppData/Local/Microsoft/Windows/Fonts/MapleMono-NF-CN-Regular.ttf");
manager.add_font(L"C:/Windows/Fonts/msyh.ttc");
// manager.add_font(L"D:/Projects/noto-emoji-2.047/fonts/Noto-COLRv1.ttf");
manager.add_font(L"C:/Windows/Fonts/seguiemj.ttf");
const auto& text_block = std::make_shared<mtext_block>();
text_block->set_text(U"Hello, World! 你好,世界!\n换行测试1111测试测试测试测试,测试测试😀🐵🙏 😃🐵🙏");
const auto& text_block2 = std::make_shared<mtext_block>();
text_block2->set_text(U"Hello, World!");
const auto button = mnew(mbutton)
mslot(mbutton)
.margin({10})
.visibility(visibility_t::visible)
[
text_block
];
const auto button2 = mnew(mbutton)
mslot(mbutton)
.visibility(visibility_t::visible)
[
text_block2
];
const auto& window = mwindow::create({ 800, 600 }, L"Hello, World!");
window->set_content(
mnew(mborder)
mslot(mborder)
.h_alignment(horizontal_alignment_t::center)
.v_alignment(vertical_alignment_t::center)
[
button
]
);
mirage_app::get().run();
return 0;
}