diff --git a/include/sharpsoft/all.hpp b/include/sharpsoft/all.hpp index c80b831..2f0ea77 100644 --- a/include/sharpsoft/all.hpp +++ b/include/sharpsoft/all.hpp @@ -1,3 +1,4 @@ #include "basic_types.hpp" +#include "enums.hpp" #include "global_misc.hpp" #include "window_types.hpp" diff --git a/include/sharpsoft/enums.hpp b/include/sharpsoft/enums.hpp new file mode 100644 index 0000000..1b1149c --- /dev/null +++ b/include/sharpsoft/enums.hpp @@ -0,0 +1,11 @@ +#pragma once + +#include + +namespace sharp +{ + enum window_flags : uint32_t + { + WINDOW_ACTIVE = 1, + }; +} diff --git a/include/sharpsoft/global_misc.hpp b/include/sharpsoft/global_misc.hpp index 7472981..f77df5d 100644 --- a/include/sharpsoft/global_misc.hpp +++ b/include/sharpsoft/global_misc.hpp @@ -1,6 +1,7 @@ #pragma once #include "sharpsoft/basic_types.hpp" +#include "sharpsoft/window_types.hpp" namespace sharp { diff --git a/include/sharpsoft/window_types.hpp b/include/sharpsoft/window_types.hpp index 020a234..bb33dff 100644 --- a/include/sharpsoft/window_types.hpp +++ b/include/sharpsoft/window_types.hpp @@ -1,7 +1,9 @@ #pragma once #include +#include #include "sharpsoft/basic_types.hpp" +#include "sharpsoft/enums.hpp" namespace sharp { @@ -10,14 +12,27 @@ namespace sharp private: uint16_t posX, posY; uint16_t width, height; + std::string title; + window_flags flags; + + protected: + window_base(const std::string& title, const int2& pos, const int2& size); + + virtual void paint() = 0; public: const int2 get_pos() const; const int2 get_size() const; const int_rect get_window_rect() const; + const std::string get_title() const; + const bool is_active() const; void set_pos(const int2& new_pos); void set_size(const int2& new_size); void set_window_rect(const int_rect& new_rect); + void set_title(const std::string& new_title); + + void show(); + void hide(); }; } diff --git a/src/main.cpp b/src/main.cpp index c57e30f..17f8e10 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4,11 +4,28 @@ // This library is intended to be referenced by the prefix `sharp::` // Including `using namespace sharp;` is not recommended. +class test_window : public sharp::window_base +{ +protected: + void paint() override + { + + } + +public: + test_window() : window_base("Testing", sharp::int2(10, 10), sharp::int2(150, 100)) + { + + } +}; + void initialize() { // Initialize Sharpsoft. sharp::initialize(); + test_window moment = test_window(); + sharp::start(); } diff --git a/src/sharpsoft/window_base.cpp b/src/sharpsoft/window_base.cpp index 48cca11..3a2b995 100644 --- a/src/sharpsoft/window_base.cpp +++ b/src/sharpsoft/window_base.cpp @@ -1,7 +1,19 @@ +#include "enums.hpp" #include "sharpsoft/window_types.hpp" +using std::string; using namespace sharp; +sharp::window_base::window_base(const string& title, const int2& pos, const int2& size) +{ + this->title = title; + posX = pos.x; + posY = pos.y; + width = size.x; + width = size.y; + flags = (window_flags)0; +} + const int2 sharp::window_base::get_pos() const { return int2(posX, posY); @@ -14,8 +26,16 @@ const int_rect sharp::window_base::get_window_rect() const { return int_rect(posX, posY, width, height); } +const string sharp::window_base::get_title() const +{ + return title; +} +const bool sharp::window_base::is_active() const +{ + return (flags & WINDOW_ACTIVE) > 0; +} -void sharp::window_base::set_pos(const int2 &new_pos) +void sharp::window_base::set_pos(const int2& new_pos) { // TODO: I'll have to re-render some parts. posX = new_pos.x; @@ -27,7 +47,7 @@ void sharp::window_base::set_size(const int2& new_pos) width = new_pos.x; height = new_pos.y; } -void sharp::window_base::set_window_rect(const int_rect &new_rect) +void sharp::window_base::set_window_rect(const int_rect& new_rect) { // TODO: I'll have to re-render some parts. posX = new_rect.left; @@ -35,3 +55,20 @@ void sharp::window_base::set_window_rect(const int_rect &new_rect) width = new_rect.width; height = new_rect.height; } +void sharp::window_base::set_title(const std::string& new_title) +{ + title = new_title; +} + +void sharp::window_base::hide() +{ + // TODO: This will affect the renderer + + flags = (window_flags)(flags & ~WINDOW_ACTIVE); +} +void sharp::window_base::show() +{ + // TODO: This will affect the renderer + + flags = (window_flags)(flags | WINDOW_ACTIVE); +}