summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/animation/animation_player.cpp11
-rw-r--r--scene/audio/stream_player.cpp14
-rw-r--r--scene/audio/stream_player.h1
-rw-r--r--scene/gui/color_picker.cpp33
-rw-r--r--scene/gui/color_picker.h3
-rw-r--r--scene/gui/control.cpp4
-rw-r--r--scene/gui/tree.cpp26
-rw-r--r--scene/gui/tree.h6
-rw-r--r--scene/main/timer.cpp1
-rw-r--r--scene/resources/default_theme/default_theme.cpp4
10 files changed, 87 insertions, 16 deletions
diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp
index f6d058c2fd..344fc5ecde 100644
--- a/scene/animation/animation_player.cpp
+++ b/scene/animation/animation_player.cpp
@@ -147,14 +147,21 @@ void AnimationPlayer::_get_property_list( List<PropertyInfo> *p_list) const {
List<String> names;
+ List<PropertyInfo> anim_names;
+
for( Map<StringName, AnimationData>::Element *E=animation_set.front();E;E=E->next()) {
- p_list->push_back( PropertyInfo( Variant::OBJECT, "anims/"+String(E->key()), PROPERTY_HINT_RESOURCE_TYPE, "Animation",PROPERTY_USAGE_NOEDITOR) );
+ anim_names.push_back( PropertyInfo( Variant::OBJECT, "anims/"+String(E->key()), PROPERTY_HINT_RESOURCE_TYPE, "Animation",PROPERTY_USAGE_NOEDITOR) );
if (E->get().next!=StringName())
- p_list->push_back( PropertyInfo( Variant::STRING, "next/"+String(E->key()), PROPERTY_HINT_NONE, "",PROPERTY_USAGE_NOEDITOR) );
+ anim_names.push_back( PropertyInfo( Variant::STRING, "next/"+String(E->key()), PROPERTY_HINT_NONE, "",PROPERTY_USAGE_NOEDITOR) );
names.push_back(E->key());
}
+ anim_names.sort();
+
+ for( List<PropertyInfo>::Element *E=anim_names.front();E;E=E->next()) {
+ p_list->push_back(E->get());
+ }
{
names.sort();
diff --git a/scene/audio/stream_player.cpp b/scene/audio/stream_player.cpp
index f7cfc31b03..fd18803394 100644
--- a/scene/audio/stream_player.cpp
+++ b/scene/audio/stream_player.cpp
@@ -100,11 +100,20 @@ void StreamPlayer::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE: {
//set_idle_process(false); //don't annoy
- if (stream.is_valid() && autoplay && !get_tree()->is_editor_hint())
- play();
+ if (stream.is_valid() && !get_tree()->is_editor_hint()) {
+ if (resume_pos>=0) {
+ play(resume_pos);
+ resume_pos=-1;
+ } else if (autoplay) {
+ play();
+ }
+ }
} break;
case NOTIFICATION_EXIT_TREE: {
+ if (is_playing()) {
+ resume_pos=get_pos();
+ }
stop(); //wathever it may be doing, stop
} break;
}
@@ -397,6 +406,7 @@ StreamPlayer::StreamPlayer() {
buffering_ms=500;
loop_point=0;
stop_request=false;
+ resume_pos=-1;
}
diff --git a/scene/audio/stream_player.h b/scene/audio/stream_player.h
index 30840137e2..475139c2a4 100644
--- a/scene/audio/stream_player.h
+++ b/scene/audio/stream_player.h
@@ -67,6 +67,7 @@ class StreamPlayer : public Node {
float loop_point;
int buffering_ms;
volatile bool stop_request;
+ float resume_pos;
AudioRBResampler resampler;
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index 862a5d6bcb..7b553543b6 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -64,7 +64,18 @@ void ColorPicker::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE: {
btn_pick->set_icon(get_icon("screen_picker", "ColorPicker"));
+ update_material(uv_material, color);
+ update_material(w_material, color);
+
+ uv_edit->get_child(0)->cast_to<Control>()->update();
+ w_edit->get_child(0)->cast_to<Control>()->update();
+ _update_color();
}
+
+ case NOTIFICATION_VISIBILITY_CHANGED: {
+ c_text->call_deferred("grab_focus");
+ c_text->call_deferred("select");
+ } break;
}
}
@@ -88,8 +99,13 @@ void ColorPicker::set_color(const Color& p_color) {
h=color.get_h();
s=color.get_s();
v=color.get_v();
+
+ if (!is_inside_tree())
+ return;
+
update_material(uv_material, color);
update_material(w_material, color);
+
uv_edit->get_child(0)->cast_to<Control>()->update();
w_edit->get_child(0)->cast_to<Control>()->update();
_update_color();
@@ -100,6 +116,10 @@ void ColorPicker::set_edit_alpha(bool p_show) {
edit_alpha=p_show;
_update_controls();
+
+ if (!is_inside_tree())
+ return;
+
_update_color();
sample->update();
}
@@ -136,6 +156,10 @@ void ColorPicker::_html_entered(const String& p_html) {
return;
color = Color::html(p_html);
+
+ if (!is_inside_tree())
+ return;
+
_update_color();
emit_signal("color_changed",color);
}
@@ -163,8 +187,6 @@ void ColorPicker::_update_color() {
} else {
c_text->set_text(color.to_html(edit_alpha && color.a<1));
}
- c_text->grab_focus();
- c_text->select();
sample->update();
updating=false;
@@ -225,6 +247,9 @@ void ColorPicker::set_raw_mode(bool p_enabled) {
if (btn_mode->is_pressed()!=p_enabled)
btn_mode->set_pressed(p_enabled);
+ if (!is_inside_tree())
+ return;
+
_update_controls();
_update_color();
}
@@ -531,7 +556,7 @@ ColorPicker::ColorPicker() :
_update_controls();
- _update_color();
+ //_update_color();
updating=false;
uv_material.instance();
@@ -594,6 +619,8 @@ void ColorPickerButton::pressed() {
popup->set_pos(get_global_pos()-Size2(0,ms.height));
popup->set_size(ms);
popup->popup();
+
+
}
void ColorPickerButton::_notification(int p_what) {
diff --git a/scene/gui/color_picker.h b/scene/gui/color_picker.h
index 59668ebac1..35f4ae7a99 100644
--- a/scene/gui/color_picker.h
+++ b/scene/gui/color_picker.h
@@ -89,6 +89,9 @@ private:
void _screen_input(const InputEvent& p_input);
void _add_preset_pressed();
void _screen_pick_pressed();
+
+friend class ColorPicker;
+
protected:
void _notification(int);
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index 71a0f50240..c319e306e0 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -1597,7 +1597,9 @@ bool Control::has_focus() const {
void Control::grab_focus() {
- ERR_FAIL_COND(!is_inside_tree());
+ if (!is_inside_tree()){
+ ERR_FAIL_COND(!is_inside_tree());
+ }
if (data.focus_mode==FOCUS_NONE)
return;
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 3b25701944..05b1e8bcea 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -482,7 +482,7 @@ void TreeItem::deselect(int p_column) {
_cell_deselected(p_column);
}
-void TreeItem::add_button(int p_column,const Ref<Texture>& p_button,int p_id) {
+void TreeItem::add_button(int p_column, const Ref<Texture>& p_button, int p_id, bool p_disabled) {
ERR_FAIL_INDEX( p_column, cells.size() );
@@ -492,6 +492,7 @@ void TreeItem::add_button(int p_column,const Ref<Texture>& p_button,int p_id) {
if (p_id<0)
p_id=cells[p_column].buttons.size();
button.id=p_id;
+ button.disabled=p_disabled;
cells[p_column].buttons.push_back(button);
_changed_notify(p_column);
}
@@ -533,6 +534,15 @@ int TreeItem::get_button_by_id(int p_column,int p_id) const {
return -1;
}
+
+bool TreeItem::is_button_disabled(int p_column, int p_idx) const {
+
+ ERR_FAIL_INDEX_V( p_column, cells.size(), false );
+ ERR_FAIL_INDEX_V( p_idx, cells[p_column].buttons.size(), false );
+
+ return cells[p_column].buttons[p_idx].disabled;
+
+}
void TreeItem::set_button(int p_column,int p_idx,const Ref<Texture>& p_button){
ERR_FAIL_COND( p_button.is_null() );
@@ -672,10 +682,11 @@ void TreeItem::_bind_methods() {
ObjectTypeDB::bind_method(_MD("clear_custom_bg_color","column"),&TreeItem::clear_custom_bg_color);
ObjectTypeDB::bind_method(_MD("get_custom_bg_color","column"),&TreeItem::get_custom_bg_color);
- ObjectTypeDB::bind_method(_MD("add_button","column","button:Texture","button_idx"),&TreeItem::add_button);
+ ObjectTypeDB::bind_method(_MD("add_button","column","button:Texture","button_idx","disabled"),&TreeItem::add_button,DEFVAL(-1),DEFVAL(false));
ObjectTypeDB::bind_method(_MD("get_button_count","column"),&TreeItem::get_button_count);
ObjectTypeDB::bind_method(_MD("get_button:Texture","column","button_idx"),&TreeItem::get_button);
ObjectTypeDB::bind_method(_MD("erase_button","column","button_idx"),&TreeItem::erase_button);
+ ObjectTypeDB::bind_method(_MD("is_button_disabled","column","button_idx"),&TreeItem::is_button_disabled);
ObjectTypeDB::bind_method(_MD("set_tooltip","column","tooltip"),&TreeItem::set_tooltip);
ObjectTypeDB::bind_method(_MD("get_tooltip","column"),&TreeItem::get_tooltip);
@@ -1015,14 +1026,15 @@ int Tree::draw_item(const Point2i& p_pos,const Point2& p_draw_ofs, const Size2&
Point2i o = Point2i( ofs+w-s.width, p_pos.y )-cache.offset+p_draw_ofs;
- if (cache.click_type==Cache::CLICK_BUTTON && cache.click_item==p_item && cache.click_column==i) {
+ if (cache.click_type==Cache::CLICK_BUTTON && cache.click_item==p_item && cache.click_column==i && !p_item->cells[i].buttons[j].disabled) {
//being pressed
cache.button_pressed->draw(get_canvas_item(),Rect2(o,s));
}
o.y+=(label_h-s.height)/2;
o+=cache.button_pressed->get_offset();
- b->draw(ci,o);
+
+ b->draw(ci,o,p_item->cells[i].buttons[j].disabled?Color(1,1,1,0.5):Color(1,1,1,1));
w-=s.width+cache.button_margin;
bw+=s.width+cache.button_margin;
}
@@ -1472,7 +1484,13 @@ int Tree::propagate_mouse_event(const Point2i &p_pos,int x_ofs,int y_ofs,bool p_
for(int j=c.buttons.size()-1;j>=0;j--) {
Ref<Texture> b=c.buttons[j].texture;
int w = b->get_size().width + cache.button_pressed->get_minimum_size().width;
+
if (x>col_width-w) {
+ if (c.buttons[j].disabled) {
+ pressed_button=-1;
+ cache.click_type=Cache::CLICK_NONE;
+ return -1;
+ }
pressed_button=j;
cache.click_type=Cache::CLICK_BUTTON;
cache.click_index=j;
diff --git a/scene/gui/tree.h b/scene/gui/tree.h
index e4d349978c..e5c95b4d66 100644
--- a/scene/gui/tree.h
+++ b/scene/gui/tree.h
@@ -86,8 +86,9 @@ friend class Tree;
struct Button {
int id;
+ bool disabled;
Ref<Texture> texture;
- Button() { id=0; }
+ Button() { id=0; disabled=false; }
};
Vector< Button > buttons;
@@ -172,12 +173,13 @@ public:
void set_icon_max_width(int p_column,int p_max);
int get_icon_max_width(int p_column) const;
- void add_button(int p_column,const Ref<Texture>& p_button,int p_id=-1);
+ void add_button(int p_column,const Ref<Texture>& p_button,int p_id=-1,bool p_disabled=false);
int get_button_count(int p_column) const;
Ref<Texture> get_button(int p_column,int p_idx) const;
int get_button_id(int p_column,int p_idx) const;
void erase_button(int p_column,int p_idx);
int get_button_by_id(int p_column,int p_id) const;
+ bool is_button_disabled(int p_column,int p_idx) const;
void set_button(int p_column,int p_idx,const Ref<Texture>& p_button);
/* range works for mode number or mode combo */
diff --git a/scene/main/timer.cpp b/scene/main/timer.cpp
index 2c23b62b12..a118bc9782 100644
--- a/scene/main/timer.cpp
+++ b/scene/main/timer.cpp
@@ -42,6 +42,7 @@ void Timer::_notification(int p_what) {
break;
#endif
start();
+ autostart=false;
}
} break;
case NOTIFICATION_PROCESS: {
diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp
index f713b9e979..2c22c81455 100644
--- a/scene/resources/default_theme/default_theme.cpp
+++ b/scene/resources/default_theme/default_theme.cpp
@@ -264,8 +264,8 @@ void make_default_theme() {
// ToolButton
Ref<StyleBox> tb_empty = memnew( StyleBoxEmpty );
- tb_empty->set_default_margin(MARGIN_LEFT,8);
- tb_empty->set_default_margin(MARGIN_RIGHT,8);
+ tb_empty->set_default_margin(MARGIN_LEFT,6);
+ tb_empty->set_default_margin(MARGIN_RIGHT,6);
tb_empty->set_default_margin(MARGIN_TOP,4);
tb_empty->set_default_margin(MARGIN_BOTTOM,4);