The Battle for Wesnoth  1.15.12+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::dialogs
24 {
25 
26 REGISTER_DIALOG(hotkey_bind)
27 
28 hotkey_bind::hotkey_bind(const std::string& hotkey_id)
29  : hotkey_id_(hotkey_id)
30  , new_binding_()
31 {
32  set_restore(true);
33 }
34 
36 {
38  std::bind(&hotkey_bind::sdl_event_callback, this, std::placeholders::_5),
40 }
41 
42 void hotkey_bind::sdl_event_callback(const SDL_Event &event)
43 {
44  if (hotkey::is_hotkeyable_event(event)) {
46  }
47  if(new_binding_) {
49  }
50 }
51 
52 
53 } // namespace dialogs
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
Actions to be taken before showing the window.
Definition: hotkey_bind.cpp:35
This file contains the settings handling of the widget library.
hotkey::hotkey_ptr new_binding_
Definition: hotkey_bind.hpp:39
const std::string & hotkey_id_
Definition: hotkey_bind.hpp:37
std::enable_if_t< is_general_event(E)> connect_signal(const signal_function &signal, const queue_position position=back_child)
Connect a signal for callback in set_event.
Definition: dispatcher.hpp:505
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)
void sdl_event_callback(const SDL_Event &event)
Definition: hotkey_bind.cpp:42
Dialog was closed with the OK button.
Definition: retval.hpp:34
void set_retval(int retval)
Convenience wrapper to set the window&#39;s exit code.
base class of top level items, the only item which needs to store the final canvases to draw on...
Definition: window.hpp:64