summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/slider.cpp10
-rw-r--r--scene/gui/tree.cpp17
-rw-r--r--scene/gui/tree.h4
3 files changed, 28 insertions, 3 deletions
diff --git a/scene/gui/slider.cpp b/scene/gui/slider.cpp
index 4661f54526..8fda5df53c 100644
--- a/scene/gui/slider.cpp
+++ b/scene/gui/slider.cpp
@@ -162,18 +162,20 @@ void Slider::_notification(int p_what) {
Size2i size = get_size();
Ref<StyleBox> style = get_stylebox("slider");
Ref<StyleBox> focus = get_stylebox("focus");
+ Ref<StyleBox> grabber_area = get_stylebox("grabber_area");
Ref<Texture> grabber = get_icon(editable ? ((mouse_inside || has_focus()) ? "grabber_highlight" : "grabber") : "grabber_disabled");
Ref<Texture> tick = get_icon("tick");
if (orientation == VERTICAL) {
int widget_width = style->get_minimum_size().width + style->get_center_size().width;
+ float areasize = size.height - grabber->get_size().height;
style->draw(ci, Rect2i(Point2i(size.width / 2 - widget_width / 2, 0), Size2i(widget_width, size.height)));
+ grabber_area->draw(ci, Rect2i(Point2i((size.width - widget_width) / 2, size.height - areasize * get_as_ratio() - grabber->get_size().height / 2), Size2i(widget_width, areasize * get_as_ratio() + grabber->get_size().width / 2)));
/*
if (mouse_inside||has_focus())
focus->draw(ci,Rect2i(Point2i(),Size2i(style->get_minimum_size().width+style->get_center_size().width,size.height)));
*/
- float areasize = size.height - grabber->get_size().height;
if (ticks > 1) {
int tickarea = size.height - tick->get_height();
for (int i = 0; i < ticks; i++) {
@@ -186,13 +188,15 @@ void Slider::_notification(int p_what) {
} else {
int widget_height = style->get_minimum_size().height + style->get_center_size().height;
- style->draw(ci, Rect2i(Point2i(0, size.height / 2 - widget_height / 2), Size2i(size.width, widget_height)));
+ float areasize = size.width - grabber->get_size().width;
+
+ style->draw(ci, Rect2i(Point2i(0, (size.height - widget_height) / 2), Size2i(size.width, widget_height)));
+ grabber_area->draw(ci, Rect2i(Point2i(0, (size.height - widget_height) / 2), Size2i(areasize * get_as_ratio() + grabber->get_size().width / 2, widget_height)));
/*
if (mouse_inside||has_focus())
focus->draw(ci,Rect2i(Point2i(),Size2i(size.width,style->get_minimum_size().height+style->get_center_size().height)));
*/
- float areasize = size.width - grabber->get_size().width;
if (ticks > 1) {
int tickarea = size.width - tick->get_width();
for (int i = 0; i < ticks; i++) {
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index db282262ec..4975b66744 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -333,6 +333,15 @@ bool TreeItem::is_collapsed() {
return collapsed;
}
+void TreeItem::set_custom_minimum_height(int p_height) {
+ custom_min_height = p_height;
+ _changed_notify();
+}
+
+int TreeItem::get_custom_minimum_height() const {
+ return custom_min_height;
+}
+
TreeItem *TreeItem::get_next() {
return next;
@@ -703,6 +712,9 @@ void TreeItem::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_collapsed", "enable"), &TreeItem::set_collapsed);
ClassDB::bind_method(D_METHOD("is_collapsed"), &TreeItem::is_collapsed);
+ ClassDB::bind_method(D_METHOD("set_custom_minimum_height", "height"), &TreeItem::set_custom_minimum_height);
+ ClassDB::bind_method(D_METHOD("get_custom_minimum_height"), &TreeItem::get_custom_minimum_height);
+
ClassDB::bind_method(D_METHOD("get_next"), &TreeItem::get_next);
ClassDB::bind_method(D_METHOD("get_prev"), &TreeItem::get_prev);
ClassDB::bind_method(D_METHOD("get_parent"), &TreeItem::get_parent);
@@ -780,6 +792,7 @@ TreeItem::TreeItem(Tree *p_tree) {
tree = p_tree;
collapsed = false;
disable_folding = false;
+ custom_min_height = 0;
parent = 0; // parent item
next = 0; // next in list
@@ -921,6 +934,9 @@ int Tree::compute_item_height(TreeItem *p_item) const {
default: {}
}
}
+ int item_min_height = p_item->get_custom_minimum_height();
+ if (height < item_min_height)
+ height = item_min_height;
height += cache.vseparation;
@@ -3593,6 +3609,7 @@ void Tree::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_item_area_rect", "item", "column"), &Tree::_get_item_rect, DEFVAL(-1));
ClassDB::bind_method(D_METHOD("get_item_at_pos", "pos"), &Tree::get_item_at_pos);
ClassDB::bind_method(D_METHOD("get_column_at_pos", "pos"), &Tree::get_column_at_pos);
+ ClassDB::bind_method(D_METHOD("get_drop_section_at_pos", "pos"), &Tree::get_drop_section_at_pos);
ClassDB::bind_method(D_METHOD("ensure_cursor_is_visible"), &Tree::ensure_cursor_is_visible);
diff --git a/scene/gui/tree.h b/scene/gui/tree.h
index 06d6d3ad5a..5f19558597 100644
--- a/scene/gui/tree.h
+++ b/scene/gui/tree.h
@@ -145,6 +145,7 @@ private:
bool collapsed; // wont show childs
bool disable_folding;
+ int custom_min_height;
TreeItem *parent; // parent item
TreeItem *next; // next in list
@@ -230,6 +231,9 @@ public:
void set_collapsed(bool p_collapsed);
bool is_collapsed();
+ void set_custom_minimum_height(int p_height);
+ int get_custom_minimum_height() const;
+
TreeItem *get_prev();
TreeItem *get_next();
TreeItem *get_parent();