The Battle for Wesnoth  1.13.10+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
editor_toolkit.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2012 - 2017 by Fabian Mueller <fabianmueller5@gmx.de>
3  Part of the Battle for Wesnoth Project http://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 #pragma once
16 
19 #include "editor/toolkit/brush.hpp"
21 
22 class config;
23 
24 namespace editor {
25 
26 
28 
29 public:
31  const config& game_config, context_manager& c_manager);
32 
34 
35  void adjust_size();
36 
38 
39 private:
40  /** init the sidebar objects */
41  void init_sidebar(const config& game_config);
42 
43  /** init the brushes */
44  void init_brushes(const config& game_config);
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  /** TODO */
78  void set_brush(std::string id);
79 
80  /** TODO */
81  bool is_active_brush(std::string id) const { return brush_->id() == id; }
82 
84 
85 private:
86 
88 
89  const CKey& key_;
90 
91  std::unique_ptr<palette_manager> palette_manager_;
92 
93 //Tools
94 
95  /** The current mouse action */
96  std::shared_ptr<mouse_action> mouse_action_; // Never null (outside the constructor).
97 
98  /** The mouse actions */
99  typedef std::map<hotkey::HOTKEY_COMMAND, std::shared_ptr<mouse_action> > mouse_action_map;
100  mouse_action_map mouse_actions_;
101 
102 //Brush members
103 
104  /** The current brush */
106 
107  /** All available brushes */
108  std::vector<brush> brushes_;
109 
110 };
111 
112 }
editor_display & gui_
std::vector< char_t > string
void hotkey_set_mouse_action(hotkey::HOTKEY_COMMAND command)
Set the current mouse action based on a hotkey id.
mouse_action_map mouse_actions_
bool is_mouse_action_set(hotkey::HOTKEY_COMMAND command) const
void cycle_brush()
Cycle to the next brush.
std::shared_ptr< mouse_action > mouse_action_
The current mouse action.
void init_sidebar(const config &game_config)
init the sidebar objects
General purpose widgets.
brush * brush_
The current brush.
void set_brush(std::string id)
TODO.
editor_toolkit(editor_display &gui, const CKey &key, const config &game_config, context_manager &c_manager)
bool is_active_brush(std::string id) const
TODO.
const std::string id() const
Definition: brush.hpp:57
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:25
std::unique_ptr< palette_manager > palette_manager_
Manage the empty-palette in the editor.
Definition: action.cpp:29
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)
void init_brushes(const config &game_config)
init the brushes
const mouse_action & get_mouse_action() const
Get the current mouse action.
Game configuration data as global variables.
Definition: build_info.cpp:53
mouse_action & get_mouse_action()
Get the current mouse action.
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:93
Class that keeps track of all the keys on the keyboard.
Definition: key.hpp:27
palette_manager * get_palette_manager()