summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/color_picker.cpp2
-rw-r--r--scene/gui/control.cpp2
-rw-r--r--scene/gui/dialogs.cpp4
-rw-r--r--scene/gui/line_edit.cpp2
-rw-r--r--scene/gui/popup.cpp4
-rw-r--r--scene/gui/reference_rect.cpp4
-rw-r--r--scene/gui/spin_box.cpp2
-rw-r--r--scene/gui/text_edit.cpp16
-rw-r--r--scene/gui/text_edit.h4
-rw-r--r--scene/gui/texture_progress.cpp4
-rw-r--r--scene/gui/video_player.cpp2
11 files changed, 34 insertions, 12 deletions
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index 5e110362c8..5257f9df35 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -204,7 +204,7 @@ void ColorPicker::_update_presets() {
}
void ColorPicker::_text_type_toggled() {
- if (!get_tree()->is_editor_hint())
+ if (!Engine::get_singleton()->is_editor_hint())
return;
text_is_constructor = !text_is_constructor;
if (text_is_constructor) {
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index 08ff12f878..6a3ef66e0a 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -1329,7 +1329,7 @@ void Control::set_anchor(Margin p_margin, float p_anchor, bool p_keep_margin, bo
void Control::_set_anchor(Margin p_margin, float p_anchor) {
#ifdef TOOLS_ENABLED
- if (is_inside_tree() && get_tree()->is_editor_hint()) {
+ if (is_inside_tree() && Engine::get_singleton()->is_editor_hint()) {
set_anchor(p_margin, p_anchor, EDITOR_DEF("editors/2d/keep_margins_when_changing_anchors", false));
} else {
set_anchor(p_margin, p_anchor, false);
diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp
index ef8b0adfa9..b911a18312 100644
--- a/scene/gui/dialogs.cpp
+++ b/scene/gui/dialogs.cpp
@@ -227,11 +227,11 @@ void WindowDialog::_notification(int p_what) {
} break;
#ifdef TOOLS_ENABLED
case NOTIFICATION_POST_POPUP: {
- if (get_tree() && get_tree()->is_editor_hint() && EditorNode::get_singleton())
+ if (get_tree() && Engine::get_singleton()->is_editor_hint() && EditorNode::get_singleton())
EditorNode::get_singleton()->dim_editor(true);
} break;
case NOTIFICATION_POPUP_HIDE: {
- if (get_tree() && get_tree()->is_editor_hint() && EditorNode::get_singleton())
+ if (get_tree() && Engine::get_singleton()->is_editor_hint() && EditorNode::get_singleton())
EditorNode::get_singleton()->dim_editor(false);
} break;
#endif
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index 24c1f73667..c5360b0df0 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -534,7 +534,7 @@ void LineEdit::_notification(int p_what) {
switch (p_what) {
#ifdef TOOLS_ENABLED
case NOTIFICATION_ENTER_TREE: {
- if (get_tree()->is_editor_hint()) {
+ if (Engine::get_singleton()->is_editor_hint()) {
cursor_set_blink_enabled(EDITOR_DEF("text_editor/cursor/caret_blink", false));
cursor_set_blink_speed(EDITOR_DEF("text_editor/cursor/caret_blink_speed", 0.65));
diff --git a/scene/gui/popup.cpp b/scene/gui/popup.cpp
index ebf18bad41..4725300a5f 100644
--- a/scene/gui/popup.cpp
+++ b/scene/gui/popup.cpp
@@ -28,6 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "popup.h"
+
+#include "engine.h"
#include "os/keyboard.h"
void Popup::_gui_input(Ref<InputEvent> p_event) {
@@ -48,7 +50,7 @@ void Popup::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
//small helper to make editing of these easier in editor
#ifdef TOOLS_ENABLED
- if (get_tree()->is_editor_hint() && get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root()->is_a_parent_of(this)) {
+ if (Engine::get_singleton()->is_editor_hint() && get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root()->is_a_parent_of(this)) {
set_as_toplevel(false);
}
#endif
diff --git a/scene/gui/reference_rect.cpp b/scene/gui/reference_rect.cpp
index 400ff299a9..441c3e721b 100644
--- a/scene/gui/reference_rect.cpp
+++ b/scene/gui/reference_rect.cpp
@@ -29,13 +29,15 @@
/*************************************************************************/
#include "reference_rect.h"
+#include "engine.h"
+
void ReferenceRect::_notification(int p_what) {
if (p_what == NOTIFICATION_DRAW) {
if (!is_inside_tree())
return;
- if (get_tree()->is_editor_hint())
+ if (Engine::get_singleton()->is_editor_hint())
draw_style_box(get_stylebox("border"), Rect2(Point2(), get_size()));
}
}
diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp
index c5b9df15b9..751edc5a43 100644
--- a/scene/gui/spin_box.cpp
+++ b/scene/gui/spin_box.cpp
@@ -192,7 +192,7 @@ void SpinBox::_notification(int p_what) {
int w = updown->get_width();
if (w != last_w) {
- line_edit->set_margin(MARGIN_RIGHT, w);
+ line_edit->set_margin(MARGIN_RIGHT, -w);
last_w = w;
}
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 1ae347c79b..0ed2487e5e 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -429,7 +429,7 @@ void TextEdit::_notification(int p_what) {
if (scrolling && v_scroll->get_value() != target_v_scroll) {
double target_y = target_v_scroll - v_scroll->get_value();
double dist = sqrt(target_y * target_y);
- double vel = ((target_y / dist) * 50) * get_fixed_process_delta_time();
+ double vel = ((target_y / dist) * v_scroll_speed) * get_fixed_process_delta_time();
if (vel >= dist) {
v_scroll->set_value(target_v_scroll);
@@ -459,7 +459,7 @@ void TextEdit::_notification(int p_what) {
int line_number_char_count = 0;
{
- int lc = text.size() + 1;
+ int lc = text.size();
cache.line_number_w = 0;
while (lc) {
cache.line_number_w += 1;
@@ -4264,6 +4264,14 @@ bool TextEdit::is_smooth_scroll_enabled() const {
return smooth_scroll_enabled;
}
+void TextEdit::set_v_scroll_speed(float p_speed) {
+ v_scroll_speed = p_speed;
+}
+
+float TextEdit::get_v_scroll_speed() const {
+ return v_scroll_speed;
+}
+
void TextEdit::set_completion(bool p_enabled, const Vector<String> &p_prefixes) {
completion_prefixes.clear();
@@ -4766,6 +4774,8 @@ void TextEdit::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_smooth_scroll_enable", "enable"), &TextEdit::set_smooth_scroll_enabled);
ClassDB::bind_method(D_METHOD("is_smooth_scroll_enabled"), &TextEdit::is_smooth_scroll_enabled);
+ ClassDB::bind_method(D_METHOD("set_v_scroll_speed", "speed"), &TextEdit::set_v_scroll_speed);
+ ClassDB::bind_method(D_METHOD("get_v_scroll_speed"), &TextEdit::get_v_scroll_speed);
ClassDB::bind_method(D_METHOD("add_keyword_color", "keyword", "color"), &TextEdit::add_keyword_color);
ClassDB::bind_method(D_METHOD("add_color_region", "begin_key", "end_key", "color", "line_only"), &TextEdit::add_color_region, DEFVAL(false));
@@ -4777,6 +4787,7 @@ void TextEdit::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "show_line_numbers"), "set_show_line_numbers", "is_show_line_numbers_enabled");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "highlight_all_occurrences"), "set_highlight_all_occurrences", "is_highlight_all_occurrences_enabled");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "smooth_scrolling"), "set_smooth_scroll_enable", "is_smooth_scroll_enabled");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "v_scroll_speed"), "set_v_scroll_speed", "get_v_scroll_speed");
ADD_GROUP("Caret", "caret_");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "caret_block_mode"), "cursor_set_block_mode", "cursor_is_block_mode");
@@ -4916,6 +4927,7 @@ TextEdit::TextEdit() {
smooth_scroll_enabled = false;
scrolling = false;
target_v_scroll = 0;
+ v_scroll_speed = 80;
raised_from_completion = false;
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index 96d6625bc4..1abfe368dd 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -259,6 +259,7 @@ class TextEdit : public Control {
bool smooth_scroll_enabled;
bool scrolling;
float target_v_scroll;
+ float v_scroll_speed;
bool raised_from_completion;
@@ -494,6 +495,9 @@ public:
void set_smooth_scroll_enabled(bool p_enable);
bool is_smooth_scroll_enabled() const;
+ void set_v_scroll_speed(float p_speed);
+ float get_v_scroll_speed() const;
+
uint32_t get_version() const;
uint32_t get_saved_version() const;
void tag_saved_version();
diff --git a/scene/gui/texture_progress.cpp b/scene/gui/texture_progress.cpp
index b45c783919..08025452d8 100644
--- a/scene/gui/texture_progress.cpp
+++ b/scene/gui/texture_progress.cpp
@@ -29,6 +29,8 @@
/*************************************************************************/
#include "texture_progress.h"
+#include "engine.h"
+
void TextureProgress::set_under_texture(const Ref<Texture> &p_texture) {
under = p_texture;
@@ -179,7 +181,7 @@ void TextureProgress::_notification(int p_what) {
}
draw_polygon(points, Vector<Color>(), uvs, progress);
}
- if (get_tree()->is_editor_hint()) {
+ if (Engine::get_singleton()->is_editor_hint()) {
Point2 p = progress->get_size();
p.x *= get_relative_center().x;
p.y *= get_relative_center().y;
diff --git a/scene/gui/video_player.cpp b/scene/gui/video_player.cpp
index 9c018a4e7c..4886b1cc26 100644
--- a/scene/gui/video_player.cpp
+++ b/scene/gui/video_player.cpp
@@ -116,7 +116,7 @@ void VideoPlayer::_notification(int p_notification) {
case NOTIFICATION_ENTER_TREE: {
- if (stream.is_valid() && autoplay && !get_tree()->is_editor_hint()) {
+ if (stream.is_valid() && autoplay && !Engine::get_singleton()->is_editor_hint()) {
play();
}
} break;