The Battle for Wesnoth  1.19.5+dev
empty_palette.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  * 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 
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 
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(std::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 std::size_t num_items() override {return 0;}
73  virtual std::size_t start_num() override {return 0;}
74  virtual void set_start_item(std::size_t /*index*/) override {}
75  virtual bool supports_swap() override { return false; }
76  virtual void swap() override {}
77 
78 private:
80 };
81 
82 }
Sort-of-Singleton that many classes, both GUI and non-GUI, use to access the game data.
Definition: display.hpp:97
std::shared_ptr< gui::button > find_action_button(const std::string &id)
Retrieves a pointer to a theme UI button.
Definition: display.cpp:770
std::shared_ptr< gui::button > find_menu_button(const std::string &id)
Definition: display.cpp:780
virtual void expand_palette_groups_menu(std::vector< config > &items, int i) override
Menu expanding for palette group list.
virtual bool can_scroll_down() override
virtual void next_group() override
virtual void swap() override
For tools which support fg and bg items, exchange the two items.
void hide(bool) override
virtual std::size_t start_num() override
empty_palette(display &gui)
virtual void set_start_item(std::size_t) override
virtual bool scroll_down() override
Scroll the editor-palette down one step if possible.
virtual std::size_t num_items() override
virtual bool mouse_click()
std::vector< gui::widget > * get_widgets()
virtual const std::vector< item_group > & get_groups() const override
virtual bool can_scroll_up() override
virtual bool supports_swap() override
Whether the hotkey system should the enable GUI button connected to swap().
virtual void adjust_size(const SDL_Rect &) override
virtual void set_group(std::size_t) override
virtual bool scroll_up() override
Scroll the editor-palette up one step if possible.
virtual void prev_group() override
std::size_t i
Definition: function.cpp:1028
Manage the empty-palette in the editor.
Definition: action.cpp:31
General purpose widgets.