Merge pull request #10508 from Paulb23/increase_smooth_scroll_speed

Increased smooth scroll speed and added user setting
This commit is contained in:
Rémi Verschelde 2017-08-21 22:19:18 +02:00 committed by GitHub
commit 328452e028
4 changed files with 19 additions and 1 deletions

View file

@ -1088,6 +1088,7 @@ void CodeTextEditor::update_editor_settings() {
text_editor->set_draw_breakpoint_gutter(EditorSettings::get_singleton()->get("text_editor/line_numbers/show_breakpoint_gutter"));
text_editor->cursor_set_block_mode(EditorSettings::get_singleton()->get("text_editor/cursor/block_caret"));
text_editor->set_smooth_scroll_enabled(EditorSettings::get_singleton()->get("text_editor/open_scripts/smooth_scrolling"));
text_editor->set_v_scroll_speed(EditorSettings::get_singleton()->get("text_editor/open_scripts/v_scroll_speed"));
}
void CodeTextEditor::set_error(const String &p_error) {

View file

@ -616,6 +616,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
hints["text_editor/line_numbers/line_length_guideline_column"] = PropertyInfo(Variant::INT, "text_editor/line_numbers/line_length_guideline_column", PROPERTY_HINT_RANGE, "20, 160, 10");
set("text_editor/open_scripts/smooth_scrolling", true);
set("text_editor/open_scripts/v_scroll_speed", 80);
set("text_editor/open_scripts/show_members_overview", true);
set("text_editor/files/trim_trailing_whitespace_on_save", false);

View file

@ -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);
@ -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;

View file

@ -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();