The Battle for Wesnoth  1.13.10+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
palette_manager.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 /**
16  * Manages all the palettes in the editor.
17  */
18 
19 #pragma once
20 
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(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  void restore_palette_bg(bool scroll_top);
53  void scroll_bottom();
54 
55 //TODO
56 // void swap();
57 
58  void adjust_size();
59 
61  virtual void handle_event(const SDL_Event& event);
62 
63  /**
64  * Draw the palette.
65  *
66  * If force is true everything will be redrawn,
67  * even though it is not invalidated.
68  */
69  //void draw(bool force=false);
70  void draw_contents(); // { draw(false); };
71 
72 public:
73 
75 
76 private:
77 
81 
82 public:
83 
84  const std::unique_ptr<terrain_palette> terrain_palette_;
85  const std::unique_ptr<unit_palette> unit_palette_;
86  const std::unique_ptr<empty_palette> empty_palette_;
87  const std::unique_ptr<item_palette> item_palette_;
88  const std::unique_ptr<location_palette> location_palette_;
89 };
90 
91 }
const std::unique_ptr< unit_palette > unit_palette_
palette_manager(editor_display &gui, const config &cfg, editor_toolkit &toolkit)
size_t index(const utf8::string &str, const size_t index)
Codepoint index corresponding to the nth character in a UTF-8 string.
Definition: unicode.cpp:71
void set_group(size_t index)
std::vector< events::sdl_handler * > sdl_handler_vector
Definition: events.hpp:176
common_palette & active_palette()
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:29
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.
const std::unique_ptr< terrain_palette > terrain_palette_
const std::unique_ptr< empty_palette > empty_palette_
void restore_palette_bg(bool scroll_top)
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:93
const std::unique_ptr< location_palette > location_palette_