Commit graph

189 commits

Author SHA1 Message Date
Chris Taylor 7ac820248c Use new event_process_all() for event loops that check for window_event_result::deleted (which is most of them) 2016-10-29 20:06:01 +08:00
Chris Taylor 1c8ad24da3 Check for window_event_result::deleted for ui_get_filename polling loop
This is instead of using window_exists, which could give a false positive if a new window was allocated with the same pointer value as a deleted one.
2016-10-28 15:25:25 +08:00
Chris Taylor 917f079f02 Check for window_event_result::deleted in ui_dialog_do_gadgets
This is instead of using window_exists, which could give a false positive if a new window was allocated with the same pointer value as a deleted one.
2016-10-28 08:40:50 +08:00
Chris Taylor 7b83123010 Pass window_event_result from a dialog handler all the way to the event system
In particular, window_event_result::deleted so the event system doesn't have to rely on the somewhat problematic window_exists. If a gadget is manipulated, it still returns at least window_event_result::handled so all the other gadgets in all the other windows don't have to be checked (that weren't already checked).
2016-10-27 19:42:48 +08:00
Chris Taylor 18062bf812 Make browser_handler (editor file opening dialog) return window_event_result::close instead of closing itself
This ensures the event system will know what's going on.
2016-10-27 17:38:20 +08:00
Chris Taylor 66de1a1823 Make sure if a UI_DIALOG handler returns window_event_result::close or window_event_result::deleted, it will be passed onto window_send_event 2016-10-27 17:12:17 +08:00
Kp 01f2932824 Pass grs_canvas &to window_create 2016-10-15 00:53:20 +00:00
Chris Taylor bc1c9ebd97 Merge branch 'unification/master' into allow_dialog_subclass
Conflicts:
	common/arch/sdl/window.cpp - Remove unused EVENT_WINDOW_CLOSED and w_callback local var
	common/ui/dialog.cpp - Remove unused EVENT_WINDOW_CLOSED
2016-10-10 14:40:11 +08:00
Kp 1af65071d7 Remove unused EVENT_WINDOW_CLOSED
Every callee that recognized EVENT_WINDOW_CLOSED did so only to
explicitly ignore it.  Remove the code to send it and all sites that
ignored it.
2016-10-10 00:25:15 +00:00
Chris Taylor 9631d319f6 Allow dcx::UI_DIALOG struct to be subclassed - step 3
Allow dcx::UI_DIALOG struct to be subclassed step 3. This step adds the destructor and makes sure the dialog is only deleted within the main dialog handler if the specific handler didn't return window_event_result::deleted.
2016-10-04 16:09:21 +08:00
Chris Taylor db665d8c33 Allow dcx::UI_DIALOG struct to be subclassed - step 2
Allow dcx::UI_DIALOG struct to be subclassed step 2. Make all the UI_DIALOG handlers return a window_event_result like everyone else.
2016-10-04 15:58:20 +08:00
Chris Taylor 60ac1eaad3 Replace delete dcx::window kludge with a better solution
Replace delete dcx::window kludge with a better solution: instead of requiring every handler to delete the window, add a window_event_result::deleted, which gets returned if the window was deleted by the handler, so window_close knows not to attempt to delete it again.
2016-10-04 14:05:44 +08:00
Chris Taylor 4d9eb4e743 Allow dcx::UI_DIALOG struct to be subclassed - step 1
Allow dcx::UI_DIALOG struct to be subclassed step 1. This step renames and reconfigures untyped_ui_dialog_create in dialog.cpp to be the main constructor. Also adds a template constructor that allows an event handler that takes a subclass of UI_DIALOG.
2016-10-04 11:29:19 +08:00
Chris Taylor 87617e8ac9 Allow dcx::window struct to be subclassed - step 3
Allow dcx::window struct to be subclassed step 3. This step adds the window destructor and both requires and implements the window to be deleted by the event handler/client in all cases.
2016-10-02 17:49:19 +08:00
Kp e06d8b33aa Reuse string_array_sort_func for file_sort_func
Both functions have the same implementation, so delete static
file_sort_func and use string_array_sort_func.
2016-09-04 19:10:43 +00:00
Kp 2e88fec559 Flatten some ui type hierarchy 2016-08-06 19:55:24 +00:00
Kp c636dc4b98 Convert various static const expressions to constexpr 2016-07-16 16:52:04 +00:00
Kp b6fd8572d1 Simplify ui_radio_set_value loop 2016-07-06 01:54:25 +00:00
Kp e92a7aea14 Use C++ static_cast for gadget downcast 2016-07-06 01:54:25 +00:00
Kp 65f68877aa Rewrite simple integer casts from C style to static_cast<>
This pass only targets commonly used standard types.

s/(\(\s*\(\(un\)\?signed\|int\|char\|short\|long\|float\|double\|s\?size_t\|\(u\?int[[:digit:]]\+_t\)\)\)\s*)\s*(/static_cast<\1>(/g
2016-06-16 03:56:44 +00:00
Kp 1b12a3f7ef Add parentheses around target of more complicated casts
C casts do not require parentheses.  C++ casts require grouping around
the target.  Prepare for conversion to C++ casts by adding otherwise
unnecessary parentheses around the target of some C casts.

This pass attempts to process expressions that involve parenthesized or
bracketed subexpressions, but only if those subexpressions do not
themselves contain parenthesized or bracketed subexpressions.

	(int) f(1);	// changed
	(int) f(g());	// not changed

perl -p -i -e 's/(\(\s*((?:un)?signed|int|char|short|long|float|double|s?size_t|(?:u?int[[:digit:]]+_t))\s*\**\s*\)\s*)([&+-]?)([[:alnum:]_.]+\s*->\s*)*([[:alnum:]_.]+)((?:\s*(?:\[[^][]*\])*|(?:\([^()]*\))*))(\s*([;+>*\/^%,|&<>])|$|(\s*-\s*[^>]))/\1\(\3\4\5\6\)\7/g'
2016-06-12 03:45:37 +00:00
Kp bc30ccd216 Rewrite cast of (sbyte) to standard type int8_t
s/(sbyte)\s*\(\w\)/(int8_t) \1/g
2016-06-12 03:45:37 +00:00
Kp 1789643480 Remove UserError on unknown MED function
Jayman2000 reports that users who do not update their MED.MNU after
updating to 8b61b9f ("Remove unused symbols") receive an "editor crash"
on startup.  This is not a crash, but instead is poor error handling in
menubar.cpp, which calls UserError instead of ignoring the offending
line.  Calls to UserError are fatal, but do not crash the program.
Replace that call with a con_printf(CON_URGENT) and ignore the line.

Additionally, change the handling for excess menus and for excess menu
items to con_printf+ignore instead of UserError.

Reported-by: Jayman2000 <https://github.com/dxx-rebirth/dxx-rebirth/pull/190>
Fixes: 8b61b9f0db ("Remove unused symbols")
2016-04-03 17:50:42 +00:00
Kp 27cef20eb3 Move namespace dsx handling to dsx-ns.h 2016-03-19 19:08:10 +00:00
Kp 08de1bbff0 Remove cv_color
It is only ever set to 0 or copied from other canvases.  Set it to zero
everywhere.
2016-02-12 04:02:28 +00:00
Kp f4e1ebb576 Remove unnecessary gr_setcolor calls 2016-02-12 04:02:28 +00:00
Kp e09a590e6f Pass color to Vline 2016-02-12 04:02:28 +00:00
Kp 76d0e01b6e Pass color to Hline 2016-02-12 04:02:28 +00:00
Kp de08a67321 Pass color to gr_ubox 2016-02-12 04:02:28 +00:00
Kp 23047b1165 Pass color to gr_rect 2016-02-12 04:02:28 +00:00
Kp 35a4736df0 Pass color to gr_urect 2016-02-12 04:02:28 +00:00
Kp 053901b62b Pass color to gr_uline 2016-02-12 04:02:28 +00:00
Kp b57f08c798 Use partial_const_range 2016-02-12 04:02:28 +00:00
Kp eb3fe7acdb Remove sprintf from menubar.cpp 2016-01-09 16:38:16 +00:00
Kp dc8c0323d8 Uninline namespace dcx 2015-12-13 18:00:49 +00:00
Kp 22bd3ce8d8 Use inline namespace dcx for common/ui 2015-12-05 22:57:24 +00:00
Kp ed55763603 Remove unused symbols 2015-12-04 03:36:31 +00:00
Kp dad504cfef Fix some -Wshadow warnings 2015-11-26 02:56:54 +00:00
Kp 50f672ba34 Reuse computed string length 2015-09-29 02:41:22 +00:00
Kp d9cef82f81 Allow nullptr for gr_get_string_size 2015-09-29 02:41:22 +00:00
Kp 17b1943c5e Mark various per-file structures as static 2015-08-12 03:11:46 +00:00
Kp 968cdbecf4 Add non-aborting UserError for user-caused fatal errors 2015-06-16 03:15:40 +00:00
Kp 06c363fb19 Fix UI_GADGET -fno-inline build
Fixes: 95e3ac1e5b ("Use integral_constant for UI kind")
2015-06-11 03:06:58 +00:00
Kp 25186ca984 Remove write-only keyd_last_released 2015-05-28 03:08:38 +00:00
Kp badad2ef33 Remove write-only keyd_last_pressed 2015-05-28 03:08:38 +00:00
Kp bdee338e34 Preserve array size for ui_get_filename 2015-05-09 17:38:58 +00:00
Kp 649993982f Enable tail call optimization in menubar_close 2015-05-09 17:38:58 +00:00
Kp fc4b686d9d Store PHYSFS_list element count in list when needed 2015-05-09 17:38:57 +00:00
Kp 1d08cb6058 Fix file_get*list nullptr without constructor inheritance 2015-05-05 03:20:42 +00:00
Kp c3925353fd Use null_sentinel_iterator for PHYSFS_list_t 2015-04-26 20:15:51 +00:00