diff --git a/meson.build b/meson.build index 464d4d5..19a6464 100644 --- a/meson.build +++ b/meson.build @@ -9,6 +9,7 @@ executable( './src/Box.cpp', './src/Events.cpp', './src/Widget.cpp', + './src/Button.cpp', './src/Painter.cpp', './src/Window.cpp', './src/main.cpp', diff --git a/src/Button.cpp b/src/Button.cpp index 2bf5ca5..c245c26 100644 --- a/src/Button.cpp +++ b/src/Button.cpp @@ -1,13 +1,16 @@ #include "Button.hpp" +#include "Box.hpp" #include "Window.hpp" namespace Raven { void Button::on_paint() { auto painter = get_window()->get_painter(); - auto ctx = painter.get_cairo(); + auto cr = painter.get_cairo(); - + cr->set_source_rgb(0.866, 0.713, 0.949); + painter.rounded_rectangle(get_current_geometry(), 8); + cr->fill(); } } diff --git a/src/Button.hpp b/src/Button.hpp index d264d7d..8f1c6c6 100644 --- a/src/Button.hpp +++ b/src/Button.hpp @@ -10,8 +10,8 @@ private: std::string m_text; public: Button(std::string text) - : Widget() - , m_text(text) {} + : m_text(text) + , Widget() {} void set_text(std::string text) { m_text = text; wants_repaint(); } std::string &get_text() { return m_text; } diff --git a/src/Widget.hpp b/src/Widget.hpp index 0a813e5..f2d3df7 100644 --- a/src/Widget.hpp +++ b/src/Widget.hpp @@ -38,7 +38,7 @@ public: virtual void on_mouse_move(MouseMoveEvent &event) {}; virtual void on_paint() {}; - virtual ~Widget() = default; + virtual ~Widget() {}; private: void process_event(Event &event); void handle_repaint_requested(WidgetRepaintRequestedEvent &event); diff --git a/src/main.cpp b/src/main.cpp index 638b76a..ca3c660 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,16 +1,17 @@ #include #include "Window.hpp" #include "Widget.hpp" +#include "Button.hpp" #include "Box.hpp" int main() { Raven::Window window {}; - Raven::Widget main_widget {}; + Raven::Button button {"click me!"}; window.spawn_window(); - main_widget.set_current_geometry(Raven::Box(10, 10, 100, 30)); - window.set_main_widget(&main_widget); + button.set_current_geometry(Raven::Box(10, 10, 100, 30)); + window.set_main_widget(&button); window.run(true); return 0;