void RichTextLabel::set_use_bbcode(bool p_enable) { if (use_bbcode==p_enable) return; use_bbcode=p_enable; if (is_inside_tree() && use_bbcode) parse_bbcode(bbcode); }
void RichTextLabel::set_bbcode(const String& p_bbcode) { bbcode=p_bbcode; if (is_inside_tree() && use_bbcode) parse_bbcode(p_bbcode); else { // raw text clear(); add_text(p_bbcode); } }
void RichTextLabel::_notification(int p_what) { switch (p_what) { case NOTIFICATION_RESIZED: { main->first_invalid_line=0; //invalidate ALL update(); } break; case NOTIFICATION_ENTER_TREE: { set_bbcode(bbcode); main->first_invalid_line=0; //invalidate ALL update(); } break; case NOTIFICATION_THEME_CHANGED: { if (is_inside_tree() && use_bbcode) { parse_bbcode(bbcode); //first_invalid_line=0; //invalidate ALL //update(); } } break; case NOTIFICATION_DRAW: { _validate_line_caches(main); _update_scroll(); RID ci=get_canvas_item(); Size2 size = get_size(); VisualServer::get_singleton()->canvas_item_set_clip(ci,true); if (has_focus()) { VisualServer::get_singleton()->canvas_item_add_clip_ignore(ci,true); draw_style_box(get_stylebox("focus"),Rect2(Point2(),size)); VisualServer::get_singleton()->canvas_item_add_clip_ignore(ci,false); } int ofs = vscroll->get_val(); //todo, change to binary search int from_line = 0; int total_chars = 0; while (from_line<main->lines.size()) { if (main->lines[from_line].height_accum_cache>=ofs) break; from_line++; total_chars+=main->lines[from_line].char_count; } if (from_line>=main->lines.size()) break; //nothing to draw int y = (main->lines[from_line].height_accum_cache - main->lines[from_line].height_cache) - ofs; Ref<Font> base_font=get_font("normal_font"); Color base_color=get_color("default_color"); while (y<size.height && from_line<main->lines.size()) { _process_line(main,Point2(),y,size.width-scroll_w,from_line,PROCESS_DRAW,base_font,base_color,Point2i(),NULL,NULL,NULL,total_chars); total_chars+=main->lines[from_line].char_count; from_line++; } } } }
void RichTextLabel::set_bbcode(const String& p_bbcode) { bbcode=p_bbcode; if (is_inside_tree() && use_bbcode) parse_bbcode(p_bbcode); }