Compare commits

..

No commits in common. "7812a4a44abab22d7820546e7779f71905589f0f" and "d3a347e4322bc19ca7010334de8081b54e73664e" have entirely different histories.

5 changed files with 7 additions and 40 deletions

View File

@ -360,5 +360,7 @@ Result<int> luna_main(int argc, char** argv)
window->set_main_widget(game); window->set_main_widget(game);
game.reset(); game.reset();
window->draw();
return app.run(); return app.run();
} }

View File

@ -42,5 +42,7 @@ Result<int> luna_main(int argc, char** argv)
ui::Label kernel_version(kernel_version_text.view()); ui::Label kernel_version(kernel_version_text.view());
version_info.add_widget(kernel_version); version_info.add_widget(kernel_version);
window->draw();
return app.run(); return app.run();
} }

View File

@ -48,7 +48,6 @@ Result<int> luna_main(int argc, char** argv)
auto window = TRY(ui::Window::create(bar, ui::WindowType::System)); auto window = TRY(ui::Window::create(bar, ui::WindowType::System));
app.set_main_window(window); app.set_main_window(window);
window->set_background(TASKBAR_COLOR); window->set_background(TASKBAR_COLOR);
ui::HorizontalLayout layout(ui::Margins { 0, 0, 0, 0 }, ui::AdjustHeight::Yes, ui::AdjustWidth::No); ui::HorizontalLayout layout(ui::Margins { 0, 0, 0, 0 }, ui::AdjustHeight::Yes, ui::AdjustWidth::No);
@ -66,5 +65,7 @@ Result<int> luna_main(int argc, char** argv)
StringView clock_command[] = { "/usr/bin/clock" }; StringView clock_command[] = { "/usr/bin/clock" };
TRY(create_widget_group_for_app(layout, { clock_command, 1 }, "/usr/share/icons/32x32/app-clock.tga")); TRY(create_widget_group_for_app(layout, { clock_command, 1 }, "/usr/share/icons/32x32/app-clock.tga"));
window->draw();
return app.run(); return app.run();
} }

View File

@ -12,57 +12,24 @@
namespace os namespace os
{ {
/**
* @brief Wrapper for callable objects.
*
* Certain callable types such as capture lambdas don't have a named type, thus they can't be passed to functions as
* arguments. The Action type acts as a callable wrapper for such functions, allowing them to be passed as arguments
* to any function.
*/
class Action class Action
{ {
public: public:
/**
* @brief Construct a new empty Action object.
*
* Since it is not wrapping any callable object, this object is invalid and attempting to invoke its
* (nonexistent) callable object will result in a crash at runtime.
*/
Action() Action()
{ {
m_action = nullptr; m_action = nullptr;
} }
/**
* @brief Construct a new Action object, moving it from another one.
*
* @param other The old Action object to move from. This object will become invalid.
*/
Action(Action&& other) : m_action(other.m_action) Action(Action&& other) : m_action(other.m_action)
{ {
other.m_action = nullptr; other.m_action = nullptr;
} }
/**
* @brief Construct a new Action object from a callable object.
*
* @tparam T The type of the callable object. Since this can be guessed by template deduction, the object
* doesn't actually need a type name.
* @param function The callable object to wrap.
*/
template <typename T> Action(T&& function) template <typename T> Action(T&& function)
{ {
m_action = new (std::nothrow) ActionImpl<T>(move(function)); m_action = new (std::nothrow) ActionImpl<T>(move(function));
} }
/**
* @brief Assign a new callable object to this Action.
*
* @tparam T The type of the callable object. Since this can be guessed by template deduction, the object
* doesn't actually need a type name.
* @param function The callable object to wrap.
* @return Action& A reference to this object, as required by operator=().
*/
template <typename T> Action& operator=(T&& function) template <typename T> Action& operator=(T&& function)
{ {
if (m_action) delete m_action; if (m_action) delete m_action;
@ -70,12 +37,9 @@ namespace os
return *this; return *this;
} }
/**
* @brief Call the underlying object.
*/
void operator()() void operator()()
{ {
expect(m_action, "os::Action called with no underlying callable object"); check(m_action);
return m_action->call(); return m_action->call();
} }

View File

@ -59,8 +59,6 @@ namespace ui
Result<int> App::run() Result<int> App::run()
{ {
TRY(m_main_window->draw());
return m_loop.run(); return m_loop.run();
} }