summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/range.cpp16
-rw-r--r--scene/gui/range.h4
-rw-r--r--scene/gui/tabs.cpp84
-rw-r--r--scene/gui/tabs.h6
4 files changed, 100 insertions, 10 deletions
diff --git a/scene/gui/range.cpp b/scene/gui/range.cpp
index d3b7521c9a..ffcdf98519 100644
--- a/scene/gui/range.cpp
+++ b/scene/gui/range.cpp
@@ -48,20 +48,20 @@ void Range::Shared::emit_value_changed() {
}
}
-void Range::_changed_notify() {
+void Range::_changed_notify(const char *p_what) {
emit_signal("changed",shared->val);
update();
- _change_notify();
+ _change_notify(p_what);
}
-void Range::Shared::emit_changed() {
+void Range::Shared::emit_changed(const char *p_what) {
for (Set<Range*>::Element *E=owners.front();E;E=E->next()) {
Range *r=E->get();
if (!r->is_inside_tree())
continue;
- r->_changed_notify();
+ r->_changed_notify(p_what);
}
}
@@ -94,20 +94,20 @@ void Range::set_min(double p_min) {
shared->min=p_min;
set_val(shared->val);
- shared->emit_changed();
+ shared->emit_changed("range/min");
}
void Range::set_max(double p_max) {
shared->max=p_max;
set_val(shared->val);
- shared->emit_changed();
+ shared->emit_changed("range/max");
}
void Range::set_step(double p_step) {
shared->step=p_step;
- shared->emit_changed();
+ shared->emit_changed("range/step");
}
void Range::set_page(double p_page) {
@@ -115,7 +115,7 @@ void Range::set_page(double p_page) {
shared->page=p_page;
set_val(shared->val);
- shared->emit_changed();
+ shared->emit_changed("range/page");
}
double Range::get_val() const {
diff --git a/scene/gui/range.h b/scene/gui/range.h
index 2967c2790c..d96ecdfb0b 100644
--- a/scene/gui/range.h
+++ b/scene/gui/range.h
@@ -44,7 +44,7 @@ class Range : public Control {
bool exp_unit_value;
Set<Range*> owners;
void emit_value_changed();
- void emit_changed();
+ void emit_changed(const char *p_what="");
};
Shared *shared;
@@ -55,7 +55,7 @@ class Range : public Control {
void _share(Node *p_range);
void _value_changed_notify();
- void _changed_notify();
+ void _changed_notify(const char *p_what="");
protected:
diff --git a/scene/gui/tabs.cpp b/scene/gui/tabs.cpp
index 14cd0bee8e..bb64a57212 100644
--- a/scene/gui/tabs.cpp
+++ b/scene/gui/tabs.cpp
@@ -266,6 +266,7 @@ void Tabs::_notification(int p_what) {
int label_valign_fg = get_constant("label_valign_fg");
int label_valign_bg = get_constant("label_valign_bg");
+
int w=0;
int mw = 0;
@@ -277,12 +278,16 @@ void Tabs::_notification(int p_what) {
for(int i=0;i<tabs.size();i++) {
+
Ref<Texture> tex = tabs[i].icon;
if (tex.is_valid()) {
if (tabs[i].text!="")
mw+=get_constant("hseparation");
}
+
+ tabs[i].ofs_cache=mw;
+
mw+=font->get_string_size(tabs[i].text).width;
if (current==i)
mw+=tab_fg->get_minimum_size().width;
@@ -303,6 +308,9 @@ void Tabs::_notification(int p_what) {
bms.width+=get_constant("hseparation");
mw+=bms.width;
}
+
+
+
}
}
@@ -758,6 +766,79 @@ Tabs::TabAlign Tabs::get_tab_align() const {
}
+void Tabs::ensure_tab_visible(int p_idx) {
+
+ if (!is_inside_tree())
+ return;
+
+ ERR_FAIL_INDEX(p_idx,tabs.size());
+
+ if (p_idx<offset) {
+ offset=p_idx;
+ update();
+ return;
+ }
+
+ Ref<StyleBox> tab_bg = get_stylebox("tab_bg");
+ Ref<StyleBox> tab_fg = get_stylebox("tab_fg");
+ Ref<Font> font = get_font("font");
+
+ Ref<Texture> incr = get_icon("increment");
+ Ref<Texture> decr = get_icon("decrement");
+
+ int limit=get_size().width-incr->get_width()-decr->get_width();
+
+
+
+ int x=0;
+ for(int i=0;i<tabs.size();i++) {
+
+ if (i<offset)
+ continue;
+
+ Ref<Texture> tex = tabs[i].icon;
+ if (tex.is_valid()) {
+ if (tabs[i].text!="")
+ x+=get_constant("hseparation");
+
+ }
+
+ tabs[i].x_cache=x;
+
+ x+=font->get_string_size(tabs[i].text).width;
+ if (current==i)
+ x+=tab_fg->get_minimum_size().width;
+ else
+ x+=tab_bg->get_minimum_size().width;
+
+ if (tabs[i].right_button.is_valid()) {
+ Ref<Texture> rb=tabs[i].right_button;
+ Size2 bms = rb->get_size();//+get_stylebox("button")->get_minimum_size();
+ bms.width+=get_constant("hseparation");
+
+ x+=bms.width;
+ }
+
+ if (tabs[i].close_button.is_valid()) {
+ Ref<Texture> cb=tabs[i].close_button;
+ Size2 bms = cb->get_size();//+get_stylebox("button")->get_minimum_size();
+ bms.width+=get_constant("hseparation");
+ x+=bms.width;
+ }
+
+ tabs[i].x_size_cache=x-tabs[i].x_cache;
+
+
+
+ }
+
+ while(offset<tabs.size() && ( (tabs[p_idx].x_cache + tabs[p_idx].x_size_cache) - tabs[offset].x_cache) < limit) {
+ offset++;
+ }
+
+ update();
+}
+
void Tabs::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_input_event"),&Tabs::_input_event);
@@ -772,6 +853,7 @@ void Tabs::_bind_methods() {
ObjectTypeDB::bind_method(_MD("add_tab","title","icon:Texture"),&Tabs::add_tab);
ObjectTypeDB::bind_method(_MD("set_tab_align","align"),&Tabs::set_tab_align);
ObjectTypeDB::bind_method(_MD("get_tab_align"),&Tabs::get_tab_align);
+ ObjectTypeDB::bind_method(_MD("ensure_tab_visible","idx"),&Tabs::ensure_tab_visible);
ADD_SIGNAL(MethodInfo("tab_changed",PropertyInfo(Variant::INT,"tab")));
ADD_SIGNAL(MethodInfo("right_button_pressed",PropertyInfo(Variant::INT,"tab")));
@@ -804,4 +886,6 @@ Tabs::Tabs() {
cb_displaypolicy = SHOW_NEVER; // Default : no close button
offset=0;
max_drawn_tab=0;
+
+
}
diff --git a/scene/gui/tabs.h b/scene/gui/tabs.h
index efcb291a52..82035291ec 100644
--- a/scene/gui/tabs.h
+++ b/scene/gui/tabs.h
@@ -59,10 +59,14 @@ private:
Ref<Texture> icon;
int ofs_cache;
int size_cache;
+ int x_cache;
+ int x_size_cache;
+
Ref<Texture> right_button;
Rect2 rb_rect;
Ref<Texture> close_button;
Rect2 cb_rect;
+
};
@@ -119,6 +123,8 @@ public:
void clear_tabs();
+ void ensure_tab_visible(int p_idx);
+
Size2 get_minimum_size() const;
Tabs();