The Battle for Wesnoth  1.17.0-dev
mouse_action_select.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 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 
19 
20 class CKey;
21 class empty_palette;
22 
23 namespace editor {
24 
25 /**
26  * Select (and deselect) action, by brush or "magic wand" (via keyboard modifier)
27  */
29 {
30 public:
31  mouse_action_select(const brush* const * const brush, const CKey& key, empty_palette& palette)
32  : brush_drag_mouse_action(palette, brush, key)
33  {
34  }
35 
36  /**
37  * Overridden to allow special behavior based on modifier keys
38  */
39  std::set<map_location> affected_hexes(editor_display& disp, const map_location& hex) override;
40 
41  /**
42  * Force a fake "move" event to update brush overlay on key event
43  */
44  std::unique_ptr<editor_action> key_event(editor_display& disp, const SDL_Event& e) override;
45 
46  /**
47  * Left click/drag selects
48  */
49  std::unique_ptr<editor_action> click_perform_left(editor_display& disp, const std::set<map_location>& hexes) override;
50 
51  /**
52  * Right click does nothing for now
53  */
54  std::unique_ptr<editor_action> click_right(editor_display& disp, int x, int y) override;
55 
56 
57  /**
58  * Right click/drag
59  */
60  std::unique_ptr<editor_action> click_perform_right(editor_display& disp, const std::set<map_location>& hexes) override;
61 
62  virtual void set_mouse_overlay(editor_display& disp) override;
63 
64  virtual bool has_context_menu() const override { return true; }
65  virtual bool supports_brushes() const override { return true; }
66 
67 };
68 
69 } //end namespace editor
mouse_action_select(const brush *const *const brush, const CKey &key, empty_palette &palette)
virtual bool has_context_menu() const override
std::vector< color_t > palette(const color_range &cr)
Creates a reference color palette from a color range.
Definition: color_range.cpp:84
std::unique_ptr< editor_action > click_right(editor_display &disp, int x, int y) override
Right click does nothing for now.
virtual void set_mouse_overlay(editor_display &disp) override
Set the mouse overlay for this action.
std::unique_ptr< editor_action > key_event(editor_display &disp, const SDL_Event &e) override
Force a fake "move" event to update brush overlay on key event.
Select (and deselect) action, by brush or "magic wand" (via keyboard modifier)
A brush-drag mouse action base class which adds brush and drag processing to a basic mouse action...
std::unique_ptr< editor_action > click_perform_right(editor_display &disp, const std::set< map_location > &hexes) override
Right click/drag.
std::set< map_location > affected_hexes(editor_display &disp, const map_location &hex) override
Overridden to allow special behavior based on modifier keys.
The brush class represents a single brush – a set of relative locations around a "hotspot"...
Definition: brush.hpp:26
Manage the empty-palette in the editor.
Definition: action.cpp:30
Encapsulates the map of the game.
Definition: location.hpp:38
#define e
virtual bool supports_brushes() const override
Whether we need the brush bar, is used to grey it out.
std::unique_ptr< editor_action > click_perform_left(editor_display &disp, const std::set< map_location > &hexes) override
Left click/drag selects.
Class that keeps track of all the keys on the keyboard.
Definition: key.hpp:28