summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/gui/item_list.cpp35
-rw-r--r--scene/gui/text_edit.cpp6
-rw-r--r--scene/gui/text_edit.h7
-rw-r--r--scene/gui/tree.cpp31
-rw-r--r--scene/gui/tree.h3
-rw-r--r--scene/gui/video_player.cpp3
-rw-r--r--scene/io/resource_format_image.cpp118
-rw-r--r--scene/io/resource_format_image.h2
-rw-r--r--scene/resources/default_theme/default_theme.cpp2
9 files changed, 128 insertions, 79 deletions
diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp
index 89cd509fbd..f69ad8fa7e 100644
--- a/scene/gui/item_list.cpp
+++ b/scene/gui/item_list.cpp
@@ -959,7 +959,23 @@ void ItemList::_notification(int p_what) {
shape_changed=false;
}
+ //ensure_selected_visible needs to be checked before we draw the list.
+ if (ensure_selected_visible && current>=0 && current <=items.size()) {
+ Rect2 r = items[current].rect_cache;
+ int from = scroll_bar->get_val();
+ int to = from + scroll_bar->get_page();
+
+ if (r.pos.y < from) {
+ scroll_bar->set_val(r.pos.y);
+ } else if (r.pos.y+r.size.y > to) {
+ scroll_bar->set_val(r.pos.y+r.size.y - (to-from));
+ }
+
+
+ }
+
+ ensure_selected_visible=false;
Vector2 base_ofs = bg->get_offset();
base_ofs.y-=int(scroll_bar->get_val());
@@ -1147,25 +1163,6 @@ void ItemList::_notification(int p_what) {
for(int i=0;i<separators.size();i++) {
draw_line(Vector2(bg->get_margin(MARGIN_LEFT),base_ofs.y+separators[i]),Vector2(size.width-bg->get_margin(MARGIN_LEFT),base_ofs.y+separators[i]),guide_color);
}
-
-
- if (ensure_selected_visible && current>=0 && current <=items.size()) {
-
- Rect2 r = items[current].rect_cache;
- int from = scroll_bar->get_val();
- int to = from + scroll_bar->get_page();
-
- if (r.pos.y < from) {
- scroll_bar->set_val(r.pos.y);
- } else if (r.pos.y+r.size.y > to) {
- scroll_bar->set_val(r.pos.y+r.size.y - (to-from));
- }
-
-
- }
-
- ensure_selected_visible=false;
-
}
}
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 8a9ed98a5f..14508e07a8 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -1651,7 +1651,7 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
update();
}
- if (mb.button_index==BUTTON_RIGHT) {
+ if (mb.button_index==BUTTON_RIGHT && context_menu_enabled) {
menu->set_pos(get_global_transform().xform(get_local_mouse_pos()));
menu->set_size(Vector2(1,1));
@@ -4569,6 +4569,9 @@ bool TextEdit::is_selecting_identifiers_on_hover_enabled() const {
return select_identifiers_enabled;
}
+void TextEdit::set_context_menu_enabled(bool p_enable) {
+ context_menu_enabled = p_enable;
+}
PopupMenu *TextEdit::get_menu() const {
return menu;
@@ -4789,6 +4792,7 @@ TextEdit::TextEdit() {
window_has_focus=true;
select_identifiers_enabled=false;
+ context_menu_enabled=true;
menu = memnew( PopupMenu );
add_child(menu);
menu->add_item(TTR("Cut"),MENU_CUT,KEY_MASK_CMD|KEY_X);
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index cb49618f18..37477e3b7e 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -269,6 +269,8 @@ class TextEdit : public Control {
int search_result_line;
int search_result_col;
+ bool context_menu_enabled;
+
int get_visible_rows() const;
int get_char_count();
@@ -319,8 +321,6 @@ class TextEdit : public Control {
void _confirm_completion();
void _update_completion_candidates();
- void _get_mouse_pos(const Point2i& p_mouse, int &r_row, int &r_col) const;
-
protected:
virtual String get_tooltip(const Point2& p_pos) const;
@@ -360,6 +360,8 @@ public:
virtual CursorShape get_cursor_shape(const Point2& p_pos=Point2i()) const;
+ void _get_mouse_pos(const Point2i& p_mouse, int &r_row, int &r_col) const;
+
//void delete_char();
//void delete_line();
@@ -499,6 +501,7 @@ public:
void set_select_identifiers_on_hover(bool p_enable);
bool is_selecting_identifiers_on_hover_enabled() const;
+ void set_context_menu_enabled(bool p_enable);
PopupMenu *get_menu() const;
String get_text_for_completion();
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 20794b2faa..5a614fb1b2 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -32,6 +32,7 @@
#include "os/keyboard.h"
#include "globals.h"
#include "os/input.h"
+#include "scene/main/viewport.h"
@@ -829,6 +830,8 @@ void Tree::update_cache() {
cache.guide_width=get_constant("guide_width");
cache.draw_relationship_lines=get_constant("draw_relationship_lines");
cache.relationship_line_color=get_color("relationship_line_color");
+ cache.scroll_border=get_constant("scroll_border");
+ cache.scroll_speed=get_constant("scroll_speed");
cache.title_button = get_stylebox("title_button_normal");
cache.title_button_pressed = get_stylebox("title_button_pressed");
@@ -2681,11 +2684,17 @@ void Tree::_notification(int p_what) {
if (p_what==NOTIFICATION_DRAG_END) {
drop_mode_flags=0;
+ scrolling = false;
+ set_fixed_process(false);
update();
}
if (p_what==NOTIFICATION_DRAG_BEGIN) {
single_select_defer=NULL;
+ if (cache.scroll_speed > 0 && get_rect().has_point(get_viewport()->get_mouse_pos() - get_global_pos())) {
+ scrolling = true;
+ set_fixed_process(true);
+ }
}
if (p_what==NOTIFICATION_FIXED_PROCESS) {
@@ -2731,6 +2740,28 @@ void Tree::_notification(int p_what) {
}
}
+
+ if (scrolling) {
+ Point2 point = get_viewport()->get_mouse_pos() - get_global_pos();
+ if (point.x < cache.scroll_border) {
+ point.x -= cache.scroll_border;
+ } else if (point.x > get_size().width - cache.scroll_border) {
+ point.x -= get_size().width - cache.scroll_border;
+ } else {
+ point.x = 0;
+ }
+ if (point.y < cache.scroll_border) {
+ point.y -= cache.scroll_border;
+ } else if (point.y > get_size().height - cache.scroll_border) {
+ point.y -= get_size().height - cache.scroll_border;
+ } else {
+ point.y = 0;
+ }
+ point *= cache.scroll_speed * get_fixed_process_delta_time();
+ point += get_scroll();
+ h_scroll->set_val(point.x);
+ v_scroll->set_val(point.y);
+ }
}
if (p_what==NOTIFICATION_DRAW) {
diff --git a/scene/gui/tree.h b/scene/gui/tree.h
index 2124dce749..6c2f1dae40 100644
--- a/scene/gui/tree.h
+++ b/scene/gui/tree.h
@@ -390,6 +390,8 @@ friend class TreeItem;
int button_margin;
Point2 offset;
int draw_relationship_lines;
+ int scroll_border;
+ int scroll_speed;
enum ClickType {
CLICK_NONE,
@@ -448,6 +450,7 @@ friend class TreeItem;
bool drag_touching_deaccel;
bool click_handled;
bool allow_rmb_select;
+ bool scrolling;
bool force_select_on_already_selected;
diff --git a/scene/gui/video_player.cpp b/scene/gui/video_player.cpp
index 1be847929d..335672126c 100644
--- a/scene/gui/video_player.cpp
+++ b/scene/gui/video_player.cpp
@@ -248,7 +248,7 @@ void VideoPlayer::stop() {
playback->stop();
AudioServer::get_singleton()->stream_set_active(stream_rid,false);
- resampler.clear();
+ resampler.flush();
set_process(false);
last_audio_time=0;
};
@@ -426,5 +426,6 @@ VideoPlayer::~VideoPlayer() {
if (stream_rid.is_valid())
AudioServer::get_singleton()->free(stream_rid);
+ resampler.clear(); //Not necessary here, but make in consistent with other "stream_player" classes
};
diff --git a/scene/io/resource_format_image.cpp b/scene/io/resource_format_image.cpp
index f3a0eaa8c4..55ad23ba93 100644
--- a/scene/io/resource_format_image.cpp
+++ b/scene/io/resource_format_image.cpp
@@ -136,61 +136,7 @@ RES ResourceFormatLoaderImage::load(const String &p_path, const String& p_origin
#endif
- uint32_t flags=0;
-
- FileAccess *f2 = FileAccess::open(p_path+".flags",FileAccess::READ);
- Map<String,bool> flags_found;
- if (f2) {
-
- while(!f2->eof_reached()) {
- String l2 = f2->get_line();
- int eqpos = l2.find("=");
- if (eqpos!=-1) {
- String flag=l2.substr(0,eqpos).strip_edges();
- String val=l2.substr(eqpos+1,l2.length()).strip_edges().to_lower();
- flags_found[flag]=(val=="true" || val=="1")?true:false;
- }
- }
- memdelete(f2);
- }
-
-
- if (flags_found.has("filter")) {
- if (flags_found["filter"])
- flags|=Texture::FLAG_FILTER;
- } else if (bool(GLOBAL_DEF("image_loader/filter",true))) {
- flags|=Texture::FLAG_FILTER;
- }
-
-
- if (flags_found.has("gen_mipmaps")) {
- if (flags_found["gen_mipmaps"])
- flags|=Texture::FLAG_MIPMAPS;
- } else if (bool(GLOBAL_DEF("image_loader/gen_mipmaps",true))) {
- flags|=Texture::FLAG_MIPMAPS;
- }
-
- if (flags_found.has("repeat")) {
- if (flags_found["repeat"])
- flags|=Texture::FLAG_REPEAT;
- } else if (bool(GLOBAL_DEF("image_loader/repeat",true))) {
- flags|=Texture::FLAG_REPEAT;
- }
-
- if (flags_found.has("anisotropic")) {
- if (flags_found["anisotropic"])
- flags|=Texture::FLAG_ANISOTROPIC_FILTER;
- }
-
- if (flags_found.has("tolinear")) {
- if (flags_found["tolinear"])
- flags|=Texture::FLAG_CONVERT_TO_LINEAR;
- }
-
- if (flags_found.has("mirroredrepeat")) {
- if (flags_found["mirroredrepeat"])
- flags|=Texture::FLAG_MIRRORED_REPEAT;
- }
+ uint32_t flags=load_image_flags(p_path);
if (debug_load_times)
begtime=OS::get_singleton()->get_ticks_usec();
@@ -214,6 +160,68 @@ RES ResourceFormatLoaderImage::load(const String &p_path, const String& p_origin
}
+uint32_t ResourceFormatLoaderImage::load_image_flags(const String &p_path) {
+
+
+ FileAccess *f2 = FileAccess::open(p_path+".flags",FileAccess::READ);
+ Map<String,bool> flags_found;
+ if (f2) {
+
+ while(!f2->eof_reached()) {
+ String l2 = f2->get_line();
+ int eqpos = l2.find("=");
+ if (eqpos!=-1) {
+ String flag=l2.substr(0,eqpos).strip_edges();
+ String val=l2.substr(eqpos+1,l2.length()).strip_edges().to_lower();
+ flags_found[flag]=(val=="true" || val=="1")?true:false;
+ }
+ }
+ memdelete(f2);
+ }
+
+
+ uint32_t flags=0;
+
+ if (flags_found.has("filter")) {
+ if (flags_found["filter"])
+ flags|=Texture::FLAG_FILTER;
+ } else if (bool(GLOBAL_DEF("image_loader/filter",true))) {
+ flags|=Texture::FLAG_FILTER;
+ }
+
+
+ if (flags_found.has("gen_mipmaps")) {
+ if (flags_found["gen_mipmaps"])
+ flags|=Texture::FLAG_MIPMAPS;
+ } else if (bool(GLOBAL_DEF("image_loader/gen_mipmaps",true))) {
+ flags|=Texture::FLAG_MIPMAPS;
+ }
+
+ if (flags_found.has("repeat")) {
+ if (flags_found["repeat"])
+ flags|=Texture::FLAG_REPEAT;
+ } else if (bool(GLOBAL_DEF("image_loader/repeat",true))) {
+ flags|=Texture::FLAG_REPEAT;
+ }
+
+ if (flags_found.has("anisotropic")) {
+ if (flags_found["anisotropic"])
+ flags|=Texture::FLAG_ANISOTROPIC_FILTER;
+ }
+
+ if (flags_found.has("tolinear")) {
+ if (flags_found["tolinear"])
+ flags|=Texture::FLAG_CONVERT_TO_LINEAR;
+ }
+
+ if (flags_found.has("mirroredrepeat")) {
+ if (flags_found["mirroredrepeat"])
+ flags|=Texture::FLAG_MIRRORED_REPEAT;
+ }
+
+ return flags;
+}
+
bool ResourceFormatLoaderImage::handles_type(const String& p_type) const {
return ObjectTypeDB::is_type(p_type,"Texture") || ObjectTypeDB::is_type(p_type,"CubeMap");
diff --git a/scene/io/resource_format_image.h b/scene/io/resource_format_image.h
index 6388aa641f..cce6ffab83 100644
--- a/scene/io/resource_format_image.h
+++ b/scene/io/resource_format_image.h
@@ -39,8 +39,8 @@ class ResourceFormatLoaderImage : public ResourceFormatLoader {
bool debug_load_times;
int max_texture_size;
public:
-
virtual RES load(const String &p_path,const String& p_original_path="",Error *r_error=NULL);
+ static uint32_t load_image_flags(const String &p_path);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
virtual bool handles_type(const String& p_type) const;
virtual String get_resource_type(const String &p_path) const;
diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp
index dea612735c..0740b591c4 100644
--- a/scene/resources/default_theme/default_theme.cpp
+++ b/scene/resources/default_theme/default_theme.cpp
@@ -714,6 +714,8 @@ void fill_default_theme(Ref<Theme>& t, const Ref<Font> & default_font, const Ref
t->set_constant("item_margin","Tree",12 *scale);
t->set_constant("button_margin","Tree",4 *scale);
t->set_constant("draw_relationship_lines", "Tree", 0);
+ t->set_constant("scroll_border", "Tree", 4);
+ t->set_constant("scroll_speed", "Tree", 12);
// ItemList