Add a display server and graphical user interface #38
@ -5,6 +5,8 @@
|
||||
#include <ui/Label.h>
|
||||
#include <ui/Layout.h>
|
||||
|
||||
static constexpr ui::Color BACKGROUND_COLOR = ui::Color::from_rgb(89, 89, 89);
|
||||
|
||||
Result<int> luna_main(int argc, char** argv)
|
||||
{
|
||||
ui::App app;
|
||||
@ -14,7 +16,7 @@ Result<int> luna_main(int argc, char** argv)
|
||||
app.set_main_window(window);
|
||||
|
||||
window->set_title("About");
|
||||
window->set_background(ui::CYAN);
|
||||
window->set_background(BACKGROUND_COLOR);
|
||||
|
||||
utsname info;
|
||||
uname(&info);
|
||||
@ -22,7 +24,7 @@ Result<int> luna_main(int argc, char** argv)
|
||||
ui::VerticalLayout main_layout;
|
||||
window->set_main_widget(main_layout);
|
||||
|
||||
ui::Label title("About Luna", ui::VerticalAlignment::Center, ui::HorizontalAlignment::Center,
|
||||
ui::Label title("About Luna", ui::WHITE, ui::VerticalAlignment::Center, ui::HorizontalAlignment::Center,
|
||||
ui::Font::default_bold_font());
|
||||
main_layout.add_widget(title);
|
||||
|
||||
|
@ -22,7 +22,7 @@ namespace ui
|
||||
class Label final : public Widget
|
||||
{
|
||||
public:
|
||||
Label(StringView text, VerticalAlignment valign = VerticalAlignment::Center,
|
||||
Label(StringView text, ui::Color color = ui::WHITE, VerticalAlignment valign = VerticalAlignment::Center,
|
||||
HorizontalAlignment halign = HorizontalAlignment::Center, SharedPtr<Font> font = Font::default_font());
|
||||
|
||||
void set_text(StringView text)
|
||||
@ -36,6 +36,7 @@ namespace ui
|
||||
StringView m_text;
|
||||
VerticalAlignment m_valign;
|
||||
HorizontalAlignment m_halign;
|
||||
ui::Color m_color;
|
||||
SharedPtr<Font> m_font;
|
||||
};
|
||||
}
|
||||
|
@ -12,8 +12,9 @@
|
||||
|
||||
namespace ui
|
||||
{
|
||||
Label::Label(StringView text, VerticalAlignment valign, HorizontalAlignment halign, SharedPtr<Font> font)
|
||||
: m_text(text), m_valign(valign), m_halign(halign), m_font(font)
|
||||
Label::Label(StringView text, ui::Color color, VerticalAlignment valign, HorizontalAlignment halign,
|
||||
SharedPtr<Font> font)
|
||||
: m_text(text), m_valign(valign), m_halign(halign), m_color(color), m_font(font)
|
||||
{
|
||||
}
|
||||
|
||||
@ -30,7 +31,7 @@ namespace ui
|
||||
wchar_t buf[4096];
|
||||
TRY(decoder.decode(buf, sizeof(buf)));
|
||||
|
||||
m_font->render(buf, ui::BLACK, subcanvas);
|
||||
m_font->render(buf, m_color, subcanvas);
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user