Skip to content

Commit bbb8132

Browse files
authored
Merge pull request #114 from cschreib/fix-typos
Various API clean up, add edit_box locale support, and frame update rate
2 parents a464bfb + d68abec commit bbb8132

Some content is hidden

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

43 files changed

+1525
-608
lines changed

bin/interface/scroll_test/addon.lua

+3-3
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ function ScrollTest:init_root_folder()
6464

6565
folderButton:set_text(folder)
6666
local font = folderButton:get_normal_font_object()
67-
font:set_word_wrap(false)
67+
font:disable_word_wrap()
6868

6969
if rootFolder.lastFolder then
7070
rootFolder.lastFolder.nextFolder = folderButton
@@ -133,7 +133,7 @@ function ScrollTest:develop_folder(id, toggle)
133133
folderButton.folderNum = 0
134134

135135
folderButton:set_text(folder)
136-
folderButton:get_normal_font_object():set_word_wrap(false)
136+
folderButton:get_normal_font_object():disable_word_wrap()
137137

138138
if parentFolder.lastFolder then
139139
parentFolder.lastFolder.nextFolder = folderButton
@@ -289,7 +289,7 @@ function ScrollTest:set_folder(id)
289289
fileButton.file = file
290290
end
291291
fileButton:set_text(file)
292-
fileButton:get_normal_font_object():set_word_wrap(false)
292+
fileButton:get_normal_font_object():disable_word_wrap()
293293

294294
if self.lastFile then
295295
fileButton:set_anchor("TOP_LEFT", self.lastFile, "BOTTOM_LEFT")

bin/interface/slider_test/templates.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<Ui>
2-
<Frame name="FrameTemplate_Dialog" virtual="true" hidden="false" movable="true" enableMouse="true" enableMouseWheel="true" clampedToScreen="true" frameStrata="DIALOG" topLevel="true">
2+
<Frame name="FrameTemplate_Dialog" virtual="true" hidden="false" movable="true" enableMouse="true" enableMouseWheel="true" clampedToScreen="true" strata="DIALOG" topLevel="true">
33
<Backdrop edgeFile="|dialog_border.png">
44
<BackgroundInsets>
55
<AbsInset left="8" right="8" top="8" bottom="8"/>

changelog.txt

+31-14
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,20 @@ Other changes:
8888
- gui: added input::window as an interface to implementation-dependent concepts (clipboard...)
8989
- gui: added frame::enable_key_capture
9090
- gui: added OnKeyRepeat frame event
91+
- gui: added OnReceiveDrag for frame
92+
- gui: added OnCursorChanged for edit_box
93+
- gui: added OnUpPressed and OnDownPressed callbacks to edit_box
94+
- gui: added set_cursor_position()/get_cursor_position() to edit_box
95+
- gui: added clear_history_lines() to edit_box
96+
- gui: added clipboard support to edit_box
97+
- gui: added automatic un-focus of edit_box when clicking outside of the box
98+
- gui: added frame::get_script
99+
- gui: added slider::set_orientation(const std::string&)
100+
- gui: added status_bar::set_orientation(const std::string&)
101+
- gui: added manager::close_ui_now and made close_ui safer
102+
- gui: added frame::enable_mouse_click and frame::enable_mouse_move
103+
- gui: added font_string::set_vertex_cache_strategy
104+
- gui: added frame::set_update_rate
91105
- gui: renamed gui::uiobject into gui::region, and merged with previous gui::region
92106
- gui: renamed gui::manager_impl into gui::renderer
93107
- gui: renamed gui::gl::manager into gui::gl::renderer
@@ -124,6 +138,23 @@ Other changes:
124138
- gui: renamed [get/set/modify]_point to [get/set/modify]_anchor
125139
- gui: renamed any function of the form "get_num_[...]()" into "get_[...]_count()"
126140
- gui: renamed set_all_points/clear_all_points to set_all_anchors/clear_all_anchors
141+
- gui: renamed strata to strata_data
142+
- gui: renamed frame_level/frameLevel to level
143+
- gui: renamed frame_strata/frameStrata to strata
144+
- gui: renamed can_non_space_wrap to is_non_space_wrap_enabled
145+
- gui: renamed set_non_space_wrap to set_non_space_wrap_enabled
146+
- gui: renamed has_shadow to is_shadow_enabled
147+
- gui: renamed set_shadow to set_shadow_enabled
148+
- gui: renamed set_word_wrap to set_word_wrap_enabled
149+
- gui: renamed can_word_wrap to is_word_wrap_enabled
150+
- gui: renamed can_non_space_wrap to is_non_space_wrap_enabled
151+
- gui: renamed set_non_space_wrap to set_word_wrap_enabled
152+
- gui: renamed nonspacewrap to nonSpaceWrap
153+
- gui: renamed enable_mouse* to set_mouse*_enabled
154+
- gui: renamed enable_key* to set_key*_enabled
155+
- gui: renamed is_password to is_password_mode_enabled
156+
- gui: renamed set_password to set_password_mode_enabled
157+
- gui: renamed blink_period/blinkPeriod to blink_time/blinkTime
127158
- gui: removed Frame:on from Lua API (instead, call scripts directly, e.g.: frame:on_update())
128159
- gui: removed the sprite class
129160
- gui: removed region::get_base()
@@ -153,7 +184,6 @@ Other changes:
153184
- gui: all UI objects are now managed with explicit single ownership (unique_ptr)
154185
- gui: added frame_renderer class interface to clarify the frame class
155186
- gui: only frames can now be flagged as having a frame_renderer
156-
- gui: "frame_level" has been renamed to just "level"
157187
- gui: frame::get_children and frame::get_regions return views rather than containers
158188
- gui: added gui::down_cast for safer down casting
159189
- gui: removed clear_links() in favor of using destructors
@@ -166,22 +196,9 @@ Other changes:
166196
- gui: renamed OnEditFocusLost to OnFocusLost (now available for FocusFrame too)
167197
- gui: key and mouse events no longer contain string names of buttons and keys
168198
- gui: objects inside a scroll_frame can now correctly anchor to other objects
169-
- gui: added OnReceiveDrag for frame
170-
- gui: added OnCursorChanged for edit_box
171-
- gui: added OnUpPressed and OnDownPressed callbacks to edit_box
172-
- gui: added set_cursor_position()/get_cursor_position() to edit_box
173-
- gui: added clear_history() to edit_box
174-
- gui: added clipboard support to edit_box
175-
- gui: added automatic un-focus of edit_box when clicking outside of the box
176-
- gui: added frame::get_script
177-
- gui: added slider::set_orientation(const std::string&)
178-
- gui: added status_bar::set_orientation(const std::string&)
179-
- gui: added manager::close_ui_now and made close_ui safer
180-
- gui: added frame::enable_mouse_click and frame::enable_mouse_move
181199
- gui: render targets can now have texture filtering other than nearest
182200
- gui: GUI caching is now disabled by default
183201
- gui: improved peformance of "update borders" notifications
184-
- gui: improved peformance of generating new object IDs
185202
- gui: improved peformance of font outline rendering
186203
- gui: improved quality and consistency of font rendering in OpenGL back-end
187204
- gui: fixed rare crash in edit_box

include/lxgui/gui_button.hpp

+12
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,18 @@ class button : public frame {
262262
*/
263263
void set_disabled_text(utils::observer_ptr<font_string> fstr);
264264

265+
/**
266+
* \brief Enables or disables this button.
267+
* \param enabled 'true' to enable, 'false' to disable
268+
*/
269+
void set_enabled(bool enabled) {
270+
if (enabled) {
271+
enable();
272+
} else {
273+
disable();
274+
}
275+
}
276+
265277
/**
266278
* \brief Disables this button.
267279
* \note A disabled button doesn't receive any input.

include/lxgui/gui_edit_box.hpp

+34-26
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,6 @@ class edit_box : public frame {
7272
*/
7373
void copy_from(const region& obj) override;
7474

75-
/**
76-
* \brief Updates this region's logic.
77-
* \param delta Time spent since last update
78-
* \note Triggered callbacks could destroy the frame. If you need
79-
* to use the frame again after calling this function, use
80-
* the helper class alive_checker.
81-
*/
82-
void update(float delta) override;
83-
8475
/**
8576
* \brief Calls a script.
8677
* \param script_name The name of the script
@@ -171,16 +162,16 @@ class edit_box : public frame {
171162
std::size_t get_letter_count() const;
172163

173164
/**
174-
* \brief Sets the carret's blink speed.
175-
* \param blink_period The number of seconds to wait between each blink
165+
* \brief Sets the carret's blink time.
166+
* \param blink_time The number of seconds to wait between each blink
176167
*/
177-
void set_blink_period(double blink_period);
168+
void set_blink_time(double blink_time);
178169

179170
/**
180-
* \brief Returns the carret's blink speed.
181-
* \return the carret's blink speed (time in seconds between each blink)
171+
* \brief Returns the carret's blink time.
172+
* \return the carret's blink time (time in seconds between each blink)
182173
*/
183-
double get_blink_period() const;
174+
double get_blink_time() const;
184175

185176
/**
186177
* \brief Makes this edit_box allow numeric characters only.
@@ -221,12 +212,28 @@ class edit_box : public frame {
221212
bool is_integer_only() const;
222213

223214
/**
224-
* \brief Enables password mode.
215+
* \brief Enables or disables password mode.
225216
* \param enable 'true' to enable password mode
226217
* \note In password mode, the content of the edit_box is replaced
227218
* by stars (*).
228219
*/
229-
void enable_password_mode(bool enable);
220+
void set_password_mode_enabled(bool enable);
221+
222+
/**
223+
* \brief Enables password mode.
224+
* \see set_password_mode_enabled
225+
*/
226+
void enable_password_mode() {
227+
set_password_mode_enabled(true);
228+
}
229+
230+
/**
231+
* \brief Disables password mode.
232+
* \see set_password_mode_enabled
233+
*/
234+
void disable_password_mode() {
235+
set_password_mode_enabled(false);
236+
}
230237

231238
/**
232239
* \brief Checks if this edit_box is in password mode.
@@ -238,10 +245,10 @@ class edit_box : public frame {
238245
* \brief Allows this edit_box to have several lines in it.
239246
* \param multi_line 'true' to allow several lines in this edit_box
240247
* \note The behavior of a "multi line" edit_box is very different from
241-
* a single line one.<br>
242-
* History lines are only available to single line edit_boxes.<br>
243-
* Scrolling in a single line edit_box is done horizontally, while
244-
* it is only done vertically in a multi line one.
248+
* a single line one. History lines are only available to single-line edit_boxes.
249+
* Scrolling in a single-line edit_box is done horizontally, while it is only done
250+
* vertically in a multi-line one.
251+
* \warning Multi-line edit_box is not yet fully implemented!
245252
*/
246253
void set_multi_line(bool multi_line);
247254

@@ -278,7 +285,7 @@ class edit_box : public frame {
278285
const std::vector<utils::ustring>& get_history_lines() const;
279286

280287
/// Clears the history line list.
281-
void clear_history();
288+
void clear_history_lines();
282289

283290
/**
284291
* \brief Sets whether keyboard arrows move the carret or not.
@@ -349,13 +356,15 @@ class edit_box : public frame {
349356
void parse_font_string_node_(const layout_node& node);
350357
void parse_text_insets_node_(const layout_node& node);
351358

359+
void update_(float delta) override;
360+
352361
const std::vector<std::string>& get_type_list_() const override;
353362

354363
void create_font_string_();
355364
void create_highlight_();
356365
void create_carret_();
357366

358-
void check_text_();
367+
bool check_text_();
359368
void update_displayed_text_();
360369
void update_font_string_();
361370
void update_carret_position_();
@@ -372,7 +381,6 @@ class edit_box : public frame {
372381
utils::ustring unicode_text_;
373382
utils::ustring displayed_text_;
374383
utils::ustring::iterator iter_carret_pos_;
375-
utils::ustring::iterator iter_carret_pos_old_;
376384

377385
std::size_t display_pos_ = 0;
378386
std::size_t num_letters_ = 0;
@@ -390,8 +398,8 @@ class edit_box : public frame {
390398
std::size_t selection_end_pos_ = 0u;
391399
bool is_text_selected_ = false;
392400

393-
utils::observer_ptr<texture> carret_ = nullptr;
394-
double blink_period_ = 0.5;
401+
utils::observer_ptr<texture> carret_ = nullptr;
402+
double blink_time_ = 0.5;
395403
utils::periodic_timer carret_timer_;
396404

397405
std::vector<utils::ustring> history_line_list_;

0 commit comments

Comments
 (0)