The Battle for Wesnoth  1.19.1+dev
editor_toolkit.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2012 - 2024
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  const game_config_view& game_config, context_manager& c_manager);
32 
34 
35  void adjust_size();
36 
38 
39 private:
40  /** init the sidebar objects */
42 
43  /** init the brushes */
45 
46  /** init the mouse actions (tools) */
47  void init_mouse_actions(context_manager& c_manager);
48 
49 public:
53 
54  /**
55  * Set the current mouse action based on a hotkey id
56  */
58 
59  /**
60  * @return true if the mouse action identified by the hotkey is active
61  */
62  bool is_mouse_action_set(hotkey::HOTKEY_COMMAND command) const;
63 
64 
65  /** Get the current mouse action */
67  /** Get the current mouse action */
68  const mouse_action& get_mouse_action() const { return *mouse_action_; }
69  /** Get the current palette */
71 
72 // Brush related methods
73 
74  /** Cycle to the next brush. */
75  void cycle_brush();
76 
77  void set_brush(std::string id);
78 
79  bool is_active_brush(std::string id) const { return brush_->id() == id; }
80 
82 
83 private:
84 
86 
87  const CKey& key_;
88 
89  std::unique_ptr<palette_manager> palette_manager_;
90 
91 //Tools
92 
93  /** The current mouse action */
94  std::shared_ptr<mouse_action> mouse_action_; // Never null (outside the constructor).
95 
96  /** The mouse actions */
97  typedef std::map<hotkey::HOTKEY_COMMAND, std::shared_ptr<mouse_action>> mouse_action_map;
99 
100 //Brush members
101 
102  /** The current brush */
104 
105  /** All available brushes */
106  std::vector<brush> brushes_;
107 
108 };
109 
110 }
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.
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_
void set_brush(std::string id)
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.
editor_toolkit(editor_display &gui, const CKey &key, const game_config_view &game_config, context_manager &c_manager)
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)
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:205
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.