Changed the gui2 scroll wheel focus.
The focus now follows the mouse pointer instead of the keyboard focus as discussed on the dev-ml [1]. [1] https://mail.gna.org/public/wesnoth-dev/2010-04/msg00049.html
This commit is contained in:
parent
2966c02ce8
commit
137637475a
6 changed files with 83 additions and 77 deletions
|
@ -12,6 +12,8 @@ Version 1.9.4+svn:
|
|||
* Reimplemented: the tooltips use the new tip class and look much better.
|
||||
* Fixed: the tooltips no longer stack when the MP dialog is opened.
|
||||
* Implemented: the helptips.
|
||||
* Changed: the scroll wheel, in gui2 code, now also follows the mouse focus
|
||||
instead of the keyboard focus.
|
||||
* WML engine:
|
||||
* Allow [color_range] and [color_palette] nodes to be inserted at top-level
|
||||
by add-ons to globally define custom ranges and palettes.
|
||||
|
|
|
@ -124,6 +124,23 @@ tmouse_motion::tmouse_motion(twidget& owner
|
|||
, this, _2, _3, _5)
|
||||
, queue_position);
|
||||
|
||||
owner_.connect_signal<event::SDL_WHEEL_UP>(
|
||||
boost::bind(
|
||||
&tmouse_motion::signal_handler_sdl_wheel
|
||||
, this, _2, _3, _5));
|
||||
owner_.connect_signal<event::SDL_WHEEL_DOWN>(
|
||||
boost::bind(
|
||||
&tmouse_motion::signal_handler_sdl_wheel
|
||||
, this, _2, _3, _5));
|
||||
owner_.connect_signal<event::SDL_WHEEL_LEFT>(
|
||||
boost::bind(
|
||||
&tmouse_motion::signal_handler_sdl_wheel
|
||||
, this, _2, _3, _5));
|
||||
owner_.connect_signal<event::SDL_WHEEL_RIGHT>(
|
||||
boost::bind(
|
||||
&tmouse_motion::signal_handler_sdl_wheel
|
||||
, this, _2, _3, _5));
|
||||
|
||||
owner.connect_signal<event::SHOW_HELPTIP>(
|
||||
boost::bind(&tmouse_motion::signal_handler_show_helptip
|
||||
, this, _2, _3, _5)
|
||||
|
@ -185,6 +202,25 @@ void tmouse_motion::signal_handler_sdl_mouse_motion(
|
|||
handled = true;
|
||||
}
|
||||
|
||||
void tmouse_motion::signal_handler_sdl_wheel(
|
||||
const event::tevent event
|
||||
, bool& handled
|
||||
, const tpoint& coordinate)
|
||||
{
|
||||
DBG_GUI_E << LOG_HEADER << event << ".\n";
|
||||
|
||||
if(mouse_captured_) {
|
||||
assert(mouse_focus_);
|
||||
owner_.fire(event, *mouse_focus_, coordinate);
|
||||
} else {
|
||||
twidget* mouse_over = owner_.find_at(coordinate, true);
|
||||
if(mouse_over) {
|
||||
owner_.fire(event, *mouse_over, coordinate);
|
||||
}
|
||||
}
|
||||
handled = true;
|
||||
}
|
||||
|
||||
void tmouse_motion::signal_handler_show_helptip(
|
||||
const event::tevent event
|
||||
, bool& handled
|
||||
|
@ -610,26 +646,6 @@ tdistributor::tdistributor(twidget& owner
|
|||
boost::bind(&tdistributor::signal_handler_sdl_key_down
|
||||
, this, _5, _6, _7));
|
||||
|
||||
|
||||
owner_.connect_signal<event::SDL_WHEEL_UP>(
|
||||
boost::bind(
|
||||
&tdistributor::signal_handler_sdl_wheel<event::SDL_WHEEL_UP>
|
||||
, this));
|
||||
owner_.connect_signal<event::SDL_WHEEL_DOWN>(
|
||||
boost::bind(
|
||||
&tdistributor::signal_handler_sdl_wheel<event::SDL_WHEEL_DOWN>
|
||||
, this));
|
||||
owner_.connect_signal<event::SDL_WHEEL_LEFT>(
|
||||
boost::bind(
|
||||
&tdistributor::signal_handler_sdl_wheel<event::SDL_WHEEL_LEFT>
|
||||
, this));
|
||||
owner_.connect_signal<event::SDL_WHEEL_RIGHT>(
|
||||
boost::bind(
|
||||
&tdistributor::signal_handler_sdl_wheel<
|
||||
event::SDL_WHEEL_RIGHT>
|
||||
, this));
|
||||
|
||||
|
||||
owner_.connect_signal<event::NOTIFY_REMOVAL>(
|
||||
boost::bind(
|
||||
&tdistributor::signal_handler_notify_removal
|
||||
|
@ -646,26 +662,6 @@ tdistributor::~tdistributor()
|
|||
boost::bind(&tdistributor::signal_handler_sdl_key_down
|
||||
, this, _5, _6, _7));
|
||||
|
||||
|
||||
owner_.disconnect_signal<event::SDL_WHEEL_UP>(
|
||||
boost::bind(
|
||||
&tdistributor::signal_handler_sdl_wheel<event::SDL_WHEEL_UP>
|
||||
, this));
|
||||
owner_.disconnect_signal<event::SDL_WHEEL_DOWN>(
|
||||
boost::bind(
|
||||
&tdistributor::signal_handler_sdl_wheel<event::SDL_WHEEL_DOWN>
|
||||
, this));
|
||||
owner_.disconnect_signal<event::SDL_WHEEL_LEFT>(
|
||||
boost::bind(
|
||||
&tdistributor::signal_handler_sdl_wheel<event::SDL_WHEEL_LEFT>
|
||||
, this));
|
||||
owner_.disconnect_signal<event::SDL_WHEEL_RIGHT>(
|
||||
boost::bind(
|
||||
&tdistributor::signal_handler_sdl_wheel<
|
||||
event::SDL_WHEEL_RIGHT>
|
||||
, this));
|
||||
|
||||
|
||||
owner_.disconnect_signal<event::NOTIFY_REMOVAL>(
|
||||
boost::bind(
|
||||
&tdistributor::signal_handler_notify_removal
|
||||
|
@ -788,19 +784,6 @@ void tdistributor::signal_handler_sdl_key_down(const SDLKey key
|
|||
}
|
||||
}
|
||||
|
||||
template<tevent event>
|
||||
void tdistributor::signal_handler_sdl_wheel()
|
||||
{
|
||||
/** @todo Test whether recursion protection is needed. */
|
||||
|
||||
DBG_GUI_E << LOG_HEADER << event << ".\n";
|
||||
|
||||
if(keyboard_focus_) {
|
||||
DBG_GUI_E << LOG_HEADER << "Firing: " << event << ".\n";
|
||||
owner_.fire(event, *keyboard_focus_);
|
||||
}
|
||||
}
|
||||
|
||||
void tdistributor::signal_handler_notify_removal(
|
||||
tdispatcher& widget, const tevent event)
|
||||
{
|
||||
|
|
|
@ -137,6 +137,11 @@ private:
|
|||
, bool& handled
|
||||
, const tpoint& coordinate);
|
||||
|
||||
void signal_handler_sdl_wheel(
|
||||
const event::tevent event
|
||||
, bool& handled
|
||||
, const tpoint& coordinate);
|
||||
|
||||
void signal_handler_show_helptip(
|
||||
const event::tevent event
|
||||
, bool& handled
|
||||
|
@ -324,10 +329,6 @@ private:
|
|||
, const SDLMod modifier
|
||||
, const Uint16 unicode);
|
||||
|
||||
|
||||
template<tevent event>
|
||||
void signal_handler_sdl_wheel();
|
||||
|
||||
void signal_handler_notify_removal(tdispatcher& widget, const tevent event);
|
||||
};
|
||||
|
||||
|
|
|
@ -509,16 +509,16 @@ void thandler::mouse_button_up(const tpoint& position, const Uint8 button)
|
|||
break;
|
||||
|
||||
case SDL_BUTTON_WHEELLEFT :
|
||||
keyboard(SDL_WHEEL_LEFT);
|
||||
mouse(SDL_WHEEL_LEFT, get_mouse_position());
|
||||
break;
|
||||
case SDL_BUTTON_WHEELRIGHT :
|
||||
keyboard(SDL_WHEEL_RIGHT);
|
||||
mouse(SDL_WHEEL_RIGHT, get_mouse_position());
|
||||
break;
|
||||
case SDL_BUTTON_WHEELUP :
|
||||
keyboard(SDL_WHEEL_UP);
|
||||
mouse(SDL_WHEEL_UP, get_mouse_position());
|
||||
break;
|
||||
case SDL_BUTTON_WHEELDOWN :
|
||||
keyboard(SDL_WHEEL_DOWN);
|
||||
mouse(SDL_WHEEL_DOWN, get_mouse_position());
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -167,10 +167,6 @@ typedef
|
|||
, boost::mpl::int_<RIGHT_BUTTON_UP>
|
||||
, boost::mpl::int_<RIGHT_BUTTON_CLICK>
|
||||
, boost::mpl::int_<RIGHT_BUTTON_DOUBLE_CLICK>
|
||||
, boost::mpl::int_<SDL_WHEEL_LEFT>
|
||||
, boost::mpl::int_<SDL_WHEEL_RIGHT>
|
||||
, boost::mpl::int_<SDL_WHEEL_UP>
|
||||
, boost::mpl::int_<SDL_WHEEL_DOWN>
|
||||
>
|
||||
tset_event;
|
||||
|
||||
|
@ -192,6 +188,10 @@ typedef
|
|||
, boost::mpl::int_<SDL_RIGHT_BUTTON_UP>
|
||||
, boost::mpl::int_<SHOW_TOOLTIP>
|
||||
, boost::mpl::int_<SHOW_HELPTIP>
|
||||
, boost::mpl::int_<SDL_WHEEL_UP>
|
||||
, boost::mpl::int_<SDL_WHEEL_DOWN>
|
||||
, boost::mpl::int_<SDL_WHEEL_LEFT>
|
||||
, boost::mpl::int_<SDL_WHEEL_RIGHT>
|
||||
>
|
||||
tset_event_mouse;
|
||||
|
||||
|
|
|
@ -80,18 +80,38 @@ tscrollbar_container::tscrollbar_container(const unsigned canvas_count)
|
|||
&tscrollbar_container::signal_handler_sdl_key_down
|
||||
, this, _2, _3, _5, _6));
|
||||
|
||||
connect_signal<event::SDL_WHEEL_UP>(boost::bind(
|
||||
&tscrollbar_container::signal_handler_sdl_wheel_up
|
||||
, this, _2, _3));
|
||||
connect_signal<event::SDL_WHEEL_DOWN>(boost::bind(
|
||||
&tscrollbar_container::signal_handler_sdl_wheel_down
|
||||
, this, _2, _3));
|
||||
connect_signal<event::SDL_WHEEL_LEFT>(boost::bind(
|
||||
&tscrollbar_container::signal_handler_sdl_wheel_left
|
||||
, this, _2, _3));
|
||||
connect_signal<event::SDL_WHEEL_RIGHT>(boost::bind(
|
||||
&tscrollbar_container::signal_handler_sdl_wheel_right
|
||||
, this, _2, _3));
|
||||
|
||||
connect_signal<event::SDL_WHEEL_UP>(
|
||||
boost::bind(
|
||||
&tscrollbar_container::signal_handler_sdl_wheel_up
|
||||
, this
|
||||
, _2
|
||||
, _3)
|
||||
, event::tdispatcher::back_post_child);
|
||||
|
||||
connect_signal<event::SDL_WHEEL_DOWN>(
|
||||
boost::bind(
|
||||
&tscrollbar_container::signal_handler_sdl_wheel_down
|
||||
, this
|
||||
, _2
|
||||
, _3)
|
||||
, event::tdispatcher::back_post_child);
|
||||
|
||||
connect_signal<event::SDL_WHEEL_LEFT>(
|
||||
boost::bind(
|
||||
&tscrollbar_container::signal_handler_sdl_wheel_left
|
||||
, this
|
||||
, _2
|
||||
, _3)
|
||||
, event::tdispatcher::back_post_child);
|
||||
|
||||
connect_signal<event::SDL_WHEEL_RIGHT>(
|
||||
boost::bind(
|
||||
&tscrollbar_container::signal_handler_sdl_wheel_right
|
||||
, this
|
||||
, _2
|
||||
, _3)
|
||||
, event::tdispatcher::back_post_child);
|
||||
}
|
||||
|
||||
void tscrollbar_container::layout_init(const bool full_initialization)
|
||||
|
|
Loading…
Add table
Reference in a new issue