The Battle for Wesnoth  1.19.13+dev
editor_toolkit.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2012 - 2025
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 game_config_view;
24 namespace editor {
25 
26 
28 
29 public:
31 
33 
34  void adjust_size();
35 
37 
38 private:
39  /** init the sidebar objects */
41 
42  /** init the brushes */
44 
45  /** init the mouse actions (tools) */
46  void init_mouse_actions(context_manager& c_manager);
47 
48 public:
52 
53  /**
54  * Set the current mouse action based on a hotkey id
55  */
57 
58  /**
59  * @return true if the mouse action identified by the hotkey is active
60  */
61  bool is_mouse_action_set(hotkey::HOTKEY_COMMAND command) const;
62 
63 
64  /** Get the current mouse action */
66  /** Get the current mouse action */
67  const mouse_action& get_mouse_action() const { return *mouse_action_; }
68  /** Get the current palette */
70 
71 // Brush related methods
72 
73  /** Cycle to the next brush. */
74  void cycle_brush();
75 
76  void set_brush(const std::string& id);
77 
78  bool is_active_brush(std::string id) const { return brush_->id() == id; }
79 
81 
82 private:
83 
85 
87 
88  std::unique_ptr<palette_manager> palette_manager_;
89 
90 //Tools
91 
92  /** The current mouse action */
93  std::shared_ptr<mouse_action> mouse_action_; // Never null (outside the constructor).
94 
95  /** The mouse actions */
96  typedef std::map<hotkey::HOTKEY_COMMAND, std::shared_ptr<mouse_action>> mouse_action_map;
98 
99 //Brush members
100 
101  /** The current brush */
103 
104  /** All available brushes */
105  std::vector<brush> brushes_;
106 
107 };
108 
109 }
Class that keeps track of all the keys on the keyboard.
Definition: key.hpp:29
The brush class represents a single brush – a set of relative locations around a "hotspot",...
Definition: brush.hpp:27
const std::string id() const
Definition: brush.hpp:58
brush * brush_
The current brush.
void cycle_brush()
Cycle to the next brush.
mouse_action & get_mouse_action()
Get the current mouse action.
std::map< hotkey::HOTKEY_COMMAND, std::shared_ptr< mouse_action > > mouse_action_map
The mouse actions.
std::vector< brush > brushes_
All available brushes.
editor_toolkit(editor_display &gui, const game_config_view &game_config, context_manager &c_manager)
bool is_mouse_action_set(hotkey::HOTKEY_COMMAND command) const
std::shared_ptr< mouse_action > mouse_action_
The current mouse action.
const mouse_action & get_mouse_action() const
Get the current mouse action.
void init_sidebar(const game_config_view &game_config)
init the sidebar objects
std::unique_ptr< palette_manager > palette_manager_
editor_display & gui_
mouse_action_map mouse_actions_
bool is_active_brush(std::string id) const
palette_manager * get_palette_manager()
void hotkey_set_mouse_action(hotkey::HOTKEY_COMMAND command)
Set the current mouse action based on a hotkey id.
void init_brushes(const game_config_view &game_config)
init the brushes
common_palette & get_palette()
Get the current palette.
void init_mouse_actions(context_manager &c_manager)
init the mouse actions (tools)
void set_brush(const std::string &id)
A mouse action receives events from the controller, and responds to them by creating an appropriate e...
A class grating read only view to a vector of config objects, viewed as one config with all children ...
std::string id
Text to match against addon_info.tags()
Definition: manager.cpp:199
Manage the empty-palette in the editor.
Definition: action.cpp:31
Game configuration data as global variables.
Definition: build_info.cpp:61
General purpose widgets.