Skip to content

Commit

Permalink
GUI2/Dispatcher: changed dispatcher signals to take a widget referenc…
Browse files Browse the repository at this point in the history
…e as a first parameter

This fixes an issue where functions taking `widget` as a parameter couldn't be bound to a signal function
with the first argument passed via placeholder since `std::bind` requires arguments match exactly when using
the placeholders.

The dispatcher's `this` was cast to `widget` before the signal functions were fired anyway, so this doesn't
really constitute any functional change.
  • Loading branch information
Vultraz committed Aug 23, 2017
1 parent f755c5c commit 8050a63
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/gui/core/event/dispatcher.cpp
Expand Up @@ -198,7 +198,7 @@ bool dispatcher::execute_hotkey(const hotkey::HOTKEY_COMMAND id)
return false;
}

return itor->second(*this, id);
return itor->second(dynamic_cast<widget&>(*this), id);
}

} // namespace event
Expand Down
20 changes: 10 additions & 10 deletions src/gui/core/event/dispatcher.hpp
Expand Up @@ -51,7 +51,7 @@ struct message;
*
* This function is used for the callbacks in set_event.
*/
typedef std::function<void(dispatcher& dispatcher,
typedef std::function<void(widget& dispatcher,
const ui_event event,
bool& handled, bool& halt)> signal_function;

Expand All @@ -60,7 +60,7 @@ typedef std::function<void(dispatcher& dispatcher,
*
* This function is used for the callbacks in set_event_mouse.
*/
typedef std::function<void(dispatcher& dispatcher,
typedef std::function<void(widget& dispatcher,
const ui_event event,
bool& handled,
bool& halt,
Expand All @@ -71,7 +71,7 @@ typedef std::function<void(dispatcher& dispatcher,
*
* This function is used for the callbacks in set_event_keyboard.
*/
typedef std::function<void(dispatcher& dispatcher,
typedef std::function<void(widget& dispatcher,
const ui_event event,
bool& handled,
bool& halt,
Expand All @@ -84,7 +84,7 @@ typedef std::function<void(dispatcher& dispatcher,
*
* This function is used for the callbacks in set_event_touch.
*/
typedef std::function<void(dispatcher& dispatcher,
typedef std::function<void(widget& dispatcher,
const ui_event event,
bool& handled,
bool& halt,
Expand All @@ -98,7 +98,7 @@ typedef std::function<void(dispatcher& dispatcher,
* Added the dummy void* parameter which will be nullptr to get a different
* signature as signal_function's callback.
*/
typedef std::function<void(dispatcher& dispatcher,
typedef std::function<void(widget& dispatcher,
const ui_event event,
bool& handled,
bool& halt,
Expand All @@ -109,7 +109,7 @@ typedef std::function<void(dispatcher& dispatcher,
*
* This function is used for the callbacks in set_event_message.
*/
typedef std::function<void(dispatcher& dispatcher,
typedef std::function<void(widget& dispatcher,
const ui_event event,
bool& handled,
bool& halt,
Expand All @@ -120,7 +120,7 @@ typedef std::function<void(dispatcher& dispatcher,
*
* This function is used for the callbacks in set_event_raw_event.
*/
typedef std::function<void(dispatcher& dispatcher,
typedef std::function<void(widget& dispatcher,
const ui_event event,
bool& handled,
bool& halt,
Expand All @@ -131,7 +131,7 @@ typedef std::function<void(dispatcher& dispatcher,
*
* This function is used for the callbacks in set_event_text_input.
*/
typedef std::function<void(dispatcher& dispatcher,
typedef std::function<void(widget& dispatcher,
const ui_event event,
bool& handled,
bool& halt,
Expand All @@ -140,7 +140,7 @@ typedef std::function<void(dispatcher& dispatcher,
int32_t select_len)> signal_text_input_function;

/** Hotkey function handler signature. */
typedef std::function<bool(dispatcher& dispatcher,
typedef std::function<bool(widget& dispatcher,
hotkey::HOTKEY_COMMAND id)> hotkey_function;

/**
Expand All @@ -155,7 +155,7 @@ typedef std::function<bool(dispatcher& dispatcher,
* track the mouse location and fire MOUSE_ENTER and MOUSE_LEAVE events to the
* widgets involved.
*
* [1] Not really sure whether it will be a base clase for a widget or
* [1] Not really sure whether it will be a base class for a widget or
* styled_widget yet.
*/
class dispatcher
Expand Down

0 comments on commit 8050a63

Please sign in to comment.