Cleanup and expose viewport / scrolling methods
This commit is contained in:
parent
7dbb0f3233
commit
0a32a6907b
|
@ -50,6 +50,13 @@
|
|||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="adjust_viewport_to_caret">
|
||||
<return type="void">
|
||||
</return>
|
||||
<description>
|
||||
Adjust the viewport so the caret is visible.
|
||||
</description>
|
||||
</method>
|
||||
<method name="backspace">
|
||||
<return type="void" />
|
||||
<description>
|
||||
|
@ -135,6 +142,13 @@
|
|||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_first_visible_line" qualifiers="const">
|
||||
<return type="int">
|
||||
</return>
|
||||
<description>
|
||||
Returns the first visible line.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_gutter_count" qualifiers="const">
|
||||
<return type="int" />
|
||||
<description>
|
||||
|
@ -165,6 +179,20 @@
|
|||
Returns the indent level of a specific line.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_last_full_visible_line" qualifiers="const">
|
||||
<return type="int">
|
||||
</return>
|
||||
<description>
|
||||
Return the last visible line. Use [method get_last_full_visible_line_wrap_index] for the wrap index.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_last_full_visible_line_wrap_index" qualifiers="const">
|
||||
<return type="int">
|
||||
</return>
|
||||
<description>
|
||||
Returns the last visible wrap index of the last visible line.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_line" qualifiers="const">
|
||||
<return type="String" />
|
||||
<argument index="0" name="line" type="int" />
|
||||
|
@ -248,6 +276,13 @@
|
|||
Returns the [PopupMenu] of this [TextEdit]. By default, this menu is displayed when right-clicking on the [TextEdit].
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_minimap_visible_lines" qualifiers="const">
|
||||
<return type="int">
|
||||
</return>
|
||||
<description>
|
||||
Gets the total amount of lines that can be draw on the minimap.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_opentype_feature" qualifiers="const">
|
||||
<return type="int" />
|
||||
<argument index="0" name="tag" type="String" />
|
||||
|
@ -255,6 +290,24 @@
|
|||
Returns OpenType feature [code]tag[/code].
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_scroll_pos_for_line" qualifiers="const">
|
||||
<return type="float">
|
||||
</return>
|
||||
<argument index="0" name="line" type="int">
|
||||
</argument>
|
||||
<argument index="1" name="wrap_index" type="int" default="0">
|
||||
</argument>
|
||||
<description>
|
||||
Gets the scroll position for [code]wrap_index[/code] of [code]line[/code].
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_selected_text" qualifiers="const">
|
||||
<return type="String">
|
||||
</return>
|
||||
<description>
|
||||
Returns the text inside the selection.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_selection_column" qualifiers="const">
|
||||
<return type="int" />
|
||||
<description>
|
||||
|
@ -282,12 +335,6 @@
|
|||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_selection_text" qualifiers="const">
|
||||
<return type="String" />
|
||||
<description>
|
||||
Returns the text inside the selection.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_selection_to_column" qualifiers="const">
|
||||
<return type="int" />
|
||||
<description>
|
||||
|
@ -311,6 +358,13 @@
|
|||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_total_visible_line_count" qualifiers="const">
|
||||
<return type="int">
|
||||
</return>
|
||||
<description>
|
||||
Gets the total amount of lines that could be draw.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_visible_line_count" qualifiers="const">
|
||||
<return type="int" />
|
||||
<description>
|
||||
|
@ -571,6 +625,39 @@
|
|||
Sets the text for a specific line.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_line_as_center_visible">
|
||||
<return type="void">
|
||||
</return>
|
||||
<argument index="0" name="line" type="int">
|
||||
</argument>
|
||||
<argument index="1" name="wrap_index" type="int" default="0">
|
||||
</argument>
|
||||
<description>
|
||||
Positions the [code]wrap_index[/code] of [code]line[/code] at the center of the viewport.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_line_as_first_visible">
|
||||
<return type="void">
|
||||
</return>
|
||||
<argument index="0" name="line" type="int">
|
||||
</argument>
|
||||
<argument index="1" name="wrap_index" type="int" default="0">
|
||||
</argument>
|
||||
<description>
|
||||
Positions the [code]wrap_index[/code] of [code]line[/code] at the top of the viewport.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_line_as_last_visible">
|
||||
<return type="void">
|
||||
</return>
|
||||
<argument index="0" name="line" type="int">
|
||||
</argument>
|
||||
<argument index="1" name="wrap_index" type="int" default="0">
|
||||
</argument>
|
||||
<description>
|
||||
Positions the [code]wrap_index[/code] of [code]line[/code] at the bottom of the viewport.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_line_background_color">
|
||||
<return type="void" />
|
||||
<argument index="0" name="line" type="int" />
|
||||
|
@ -714,6 +801,9 @@
|
|||
<member name="scroll_horizontal" type="int" setter="set_h_scroll" getter="get_h_scroll" default="0">
|
||||
If there is a horizontal scrollbar, this determines the current horizontal scroll value in pixels.
|
||||
</member>
|
||||
<member name="scroll_past_end_of_file" type="bool" setter="set_scroll_past_end_of_file_enabled" getter="is_scroll_past_end_of_file_enabled" default="false">
|
||||
Allow scrolling past the last line into "virtual" space.
|
||||
</member>
|
||||
<member name="scroll_vertical" type="float" setter="set_v_scroll" getter="get_v_scroll" default="0.0">
|
||||
If there is a vertical scrollbar, this determines the current vertical scroll value in line numbers, starting at 0 for the top line.
|
||||
</member>
|
||||
|
|
|
@ -951,7 +951,7 @@ void CodeTextEditor::update_editor_settings() {
|
|||
text_editor->set_line_folding_enabled(EditorSettings::get_singleton()->get("text_editor/appearance/code_folding"));
|
||||
text_editor->set_draw_fold_gutter(EditorSettings::get_singleton()->get("text_editor/appearance/code_folding"));
|
||||
text_editor->set_line_wrapping_mode((TextEdit::LineWrappingMode)EditorSettings::get_singleton()->get("text_editor/appearance/word_wrap").operator int());
|
||||
text_editor->set_scroll_pass_end_of_file(EditorSettings::get_singleton()->get("text_editor/cursor/scroll_past_end_of_file"));
|
||||
text_editor->set_scroll_past_end_of_file_enabled(EditorSettings::get_singleton()->get("text_editor/cursor/scroll_past_end_of_file"));
|
||||
text_editor->set_caret_type((TextEdit::CaretType)EditorSettings::get_singleton()->get("text_editor/cursor/type").operator int());
|
||||
text_editor->set_caret_blink_enabled(EditorSettings::get_singleton()->get("text_editor/cursor/caret_blink"));
|
||||
text_editor->set_caret_blink_speed(EditorSettings::get_singleton()->get("text_editor/cursor/caret_blink_speed"));
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -280,6 +280,53 @@ private:
|
|||
|
||||
void _update_caret_wrap_offset();
|
||||
|
||||
/* Viewport. */
|
||||
HScrollBar *h_scroll;
|
||||
VScrollBar *v_scroll;
|
||||
|
||||
bool scroll_past_end_of_file_enabled = false;
|
||||
|
||||
// Smooth scrolling.
|
||||
bool smooth_scroll_enabled = false;
|
||||
float target_v_scroll = 0.0;
|
||||
float v_scroll_speed = 80.0;
|
||||
|
||||
// Scrolling.
|
||||
bool scrolling = false;
|
||||
bool updating_scrolls = false;
|
||||
|
||||
void _update_scrollbars();
|
||||
|
||||
void _v_scroll_input();
|
||||
void _scroll_moved(double p_to_val);
|
||||
|
||||
double _get_visible_lines_offset() const;
|
||||
double _get_v_scroll_offset() const;
|
||||
|
||||
void _scroll_up(real_t p_delta);
|
||||
void _scroll_down(real_t p_delta);
|
||||
|
||||
void _scroll_lines_up();
|
||||
void _scroll_lines_down();
|
||||
|
||||
// Minimap
|
||||
bool draw_minimap = false;
|
||||
|
||||
int minimap_width = 80;
|
||||
Point2 minimap_char_size = Point2(1, 2);
|
||||
int minimap_line_spacing = 1;
|
||||
|
||||
// minimap scroll
|
||||
bool minimap_clicked = false;
|
||||
bool dragging_minimap = false;
|
||||
bool can_drag_minimap = false;
|
||||
|
||||
double minimap_scroll_ratio = 0.0;
|
||||
double minimap_scroll_click_pos = 0.0;
|
||||
|
||||
void _update_minimap_click();
|
||||
void _update_minimap_drag();
|
||||
|
||||
/* Syntax highlighting. */
|
||||
Map<int, Dictionary> syntax_highlighting_cache;
|
||||
|
||||
|
@ -343,29 +390,11 @@ private:
|
|||
bool draw_spaces = false;
|
||||
bool text_changed_dirty = false;
|
||||
bool undo_enabled = true;
|
||||
bool draw_minimap = false;
|
||||
int minimap_width = 80;
|
||||
Point2 minimap_char_size = Point2(1, 2);
|
||||
int minimap_line_spacing = 1;
|
||||
|
||||
bool highlight_all_occurrences = false;
|
||||
bool scroll_past_end_of_file_enabled = false;
|
||||
bool highlight_current_line = false;
|
||||
|
||||
bool smooth_scroll_enabled = false;
|
||||
bool scrolling = false;
|
||||
bool dragging_minimap = false;
|
||||
bool can_drag_minimap = false;
|
||||
bool minimap_clicked = false;
|
||||
double minimap_scroll_ratio = 0.0;
|
||||
double minimap_scroll_click_pos = 0.0;
|
||||
float target_v_scroll = 0.0;
|
||||
float v_scroll_speed = 80.0;
|
||||
|
||||
Timer *idle_detect;
|
||||
HScrollBar *h_scroll;
|
||||
VScrollBar *v_scroll;
|
||||
bool updating_scrolls = false;
|
||||
|
||||
Object *tooltip_obj = nullptr;
|
||||
StringName tooltip_func;
|
||||
|
@ -382,37 +411,9 @@ private:
|
|||
bool shortcut_keys_enabled = true;
|
||||
bool virtual_keyboard_enabled = true;
|
||||
|
||||
int get_visible_rows() const;
|
||||
int get_total_visible_rows() const;
|
||||
|
||||
int _get_minimap_visible_rows() const;
|
||||
|
||||
double get_scroll_pos_for_line(int p_line, int p_wrap_index = 0) const;
|
||||
void set_line_as_first_visible(int p_line, int p_wrap_index = 0);
|
||||
void set_line_as_center_visible(int p_line, int p_wrap_index = 0);
|
||||
void set_line_as_last_visible(int p_line, int p_wrap_index = 0);
|
||||
int get_first_visible_line() const;
|
||||
int get_last_full_visible_line() const;
|
||||
int get_last_full_visible_line_wrap_index() const;
|
||||
double get_visible_rows_offset() const;
|
||||
double get_v_scroll_offset() const;
|
||||
|
||||
int get_char_pos_for_line(int p_px, int p_line, int p_wrap_index = 0) const;
|
||||
int get_column_x_offset_for_line(int p_char, int p_line) const;
|
||||
|
||||
double get_scroll_line_diff() const;
|
||||
void _scroll_moved(double);
|
||||
void _update_scrollbars();
|
||||
void _v_scroll_input();
|
||||
|
||||
void _update_minimap_click();
|
||||
void _update_minimap_drag();
|
||||
void _scroll_up(real_t p_delta);
|
||||
void _scroll_down(real_t p_delta);
|
||||
|
||||
void _scroll_lines_up();
|
||||
void _scroll_lines_down();
|
||||
|
||||
Size2 get_minimum_size() const override;
|
||||
int _get_control_height() const;
|
||||
|
||||
|
@ -480,7 +481,6 @@ protected:
|
|||
Color background_color;
|
||||
|
||||
int line_spacing = 1;
|
||||
int minimap_width = 0;
|
||||
} cache;
|
||||
|
||||
virtual String get_tooltip(const Point2 &p_pos) const override;
|
||||
|
@ -608,6 +608,51 @@ public:
|
|||
|
||||
Vector<String> get_line_wrapped_text(int p_line) const;
|
||||
|
||||
/* Viewport. */
|
||||
//Scrolling.
|
||||
void set_smooth_scroll_enabled(const bool p_enable);
|
||||
bool is_smooth_scroll_enabled() const;
|
||||
|
||||
void set_scroll_past_end_of_file_enabled(const bool p_enabled);
|
||||
bool is_scroll_past_end_of_file_enabled() const;
|
||||
|
||||
void set_v_scroll(double p_scroll);
|
||||
double get_v_scroll() const;
|
||||
|
||||
void set_h_scroll(int p_scroll);
|
||||
int get_h_scroll() const;
|
||||
|
||||
void set_v_scroll_speed(float p_speed);
|
||||
float get_v_scroll_speed() const;
|
||||
|
||||
double get_scroll_pos_for_line(int p_line, int p_wrap_index = 0) const;
|
||||
|
||||
// Visible lines.
|
||||
void set_line_as_first_visible(int p_line, int p_wrap_index = 0);
|
||||
int get_first_visible_line() const;
|
||||
|
||||
void set_line_as_center_visible(int p_line, int p_wrap_index = 0);
|
||||
|
||||
void set_line_as_last_visible(int p_line, int p_wrap_index = 0);
|
||||
int get_last_full_visible_line() const;
|
||||
int get_last_full_visible_line_wrap_index() const;
|
||||
|
||||
int get_visible_line_count() const;
|
||||
int get_total_visible_line_count() const;
|
||||
|
||||
// Auto Adjust
|
||||
void adjust_viewport_to_caret();
|
||||
void center_viewport_to_caret();
|
||||
|
||||
// Minimap
|
||||
void set_draw_minimap(bool p_draw);
|
||||
bool is_drawing_minimap() const;
|
||||
|
||||
void set_minimap_width(int p_minimap_width);
|
||||
int get_minimap_width() const;
|
||||
|
||||
int get_minimap_visible_lines() const;
|
||||
|
||||
/* Syntax Highlighting. */
|
||||
Ref<SyntaxHighlighter> get_syntax_highlighter();
|
||||
void set_syntax_highlighter(Ref<SyntaxHighlighter> p_syntax_highlighter);
|
||||
|
@ -749,14 +794,6 @@ public:
|
|||
int get_indent_level(int p_line) const;
|
||||
int get_first_non_whitespace_column(int p_line) const;
|
||||
|
||||
inline void set_scroll_pass_end_of_file(bool p_enabled) {
|
||||
scroll_past_end_of_file_enabled = p_enabled;
|
||||
update();
|
||||
}
|
||||
|
||||
void adjust_viewport_to_caret();
|
||||
void center_viewport_to_caret();
|
||||
|
||||
void clear();
|
||||
|
||||
void swap_lines(int line1, int line2);
|
||||
|
@ -784,18 +821,6 @@ public:
|
|||
void set_draw_spaces(bool p_draw);
|
||||
bool is_drawing_spaces() const;
|
||||
|
||||
double get_v_scroll() const;
|
||||
void set_v_scroll(double p_scroll);
|
||||
|
||||
int get_h_scroll() const;
|
||||
void set_h_scroll(int p_scroll);
|
||||
|
||||
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();
|
||||
|
@ -805,12 +830,6 @@ public:
|
|||
void set_highlight_current_line(bool p_enabled);
|
||||
bool is_highlight_current_line_enabled() const;
|
||||
|
||||
void set_draw_minimap(bool p_draw);
|
||||
bool is_drawing_minimap() const;
|
||||
|
||||
void set_minimap_width(int p_minimap_width);
|
||||
int get_minimap_width() const;
|
||||
|
||||
void set_tooltip_request_func(Object *p_obj, const StringName &p_function, const Variant &p_udata);
|
||||
|
||||
void set_context_menu_enabled(bool p_enable);
|
||||
|
|
Loading…
Reference in New Issue