The Battle for Wesnoth  1.19.0-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 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 */
43 
44  /** init the brushes */
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  void set_brush(std::string id);
79 
80  bool is_active_brush(std::string id) const { return brush_->id() == id; }
81 
83 
84 private:
85 
87 
88  const CKey& key_;
89 
90  std::unique_ptr<palette_manager> palette_manager_;
91 
92 //Tools
93 
94  /** The current mouse action */
95  std::shared_ptr<mouse_action> mouse_action_; // Never null (outside the constructor).
96 
97  /** The mouse actions */
98  typedef std::map<hotkey::HOTKEY_COMMAND, std::shared_ptr<mouse_action>> mouse_action_map;
100 
101 //Brush members
102 
103  /** The current brush */
105 
106  /** All available brushes */
107  std::vector<brush> brushes_;
108 
109 };
110 
111 }
Class that keeps track of all the keys on the keyboard.
Definition: key.hpp:29
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:159
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:215
Manage the empty-palette in the editor.
Definition: action.cpp:31
Game configuration data as global variables.
Definition: build_info.cpp:63
General purpose widgets.