Wrath of Zeus
Made by Torchlight Games for CSE 125 SP24
Loading...
Searching...
No Matches
flexbox.hpp
Go to the documentation of this file.
1#pragma once
2
4
5#include <vector>
6#include <memory>
7
8namespace gui::widget {
9
10class Flexbox : public Widget {
11public:
12 using Ptr = std::unique_ptr<Flexbox>;
13
14 struct Options {
17
20 float padding;
21 };
22
37 template <typename... Params>
38 static Ptr make(Params&&... params) {
39 return std::make_unique<Flexbox>(std::forward<Params>(params)...);
40 }
41
42 Flexbox(glm::vec2 origin, glm::vec2 size, Options options);
43 Flexbox(glm::vec2 origin, Options options);
44
45 void doClick(float x, float y) override;
46 void doHover(float x, float y) override;
47
51 void push(Widget::Ptr&& widget);
57 void lock() override;
58
59 void render() override;
60
61 Widget* borrow(Handle handle) override;
62 bool hasHandle(Handle handle) const override;
63
64private:
65 Options options;
66 std::vector<Widget::Ptr> widgets;
67};
68
69
70}
Definition: flexbox.hpp:10
void doHover(float x, float y) override
Performs a hover action at the specified (x,y) position in the GUI coordinate frame.
Definition: flexbox.cpp:28
Widget * borrow(Handle handle) override
Gives a pointer to the subwidget specified by the handle.
Definition: flexbox.cpp:122
bool hasHandle(Handle handle) const override
======================================================================================
Definition: flexbox.cpp:139
static Ptr make(Params &&... params)
creates a flexbox unique ptr for use in the GUI
Definition: flexbox.hpp:38
void render() override
======================================================================================
Definition: flexbox.cpp:115
std::unique_ptr< Flexbox > Ptr
Definition: flexbox.hpp:12
void lock() override
Definition: flexbox.cpp:90
void doClick(float x, float y) override
Performs a click at the specified (x,y) position in the GUI coordinate frame.
Definition: flexbox.cpp:21
void push(Widget::Ptr &&widget)
adds a new widget to the flexbox, from the bottom up
Definition: flexbox.cpp:35
Definition: widget.hpp:41
std::unique_ptr< Widget > Ptr
Definition: widget.hpp:45
glm::vec2 origin
Origin position (bottom left) of the widget in GUI coordinates.
Definition: widget.hpp:217
Handle handle
======================================================================================
Definition: widget.hpp:207
GLint GLenum GLint x
Definition: glad.h:1655
GLint y
Definition: glad.h:1516
GLenum const GLfloat * params
Definition: glad.h:1522
GLsizeiptr size
Definition: glad.h:1803
Definition: centertext.hpp:6
std::size_t Handle
Type for a Widget Handle.
Definition: widget.hpp:16
Dir
Definition: options.hpp:5
Align
Definition: options.hpp:10
Definition: flexbox.hpp:14
float padding
Definition: flexbox.hpp:20
Dir direction
Definition: flexbox.hpp:18
Align alignment
Definition: flexbox.hpp:19
Options(Dir direction, Align alignment, float padding)
Definition: flexbox.hpp:15