Commit graph

337 commits

Author SHA1 Message Date
Kp 15d54d4d6d Precompute ui_file_browser::spaces 2023-02-04 19:21:25 +00:00
Kp f0f669e8ab Use sentinel for null_sentinel_iterator end() 2023-02-04 19:21:25 +00:00
Kp 3aef1ee569 Tighten PHYSFSX_counted_list_template reset rules
Prefer move-assignment over use of reset() so that the count cannot go
out of sync from the list.

Shorten lifetime of some lists.
2023-02-04 19:21:25 +00:00
Kp 0d97683cee Construct PHYSFSX_counted_list with the correct count
Remove the method for adjusting the count later, and instead store the
list in a PHYSFSX_uncounted_list until the count is available, then move
it into the PHYSFSX_counted_list along with the count.  This prevents
using a list with its count unset.
2023-02-04 19:21:25 +00:00
Kp 87ab4f3360 Store filename_list in ui_file_browser
Store the list directly instead of a reference to a local variable in
the caller's scope.  No compiler has warned about this yet, but gcc-12
warned about a similar construct in newmenu_do2, so fix this up before
it becomes a problem.
2023-02-04 19:21:25 +00:00
Kp 0456e8f50b Remove #if DXX_USE_EDITOR from editor-only file.cpp
This file is not compiled when !DXX_USE_EDITOR, so the preprocessor
guard is unnecessary.
2023-02-04 19:21:25 +00:00
Kp 385d51b18e Delegate UI_DIALOG deletion back to window_close
UI_DIALOG::event_handler's case `EVENT_WINDOW_CLOSE` can only be hit if
`rval == window_event_result::ignored`.  Any other result returned
before entering the switch.  If `rval == ignored`, then returning
`ignored` will cause `window_close` to delete the object.  Delegate to
that deletion instead of having an explicit deletion in this handler.
2023-01-29 20:42:03 +00:00
Kp ae4b3b4c87 Make window_send_event a method of window
Switch from using a macro to capture __FILE__,__LINE__ to using
__builtin_FILE(),__builtin_LINE().  Make the event an explicit argument,
instead of assuming it is a variable named `event`.  Move the
implementation out of line.
2022-12-18 23:10:39 +00:00
Kp 3d5de92058 Fix OS X clang build
OS X still uses clang-14, which lacks sufficient std::ranges support for
recent Rebirth changes.

- Rewrite uses of std::ranges::SYMBOL to ranges::SYMBOL
- Add a stub header that, on gcc, provides for each SYMBOL a statement
  `using std::ranges::SYMBOL;`, to delegate back to the standard library
  implementation.
- On clang, define a minimal implementation of the required symbols,
  without constraint enforcement.  Compile-testing with gcc will catch
  constraint violations.

Once OS X clang ships a standard library with the required features,
this stub header will be removed and the uses changed back to their full
names.
2022-10-31 00:51:32 +00:00
Kp e385ff1c3b Use std::ranges::find_if instead of std::find_if
std::ranges::find_if permits use of a sentinel instead of a full
iterator, and supports std::ranges::find as an alternative to certain
simple uses of std::find_if.

Where possible, use the form that takes a range, rather than the form
that takes two iterators.

Add a declared, but not defined, default constructor for
self_return_iterator to satisfy the standard library's concept
`semiregular`, which insists that sentinels be default-constructible,
even for those functions that never need to do so.

Add a defined, but unused, operator++(postfix) for zip_iterator to
satisfy a standard library concept for `forward_iterator`.
2022-10-09 23:15:20 +00:00
Kp 9c4c49fe5e Return std::unique_ptr from d_strdup 2022-10-09 23:15:20 +00:00
Kp 8fe9b8322d Check return value of PHYSFSX_fgets 2022-10-02 19:51:35 +00:00
Kp cbe6c94f1e Pass std::span to file_getdirlist 2022-09-24 17:47:52 +00:00
Kp a70188e7a5 Move various static functions into anonymous namespace 2022-07-09 13:39:29 +00:00
Kp 1c2e1c6946 Tighten type info for d_strdup
The allocated block is part of the dmem subsystem, so return a type that
reflects that.
2022-04-24 20:42:01 +00:00
Kp c4985b8606 Move UI_GADGET list setup into constructor 2022-02-13 19:13:38 +00:00
Kp d2478d0708 Require support for C++17 attribute [[fallthrough]] 2022-01-09 15:25:42 +00:00
Kp 57780e0450 Move window_is_visible,window_set_visible to be window methods
Shrink w_visible to uint8_t.  Move it to pack better.
2021-11-01 03:37:18 +00:00
Kp 21241471c6 Return string width/height from gr_get_string_size
Use structured bindings to capture the values on return, so that they
can be declared as `const` if they are immutable after initial
computation.
2021-09-12 16:20:52 +00:00
Kp 0750046bc1 Move retrieval of font average width out of gr_get_string_size
Most callers do not need it, and it is only vaguely related to the
purpose of measuring a particular string.  For those callers that need
it, lift it out.
2021-09-12 16:20:52 +00:00
Kp 5d39c52b0c Remote write-only field UI_GADGET::status 2021-08-26 03:13:46 +00:00
Kp be5061c072 Remove write-only field UI_GADGET::oldstatus 2021-08-26 03:13:46 +00:00
Kp 1c13d3c8d3 Improve error reporting for PHYSFSX_openReadBuffered
Return the PHYSFS error code on failure, so that callers can report why
the open failed.
2021-07-25 23:00:56 +00:00
Kp 7b12aac1bb Transpose returned values for enumerate() of non-tuple
Match the order used for tuple.
2021-06-28 03:37:50 +00:00
Kp 80fc124a63 Remove unnecessary definitions of static member variables
C++17 permits, but deprecates, this form.  Remove it to simplify the
code.
2020-12-27 22:03:09 +00:00
Kp 479884288c Always delegate to window_create for send_creation_events 2020-12-20 20:39:07 +00:00
Kp 5c7fc7d143 Remove unused UI_DIALOG d_callback
Every user now uses inheritance and a virtual function override.  Make
callback_handler pure virtual, delete its body, and then delete the
member variables that existed only for use in that body.  Remove the
constructor parameters that initialized those variables, and update all
derived classes accordingly.
2020-12-19 16:13:26 +00:00
Kp 2709676f8d Rename ui_create_dialog to window_create
The requirement to call send_creation_events from outside the
constructor makes the presence of a helper function convenient.  Rename
ui_create_dialog to window_create, and move it to window.h.
2020-12-19 16:13:26 +00:00
Kp ae657007fe Remove send_creation_events parameter
It is always nullptr.
2020-10-22 02:26:16 +00:00
Kp 2869566866 Remove unused ui_create_dialog parameter createdata
It is always nullptr.  Remove the parameter and pass nullptr where the
parameter was used.
2020-10-22 02:26:16 +00:00
Kp e7cd8bedec Remove obsolete embed_window_pointer_t 2020-10-22 02:26:16 +00:00
Kp 4d3eeb903e Make MENU's window to inherit from window
Due to ordering constraints, this is not merged into MENU, but is
instead kept as a distinct sub-type that is pointed at by MENU.  MENU
sets the window's position based on parsing of the menu definition file,
but the parser expects to store window position data into MENU before
creating the window.  If menubar_window were merged into MENU, the
parser would need a temporary, and all callers that create the window
would need to consult that temporary.
2020-10-12 03:28:26 +00:00
Kp 07eb412244 Make menubar.cpp Menu[] an array of MENU*, not MENU 2020-10-12 03:28:26 +00:00
Kp 6ffa495bf4 Split out special handling for creating menubar
All callers request either the menubar or something else, but never
conditionally request one or the other.  Split the special handling that
picks a different handler based on which element the caller requested.
2020-10-12 03:28:26 +00:00
Kp f8185494ad Pass UI_DIALOG& to ui_add_gadget_icon 2020-10-12 03:28:26 +00:00
Kp 4f572bbe23 Pass UI_DIALOG& to ui_add_gadget_userbox 2020-10-12 03:28:26 +00:00
Kp 95598a34e3 Pass UI_DIALOG& to ui_add_gadget_inputbox 2020-10-12 03:28:26 +00:00
Kp 466f431c91 Pass UI_DIALOG& to ui_add_gadget_checkbox 2020-10-12 03:28:26 +00:00
Kp 3b7a34b066 Pass UI_DIALOG& to ui_draw_scrollbar 2020-10-12 03:28:26 +00:00
Kp 028f0c4cda Remove unused function ui_draw_frame 2020-10-12 03:28:26 +00:00
Kp c5afd0eb55 Pass UI_DIALOG& to ui_draw_icon 2020-10-12 03:28:26 +00:00
Kp 9e9429fe58 Pass UI_DIALOG& to ui_draw_userbox 2020-10-12 03:28:26 +00:00
Kp b45e696574 Pass UI_DIALOG& to ui_draw_checkbox 2020-10-12 03:28:26 +00:00
Kp 380d30f943 Pass UI_DIALOG& to ui_draw_radio 2020-10-12 03:28:26 +00:00
Kp 506f24ed04 Pass UI_GADGET_RADIO& to ui_radio_set_value 2020-10-12 03:28:26 +00:00
Kp f531c7d43e Pass UI_DIALOG& to ui_add_gadget_radio 2020-10-12 03:28:26 +00:00
Kp ff039c0c90 Pass UI_DIALOG& to ui_add_gadget_scrollbar 2020-10-12 03:28:26 +00:00
Kp 1d7f2e2ab5 Replace ui_gadget_do with virtual function dispatch 2020-10-12 03:28:26 +00:00
Kp d78d16b82f Pass UI_DIALOG& to ui_draw_inputbox 2020-10-12 03:28:26 +00:00
Kp a399fa7b58 Rename ui_icon_do to UI_GADGET_ICON::event_handler 2020-10-12 03:28:26 +00:00