The Battle for Wesnoth  1.17.0-dev
palette_manager.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2012 - 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 /**
17  * Manages all the palettes in the editor.
18  */
19 
20 #pragma once
21 
23 
29 
30 namespace editor {
31 
32 class editor_toolkit;
33 
34 /** Empty palette */
35 class palette_manager : public gui::widget {
36 
37 public:
38 
40  , editor_toolkit &toolkit);
41 
42  void set_group(std::size_t index);
43 
44  /** Scroll the editor-palette up one step if possible. */
45  void scroll_up();
46  /** Scroll the editor-palette down one step if possible. */
47  void scroll_down();
48 
49  bool can_scroll_up();
50  bool can_scroll_down();
51 
52  void scroll_top();
53  void restore_palette_bg(bool scroll_top);
54  void scroll_bottom();
55 
56 //TODO
57 // void swap();
58 
59  void adjust_size();
60 
62  virtual void handle_event(const SDL_Event& event);
63 
64  /**
65  * Draw the palette.
66  *
67  * If force is true everything will be redrawn,
68  * even though it is not invalidated.
69  */
70  //void draw(bool force=false);
71  void draw_contents(); // { draw(false); };
72 
73 public:
74 
76 
77 private:
78 
82 
83 public:
84 
85  const std::unique_ptr<terrain_palette> terrain_palette_;
86  const std::unique_ptr<unit_palette> unit_palette_;
87  const std::unique_ptr<empty_palette> empty_palette_;
88  const std::unique_ptr<item_palette> item_palette_;
89  const std::unique_ptr<location_palette> location_palette_;
90 };
91 
92 }
const std::unique_ptr< unit_palette > unit_palette_
std::vector< events::sdl_handler * > sdl_handler_vector
Definition: events.hpp:190
common_palette & active_palette()
void set_group(std::size_t index)
virtual void handle_event(const SDL_Event &event)
General purpose widgets.
editor_toolkit & toolkit_
void draw_contents()
Draw the palette.
sdl_handler_vector handler_members()
Manage the empty-palette in the editor.
Definition: action.cpp:30
const std::unique_ptr< item_palette > item_palette_
void scroll_down()
Scroll the editor-palette down one step if possible.
void scroll_up()
Scroll the editor-palette up one step if possible.
std::size_t index(const std::string &str, const std::size_t index)
Codepoint index corresponding to the nth character in a UTF-8 string.
Definition: unicode.cpp:72
const std::unique_ptr< terrain_palette > terrain_palette_
const std::unique_ptr< empty_palette > empty_palette_
void restore_palette_bg(bool scroll_top)
palette_manager(editor_display &gui, const game_config_view &cfg, editor_toolkit &toolkit)
const std::unique_ptr< location_palette > location_palette_