The Battle for Wesnoth  1.13.10+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
empty_palette.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  * Manage the empty-palette in the editor.
17  */
18 
19 #pragma once
20 
22 
23 namespace editor {
24 
25 /** Empty palette */
26 class empty_palette : public common_palette {
27 
28 public:
29 
31  common_palette(gui.video()),
32  gui_(gui) {}
33 
34  //event handling
35  virtual bool mouse_click() { return false;}
36 
37  virtual bool scroll_up() override { return false;}
38  virtual bool can_scroll_up() override { return false;}
39  virtual bool scroll_down() override { return false;}
40  virtual bool can_scroll_down() override { return false;}
41 
42  //drawing
43  virtual void adjust_size(const SDL_Rect& /*target*/) override {}
44  virtual void draw() override {}
45 
46  void hide(bool /*hidden*/) override
47  {
48  std::shared_ptr<gui::button> upscroll_button = gui_.find_action_button("upscroll-button-editor");
49  upscroll_button->enable(false);
50  std::shared_ptr<gui::button> downscroll_button = gui_.find_action_button("downscroll-button-editor");
51  downscroll_button->enable(false);
52  std::shared_ptr<gui::button> palette_menu_button = gui_.find_menu_button("menu-editor-terrain");
53  palette_menu_button->set_overlay("");
54  palette_menu_button->enable(false);
55  }
56 
57  std::vector<gui::widget>* get_widgets() { return nullptr; }
58 
59  //group
60  virtual void set_group(size_t /*index*/) override {}
61  virtual void next_group() override {}
62  virtual void prev_group() override {}
63  virtual const std::vector<item_group>& get_groups() const override { static const std::vector<item_group> empty; return empty; }
64 
65  /** Menu expanding for palette group list */
66  virtual void expand_palette_groups_menu(std::vector<config>& items, int i) override
67  {
68  items.erase(items.begin() + i);
69  }
70 
71  //item
72  virtual int num_items() override {return 0;}
73  virtual size_t start_num() override {return 0;}
74  virtual void set_start_item(size_t /*index*/) override {}
75  virtual bool supports_swap() override { return false; }
76  virtual void swap() override {}
77 
78 private:
80 };
81 
82 }
std::shared_ptr< gui::button > find_action_button(const std::string &id)
Retrieves a pointer to a theme UI button.
Definition: display.cpp:853
virtual bool scroll_down() override
Scroll the editor-palette down one step if possible.
std::vector< gui::widget > * get_widgets()
virtual const std::vector< item_group > & get_groups() const override
virtual void expand_palette_groups_menu(std::vector< config > &items, int i) override
Menu expanding for palette group list.
CVideo & video() const
Definition: widget.hpp:84
General purpose widgets.
virtual void next_group() override
const std::vector< std::string > items
virtual size_t start_num() override
virtual void swap() override
virtual void set_start_item(size_t) override
virtual void set_group(size_t) override
virtual bool mouse_click()
Manage the empty-palette in the editor.
Definition: action.cpp:29
virtual bool supports_swap() override
virtual int num_items() override
void hide(bool) override
virtual void draw() override
size_t i
Definition: function.cpp:933
virtual bool can_scroll_down() override
virtual void prev_group() override
empty_palette(display &gui)
virtual bool can_scroll_up() override
virtual void adjust_size(const SDL_Rect &) override
std::shared_ptr< gui::button > find_menu_button(const std::string &id)
Definition: display.cpp:863
virtual bool scroll_up() override
Scroll the editor-palette up one step if possible.