Compare commits
4 Commits
0cb21c2e90
...
b42497e05e
Author | SHA1 | Date | |
---|---|---|---|
b42497e05e | |||
b370a99aa6 | |||
9fd4fc7e91 | |||
bc14b01bf8 |
@ -5,6 +5,8 @@
|
|||||||
#include <ui/Label.h>
|
#include <ui/Label.h>
|
||||||
#include <ui/Layout.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)
|
Result<int> luna_main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
ui::App app;
|
ui::App app;
|
||||||
@ -14,7 +16,7 @@ Result<int> luna_main(int argc, char** argv)
|
|||||||
app.set_main_window(window);
|
app.set_main_window(window);
|
||||||
|
|
||||||
window->set_title("About");
|
window->set_title("About");
|
||||||
window->set_background(ui::CYAN);
|
window->set_background(BACKGROUND_COLOR);
|
||||||
|
|
||||||
utsname info;
|
utsname info;
|
||||||
uname(&info);
|
uname(&info);
|
||||||
@ -22,7 +24,7 @@ Result<int> luna_main(int argc, char** argv)
|
|||||||
ui::VerticalLayout main_layout;
|
ui::VerticalLayout main_layout;
|
||||||
window->set_main_widget(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());
|
ui::Font::default_bold_font());
|
||||||
main_layout.add_widget(title);
|
main_layout.add_widget(title);
|
||||||
|
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
#include <ui/Image.h>
|
#include <ui/Image.h>
|
||||||
#include <ui/Layout.h>
|
#include <ui/Layout.h>
|
||||||
|
|
||||||
|
static constexpr ui::Color TASKBAR_COLOR = ui::Color::from_rgb(83, 83, 83);
|
||||||
|
|
||||||
void sigchld_handler(int)
|
void sigchld_handler(int)
|
||||||
{
|
{
|
||||||
wait(nullptr);
|
wait(nullptr);
|
||||||
@ -26,7 +28,7 @@ Result<int> luna_main(int argc, char** argv)
|
|||||||
|
|
||||||
auto window = TRY(ui::Window::create(bar, false));
|
auto window = TRY(ui::Window::create(bar, false));
|
||||||
app.set_main_window(window);
|
app.set_main_window(window);
|
||||||
window->set_background(ui::GRAY);
|
window->set_background(TASKBAR_COLOR);
|
||||||
|
|
||||||
ui::HorizontalLayout layout(ui::AdjustHeight::Yes, ui::AdjustWidth::No);
|
ui::HorizontalLayout layout(ui::AdjustHeight::Yes, ui::AdjustWidth::No);
|
||||||
window->set_main_widget(layout);
|
window->set_main_widget(layout);
|
||||||
|
@ -157,6 +157,13 @@ namespace MemoryManager
|
|||||||
used_mem += ARCH_PAGE_SIZE;
|
used_mem += ARCH_PAGE_SIZE;
|
||||||
free_mem -= ARCH_PAGE_SIZE;
|
free_mem -= ARCH_PAGE_SIZE;
|
||||||
|
|
||||||
|
if (free_mem < 1024 * 1024)
|
||||||
|
{
|
||||||
|
// Less than 1 MiB of free memory! Let's start clearing caches...
|
||||||
|
kwarnln("Less than 1 MiB of free memory, clearing caches to try to gain extra memory");
|
||||||
|
Scheduler::signal_oom_thread();
|
||||||
|
}
|
||||||
|
|
||||||
return index * ARCH_PAGE_SIZE;
|
return index * ARCH_PAGE_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ namespace ui
|
|||||||
class Label final : public Widget
|
class Label final : public Widget
|
||||||
{
|
{
|
||||||
public:
|
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());
|
HorizontalAlignment halign = HorizontalAlignment::Center, SharedPtr<Font> font = Font::default_font());
|
||||||
|
|
||||||
void set_text(StringView text)
|
void set_text(StringView text)
|
||||||
@ -36,6 +36,7 @@ namespace ui
|
|||||||
StringView m_text;
|
StringView m_text;
|
||||||
VerticalAlignment m_valign;
|
VerticalAlignment m_valign;
|
||||||
HorizontalAlignment m_halign;
|
HorizontalAlignment m_halign;
|
||||||
|
ui::Color m_color;
|
||||||
SharedPtr<Font> m_font;
|
SharedPtr<Font> m_font;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,9 @@
|
|||||||
|
|
||||||
namespace ui
|
namespace ui
|
||||||
{
|
{
|
||||||
Label::Label(StringView text, VerticalAlignment valign, HorizontalAlignment halign, SharedPtr<Font> font)
|
Label::Label(StringView text, ui::Color color, VerticalAlignment valign, HorizontalAlignment halign,
|
||||||
: m_text(text), m_valign(valign), m_halign(halign), m_font(font)
|
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];
|
wchar_t buf[4096];
|
||||||
TRY(decoder.decode(buf, sizeof(buf)));
|
TRY(decoder.decode(buf, sizeof(buf)));
|
||||||
|
|
||||||
m_font->render(buf, ui::BLACK, subcanvas);
|
m_font->render(buf, m_color, subcanvas);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,11 @@ Result<void> TerminalWidget::init(char* const* args)
|
|||||||
|
|
||||||
Result<ui::EventResult> TerminalWidget::handle_key_event(const ui::KeyEventRequest& request)
|
Result<ui::EventResult> TerminalWidget::handle_key_event(const ui::KeyEventRequest& request)
|
||||||
{
|
{
|
||||||
|
// Avoid handling "key released" events
|
||||||
if (!request.pressed) return ui::EventResult::DidNotHandle;
|
if (!request.pressed) return ui::EventResult::DidNotHandle;
|
||||||
|
// Non-printable key or key that has no special character (unlike Tab or Enter). We exit early to avoid inserting an
|
||||||
|
// invalid zero byte into the terminal input (this would also happen on Shift or Ctrl keypresses).
|
||||||
|
if (request.letter == '\0') return ui::EventResult::DidNotHandle;
|
||||||
|
|
||||||
query_termios();
|
query_termios();
|
||||||
|
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
|
|
||||||
LinkedList<Window> g_windows;
|
LinkedList<Window> g_windows;
|
||||||
|
|
||||||
|
static constexpr ui::Color TITLEBAR_COLOR = ui::Color::from_rgb(53, 53, 53);
|
||||||
|
|
||||||
void Window::draw(ui::Canvas& screen)
|
void Window::draw(ui::Canvas& screen)
|
||||||
{
|
{
|
||||||
dirty = false;
|
dirty = false;
|
||||||
@ -21,10 +23,10 @@ void Window::draw(ui::Canvas& screen)
|
|||||||
auto font = ui::Font::default_font();
|
auto font = ui::Font::default_font();
|
||||||
|
|
||||||
auto titlebar_canvas = window.subcanvas(titlebar);
|
auto titlebar_canvas = window.subcanvas(titlebar);
|
||||||
titlebar_canvas.fill(ui::GRAY);
|
titlebar_canvas.fill(TITLEBAR_COLOR);
|
||||||
|
|
||||||
auto textarea = titlebar_canvas.subcanvas(ui::Rect { 10, 10, titlebar_canvas.width - 10, titlebar_canvas.height });
|
auto textarea = titlebar_canvas.subcanvas(ui::Rect { 10, 10, titlebar_canvas.width - 10, titlebar_canvas.height });
|
||||||
font->render(buffer, ui::BLACK, textarea);
|
font->render(buffer, ui::WHITE, textarea);
|
||||||
|
|
||||||
static SharedPtr<ui::Image> g_close_icon;
|
static SharedPtr<ui::Image> g_close_icon;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user