summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2016-09-17 19:01:11 -0300
committerJuan Linietsky <reduzio@gmail.com>2016-09-17 19:01:47 -0300
commit8b15b26eedad4fdd33d50f5f9aa0fcc1875d503f (patch)
tree345f7082a12d539a7f55b32ebbd366626a3e96ae /scene/gui
parent0e962311be7fa5565a456ecd328202c2d6f6ca13 (diff)
Click the inspected objet name to see all subresources.
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/popup_menu.cpp17
-rw-r--r--scene/gui/popup_menu.h4
2 files changed, 18 insertions, 3 deletions
diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp
index b3f18bf8fa..422e1f5877 100644
--- a/scene/gui/popup_menu.cpp
+++ b/scene/gui/popup_menu.cpp
@@ -89,6 +89,8 @@ Size2 PopupMenu::get_minimum_size() const {
size.height=font_h;
}
+ size.width+=items[i].h_ofs;
+
if (items[i].checkable) {
size.width+=check_w+hseparation;
@@ -106,6 +108,7 @@ Size2 PopupMenu::get_minimum_size() const {
accel_max_w = MAX( accel_w, accel_max_w );
}
+
minsize.height+=size.height;
max_w = MAX( max_w, size.width );
@@ -450,6 +453,7 @@ void PopupMenu::_notification(int p_what) {
float h;
Size2 icon_size;
+ item_ofs.x+=items[i].h_ofs;
if (!items[i].icon.is_null()) {
icon_size = items[i].icon->get_size();
@@ -461,13 +465,13 @@ void PopupMenu::_notification(int p_what) {
if (i==mouse_over) {
- hover->draw(ci, Rect2( ofs+Point2(-hseparation,-vseparation), Size2( get_size().width - style->get_minimum_size().width + hseparation*2, h+vseparation*2 ) ));
+ hover->draw(ci, Rect2( item_ofs+Point2(-hseparation,-vseparation), Size2( get_size().width - style->get_minimum_size().width + hseparation*2, h+vseparation*2 ) ));
}
if (items[i].separator) {
int sep_h=separator->get_center_size().height+separator->get_minimum_size().height;
- separator->draw(ci, Rect2( ofs+Point2(0,Math::floor((h-sep_h)/2.0)), Size2( get_size().width - style->get_minimum_size().width , sep_h ) ));
+ separator->draw(ci, Rect2( item_ofs+Point2(0,Math::floor((h-sep_h)/2.0)), Size2( get_size().width - style->get_minimum_size().width , sep_h ) ));
}
@@ -819,6 +823,15 @@ void PopupMenu::set_item_shortcut(int p_idx, const Ref<ShortCut>& p_shortcut) {
update();
}
+void PopupMenu::set_item_h_offset(int p_idx, int p_offset) {
+
+ ERR_FAIL_INDEX(p_idx,items.size());
+ items[p_idx].h_ofs=p_offset;
+ update();
+
+}
+
+
bool PopupMenu::is_item_checkable(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx,items.size(),false);
return items[p_idx].checkable;
diff --git a/scene/gui/popup_menu.h b/scene/gui/popup_menu.h
index f35e91d4e4..50ba3a2569 100644
--- a/scene/gui/popup_menu.h
+++ b/scene/gui/popup_menu.h
@@ -54,9 +54,10 @@ class PopupMenu : public Popup {
String tooltip;
uint32_t accel;
int _ofs_cache;
+ int h_ofs;
Ref<ShortCut> shortcut;
- Item() { checked=false; checkable=false; separator=false; accel=0; disabled=false; _ofs_cache=0; }
+ Item() { checked=false; checkable=false; separator=false; accel=0; disabled=false; _ofs_cache=0; h_ofs=0; }
};
@@ -115,6 +116,7 @@ public:
void set_item_as_checkable(int p_idx, bool p_checkable);
void set_item_tooltip(int p_idx,const String& p_tooltip);
void set_item_shortcut(int p_idx, const Ref<ShortCut>& p_shortcut);
+ void set_item_h_offset(int p_idx, int p_offset);
String get_item_text(int p_idx) const;
Ref<Texture> get_item_icon(int p_idx) const;