1 /*
2  * Copyright (C) 2019-2020 by the Widelands Development Team
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17  *
18  */
19 
20 #ifndef WL_EDITOR_UI_MENUS_MAP_SIZE_BOX_H
21 #define WL_EDITOR_UI_MENUS_MAP_SIZE_BOX_H
22 
23 #include "ui_basic/box.h"
24 #include "ui_basic/dropdown.h"
25 
26 /**
27  * A box containing 2 dropdowns to select map width and height with horizontal layout.
28  * Selections are taken from Widelands::kMapDimensions.
29  */
30 struct MapSizeBox : public UI::Box {
31 
32 	/**
33 	 * @param parent The parent panel
34 	 * @param name A string to prefix for the dropdown names, so that they can be idenfitied uniquely
35 	 * @param spacing The horizontal space between the 2 dropdowns
36 	 * @param map_width Width to preselect
37 	 * @param map_height Height to preselect
38 	 */
39 	MapSizeBox(UI::Box& parent, const std::string& name, int spacing, int map_width, int map_height);
40 
41 	/// This function will be triggered when a new width or height is selected from the dropdowns
42 	void set_selection_function(const std::function<void()> func);
43 	/// The currently selected width
44 	uint32_t selected_width() const;
45 	/// The currently selected height
46 	uint32_t selected_height() const;
47 	/// Set the selected width
48 	void select_width(int new_width);
49 	/// Set the selected height
50 	void select_height(int new_height);
51 
52 private:
53 	UI::Dropdown<uint32_t> width_;
54 	UI::Dropdown<uint32_t> height_;
55 };
56 
57 #endif  // end of include guard: WL_EDITOR_UI_MENUS_MAP_SIZE_BOX_H
58