summaryrefslogtreecommitdiff
path: root/scene/gui/popup_menu.cpp
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/popup_menu.cpp
parent0e962311be7fa5565a456ecd328202c2d6f6ca13 (diff)
Click the inspected objet name to see all subresources.
Diffstat (limited to 'scene/gui/popup_menu.cpp')
-rw-r--r--scene/gui/popup_menu.cpp17
1 files changed, 15 insertions, 2 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;