2014-02-10 02:10:30 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* button_array.h */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* http://www.godotengine.org */
|
|
|
|
/*************************************************************************/
|
2017-01-01 22:01:57 +01:00
|
|
|
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
|
2017-04-08 00:11:42 +02:00
|
|
|
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
|
2014-02-10 02:10:30 +01:00
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/*************************************************************************/
|
2015-04-18 19:38:54 +02:00
|
|
|
#ifndef BUTTON_ARRAY_H
|
|
|
|
#define BUTTON_ARRAY_H
|
|
|
|
|
|
|
|
#include "scene/gui/control.h"
|
|
|
|
|
|
|
|
class ButtonArray : public Control {
|
|
|
|
|
2017-01-03 03:03:46 +01:00
|
|
|
GDCLASS(ButtonArray, Control);
|
2017-03-05 16:44:50 +01:00
|
|
|
|
2015-04-18 19:38:54 +02:00
|
|
|
public:
|
|
|
|
enum Align {
|
|
|
|
ALIGN_BEGIN,
|
|
|
|
ALIGN_CENTER,
|
|
|
|
ALIGN_END,
|
|
|
|
ALIGN_FILL,
|
|
|
|
ALIGN_EXPAND_FILL
|
|
|
|
};
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
private:
|
2015-04-18 19:38:54 +02:00
|
|
|
Orientation orientation;
|
|
|
|
Align align;
|
|
|
|
|
|
|
|
struct Button {
|
|
|
|
|
|
|
|
String text;
|
2017-02-08 00:38:36 +01:00
|
|
|
String xl_text;
|
2016-10-14 19:11:52 +02:00
|
|
|
String tooltip;
|
2015-04-18 19:38:54 +02:00
|
|
|
Ref<Texture> icon;
|
|
|
|
mutable int _ms_cache;
|
|
|
|
mutable int _pos_cache;
|
|
|
|
mutable int _size_cache;
|
|
|
|
};
|
|
|
|
|
|
|
|
int selected;
|
|
|
|
int hover;
|
2016-11-19 14:48:39 +01:00
|
|
|
bool flat;
|
2015-04-18 19:38:54 +02:00
|
|
|
double min_button_size;
|
|
|
|
|
|
|
|
Vector<Button> buttons;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
protected:
|
|
|
|
bool _set(const StringName &p_name, const Variant &p_value);
|
|
|
|
bool _get(const StringName &p_name, Variant &r_ret) const;
|
|
|
|
void _get_property_list(List<PropertyInfo> *p_list) const;
|
2015-04-18 19:38:54 +02:00
|
|
|
|
|
|
|
void _notification(int p_what);
|
|
|
|
static void _bind_methods();
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2015-04-18 19:38:54 +02:00
|
|
|
public:
|
2017-03-05 16:44:50 +01:00
|
|
|
void _gui_input(const InputEvent &p_event);
|
2015-04-18 19:38:54 +02:00
|
|
|
|
|
|
|
void set_align(Align p_align);
|
|
|
|
Align get_align() const;
|
|
|
|
|
2016-11-19 14:48:39 +01:00
|
|
|
void set_flat(bool p_flat);
|
|
|
|
bool is_flat() const;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void add_button(const String &p_button, const String &p_tooltip = "");
|
|
|
|
void add_icon_button(const Ref<Texture> &p_icon, const String &p_button = "", const String &p_tooltip = "");
|
2015-04-18 19:38:54 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void set_button_text(int p_button, const String &p_text);
|
|
|
|
void set_button_tooltip(int p_button, const String &p_text);
|
|
|
|
void set_button_icon(int p_button, const Ref<Texture> &p_icon);
|
2015-04-18 19:38:54 +02:00
|
|
|
|
|
|
|
String get_button_text(int p_button) const;
|
2016-10-14 19:11:52 +02:00
|
|
|
String get_button_tooltip(int p_button) const;
|
2015-04-18 19:38:54 +02:00
|
|
|
Ref<Texture> get_button_icon(int p_button) const;
|
|
|
|
|
|
|
|
int get_selected() const;
|
|
|
|
int get_hovered() const;
|
|
|
|
void set_selected(int p_selected);
|
|
|
|
|
|
|
|
int get_button_count() const;
|
|
|
|
|
|
|
|
void erase_button(int p_button);
|
|
|
|
void clear();
|
|
|
|
|
|
|
|
virtual Size2 get_minimum_size() const;
|
|
|
|
|
|
|
|
virtual void get_translatable_strings(List<String> *p_strings) const;
|
2017-03-05 16:44:50 +01:00
|
|
|
virtual String get_tooltip(const Point2 &p_pos) const;
|
2015-04-18 19:38:54 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
ButtonArray(Orientation p_orientation = HORIZONTAL);
|
2015-04-18 19:38:54 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class HButtonArray : public ButtonArray {
|
2017-03-05 16:44:50 +01:00
|
|
|
GDCLASS(HButtonArray, ButtonArray);
|
2015-04-18 19:38:54 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
public:
|
|
|
|
HButtonArray()
|
|
|
|
: ButtonArray(HORIZONTAL){};
|
2015-04-18 19:38:54 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class VButtonArray : public ButtonArray {
|
2017-03-05 16:44:50 +01:00
|
|
|
GDCLASS(VButtonArray, ButtonArray);
|
2015-04-18 19:38:54 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
public:
|
|
|
|
VButtonArray()
|
|
|
|
: ButtonArray(VERTICAL){};
|
2015-04-18 19:38:54 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // BUTTON_ARRAY_H
|