The Battle for Wesnoth  1.17.0-dev
editor_toolkit.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2012 - 2021
3  by Fabian Mueller <fabianmueller5@gmx.de>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #pragma once
17 
20 #include "editor/toolkit/brush.hpp"
22 
23 class config;
24 class game_config_view;
25 namespace editor {
26 
27 
29 
30 public:
32  const game_config_view& game_config, context_manager& c_manager);
33 
35 
36  void adjust_size();
37 
39 
40 private:
41  /** init the sidebar objects */
42  void init_sidebar(const game_config_view& game_config);
43 
44  /** init the brushes */
45  void init_brushes(const game_config_view& game_config);
46 
47  /** init the mouse actions (tools) */
48  void init_mouse_actions(context_manager& c_manager);
49 
50 public:
54 
55  /**
56  * Set the current mouse action based on a hotkey id
57  */
59 
60  /**
61  * @return true if the mouse action identified by the hotkey is active
62  */
63  bool is_mouse_action_set(hotkey::HOTKEY_COMMAND command) const;
64 
65 
66  /** Get the current mouse action */
68  /** Get the current mouse action */
69  const mouse_action& get_mouse_action() const { return *mouse_action_; }
70  /** Get the current palette */
72 
73 // Brush related methods
74 
75  /** Cycle to the next brush. */
76  void cycle_brush();
77 
78  /** TODO */
79  void set_brush(std::string id);
80 
81  /** TODO */
82  bool is_active_brush(std::string id) const { return brush_->id() == id; }
83 
85 
86 private:
87 
89 
90  const CKey& key_;
91 
92  std::unique_ptr<palette_manager> palette_manager_;
93 
94 //Tools
95 
96  /** The current mouse action */
97  std::shared_ptr<mouse_action> mouse_action_; // Never null (outside the constructor).
98 
99  /** The mouse actions */
100  typedef std::map<hotkey::HOTKEY_COMMAND, std::shared_ptr<mouse_action>> mouse_action_map;
101  mouse_action_map mouse_actions_;
102 
103 //Brush members
104 
105  /** The current brush */
107 
108  /** All available brushes */
109  std::vector<brush> brushes_;
110 
111 };
112 
113 }
editor_display & gui_
void hotkey_set_mouse_action(hotkey::HOTKEY_COMMAND command)
Set the current mouse action based on a hotkey id.
const mouse_action & get_mouse_action() const
Get the current mouse action.
mouse_action_map mouse_actions_
void cycle_brush()
Cycle to the next brush.
std::shared_ptr< mouse_action > mouse_action_
The current mouse action.
General purpose widgets.
editor_toolkit(editor_display &gui, const CKey &key, const game_config_view &game_config, context_manager &c_manager)
brush * brush_
The current brush.
void set_brush(std::string id)
TODO.
void init_sidebar(const game_config_view &game_config)
init the sidebar objects
common_palette & get_palette()
Get the current palette.
std::vector< brush > brushes_
All available brushes.
The brush class represents a single brush – a set of relative locations around a "hotspot"...
Definition: brush.hpp:26
bool is_active_brush(std::string id) const
TODO.
void init_brushes(const game_config_view &game_config)
init the brushes
std::unique_ptr< palette_manager > palette_manager_
Manage the empty-palette in the editor.
Definition: action.cpp:30
std::map< hotkey::HOTKEY_COMMAND, std::shared_ptr< mouse_action > > mouse_action_map
The mouse actions.
void init_mouse_actions(context_manager &c_manager)
init the mouse actions (tools)
const std::string id() const
Definition: brush.hpp:58
std::string id
Text to match against addon_info.tags()
Definition: manager.cpp:215
Game configuration data as global variables.
Definition: build_info.cpp:59
mouse_action & get_mouse_action()
Get the current mouse action.
bool is_mouse_action_set(hotkey::HOTKEY_COMMAND command) const
A mouse action receives events from the controller, and responds to them by creating an appropriate e...
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:61
Class that keeps track of all the keys on the keyboard.
Definition: key.hpp:28
palette_manager * get_palette_manager()