The Battle for Wesnoth  1.19.7+dev
palette_manager.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 /**
17  * Manages all the palettes in the editor.
18  */
19 
20 #pragma once
21 
22 
28 
29 namespace editor {
30 
31 class editor_toolkit;
32 
33 /** Empty palette */
34 class palette_manager : public gui::widget {
35 
36 public:
37 
39  , editor_toolkit &toolkit);
40 
41  void set_group(std::size_t index);
42 
43  /** Scroll the editor-palette up one step if possible. */
44  void scroll_up();
45  /** Scroll the editor-palette down one step if possible. */
46  void scroll_down();
47 
48  bool can_scroll_up();
49  bool can_scroll_down();
50 
51  void scroll_top();
52 
53  void adjust_size();
54 
56  virtual void handle_event(const SDL_Event& event) override;
57 
58  /** Called by draw_manager to validate layout before drawing. */
59  virtual void layout() override;
60 
61  /**
62  * Draw the palette.
63  *
64  * If force is true everything will be redrawn,
65  * even though it is not invalidated.
66  */
67  //void draw(bool force=false);
68  void draw_contents() override; // { draw(false); };
69 
70 public:
71 
73 
74 private:
75 
79 
80 public:
81 
82  const std::unique_ptr<terrain_palette> terrain_palette_;
83  const std::unique_ptr<unit_palette> unit_palette_;
84  const std::unique_ptr<empty_palette> empty_palette_;
85  const std::unique_ptr<item_palette> item_palette_;
86  const std::unique_ptr<location_palette> location_palette_;
87 };
88 
89 }
const std::unique_ptr< empty_palette > empty_palette_
void scroll_up()
Scroll the editor-palette up one step if possible.
const std::unique_ptr< item_palette > item_palette_
sdl_handler_vector handler_members() override
void scroll_down()
Scroll the editor-palette down one step if possible.
void draw_contents() override
Draw the palette.
void set_group(std::size_t index)
const std::unique_ptr< terrain_palette > terrain_palette_
palette_manager(editor_display &gui, const game_config_view &cfg, editor_toolkit &toolkit)
const std::unique_ptr< unit_palette > unit_palette_
editor_toolkit & toolkit_
const std::unique_ptr< location_palette > location_palette_
virtual void layout() override
Called by draw_manager to validate layout before drawing.
common_palette & active_palette()
virtual void handle_event(const SDL_Event &event) override
A class grating read only view to a vector of config objects, viewed as one config with all children ...
std::vector< events::sdl_handler * > sdl_handler_vector
Definition: events.hpp:182
Manage the empty-palette in the editor.
Definition: action.cpp:31
General purpose widgets.
std::size_t index(std::string_view str, const std::size_t index)
Codepoint index corresponding to the nth character in a UTF-8 string.
Definition: unicode.cpp:70