Shirag 0.1.0
Loading...
Searching...
No Matches
windowSystem.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "../../text/fonts/fonts.hpp"
4
5#include <memory>
6#include <raylib.h>
7#include <string>
8#include <unordered_map>
9
11
12 class Window {
13 private:
14 Rectangle closeBox{};
15 bool dragging = false;
16 bool resizing = false;
17 Vector2 offset = { 0, 0 };
18
19 protected:
20 float outline = 0.0;
21
22 public:
23 virtual ~Window() = default;
24 Rectangle window = {};
25 std::string title = "";
26 bool draggable = false;
27 bool resizable = false;
28 bool shown = false;
29 Vector2 minSize = { 200, 200 };
30 Vector2 maxSize = { 99999, 99999 };
31 bool mouseCursorChanged = false;
32 bool onTop = false;
33
34 Window(Rectangle WindowRect, std::string Title, bool Draggable, bool Resizeable, bool Shown, int Outline, Vector2 MaxSize)
35 : window{ WindowRect }
36 , title{ Title }
37 , draggable{ Draggable }
38 , resizable{ Resizeable }
39 , shown(Shown)
40 , outline(Outline)
41 , maxSize(MaxSize) {
42 closeBox = { window.x + window.width - 50, window.y, 50, 50 };
43 }
44
45 virtual bool draw(std::vector<Shirag::Text::Font>* Fonts); // returns true on close requested
46 virtual bool update(bool SkipUpdate, std::vector<Shirag::Text::Font>* Fonts);
47 };
48
49 class Windows { // linux user having to write windows :pensive:
50 public:
51 std::unordered_map<std::string, std::unique_ptr<Window>> windows;
52 void draw(std::vector<Shirag::Text::Font>* Fonts);
53 bool update(std::vector<Shirag::Text::Font>* Fonts);
54 void toggleWindow(std::string key);
55 };
56
58
59}
Definition windowSystem.hpp:12
Vector2 minSize
Definition windowSystem.hpp:29
virtual bool draw(std::vector< Shirag::Text::Font > *Fonts)
Definition windowSystem.cpp:94
bool mouseCursorChanged
Definition windowSystem.hpp:31
virtual bool update(bool SkipUpdate, std::vector< Shirag::Text::Font > *Fonts)
Definition windowSystem.cpp:24
bool shown
Definition windowSystem.hpp:28
std::string title
Definition windowSystem.hpp:25
float outline
Definition windowSystem.hpp:20
Rectangle window
Definition windowSystem.hpp:24
bool onTop
Definition windowSystem.hpp:32
Vector2 maxSize
Definition windowSystem.hpp:30
virtual ~Window()=default
bool resizable
Definition windowSystem.hpp:27
bool draggable
Definition windowSystem.hpp:26
Window(Rectangle WindowRect, std::string Title, bool Draggable, bool Resizeable, bool Shown, int Outline, Vector2 MaxSize)
Definition windowSystem.hpp:34
Definition windowSystem.hpp:49
bool update(std::vector< Shirag::Text::Font > *Fonts)
Definition windowSystem.cpp:108
void draw(std::vector< Shirag::Text::Font > *Fonts)
Definition windowSystem.cpp:152
std::unordered_map< std::string, std::unique_ptr< Window > > windows
Definition windowSystem.hpp:51
void toggleWindow(std::string key)
Definition windowSystem.cpp:167
Definition windowSystem.hpp:10
bool IsMouseWithinWindow()
Definition windowSystem.cpp:11