[CTL] Add missing font outline drawing routines and theme constants.
This commit is contained in:
@@ -883,6 +883,8 @@ void ItemList::_notification(int p_what) {
|
||||
int vseparation = get_theme_constant("vseparation");
|
||||
int icon_margin = get_theme_constant("icon_margin");
|
||||
int line_separation = get_theme_constant("line_separation");
|
||||
Color font_outline_color = get_theme_color("font_outline_color");
|
||||
int outline_size = get_theme_constant("outline_size");
|
||||
|
||||
Ref<StyleBox> sbsel = has_focus() ? get_theme_stylebox("selected_focus") : get_theme_stylebox("selected");
|
||||
Ref<StyleBox> cursor = has_focus() ? get_theme_stylebox("cursor") : get_theme_stylebox("cursor_unfocused");
|
||||
@@ -1204,6 +1206,10 @@ void ItemList::_notification(int p_what) {
|
||||
items.write[i].text_buf->set_width(max_len);
|
||||
items.write[i].text_buf->set_align(HALIGN_CENTER);
|
||||
|
||||
if (outline_size > 0 && font_outline_color.a > 0) {
|
||||
items[i].text_buf->draw_outline(get_canvas_item(), text_ofs, outline_size, font_outline_color);
|
||||
}
|
||||
|
||||
items[i].text_buf->draw(get_canvas_item(), text_ofs, modulate);
|
||||
} else {
|
||||
if (fixed_column_width > 0) {
|
||||
@@ -1230,6 +1236,11 @@ void ItemList::_notification(int p_what) {
|
||||
} else {
|
||||
items.write[i].text_buf->set_align(HALIGN_LEFT);
|
||||
}
|
||||
|
||||
if (outline_size > 0 && font_outline_color.a > 0) {
|
||||
items[i].text_buf->draw_outline(get_canvas_item(), text_ofs, outline_size, font_outline_color);
|
||||
}
|
||||
|
||||
items[i].text_buf->draw(get_canvas_item(), text_ofs, modulate);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -835,6 +835,24 @@ void LineEdit::_notification(int p_what) {
|
||||
|
||||
// Draw text.
|
||||
ofs.y += TS->shaped_text_get_ascent(text_rid);
|
||||
Color font_outline_color = get_theme_color("font_outline_color");
|
||||
int outline_size = get_theme_constant("outline_size");
|
||||
if (outline_size > 0 && font_outline_color.a > 0) {
|
||||
Vector2 oofs = ofs;
|
||||
for (int i = 0; i < gl_size; i++) {
|
||||
for (int j = 0; j < glyphs[i].repeat; j++) {
|
||||
if (ceil(oofs.x) >= x_ofs && (oofs.x + glyphs[i].advance) <= ofs_max) {
|
||||
if (glyphs[i].font_rid != RID()) {
|
||||
TS->font_draw_glyph_outline(glyphs[i].font_rid, ci, glyphs[i].font_size, outline_size, oofs + Vector2(glyphs[i].x_off, glyphs[i].y_off), glyphs[i].index, font_outline_color);
|
||||
}
|
||||
}
|
||||
oofs.x += glyphs[i].advance;
|
||||
}
|
||||
if (oofs.x >= ofs_max) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < gl_size; i++) {
|
||||
bool selected = selection.enabled && glyphs[i].start >= selection.begin && glyphs[i].end <= selection.end;
|
||||
for (int j = 0; j < glyphs[i].repeat; j++) {
|
||||
|
||||
@@ -191,9 +191,17 @@ void LinkButton::_notification(int p_what) {
|
||||
|
||||
int width = text_buf->get_line_width();
|
||||
|
||||
Color font_outline_color = get_theme_color("font_outline_color");
|
||||
int outline_size = get_theme_constant("outline_size");
|
||||
if (is_layout_rtl()) {
|
||||
if (outline_size > 0 && font_outline_color.a > 0) {
|
||||
text_buf->draw_outline(get_canvas_item(), Vector2(size.width - width, 0), outline_size, font_outline_color);
|
||||
}
|
||||
text_buf->draw(get_canvas_item(), Vector2(size.width - width, 0), color);
|
||||
} else {
|
||||
if (outline_size > 0 && font_outline_color.a > 0) {
|
||||
text_buf->draw_outline(get_canvas_item(), Vector2(0, 0), outline_size, font_outline_color);
|
||||
}
|
||||
text_buf->draw(get_canvas_item(), Vector2(0, 0), color);
|
||||
}
|
||||
|
||||
|
||||
@@ -572,17 +572,31 @@ void PopupMenu::_draw_items() {
|
||||
}
|
||||
|
||||
// Text
|
||||
Color font_outline_color = get_theme_color("font_outline_color");
|
||||
int outline_size = get_theme_constant("outline_size");
|
||||
if (items[i].separator) {
|
||||
if (text != String()) {
|
||||
int center = (display_width - items[i].text_buf->get_size().width) / 2;
|
||||
items[i].text_buf->draw(ci, Point2(center, item_ofs.y + Math::floor((h - items[i].text_buf->get_size().y) / 2.0)), font_separator_color);
|
||||
Vector2 text_pos = Point2(center, item_ofs.y + Math::floor((h - items[i].text_buf->get_size().y) / 2.0));
|
||||
if (outline_size > 0 && font_outline_color.a > 0) {
|
||||
items[i].text_buf->draw_outline(ci, text_pos, outline_size, font_outline_color);
|
||||
}
|
||||
items[i].text_buf->draw(ci, text_pos, font_separator_color);
|
||||
}
|
||||
} else {
|
||||
item_ofs.x += icon_ofs + check_ofs;
|
||||
if (rtl) {
|
||||
items[i].text_buf->draw(ci, Size2(control->get_size().width - items[i].text_buf->get_size().width - item_ofs.x, item_ofs.y) + Point2(0, Math::floor((h - items[i].text_buf->get_size().y) / 2.0)), items[i].disabled ? font_disabled_color : (i == mouse_over ? font_hover_color : font_color));
|
||||
Vector2 text_pos = Size2(control->get_size().width - items[i].text_buf->get_size().width - item_ofs.x, item_ofs.y) + Point2(0, Math::floor((h - items[i].text_buf->get_size().y) / 2.0));
|
||||
if (outline_size > 0 && font_outline_color.a > 0) {
|
||||
items[i].text_buf->draw_outline(ci, text_pos, outline_size, font_outline_color);
|
||||
}
|
||||
items[i].text_buf->draw(ci, text_pos, items[i].disabled ? font_disabled_color : (i == mouse_over ? font_hover_color : font_color));
|
||||
} else {
|
||||
items[i].text_buf->draw(ci, item_ofs + Point2(0, Math::floor((h - items[i].text_buf->get_size().y) / 2.0)), items[i].disabled ? font_disabled_color : (i == mouse_over ? font_hover_color : font_color));
|
||||
Vector2 text_pos = item_ofs + Point2(0, Math::floor((h - items[i].text_buf->get_size().y) / 2.0));
|
||||
if (outline_size > 0 && font_outline_color.a > 0) {
|
||||
items[i].text_buf->draw_outline(ci, text_pos, outline_size, font_outline_color);
|
||||
}
|
||||
items[i].text_buf->draw(ci, text_pos, items[i].disabled ? font_disabled_color : (i == mouse_over ? font_hover_color : font_color));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -593,7 +607,11 @@ void PopupMenu::_draw_items() {
|
||||
} else {
|
||||
item_ofs.x = display_width - style->get_margin(SIDE_RIGHT) - items[i].accel_text_buf->get_size().x;
|
||||
}
|
||||
items[i].accel_text_buf->draw(ci, item_ofs + Point2(0, Math::floor((h - items[i].text_buf->get_size().y) / 2.0)), i == mouse_over ? font_hover_color : font_accelerator_color);
|
||||
Vector2 text_pos = item_ofs + Point2(0, Math::floor((h - items[i].text_buf->get_size().y) / 2.0));
|
||||
if (outline_size > 0 && font_outline_color.a > 0) {
|
||||
items[i].accel_text_buf->draw_outline(ci, text_pos, outline_size, font_outline_color);
|
||||
}
|
||||
items[i].accel_text_buf->draw(ci, text_pos, i == mouse_over ? font_hover_color : font_accelerator_color);
|
||||
}
|
||||
|
||||
// Cache the item vertical offset from the first item and the height
|
||||
|
||||
@@ -74,7 +74,13 @@ void ProgressBar::_notification(int p_what) {
|
||||
if (percent_visible) {
|
||||
String txt = TS->format_number(itos(int(get_as_ratio() * 100))) + TS->percent_sign();
|
||||
TextLine tl = TextLine(txt, font, font_size);
|
||||
tl.draw(get_canvas_item(), (Point2(get_size().width - tl.get_size().x, get_size().height - tl.get_size().y) / 2).round(), font_color);
|
||||
Vector2 text_pos = (Point2(get_size().width - tl.get_size().x, get_size().height - tl.get_size().y) / 2).round();
|
||||
Color font_outline_color = get_theme_color("font_outline_color");
|
||||
int outline_size = get_theme_constant("outline_size");
|
||||
if (outline_size > 0 && font_outline_color.a > 0) {
|
||||
tl.draw_outline(get_canvas_item(), text_pos, outline_size, font_outline_color);
|
||||
}
|
||||
tl.draw(get_canvas_item(), text_pos, font_color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -819,8 +819,8 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o
|
||||
// Draw oulines and shadow.
|
||||
for (int i = 0; i < gl_size; i++) {
|
||||
Item *it = _get_item_at_pos(it_from, it_to, glyphs[i].start);
|
||||
int size = _find_outline_size(it);
|
||||
Color font_color = _find_outline_color(it, Color(0, 0, 0, 0));
|
||||
int size = _find_outline_size(it, p_outline_size);
|
||||
Color font_color = _find_outline_color(it, p_outline_color);
|
||||
if (size <= 0) {
|
||||
gloff.x += glyphs[i].advance;
|
||||
continue;
|
||||
@@ -1398,7 +1398,7 @@ void RichTextLabel::_notification(int p_what) {
|
||||
}
|
||||
Ref<Font> base_font = get_theme_font("normal_font");
|
||||
Color base_color = get_theme_color("default_color");
|
||||
Color outline_color = get_theme_color("outline_color");
|
||||
Color outline_color = get_theme_color("font_outline_color");
|
||||
int outline_size = get_theme_constant("outline_size");
|
||||
Color font_shadow_color = get_theme_color("font_shadow_color");
|
||||
bool use_outline = get_theme_constant("shadow_as_outline");
|
||||
@@ -1753,7 +1753,7 @@ int RichTextLabel::_find_font_size(Item *p_item) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int RichTextLabel::_find_outline_size(Item *p_item) {
|
||||
int RichTextLabel::_find_outline_size(Item *p_item, int p_default) {
|
||||
Item *sizeitem = p_item;
|
||||
|
||||
while (sizeitem) {
|
||||
@@ -1765,7 +1765,7 @@ int RichTextLabel::_find_outline_size(Item *p_item) {
|
||||
sizeitem = sizeitem->parent;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return p_default;
|
||||
}
|
||||
|
||||
Dictionary RichTextLabel::_find_font_features(Item *p_item) {
|
||||
|
||||
@@ -405,7 +405,7 @@ private:
|
||||
Ref<Font> _find_font(Item *p_item);
|
||||
int _find_font_size(Item *p_item);
|
||||
Dictionary _find_font_features(Item *p_item);
|
||||
int _find_outline_size(Item *p_item);
|
||||
int _find_outline_size(Item *p_item, int p_default);
|
||||
ItemList *_find_list_item(Item *p_item);
|
||||
ItemDropcap *_find_dc_item(Item *p_item);
|
||||
int _find_list(Item *p_item, Vector<int> &r_index, Vector<ItemList *> &r_list);
|
||||
|
||||
@@ -535,6 +535,8 @@ void TabContainer::_draw_tab(Ref<StyleBox> &p_tab_style, Color &p_font_color, in
|
||||
Vector<Control *> tabs = _get_tabs();
|
||||
RID canvas = get_canvas_item();
|
||||
Ref<Font> font = get_theme_font("font");
|
||||
Color font_outline_color = get_theme_color("font_outline_color");
|
||||
int outline_size = get_theme_constant("outline_size");
|
||||
int icon_text_distance = get_theme_constant("icon_separation");
|
||||
int tab_width = _get_tab_width(p_index);
|
||||
int header_height = _get_top_margin();
|
||||
@@ -565,6 +567,9 @@ void TabContainer::_draw_tab(Ref<StyleBox> &p_tab_style, Color &p_font_color, in
|
||||
|
||||
// Draw the tab text.
|
||||
Point2i text_pos(x_content, y_center - text_buf[p_index]->get_size().y / 2);
|
||||
if (outline_size > 0 && font_outline_color.a > 0) {
|
||||
text_buf[p_index]->draw_outline(canvas, text_pos, outline_size, font_outline_color);
|
||||
}
|
||||
text_buf[p_index]->draw(canvas, text_pos, p_font_color);
|
||||
}
|
||||
|
||||
|
||||
+13
-2
@@ -275,6 +275,9 @@ void Tabs::_notification(int p_what) {
|
||||
Color font_unselected_color = get_theme_color("font_unselected_color");
|
||||
Color font_disabled_color = get_theme_color("font_disabled_color");
|
||||
Ref<Texture2D> close = get_theme_icon("close");
|
||||
Color font_outline_color = get_theme_color("font_outline_color");
|
||||
int outline_size = get_theme_constant("outline_size");
|
||||
|
||||
Vector2 size = get_size();
|
||||
bool rtl = is_layout_rtl();
|
||||
|
||||
@@ -357,9 +360,17 @@ void Tabs::_notification(int p_what) {
|
||||
}
|
||||
|
||||
if (rtl) {
|
||||
tabs[i].text_buf->draw(ci, Point2i(size.width - w - tabs[i].text_buf->get_size().x, sb->get_margin(SIDE_TOP) + ((sb_rect.size.y - sb_ms.y) - tabs[i].text_buf->get_size().y) / 2), col);
|
||||
Vector2 text_pos = Point2i(size.width - w - tabs[i].text_buf->get_size().x, sb->get_margin(SIDE_TOP) + ((sb_rect.size.y - sb_ms.y) - tabs[i].text_buf->get_size().y) / 2);
|
||||
if (outline_size > 0 && font_outline_color.a > 0) {
|
||||
tabs[i].text_buf->draw_outline(ci, text_pos, outline_size, font_outline_color);
|
||||
}
|
||||
tabs[i].text_buf->draw(ci, text_pos, col);
|
||||
} else {
|
||||
tabs[i].text_buf->draw(ci, Point2i(w, sb->get_margin(SIDE_TOP) + ((sb_rect.size.y - sb_ms.y) - tabs[i].text_buf->get_size().y) / 2), col);
|
||||
Vector2 text_pos = Point2i(w, sb->get_margin(SIDE_TOP) + ((sb_rect.size.y - sb_ms.y) - tabs[i].text_buf->get_size().y) / 2);
|
||||
if (outline_size > 0 && font_outline_color.a > 0) {
|
||||
tabs[i].text_buf->draw_outline(ci, text_pos, outline_size, font_outline_color);
|
||||
}
|
||||
tabs[i].text_buf->draw(ci, text_pos, col);
|
||||
}
|
||||
|
||||
w += tabs[i].size_text;
|
||||
|
||||
@@ -1117,6 +1117,9 @@ void TextEdit::_notification(int p_what) {
|
||||
tl->add_string(text, cache.font, cache.font_size);
|
||||
|
||||
int yofs = ofs_y + (row_height - tl->get_size().y) / 2;
|
||||
if (cache.outline_size > 0 && cache.outline_color.a > 0) {
|
||||
tl->draw_outline(ci, Point2(gutter_offset + ofs_x, yofs), cache.outline_size, cache.outline_color);
|
||||
}
|
||||
tl->draw(ci, Point2(gutter_offset + ofs_x, yofs), get_line_gutter_item_color(line, g));
|
||||
} break;
|
||||
case GUTTER_TPYE_ICON: {
|
||||
@@ -1273,6 +1276,22 @@ void TextEdit::_notification(int p_what) {
|
||||
|
||||
ofs_y += ldata->get_line_ascent(line_wrap_index);
|
||||
int char_ofs = 0;
|
||||
if (cache.outline_size > 0 && cache.outline_color.a > 0) {
|
||||
for (int j = 0; j < gl_size; j++) {
|
||||
for (int k = 0; k < glyphs[j].repeat; k++) {
|
||||
if ((char_ofs + char_margin) >= xmargin_beg && (char_ofs + glyphs[j].advance + char_margin) <= xmargin_end) {
|
||||
if (glyphs[j].font_rid != RID()) {
|
||||
TS->font_draw_glyph_outline(glyphs[j].font_rid, ci, glyphs[j].font_size, cache.outline_size, Vector2(char_margin + char_ofs + ofs_x + glyphs[j].x_off, ofs_y + glyphs[j].y_off), glyphs[j].index, cache.outline_color);
|
||||
}
|
||||
}
|
||||
char_ofs += glyphs[j].advance;
|
||||
}
|
||||
if ((char_ofs + char_margin) >= xmargin_end) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
char_ofs = 0;
|
||||
}
|
||||
for (int j = 0; j < gl_size; j++) {
|
||||
if (color_map.has(glyphs[j].start)) {
|
||||
current_color = color_map[glyphs[j].start].get("color");
|
||||
@@ -1601,6 +1620,9 @@ void TextEdit::_notification(int p_what) {
|
||||
}
|
||||
tl->set_align(HALIGN_LEFT);
|
||||
}
|
||||
if (cache.outline_size > 0 && cache.outline_color.a > 0) {
|
||||
tl->draw_outline(ci, title_pos, cache.outline_size, cache.outline_color);
|
||||
}
|
||||
tl->draw(ci, title_pos, completion_options[l].font_color);
|
||||
}
|
||||
|
||||
@@ -4944,6 +4966,8 @@ void TextEdit::_update_caches() {
|
||||
cache.completion_font_color = get_theme_color("completion_font_color");
|
||||
cache.font = get_theme_font("font");
|
||||
cache.font_size = get_theme_font_size("font_size");
|
||||
cache.outline_color = get_theme_color("font_outline_color");
|
||||
cache.outline_size = get_theme_constant("outline_size");
|
||||
cache.caret_color = get_theme_color("caret_color");
|
||||
cache.caret_background_color = get_theme_color("caret_background_color");
|
||||
cache.font_color = get_theme_color("font_color");
|
||||
|
||||
@@ -451,6 +451,8 @@ protected:
|
||||
Ref<StyleBox> style_readonly;
|
||||
Ref<Font> font;
|
||||
int font_size = 16;
|
||||
int outline_size = 0;
|
||||
Color outline_color;
|
||||
Color completion_background_color;
|
||||
Color completion_selected_color;
|
||||
Color completion_existing_color;
|
||||
|
||||
+33
-6
@@ -1118,7 +1118,7 @@ int Tree::get_item_height(TreeItem *p_item) const {
|
||||
return height;
|
||||
}
|
||||
|
||||
void Tree::draw_item_rect(TreeItem::Cell &p_cell, const Rect2i &p_rect, const Color &p_color, const Color &p_icon_color) {
|
||||
void Tree::draw_item_rect(TreeItem::Cell &p_cell, const Rect2i &p_rect, const Color &p_color, const Color &p_icon_color, int p_ol_size, const Color &p_ol_color) {
|
||||
ERR_FAIL_COND(cache.font.is_null());
|
||||
|
||||
Rect2i rect = p_rect;
|
||||
@@ -1160,6 +1160,9 @@ void Tree::draw_item_rect(TreeItem::Cell &p_cell, const Rect2i &p_rect, const Co
|
||||
Point2 draw_pos = rect.position;
|
||||
draw_pos.y += Math::floor((rect.size.y - p_cell.text_buf->get_size().y) / 2.0);
|
||||
p_cell.text_buf->set_width(MAX(0, rect.size.width));
|
||||
if (p_ol_size > 0 && p_ol_color.a > 0) {
|
||||
p_cell.text_buf->draw_outline(ci, draw_pos, p_ol_size, p_ol_color);
|
||||
}
|
||||
p_cell.text_buf->draw(ci, draw_pos, p_color);
|
||||
rect.position.x += ts.width + cache.hseparation;
|
||||
rect.size.x -= ts.width + cache.hseparation;
|
||||
@@ -1182,6 +1185,9 @@ void Tree::draw_item_rect(TreeItem::Cell &p_cell, const Rect2i &p_rect, const Co
|
||||
Point2 draw_pos = rect.position;
|
||||
draw_pos.y += Math::floor((rect.size.y - p_cell.text_buf->get_size().y) / 2.0);
|
||||
p_cell.text_buf->set_width(MAX(0, rect.size.width));
|
||||
if (p_ol_size > 0 && p_ol_color.a > 0) {
|
||||
p_cell.text_buf->draw_outline(ci, draw_pos, p_ol_size, p_ol_color);
|
||||
}
|
||||
p_cell.text_buf->draw(ci, draw_pos, p_color);
|
||||
}
|
||||
}
|
||||
@@ -1434,6 +1440,8 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
|
||||
}
|
||||
|
||||
Color col = p_item->cells[i].custom_color ? p_item->cells[i].color : get_theme_color(p_item->cells[i].selected ? "font_selected_color" : "font_color");
|
||||
Color font_outline_color = get_theme_color("font_outline_color");
|
||||
int outline_size = get_theme_constant("outline_size");
|
||||
Color icon_col = p_item->cells[i].icon_color;
|
||||
|
||||
if (p_item->cells[i].dirty) {
|
||||
@@ -1450,7 +1458,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
|
||||
|
||||
switch (p_item->cells[i].mode) {
|
||||
case TreeItem::CELL_MODE_STRING: {
|
||||
draw_item_rect(p_item->cells.write[i], item_rect, col, icon_col);
|
||||
draw_item_rect(p_item->cells.write[i], item_rect, col, icon_col, outline_size, font_outline_color);
|
||||
} break;
|
||||
case TreeItem::CELL_MODE_CHECK: {
|
||||
Ref<Texture2D> checked = cache.checked;
|
||||
@@ -1471,7 +1479,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
|
||||
item_rect.size.x -= check_w;
|
||||
item_rect.position.x += check_w;
|
||||
|
||||
draw_item_rect(p_item->cells.write[i], item_rect, col, icon_col);
|
||||
draw_item_rect(p_item->cells.write[i], item_rect, col, icon_col, outline_size, font_outline_color);
|
||||
|
||||
} break;
|
||||
case TreeItem::CELL_MODE_RANGE: {
|
||||
@@ -1485,8 +1493,14 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
|
||||
|
||||
p_item->cells.write[i].text_buf->set_width(cell_width);
|
||||
if (rtl) {
|
||||
if (outline_size > 0 && font_outline_color.a > 0) {
|
||||
p_item->cells[i].text_buf->draw_outline(ci, text_pos + Vector2(cell_width - text_width, 0), outline_size, font_outline_color);
|
||||
}
|
||||
p_item->cells[i].text_buf->draw(ci, text_pos + Vector2(cell_width - text_width, 0), col);
|
||||
} else {
|
||||
if (outline_size > 0 && font_outline_color.a > 0) {
|
||||
p_item->cells[i].text_buf->draw_outline(ci, text_pos, outline_size, font_outline_color);
|
||||
}
|
||||
p_item->cells[i].text_buf->draw(ci, text_pos, col);
|
||||
}
|
||||
|
||||
@@ -1501,8 +1515,14 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
|
||||
int cell_width = item_rect.size.x - updown->get_width();
|
||||
|
||||
if (rtl) {
|
||||
if (outline_size > 0 && font_outline_color.a > 0) {
|
||||
p_item->cells[i].text_buf->draw_outline(ci, text_pos + Vector2(cell_width - text_width, 0), outline_size, font_outline_color);
|
||||
}
|
||||
p_item->cells[i].text_buf->draw(ci, text_pos + Vector2(cell_width - text_width, 0), col);
|
||||
} else {
|
||||
if (outline_size > 0 && font_outline_color.a > 0) {
|
||||
p_item->cells[i].text_buf->draw_outline(ci, text_pos, outline_size, font_outline_color);
|
||||
}
|
||||
p_item->cells[i].text_buf->draw(ci, text_pos, col);
|
||||
}
|
||||
|
||||
@@ -1543,7 +1563,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
|
||||
}
|
||||
|
||||
if (!p_item->cells[i].editable) {
|
||||
draw_item_rect(p_item->cells.write[i], item_rect, col, icon_col);
|
||||
draw_item_rect(p_item->cells.write[i], item_rect, col, icon_col, outline_size, font_outline_color);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1571,7 +1591,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
|
||||
ir.position += cache.custom_button->get_offset();
|
||||
}
|
||||
|
||||
draw_item_rect(p_item->cells.write[i], ir, col, icon_col);
|
||||
draw_item_rect(p_item->cells.write[i], ir, col, icon_col, outline_size, font_outline_color);
|
||||
|
||||
downarrow->draw(ci, arrow_pos);
|
||||
|
||||
@@ -3143,6 +3163,8 @@ void Tree::_notification(int p_what) {
|
||||
|
||||
Ref<StyleBox> bg = cache.bg;
|
||||
Ref<StyleBox> bg_focus = get_theme_stylebox("bg_focus");
|
||||
Color font_outline_color = get_theme_color("font_outline_color");
|
||||
int outline_size = get_theme_constant("outline_size");
|
||||
|
||||
Point2 draw_ofs;
|
||||
draw_ofs += bg->get_offset();
|
||||
@@ -3179,7 +3201,12 @@ void Tree::_notification(int p_what) {
|
||||
//text
|
||||
int clip_w = tbrect.size.width - sb->get_minimum_size().width;
|
||||
columns.write[i].text_buf->set_width(clip_w);
|
||||
columns[i].text_buf->draw(ci, tbrect.position + Point2i(sb->get_offset().x + (tbrect.size.width - columns[i].text_buf->get_size().x) / 2, (tbrect.size.height - columns[i].text_buf->get_size().y) / 2), cache.title_button_color);
|
||||
|
||||
Vector2 text_pos = tbrect.position + Point2i(sb->get_offset().x + (tbrect.size.width - columns[i].text_buf->get_size().x) / 2, (tbrect.size.height - columns[i].text_buf->get_size().y) / 2);
|
||||
if (outline_size > 0 && font_outline_color.a > 0) {
|
||||
columns[i].text_buf->draw_outline(ci, text_pos, outline_size, font_outline_color);
|
||||
}
|
||||
columns[i].text_buf->draw(ci, text_pos, cache.title_button_color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -385,7 +385,7 @@ private:
|
||||
void update_item_cell(TreeItem *p_item, int p_col);
|
||||
void update_item_cache(TreeItem *p_item);
|
||||
//void draw_item_text(String p_text,const Ref<Texture2D>& p_icon,int p_icon_max_w,bool p_tool,Rect2i p_rect,const Color& p_color);
|
||||
void draw_item_rect(TreeItem::Cell &p_cell, const Rect2i &p_rect, const Color &p_color, const Color &p_icon_color);
|
||||
void draw_item_rect(TreeItem::Cell &p_cell, const Rect2i &p_rect, const Color &p_color, const Color &p_icon_color, int p_ol_size, const Color &p_ol_color);
|
||||
int draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 &p_draw_size, TreeItem *p_item);
|
||||
void select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_col, TreeItem *p_prev = nullptr, bool *r_in_range = nullptr, bool p_force_deselect = false);
|
||||
int propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool p_doubleclick, TreeItem *p_item, int p_button, const Ref<InputEventWithModifiers> &p_mod);
|
||||
|
||||
Reference in New Issue
Block a user