Skip to content

Commit a464bfb

Browse files
authored
Merge pull request #113 from cschreib/special
Clean up `region` class
2 parents 1ebdb20 + ab8b4e4 commit a464bfb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+806
-715
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -587,13 +587,13 @@ gui::root& root = manager->get_root();
587587
// NB: observer_ptr is a lightweight, non-owning smart pointer (vaguely similar to std::weak_ptr).
588588
utils::observer_ptr<gui::frame> frame =
589589
root.create_root_frame<gui::frame>("FPSCounter");
590-
frame->set_point(gui::point::TOP_LEFT);
591-
frame->set_point(gui::point::BOTTOM_RIGHT);
590+
frame->set_anchor(gui::point::TOP_LEFT);
591+
frame->set_anchor(gui::point::BOTTOM_RIGHT);
592592

593593
// Create the FontString as a child region of the frame.
594594
utils::observer_ptr<gui::font_string> text =
595595
frame->create_layered_region<gui::font_string>(gui::layer::ARTWORK, "$parentText");
596-
text->set_point(gui::point::BOTTOM_RIGHT, gui::vector2f{-5, -5});
596+
text->set_anchor(gui::point::BOTTOM_RIGHT, gui::vector2f{-5, -5});
597597
text->set_font("interface/fonts/main.ttf", 12);
598598
text->set_alignment_x(gui::alignment_x::RIGHT);
599599
text->set_alignment_y(gui::alignment_y::BOTTOM);

bin/interface/scroll_test/addon.lua

+10-10
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ function ScrollTest:init_root_folder()
2929
rootFolder.folderNum = 0
3030

3131
rootFolder:set_text("/")
32-
rootFolder:set_point("RIGHT", self.Splitter.FolderFrame.Scroll, "RIGHT", -5, 0)
33-
rootFolder:set_point("TOP_LEFT", self.Splitter.FolderFrame.Scroll, "TOP_LEFT", 5, 5)
32+
rootFolder:set_anchor("RIGHT", self.Splitter.FolderFrame.Scroll, "RIGHT", -5, 0)
33+
rootFolder:set_anchor("TOP_LEFT", self.Splitter.FolderFrame.Scroll, "TOP_LEFT", 5, 5)
3434

3535
rootFolder.Develop.Plus:hide()
3636

@@ -68,9 +68,9 @@ function ScrollTest:init_root_folder()
6868

6969
if rootFolder.lastFolder then
7070
rootFolder.lastFolder.nextFolder = folderButton
71-
folderButton:set_point("TOP_LEFT", rootFolder.lastFolder, "BOTTOM_LEFT")
71+
folderButton:set_anchor("TOP_LEFT", rootFolder.lastFolder, "BOTTOM_LEFT")
7272
else
73-
folderButton:set_point("TOP_LEFT", rootFolder, "BOTTOM_LEFT", 16, 0)
73+
folderButton:set_anchor("TOP_LEFT", rootFolder, "BOTTOM_LEFT", 16, 0)
7474
end
7575

7676
self.folders[self.lastID] = folderButton
@@ -137,9 +137,9 @@ function ScrollTest:develop_folder(id, toggle)
137137

138138
if parentFolder.lastFolder then
139139
parentFolder.lastFolder.nextFolder = folderButton
140-
folderButton:set_point("TOP_LEFT", parentFolder.lastFolder, "BOTTOM_LEFT")
140+
folderButton:set_anchor("TOP_LEFT", parentFolder.lastFolder, "BOTTOM_LEFT")
141141
else
142-
folderButton:set_point("TOP_LEFT", parentFolder, "BOTTOM_LEFT", 16, 0)
142+
folderButton:set_anchor("TOP_LEFT", parentFolder, "BOTTOM_LEFT", 16, 0)
143143
end
144144

145145
self.folders[self.lastID] = folderButton
@@ -163,7 +163,7 @@ function ScrollTest:develop_folder(id, toggle)
163163
end
164164

165165
if parentFolder.nextFolder then
166-
parentFolder.nextFolder:set_point(
166+
parentFolder.nextFolder:set_anchor(
167167
"TOP_LEFT", parentFolder.lastFolder, "BOTTOM_LEFT",
168168
-16*(parentFolder.lastFolder.level - parentFolder.nextFolder.level), 0
169169
)
@@ -176,7 +176,7 @@ function ScrollTest:develop_folder(id, toggle)
176176
parentFolder.developed = false
177177

178178
if (parentFolder.lastFolder.nextFolder) then
179-
parentFolder.lastFolder.nextFolder:set_point("TOP_LEFT", parentFolder, "BOTTOM_LEFT")
179+
parentFolder.lastFolder.nextFolder:set_anchor("TOP_LEFT", parentFolder, "BOTTOM_LEFT")
180180
parentFolder.nextFolder = parentFolder.lastFolder.nextFolder
181181
end
182182

@@ -292,9 +292,9 @@ function ScrollTest:set_folder(id)
292292
fileButton:get_normal_font_object():set_word_wrap(false)
293293

294294
if self.lastFile then
295-
fileButton:set_point("TOP_LEFT", self.lastFile, "BOTTOM_LEFT")
295+
fileButton:set_anchor("TOP_LEFT", self.lastFile, "BOTTOM_LEFT")
296296
else
297-
fileButton:set_point("TOP_LEFT", self.Splitter.FileFrame.Scroll, "TOP_LEFT", 5, 5)
297+
fileButton:set_anchor("TOP_LEFT", self.Splitter.FileFrame.Scroll, "TOP_LEFT", 5, 5)
298298
end
299299

300300
fileButton.IconFrame.Icon:set_texture("|icons.png")

bin/interface/scroll_test/addon.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@
9999
</Anchors>
100100
<Scripts>
101101
<OnLoad>
102-
self.ThumbTexture:set_point("TOP", self, "TOP");
103-
self.ThumbTexture:set_point("BOTTOM", self, "BOTTOM");
102+
self.ThumbTexture:set_anchor("TOP", self, "TOP");
103+
self.ThumbTexture:set_anchor("BOTTOM", self, "BOTTOM");
104104
</OnLoad>
105105
</Scripts>
106106
<Frames>

bin/interface/scroll_test/templates.xml

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</Offset>
1111
</Anchor>
1212
</Anchors>
13-
<NormalText font="interface/fonts/main.ttf" fontHeight="11" setAllPoints="false" alignX="LEFT">
13+
<NormalText font="interface/fonts/main.ttf" fontHeight="11" setAllAnchors="false" alignX="LEFT">
1414
<Anchors>
1515
<Anchor point="LEFT" relativeTo="$parentIconFrame" relativePoint="RIGHT">
1616
<Offset>
@@ -36,7 +36,7 @@
3636
</Anchors>
3737
<Layers>
3838
<Layer>
39-
<Texture name="$parentIcon" setAllPoints="true"/>
39+
<Texture name="$parentIcon" setAllAnchors="true"/>
4040
</Layer>
4141
</Layers>
4242
</Frame>
@@ -50,7 +50,7 @@
5050
<Anchors>
5151
<Anchor point="RIGHT"/>
5252
</Anchors>
53-
<NormalText font="interface/fonts/main.ttf" fontHeight="11" setAllPoints="false" alignX="LEFT">
53+
<NormalText font="interface/fonts/main.ttf" fontHeight="11" setAllAnchors="false" alignX="LEFT">
5454
<Anchors>
5555
<Anchor point="LEFT" relativeTo="$parentIconFrame" relativePoint="RIGHT">
5656
<Offset>
@@ -77,10 +77,10 @@
7777
</Anchors>
7878
<Layers>
7979
<Layer>
80-
<Texture name="$parentPlus" file="|icons.png" setAllPoints="true">
80+
<Texture name="$parentPlus" file="|icons.png" setAllAnchors="true">
8181
<TexCoords left="0" right="0.125" top="0.0" bottom="1.0"/>
8282
</Texture>
83-
<Texture name="$parentMinus" file="|icons.png" hidden="true" setAllPoints="true">
83+
<Texture name="$parentMinus" file="|icons.png" hidden="true" setAllAnchors="true">
8484
<TexCoords left="0.125" right="0.25" top="0.0" bottom="1.0"/>
8585
</Texture>
8686
</Layer>
@@ -100,7 +100,7 @@
100100
</Anchors>
101101
<Layers>
102102
<Layer>
103-
<Texture name="$parentFolder" file="|icons.png" setAllPoints="true">
103+
<Texture name="$parentFolder" file="|icons.png" setAllAnchors="true">
104104
<TexCoords left="0.25" right="0.375" top="0.0" bottom="1.0"/>
105105
</Texture>
106106
</Layer>

bin/interface/slider_test/addon.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
</Anchor>
3939
</Anchors>
4040
<Frames>
41-
<Frame name="$parentColorZone" setAllPoints="true">
41+
<Frame name="$parentColorZone" setAllAnchors="true">
4242
<Backdrop edgeFile="|border_2px.png">
4343
<BackgroundInsets>
4444
<AbsInset left="2" right="2" top="2" bottom="2"/>

bin/interface/slider_test/templates.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
</Offset>
9090
</Anchor>
9191
</Anchors>
92-
<NormalText font="interface/fonts/main.ttf" fontHeight="11" setAllPoints="false">
92+
<NormalText font="interface/fonts/main.ttf" fontHeight="11" setAllAnchors="false">
9393
<Anchors>
9494
<Anchor point="CENTER"/>
9595
</Anchors>

bin/interface/statusbar_test/addon.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
</Scripts>
3838
<Layers>
3939
<Layer level="HIGHLIGHT">
40-
<FontString name="$parentText" font="interface/fonts/main.ttf" fontHeight="11" outline="NORMAL" text="Zoom x1.0" setAllPoints="true"/>
40+
<FontString name="$parentText" font="interface/fonts/main.ttf" fontHeight="11" outline="NORMAL" text="Zoom x1.0" setAllAnchors="true"/>
4141
</Layer>
4242
</Layers>
4343
</StatusBar>
@@ -59,7 +59,7 @@
5959
self.timer = self.update_time;
6060
self.total_fps = 0;
6161
self.frames = 0;
62-
FontstringTestFrameText:set_point("BOTTOM_RIGHT", self, "TOP_RIGHT", -2, -5);
62+
FontstringTestFrameText:set_anchor("BOTTOM_RIGHT", self, "TOP_RIGHT", -2, -5);
6363
</OnLoad>
6464
<OnUpdate>
6565
if (arg1 == 0) then arg1 = 0.1; end
@@ -85,7 +85,7 @@
8585
</Scripts>
8686
<Layers>
8787
<Layer level="HIGHLIGHT">
88-
<Texture name="$parentBorder" file="|bar_outline.png" setAllPoints="true"/>
88+
<Texture name="$parentBorder" file="|bar_outline.png" setAllAnchors="true"/>
8989
</Layer>
9090
</Layers>
9191
</StatusBar>

changelog.txt

+6
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ Other changes:
119119
- gui: renamed justifyH to alignX, justifyV to alignY
120120
- gui: renamed anchor_point to point
121121
- gui: renamed register_for_drag to enable_drag
122+
- gui: renamed get_object_type to get_region_type
123+
- gui: renamed clear_all_points to clear_all_anchors
124+
- gui: renamed [get/set/modify]_point to [get/set/modify]_anchor
125+
- gui: renamed any function of the form "get_num_[...]()" into "get_[...]_count()"
126+
- gui: renamed set_all_points/clear_all_points to set_all_anchors/clear_all_anchors
122127
- gui: removed Frame:on from Lua API (instead, call scripts directly, e.g.: frame:on_update())
123128
- gui: removed the sprite class
124129
- gui: removed region::get_base()
@@ -138,6 +143,7 @@ Other changes:
138143
- gui: removed frame::is_in_frame; use is_in_region instead
139144
- gui: removed frame::register_all_events and unregister_all_events
140145
- gui: removed event class; generic events are now only using event_data
146+
- gui: removed get_frame_type, use get_region_type instead
141147
- gui: edit_box::set_text_insets now takes a single bounds2f argument
142148
- gui: frame::on_script now takes the full script name ("OnUpdate" vs "Update")
143149
- gui: frame::on_script now takes a 'const event_data&' instead of an 'event*' argument

examples/common/examples_common.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,15 @@ void examples_setup_gui(gui::manager& manager) {
111111
// Create a root frame.
112112
utils::observer_ptr<gui::frame> fps_frame;
113113
fps_frame = root.create_root_frame<gui::frame>("FPSCounter");
114-
fps_frame->set_point(gui::point::top_left);
115-
fps_frame->set_point(
114+
fps_frame->set_anchor(gui::point::top_left);
115+
fps_frame->set_anchor(
116116
gui::point::bottom_right, "FontstringTestFrameText", gui::point::top_right);
117117

118118
// Create a font_string in the frame.
119119
utils::observer_ptr<gui::font_string> fps_text;
120120
fps_text =
121121
fps_frame->create_layered_region<gui::font_string>(gui::layer::artwork, "$parentText");
122-
fps_text->set_point(gui::point::bottom_right, gui::vector2f(0, -5));
122+
fps_text->set_anchor(gui::point::bottom_right, gui::vector2f(0, -5));
123123
fps_text->set_font("interface/fonts/main.ttf", 15);
124124
fps_text->set_alignment_y(gui::alignment_y::bottom);
125125
fps_text->set_alignment_x(gui::alignment_x::right);

examples/opengl-sdl-emscripten/main.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ void main_loop(void* type_erased_data) try {
5656
return;
5757
}
5858

59+
// Reset batch count (for analytics only, optional)
60+
context.manager->get_renderer().reset_counters();
61+
5962
// Update the gui
6063
SDL_GL_MakeCurrent(context.window, context.gl_context);
6164
context.manager->update_ui(context.delta);

examples/opengl-sdl/main.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ int main(int argc, char* argv[]) {
145145
continue;
146146
}
147147

148+
// Reset batch count (for analytics only, optional)
149+
manager->get_renderer().reset_counters();
150+
148151
// Update the gui
149152
SDL_GL_MakeCurrent(window.get(), gl_context.context);
150153
manager->update_ui(delta);

examples/opengl-sfml/main.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ int main(int argc, char* argv[]) {
101101
continue;
102102
}
103103

104+
// Reset batch count (for analytics only, optional)
105+
manager->get_renderer().reset_counters();
106+
104107
// Update the gui
105108
manager->update_ui(delta);
106109

examples/sdl-emscripten/main.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ void main_loop(void* type_erased_data) try {
5454
return;
5555
}
5656

57+
// Reset batch count (for analytics only, optional)
58+
context.manager->get_renderer().reset_counters();
59+
5760
// Update the gui
5861
context.manager->update_ui(context.delta);
5962

examples/sdl/main.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ int main(int argc, char* argv[]) {
116116
continue;
117117
}
118118

119+
// Reset batch count (for analytics only, optional)
120+
manager->get_renderer().reset_counters();
121+
119122
// Update the gui
120123
manager->update_ui(delta);
121124

examples/sfml/main.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ int main(int argc, char* argv[]) {
8585
continue;
8686
}
8787

88+
// Reset batch count (for analytics only, optional)
89+
manager->get_renderer().reset_counters();
90+
8891
// Update the gui
8992
manager->update_ui(delta);
9093

impl/gui/gl/src/gui_gl_vertex_cache.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ void vertex_cache::update_indices(const std::uint32_t* vertex_indices, std::size
8787
}
8888

8989
current_size_index_ = num_indices;
90+
num_vertex_ = current_size_index_;
9091
}
9192

9293
void vertex_cache::update_indices_if_grow(
@@ -96,6 +97,7 @@ void vertex_cache::update_indices_if_grow(
9697
} else {
9798
// Cheap resize, do not update indices
9899
current_size_index_ = num_indices;
100+
num_vertex_ = current_size_index_;
99101
}
100102
}
101103

impl/gui/sfml/src/gui_sfml_renderer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ void renderer::render_cache_(
142142
if (sf_mat)
143143
state.texture = sf_mat->get_texture();
144144
state.transform = to_sfml(model_transform);
145-
current_sfml_target_->draw(sf_cache.get_impl(), 0, sf_cache.get_num_vertex(), state);
145+
current_sfml_target_->draw(sf_cache.get_impl(), 0, sf_cache.get_vertex_count(), state);
146146
#else
147147
throw gui::exception("gui::sfml::renderer", "SFML does not support vertex caches.");
148148
#endif

impl/gui/sfml/src/gui_sfml_vertex_cache.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,6 @@ void vertex_cache::update(const vertex* vertex_data, std::size_t num_vertex) {
5555
}
5656
}
5757

58-
std::size_t vertex_cache::get_num_vertex() const {
59-
return num_vertex_;
60-
}
61-
6258
const sf::VertexBuffer& vertex_cache::get_impl() const {
6359
return buffer_;
6460
}

include/lxgui/gui_animated_texture.hpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ class renderer;
1515
* \details This object contains an animated texture taken from a file.
1616
*/
1717
class animated_texture : public layered_region {
18+
public:
1819
using base = layered_region;
1920

20-
public:
2121
/// Constructor.
2222
explicit animated_texture(
2323
utils::control_block& block, manager& mgr, const region_core_attributes& attr);
@@ -134,6 +134,8 @@ class animated_texture : public layered_region {
134134
void update_tex_coords_();
135135
void update_borders_() override;
136136

137+
const std::vector<std::string>& get_type_list_() const override;
138+
137139
std::string file_;
138140

139141
float speed_ = 1.0f;

include/lxgui/gui_atlas.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ class atlas {
181181
* \brief Return the number of pages in this atlas.
182182
* \return The number of pages in this atlas
183183
*/
184-
std::size_t get_num_pages() const;
184+
std::size_t get_page_count() const;
185185

186186
protected:
187187
/**

include/lxgui/gui_button.hpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ class font_string;
4141
* - `OnDisable`: Triggered by button::disable.
4242
*/
4343
class button : public frame {
44+
public:
4445
using base = frame;
4546

46-
public:
4747
enum class state { up, down, disabled };
4848

4949
/// Constructor.
@@ -342,6 +342,8 @@ class button : public frame {
342342
void parse_attributes_(const layout_node& node) override;
343343
void parse_all_nodes_before_children_(const layout_node& node) override;
344344

345+
const std::vector<std::string>& get_type_list_() const override;
346+
345347
state state_ = state::up;
346348
bool is_highlighted_ = false;
347349
bool is_highlight_locked_ = false;

include/lxgui/gui_check_button.hpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ namespace lxgui::gui {
1313
* additional special textures for the check sign.
1414
*/
1515
class check_button : public button {
16+
public:
1617
using base = button;
1718

18-
public:
1919
/// Constructor.
2020
explicit check_button(
2121
utils::control_block& block, manager& mgr, const frame_core_attributes& attr);
@@ -113,6 +113,8 @@ class check_button : public button {
113113
protected:
114114
void parse_all_nodes_before_children_(const layout_node& node) override;
115115

116+
const std::vector<std::string>& get_type_list_() const override;
117+
116118
bool is_checked_ = false;
117119

118120
utils::observer_ptr<texture> checked_texture_ = nullptr;

0 commit comments

Comments
 (0)