Convert the toggle panel to use new click events.

This needs some work regarding the pre events to properly select in all
cases but that will follow later.
This commit is contained in:
Mark de Wever 2009-09-28 21:04:14 +00:00
parent 2b83b2b48c
commit 17d6191d6a
2 changed files with 50 additions and 1 deletions

View file

@ -38,6 +38,13 @@ ttoggle_panel::ttoggle_panel()
&ttoggle_panel::signal_handler_mouse_enter, this, _1, _2));
connect_signal<event::MOUSE_LEAVE>(boost::bind(
&ttoggle_panel::signal_handler_mouse_leave, this, _1, _2));
connect_signal<event::LEFT_BUTTON_CLICK>(boost::bind(
&ttoggle_panel::signal_handler_left_button_click
, this, _1, _2));
connect_signal<event::LEFT_BUTTON_DOUBLE_CLICK>(boost::bind(
&ttoggle_panel::signal_handler_left_button_double_click
, this, _1, _2));
}
void ttoggle_panel::set_child_members(const std::map<std::string /* widget id */, string_map>& data)
@ -213,6 +220,42 @@ void ttoggle_panel::signal_handler_mouse_leave(
handled = true;
}
void ttoggle_panel::signal_handler_left_button_click(
const event::tevent event, bool& handled)
{
DBG_GUI_E << get_control_type() << "[" << id() << "]: " << event << ".\n";
sound::play_UI_sound(settings::sound_toggle_panel_click);
if(get_value()) {
set_state(ENABLED);
} else {
set_state(ENABLED_SELECTED);
}
if(callback_state_change_) {
callback_state_change_(this);
}
handled = true;
}
void ttoggle_panel::signal_handler_left_button_double_click(
const event::tevent event, bool& handled)
{
DBG_GUI_E << get_control_type() << "[" << id() << "]: " << event << ".\n";
if (retval_) {
twindow* window = get_window();
assert(window);
window->set_retval(retval_);
}
if (callback_mouse_left_double_click_) {
callback_mouse_left_double_click_(this);
}
handled = true;
}
} // namespace gui2

View file

@ -195,6 +195,12 @@ private:
void signal_handler_mouse_enter(const event::tevent event, bool& handled);
void signal_handler_mouse_leave(const event::tevent event, bool& handled);
void signal_handler_left_button_click(
const event::tevent event, bool& handled);
void signal_handler_left_button_double_click(
const event::tevent event, bool& handled);
};
} // namespace gui2