mirror of https://github.com/godotengine/godot
Merge pull request #2458 from TheHX/text_edit_hscroll
Fix HScrollBar of TextEdit
This commit is contained in:
commit
d5579b1506
|
|
@ -94,8 +94,8 @@ void TextEdit::Text::set_tab_size(int p_tab_size) {
|
||||||
|
|
||||||
void TextEdit::Text::_update_line_cache(int p_line) const {
|
void TextEdit::Text::_update_line_cache(int p_line) const {
|
||||||
|
|
||||||
int w =0;
|
int w = 0;
|
||||||
int tab_w=font->get_char_size(' ').width;
|
int tab_w=font->get_char_size(' ').width*tab_size;
|
||||||
|
|
||||||
int len = text[p_line].data.length();
|
int len = text[p_line].data.length();
|
||||||
const CharType *str = text[p_line].data.c_str();
|
const CharType *str = text[p_line].data.c_str();
|
||||||
|
|
@ -292,7 +292,10 @@ void TextEdit::_update_scrollbars() {
|
||||||
|
|
||||||
int vscroll_pixels = v_scroll->get_combined_minimum_size().width;
|
int vscroll_pixels = v_scroll->get_combined_minimum_size().width;
|
||||||
int visible_width = size.width - cache.style_normal->get_minimum_size().width;
|
int visible_width = size.width - cache.style_normal->get_minimum_size().width;
|
||||||
int total_width = text.get_max_width();
|
int total_width = text.get_max_width() + vmin.x;
|
||||||
|
|
||||||
|
if (line_numbers)
|
||||||
|
total_width += cache.line_number_w;
|
||||||
|
|
||||||
bool use_hscroll=true;
|
bool use_hscroll=true;
|
||||||
bool use_vscroll=true;
|
bool use_vscroll=true;
|
||||||
|
|
@ -322,7 +325,6 @@ void TextEdit::_update_scrollbars() {
|
||||||
v_scroll->show();
|
v_scroll->show();
|
||||||
v_scroll->set_max(total_rows);
|
v_scroll->set_max(total_rows);
|
||||||
v_scroll->set_page(visible_rows);
|
v_scroll->set_page(visible_rows);
|
||||||
|
|
||||||
v_scroll->set_val(cursor.line_ofs);
|
v_scroll->set_val(cursor.line_ofs);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -336,6 +338,7 @@ void TextEdit::_update_scrollbars() {
|
||||||
h_scroll->set_max(total_width);
|
h_scroll->set_max(total_width);
|
||||||
h_scroll->set_page(visible_width);
|
h_scroll->set_page(visible_width);
|
||||||
h_scroll->set_val(cursor.x_ofs);
|
h_scroll->set_val(cursor.x_ofs);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
h_scroll->hide();
|
h_scroll->hide();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue