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