Skip to content

Commit 64527e3

Browse files
committed
[ref][update] layout scale, and viewport context
1 parent fe67e12 commit 64527e3

File tree

16 files changed

+222
-122
lines changed

16 files changed

+222
-122
lines changed

include/ekg/core/context.hpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,31 @@
33

44
#include "ekg/io/typography.hpp"
55
#include "ekg/math/geometry.hpp"
6+
#include "ekg/ui/properties.hpp"
67

78
namespace ekg {
89
extern FT_Library freetype_library;
9-
extern bool redraw;
10+
11+
extern struct viewport_t {
12+
float x {};
13+
float y {};
14+
float w {};
15+
float h {};
16+
17+
bool auto_scale {};
18+
ekg::vec4_t<float> scale {};
19+
bool redraw {};
20+
} viewport;
21+
22+
extern struct current_t {
23+
ekg::id_t pressed {};
24+
ekg::type pressed_type {};
25+
ekg::id_t released {};
26+
ekg::type released_type {};
27+
ekg::id_t last {};
28+
ekg::id_t unique_id {};
29+
ekg::type type {};
30+
} current;
1031
}
1132

1233
#endif

include/ekg/draw/shape.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include <vector>
2929
#include <iostream>
3030

31-
#include "ekg/geometry/geometry.hpp"
31+
#include "ekg/math/geometry.hpp"
3232
#include "ekg/gpu/api.hpp"
3333

3434
#define ekg_draw_assert_scissor() if (ekg::gpu::allocator::is_out_of_scissor) { return; }

include/ekg/gpu/allocator.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#include <vector>
3030

3131
#include "ekg/gpu/api.hpp"
32-
#include "ekg/util/geometry.hpp"
3332

3433
namespace ekg::gpu {
3534
class allocator {

include/ekg/layout/dimension.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ namespace ekg {
66
* Estimate height from a container children list.
77
* Note: Recursive.
88
**/
9-
float estimate_height(
10-
ekg::ui::abstract_widget *p_parent_widget
9+
float estimate_docknizable_height(
10+
ekg::ui::abstract *p_parent_widget
1111
);
1212
}
1313

include/ekg/math/geometry.hpp

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ namespace ekg {
4141
}
4242

4343
// TODO: add non-useless vector 2 properties operators
44+
45+
template<typename t>
46+
operator ekg::vec2_t<t>() {
47+
return ekg::vec2_t<t>{
48+
static_cast<t>(this->x),
49+
static_cast<t>(this->y)
50+
};
51+
}
4452
};
4553

4654
template<typename t>
@@ -62,6 +70,15 @@ namespace ekg {
6270
}
6371

6472
// TODO: add non-useless vector 3 properties operators
73+
74+
template<typename t>
75+
operator ekg::vec3_t<t>() {
76+
return ekg::vec3_t<t>{
77+
static_cast<t>(this->x),
78+
static_cast<t>(this->y),
79+
static_cast<t>(this->z)
80+
};
81+
}
6582
};
6683

6784
template<typename t>
@@ -86,6 +103,16 @@ namespace ekg {
86103

87104
// TODO: add non-useless vector 4 properties operators
88105

106+
template<typename t>
107+
operator ekg::vec4_t<t>() {
108+
return ekg::vec4_t<t>{
109+
static_cast<t>(this->x),
110+
static_cast<t>(this->y),
111+
static_cast<t>(this->z),
112+
static_cast<t>(this->w)
113+
};
114+
}
115+
89116
template<typename s>
90117
ekg::vec4_t<t> operator / (s div_by) {
91118
return ekg::vec4_t<t> {
@@ -129,6 +156,26 @@ namespace ekg {
129156
}
130157

131158
// TODO: add non-useless rect (aka vector 4 properties) operators
159+
160+
template<typename t>
161+
operator ekg::rect_t<t>() {
162+
return ekg::rect_t<t>{
163+
static_cast<t>(this->x),
164+
static_cast<t>(this->y),
165+
static_cast<t>(this->w),
166+
static_cast<t>(this->h)
167+
};
168+
}
169+
170+
template<typename t>
171+
operator ekg::vec4_t<t>() {
172+
return ekg::vec4_t<t>{
173+
static_cast<t>(this->x),
174+
static_cast<t>(this->y),
175+
static_cast<t>(this->w),
176+
static_cast<t>(this->h)
177+
};
178+
}
132179
};
133180

134181
struct rect_descriptor_t {

include/ekg/os/ekg_glfw.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ namespace ekg {
2424
public:
2525
void init() override;
2626
void quit() override;
27-
void update_monitor_resolution() override;
28-
void update_cursor(ekg::system_cursor_type system_cursor) override;
27+
void update_display_size() override;
28+
void update_cursor() override;
2929
void get_key_name(ekg::io::input_key_t &key, std::string &name) override;
3030
void get_special_key(ekg::io::input_key_t &key, ekg::special_key_type &special_key) override;
3131
const char *get_clipboard_text() override;

include/ekg/os/ekg_sdl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ namespace ekg {
4848
public:
4949
void init() override;
5050
void quit() override;
51-
void update_monitor_resolution() override;
51+
void update_display_size() override;
5252
void update_cursor(ekg::system_cursor_type system_cursor) override;
5353
void get_key_name(ekg::io::input_key_t &key, std::string &name) override;
5454
void get_special_key(ekg::io::input_key_t &key, ekg::special_key_type &special_key) override;

include/ekg/os/platform.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ namespace ekg::os {
3737
public:
3838
virtual void init() {}
3939
virtual void quit() {}
40-
virtual void update_monitor_resolution() {}
40+
virtual void update_display_size() {}
4141
virtual void update_cursor() {}
4242
virtual void get_key_name(ekg::io::input_key_t &key, std::string &name) {}
4343
virtual void get_special_key(ekg::io::input_key_t &key, ekg::special_key_type special_key) {}

src/core/context.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "ekg/context.hpp"
22

33
FT_Library ekg::freetype_library {};
4-
bool ekg::redraw {};
4+
ekg::viewport_t ekg::viewport {};
5+
ekg::current_t ekg::current {};

src/core/runtime.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,8 @@ void ekg::runtime::update() {
277277
}
278278

279279
void ekg::runtime::render() {
280-
if (ekg::redraw) {
281-
ekg::redraw = false;
280+
if (ekg::viewport.redraw) {
281+
ekg::viewport.redraw = false;
282282

283283
/**
284284
* The allocator starts here, the GPU data instance

0 commit comments

Comments
 (0)