The Battle for Wesnoth  1.17.0-dev
hotkey_bind.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2016 - 2021
3  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #define GETTEXT_DOMAIN "wesnoth-lib"
16 
18 
19 #include "gui/widgets/settings.hpp"
20 #include "gui/widgets/window.hpp"
21 
22 #include <SDL2/SDL.h>
23 
24 namespace gui2::dialogs
25 {
26 
27 REGISTER_DIALOG(hotkey_bind)
28 
29 hotkey_bind::hotkey_bind(const std::string& hotkey_id)
30  : hotkey_id_(hotkey_id)
31  , new_binding_()
32 {
33  set_restore(true);
34 }
35 
37 {
39  std::bind(&hotkey_bind::sdl_event_callback, this, std::placeholders::_5),
41 }
42 
43 void hotkey_bind::sdl_event_callback(const SDL_Event &event)
44 {
45  if (hotkey::is_hotkeyable_event(event)) {
47  }
48  if(new_binding_) {
50  }
51 }
52 
53 
54 } // 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:36
This file contains the settings handling of the widget library.
hotkey::hotkey_ptr new_binding_
Definition: hotkey_bind.hpp:40
const std::string & hotkey_id_
Definition: hotkey_bind.hpp:38
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:506
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:43
Dialog was closed with the OK button.
Definition: retval.hpp:35
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:65