The Battle for Wesnoth  1.15.2+dev
hotkey_bind.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2016 - 2018 by the Battle for Wesnoth Project https://www.wesnoth.org/
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY.
10 
11  See the COPYING file for more details.
12 */
13 
14 #define GETTEXT_DOMAIN "wesnoth-lib"
15 
17 
18 #include "gui/widgets/settings.hpp"
19 #include "gui/widgets/window.hpp"
20 
21 #include <SDL2/SDL.h>
22 
23 namespace gui2
24 {
25 namespace dialogs
26 {
27 
28 REGISTER_DIALOG(hotkey_bind)
29 
30 hotkey_bind::hotkey_bind(const std::string& hotkey_id)
31  : hotkey_id_(hotkey_id)
32  , new_binding_()
33 {
34  set_restore(true);
35 }
36 
38 {
40  std::bind(&hotkey_bind::sdl_event_callback, this, std::ref(window), _5),
42 }
43 
44 void hotkey_bind::sdl_event_callback(window& win, const SDL_Event &event)
45 {
46  if (hotkey::is_hotkeyable_event(event)) {
48  }
49  if(new_binding_) {
51  }
52 }
53 
54 
55 } // namespace dialogs
56 } // namespace gui2
This file contains the window object, this object is a top level container which has the event manage...
STL namespace.
virtual void pre_show(window &window) override
Inherited from modal_dialog.
Definition: hotkey_bind.cpp:37
std::enable_if_t< has_key< set_event, E >::value > connect_signal(const signal_function &signal, const queue_position position=back_child)
Connect a signal for callback in set_event.
Definition: dispatcher.hpp:393
Generic file dialog.
Definition: field-fwd.hpp:22
This file contains the settings handling of the widget library.
hotkey::hotkey_ptr new_binding_
Definition: hotkey_bind.hpp:41
Various uncategorised dialogs.
const std::string & hotkey_id_
Definition: hotkey_bind.hpp:39
void sdl_event_callback(window &win, const SDL_Event &event)
Definition: hotkey_bind.cpp:44
void set_retval(const int retval, const bool close_window=true)
Sets there return value of the window.
Definition: window.hpp:363
hotkey_ptr create_hotkey(const std::string &id, const SDL_Event &event)
Create a new hotkey item for a command from an SDL_Event.
bool is_hotkeyable_event(const SDL_Event &event)
Dialog was closed with the OK button.
Definition: retval.hpp:34
base class of top level items, the only item which needs to store the final canvases to draw on ...
Definition: window.hpp:62