Squash commits for public release

This commit is contained in:
2025-02-12 09:54:05 -05:00
commit 7118adc514
1108 changed files with 80873 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
APPS += ABOUT
ABOUT_NAME = about
ABOUT_LIBS = cxx ui
ABOUT_INSTALL_PATH = bin/

View File

@@ -0,0 +1,64 @@
#pragma once
#include <libg/Font.h>
#include <libui/Label.h>
#include <libui/View.h>
#include <string>
class AboutLineView : public UI::View {
UI_OBJECT();
public:
AboutLineView(UI::View* superview, const LG::Rect& frame, std::string title, std::string content)
: UI::View(superview, frame)
, m_title(title)
, m_content(content)
{
const int spacing = 4;
set_background_color(LG::Color::LightSystemBackground);
auto& label = add_subview<UI::Label>(LG::Rect(0, 0, 16, 16));
label.set_text_color(LG::Color::DarkSystemText);
label.set_text(m_title);
label.set_width(label.preferred_width());
auto& target_label = add_subview<UI::Label>(LG::Rect(0, 0, 16, 16));
target_label.set_text_color(LG::Color::DarkSystemText);
target_label.set_text(m_content);
target_label.set_width(target_label.preferred_width());
add_constraint(UI::Constraint(target_label, UI::Constraint::Attribute::Left, UI::Constraint::Relation::Equal, label, UI::Constraint::Attribute::Right, 1, spacing));
add_constraint(UI::Constraint(target_label, UI::Constraint::Attribute::Top, UI::Constraint::Relation::Equal, label, UI::Constraint::Attribute::Top, 1, 0));
set_width(label.preferred_width() + spacing + target_label.preferred_width());
}
AboutLineView(UI::View* superview, UI::Window* window, const LG::Rect& frame, std::string title, std::string content)
: UI::View(superview, window, frame)
, m_title(title)
, m_content(content)
{
const int spacing = 4;
set_background_color(LG::Color::LightSystemBackground);
auto& label = add_subview<UI::Label>(LG::Rect(0, 0, 16, 16));
label.set_text_color(LG::Color::DarkSystemText);
label.set_text(m_title);
label.set_width(label.preferred_width());
auto& target_label = add_subview<UI::Label>(LG::Rect(0, 0, 16, 16));
target_label.set_text_color(LG::Color::DarkSystemText);
target_label.set_text(m_content);
target_label.set_width(target_label.preferred_width());
add_constraint(UI::Constraint(target_label, UI::Constraint::Attribute::Left, UI::Constraint::Relation::Equal, label, UI::Constraint::Attribute::Right, 1, spacing));
add_constraint(UI::Constraint(target_label, UI::Constraint::Attribute::Top, UI::Constraint::Relation::Equal, label, UI::Constraint::Attribute::Top, 1, 0));
set_width(label.preferred_width() + spacing + target_label.preferred_width());
}
~AboutLineView() = default;
private:
std::string m_title {};
std::string m_content {};
};

View File

@@ -0,0 +1,29 @@
#include "ViewController.h"
#include <libui/AppDelegate.h>
#include <libui/MenuBar.h>
class AppDelegate : public UI::AppDelegate {
public:
AppDelegate() = default;
virtual ~AppDelegate() = default;
LG::Size preferred_desktop_window_size() const override { return LG::Size(200, 210); }
const char* icon_path() const override { return "/res/icons/apps/about.icon"; }
virtual bool application() override
{
auto style = StatusBarStyle(LG::Color(231, 240, 250)).set_hide_text();
auto& window = std::xos::construct<UI::Window>("About", window_size(), icon_path(), style);
auto& superview = window.create_superview<UI::View, ViewController>();
auto demo_menu = UI::Menu("Demo");
demo_menu.add_item(UI::MenuItem("Say hello", [] { Logger::debug << "Hello!" << std::endl; }));
window.menubar().add_menu(std::move(demo_menu));
return true;
}
private:
};
SET_APP_DELEGATE(AppDelegate);

View File

@@ -0,0 +1,17 @@
import("//build/userland/TEMPLATE.gni")
xOS_application("about") {
display_name = "About"
sources = [
"AppDelegate.cpp",
]
configs = [
"//build/userland:userland_flags",
]
deplibs = [
"libcxx",
"libfoundation",
"libg",
"libui"
]
}

View File

@@ -0,0 +1,78 @@
#pragma once
#include "AboutLineView.h"
#include <libui/App.h>
#include <libui/Button.h>
#include <libui/Label.h>
#include <libui/View.h>
#include <libui/ViewController.h>
#include <libui/Window.h>
#include <memory>
#include <sys/types.h>
#include <sys/utsname.h>
class ViewController : public UI::ViewController<UI::View> {
public:
ViewController(UI::View& view)
: UI::ViewController<UI::View>(view)
{
}
virtual ~ViewController() = default;
void view_did_load() override
{
view().set_background_color(LG::Color::LightSystemBackground);
utsname_t uts;
int rc = uname(&uts);
auto& header = view().add_subview<UI::View>(LG::Rect(0, 0, 0, 0));
header.set_background_color(LG::Color(231, 240, 250));
auto& label = header.add_subview<UI::Label>(LG::Rect(0, 0, 16, 22));
label.set_text("About");
label.set_text_color(LG::Color(35, 70, 106));
label.set_font(LG::Font::system_bold_font(LG::Font::SystemTitleSize));
label.set_width(label.preferred_width());
auto& name_label = view().add_subview<AboutLineView>(LG::Rect(0, 0, 16, 16), "Name:", uts.sysname);
auto& cpu_label = view().add_subview<AboutLineView>(LG::Rect(0, 0, 16, 16), "CPU:", uts.machine);
auto& version_label = view().add_subview<AboutLineView>(LG::Rect(0, 0, 16, 16), "Version:", uts.release);
auto& button = view().add_subview<UI::Button>(LG::Rect(0, 0, 10, 10));
button.set_background_color(LG::Color::LightSystemButton);
button.set_title("System info");
button.set_title_color(LG::Color::DarkSystemText);
auto& footer = view().add_subview<UI::Label>(LG::Rect(0, 0, 16, 16));
footer.set_text_color(LG::Color::DarkSystemText);
footer.set_text("(c) 2020-2023");
footer.set_width(footer.preferred_width());
view().add_constraint(UI::Constraint(header, UI::Constraint::Attribute::Left, UI::Constraint::Relation::Equal, 0));
view().add_constraint(UI::Constraint(header, UI::Constraint::Attribute::Top, UI::Constraint::Relation::Equal, 0));
view().add_constraint(UI::Constraint(header, UI::Constraint::Attribute::Right, UI::Constraint::Relation::Equal, 0));
view().add_constraint(UI::Constraint(header, UI::Constraint::Attribute::Height, UI::Constraint::Relation::Equal, 60));
view().add_constraint(UI::Constraint(label, UI::Constraint::Attribute::Left, UI::Constraint::Relation::Equal, UI::SafeArea::Left));
view().add_constraint(UI::Constraint(label, UI::Constraint::Attribute::CenterY, UI::Constraint::Relation::Equal, header, UI::Constraint::Attribute::CenterY, 1, 0));
view().add_constraint(UI::Constraint(name_label, UI::Constraint::Attribute::Left, UI::Constraint::Relation::Equal, UI::SafeArea::Left));
view().add_constraint(UI::Constraint(name_label, UI::Constraint::Attribute::Top, UI::Constraint::Relation::Equal, header, UI::Constraint::Attribute::Bottom, 1, UI::Padding::AfterTitle));
view().add_constraint(UI::Constraint(cpu_label, UI::Constraint::Attribute::Left, UI::Constraint::Relation::Equal, UI::SafeArea::Left));
view().add_constraint(UI::Constraint(cpu_label, UI::Constraint::Attribute::Top, UI::Constraint::Relation::Equal, name_label, UI::Constraint::Attribute::Bottom, 1, 4));
view().add_constraint(UI::Constraint(version_label, UI::Constraint::Attribute::Left, UI::Constraint::Relation::Equal, UI::SafeArea::Left));
view().add_constraint(UI::Constraint(version_label, UI::Constraint::Attribute::Top, UI::Constraint::Relation::Equal, cpu_label, UI::Constraint::Attribute::Bottom, 1, 4));
view().add_constraint(UI::Constraint(button, UI::Constraint::Attribute::Left, UI::Constraint::Relation::Equal, UI::SafeArea::Left));
view().add_constraint(UI::Constraint(button, UI::Constraint::Attribute::Top, UI::Constraint::Relation::Equal, version_label, UI::Constraint::Attribute::Bottom, 1, 8));
view().add_constraint(UI::Constraint(footer, UI::Constraint::Attribute::CenterX, UI::Constraint::Relation::Equal, view(), UI::Constraint::Attribute::CenterX, 1, 0));
view().add_constraint(UI::Constraint(footer, UI::Constraint::Attribute::Bottom, UI::Constraint::Relation::Equal, view(), UI::Constraint::Attribute::Bottom, 1, -UI::SafeArea::Bottom));
view().set_needs_layout();
}
private:
};