|
Blender V5.0
|
#include <cmath>#include <cstdio>#include <cstdlib>#include <cstring>#include "MEM_guardedalloc.h"#include "DNA_userdef_types.h"#include "BLI_listbase.h"#include "BLI_rect.h"#include "BLI_string.h"#include "BLI_string_utf8.h"#include "BLI_utildefines.h"#include "BKE_global.hh"#include "BLF_api.hh"#include "CLG_log.h"#include "interface_intern.hh"Go to the source code of this file.
Functions | |
| static void | fontstyle_set_ex (const uiFontStyle *fs, const float dpi_fac) |
| static uiStyle * | ui_style_new (ListBase *styles, const char *name, short uifont_id) |
| static uiFont * | uifont_to_blfont (int id) |
| void | UI_fontstyle_draw_ex (const uiFontStyle *fs, const rcti *rect, const char *str, const size_t str_len, const uchar col[4], const uiFontStyleDraw_Params *fs_params, int *r_xofs, int *r_yofs, ResultBLF *r_info) |
| void | UI_fontstyle_draw (const uiFontStyle *fs, const rcti *rect, const char *str, const size_t str_len, const uchar col[4], const uiFontStyleDraw_Params *fs_params) |
| void | UI_fontstyle_draw_multiline_clipped_ex (const uiFontStyle *fs, const rcti *rect, const char *str, const uchar col[4], const eFontStyle_Align align, int *r_xofs, int *r_yofs, ResultBLF *r_info) |
| void | UI_fontstyle_draw_multiline_clipped (const uiFontStyle *fs, const rcti *rect, const char *str, const uchar col[4], const eFontStyle_Align align) |
| void | UI_fontstyle_draw_rotated (const uiFontStyle *fs, const rcti *rect, const char *str, const uchar col[4]) |
| void | UI_fontstyle_draw_simple (const uiFontStyle *fs, float x, float y, const char *str, const uchar col[4]) |
| void | UI_fontstyle_draw_simple_backdrop (const uiFontStyle *fs, float x, float y, const blender::StringRef str, const float col_fg[4], const float col_bg[4]) |
| const uiStyle * | UI_style_get () |
| const uiStyle * | UI_style_get_dpi () |
| int | UI_fontstyle_string_width (const uiFontStyle *fs, const char *str) |
| int | UI_fontstyle_string_width_with_block_aspect (const uiFontStyle *fs, const StringRef str, const float aspect) |
| int | UI_fontstyle_height_max (const uiFontStyle *fs) |
| void | uiStyleInit () |
| void | UI_fontstyle_set (const uiFontStyle *fs) |
Variables | |
| static CLG_LogRef | LOG = {"ui.font"} |
|
static |
Definition at line 597 of file interface_style.cc.
References BLF_character_weight(), uiFont::blf_id, BLF_size(), uiFontStyle::character_weight, uiFontStyle::points, uiFontStyle::uifont_id, and uifont_to_blfont().
Referenced by UI_fontstyle_set(), and UI_fontstyle_string_width_with_block_aspect().
| void UI_fontstyle_draw | ( | const uiFontStyle * | fs, |
| const rcti * | rect, | ||
| const char * | str, | ||
| const size_t | str_len, | ||
| const uchar | col[4], | ||
| const uiFontStyleDraw_Params * | fs_params ) |
Definition at line 200 of file interface_style.cc.
References col, str, and UI_fontstyle_draw_ex().
Referenced by draw_marker_name(), file_draw_string(), icon_draw_size(), panel_draw_aligned_widgets(), ui_draw_menu_item(), ui_draw_preview_item_stateless(), ui_tooltip_region_draw_cb(), and widget_draw_text().
| void UI_fontstyle_draw_ex | ( | const uiFontStyle * | fs, |
| const rcti * | rect, | ||
| const char * | str, | ||
| const size_t | str_len, | ||
| const uchar | col[4], | ||
| const uiFontStyleDraw_Params * | fs_params, | ||
| int * | r_xofs, | ||
| int * | r_yofs, | ||
| ResultBLF * | r_info ) |
Definition at line 129 of file interface_style.cc.
References uiFontStyleDraw_Params::align, BLF_ascender(), BLF_BOLD, BLF_CLIPPING, BLF_clipping(), BLF_color4ubv(), BLF_descender(), BLF_disable(), BLF_draw(), BLF_enable(), BLF_height_max(), BLF_ITALIC, BLF_position(), BLF_SHADOW, BLF_shadow(), BLF_shadow_offset(), BLF_width(), BLF_WORD_WRAP, BLI_rcti_size_x(), BLI_rcti_size_y(), uiFontStyle::bold, ceil, col, floor, uiFontStyle::italic, uiFontStyle::shadow, uiFontStyle::shadowalpha, uiFontStyle::shadowcolor, uiFontStyle::shadx, uiFontStyle::shady, str, UI_fontstyle_set(), UI_STYLE_TEXT_CENTER, UI_STYLE_TEXT_RIGHT, uiFontStyle::uifont_id, uiFontStyleDraw_Params::word_wrap, rcti::xmax, rcti::xmin, rcti::ymax, and rcti::ymin.
Referenced by file_draw_string_multiline(), ui_draw_menu_item(), UI_fontstyle_draw(), and widget_draw_text().
| void UI_fontstyle_draw_multiline_clipped | ( | const uiFontStyle * | fs, |
| const rcti * | rect, | ||
| const char * | str, | ||
| const uchar | col[4], | ||
| eFontStyle_Align | align ) |
Draws text with wrapping and shortening using "..." so that it fits into the given rectangle.
Definition at line 301 of file interface_style.cc.
References col, str, and UI_fontstyle_draw_multiline_clipped_ex().
Referenced by file_draw_string_mulitline_clipped().
| void UI_fontstyle_draw_multiline_clipped_ex | ( | const uiFontStyle * | fs, |
| const rcti * | rect, | ||
| const char * | str, | ||
| const uchar | col[4], | ||
| const eFontStyle_Align | align, | ||
| int * | r_xofs, | ||
| int * | r_yofs, | ||
| ResultBLF * | r_info ) |
Definition at line 210 of file interface_style.cc.
References BLF_ascender(), BLF_BOLD, BLF_CLIPPING, BLF_clipping(), BLF_color4ubv(), BLF_descender(), BLF_disable(), BLF_draw(), BLF_enable(), BLF_height_max(), BLF_ITALIC, BLF_position(), BLF_SHADOW, BLF_shadow(), BLF_shadow_offset(), BLF_width(), BLI_assert, BLI_rcti_size_x(), BLI_rcti_size_y(), uiFontStyle::bold, col, floor, uiFontStyle::italic, ResultBLF::lines, uiFontStyle::shadow, uiFontStyle::shadowalpha, uiFontStyle::shadowcolor, uiFontStyle::shadx, uiFontStyle::shady, blender::Vector< T, InlineBufferCapacity, Allocator >::size(), str, UI_fontstyle_set(), UI_MAX_DRAW_STR, UI_STYLE_TEXT_CENTER, UI_STYLE_TEXT_RIGHT, UI_text_clip_multiline_middle(), uiFontStyle::uifont_id, ResultBLF::width, rcti::xmax, rcti::xmin, rcti::ymax, and rcti::ymin.
Referenced by UI_fontstyle_draw_multiline_clipped().
| void UI_fontstyle_draw_rotated | ( | const uiFontStyle * | fs, |
| const rcti * | rect, | ||
| const char * | str, | ||
| const uchar | col[4] ) |
Drawn same as UI_fontstyle_draw, but at 90 degree angle.
Definition at line 310 of file interface_style.cc.
References angle(), BLF_ascender(), BLF_CLIPPING, BLF_clipping(), BLF_color4ubv(), BLF_descender(), BLF_disable(), BLF_draw(), BLF_DRAW_STR_DUMMY_MAX, BLF_enable(), BLF_position(), BLF_ROTATION, BLF_rotation(), BLF_SHADOW, BLF_shadow(), BLF_shadow_offset(), BLF_width(), BLI_rcti_size_x(), BLI_rcti_size_y(), ceil, col, M_PI_2, uiFontStyle::shadow, uiFontStyle::shadowalpha, uiFontStyle::shadowcolor, uiFontStyle::shadx, uiFontStyle::shady, str, UI_fontstyle_set(), uiFontStyle::uifont_id, rcti::xmax, rcti::xmin, rcti::ymax, and rcti::ymin.
| void UI_fontstyle_draw_simple | ( | const uiFontStyle * | fs, |
| float | x, | ||
| float | y, | ||
| const char * | str, | ||
| const uchar | col[4] ) |
Similar to UI_fontstyle_draw but ignore alignment, shadow & no clipping rect.
For drawing on-screen labels.
Definition at line 369 of file interface_style.cc.
References BLF_color4ubv(), BLF_draw(), BLF_DRAW_STR_DUMMY_MAX, BLF_position(), col, str, UI_fontstyle_set(), uiFontStyle::uifont_id, x, and y.
Referenced by ANIM_channel_draw(), draw_current_frame(), file_draw_list(), blender::ed::outliner::outliner_draw_tree_element(), and wm_drag_draw_item_name().
| void UI_fontstyle_draw_simple_backdrop | ( | const uiFontStyle * | fs, |
| float | x, | ||
| float | y, | ||
| blender::StringRef | str, | ||
| const float | col_fg[4], | ||
| const float | col_bg[4] ) |
Same as UI_fontstyle_draw but draw a colored backdrop.
Definition at line 378 of file interface_style.cc.
References BLF_color4fv(), BLF_descender(), BLF_draw(), BLF_height_max(), BLF_position(), BLF_width(), str, UI_CNR_ALL, UI_draw_roundbox_4fv(), UI_draw_roundbox_corner_set(), UI_fontstyle_set(), uiFontStyle::uifont_id, x, rctf::xmax, rctf::xmin, y, rctf::ymax, and rctf::ymin.
Referenced by eyedropper_draw_cursor_text_region(), wm_drop_operator_draw(), and wm_drop_redalert_draw().
| int UI_fontstyle_height_max | ( | const uiFontStyle * | fs | ) |
Definition at line 464 of file interface_style.cc.
References BLF_height_max(), UI_fontstyle_set(), and uiFontStyle::uifont_id.
Referenced by file_font_pointsize(), and blender::ed::vse::text_size_get().
| void UI_fontstyle_set | ( | const uiFontStyle * | fs | ) |
Definition at line 605 of file interface_style.cc.
References fontstyle_set_ex(), and UI_SCALE_FAC.
Referenced by block_create_autorun_warning(), file_string_width(), ui_alert_create(), ui_block_bounds_calc_text(), ui_draw_menu_item(), UI_fontstyle_draw_ex(), UI_fontstyle_draw_multiline_clipped_ex(), UI_fontstyle_draw_rotated(), UI_fontstyle_draw_simple(), UI_fontstyle_draw_simple_backdrop(), UI_fontstyle_height_max(), UI_fontstyle_string_width(), UI_panel_category_draw_all(), ui_searchbox_create_generic_ex(), ui_text_clip_cursor(), UI_text_clip_middle_ex(), ui_text_clip_right_label(), ui_textedit_set_cursor_pos(), ui_tooltip_create_with_data(), ui_tooltip_region_draw_cb(), uiTemplateReportsBanner(), uiTemplateStatusInfo(), view3d_draw_region_info(), widget_draw_text(), and wm_block_dialog_create().
| int UI_fontstyle_string_width | ( | const uiFontStyle * | fs, |
| const char * | str ) |
Definition at line 448 of file interface_style.cc.
References BLF_DRAW_STR_DUMMY_MAX, BLF_width(), str, UI_fontstyle_set(), and uiFontStyle::uifont_id.
| int UI_fontstyle_string_width_with_block_aspect | ( | const uiFontStyle * | fs, |
| blender::StringRef | str, | ||
| float | aspect ) |
Return the width of str with the spacing & kerning of fs with aspect (representing uiBlock.aspect) applied.
When calculating text width, the UI layout logic calculate widths without scale, only applying scale when drawing. This causes problems for fonts since kerning at smaller sizes often makes them wider than a scaled down version of the larger text. Resolve this by calculating the text at the on-screen size, returning the result scaled back to 1:1. See #92361.
Definition at line 454 of file interface_style.cc.
References BLF_width(), fontstyle_set_ex(), str, UI_SCALE_FAC, and uiFontStyle::uifont_id.
Referenced by ui_text_icon_width_ex().
| const uiStyle * UI_style_get | ( | ) |
Read a style (without any scaling applied).
Definition at line 409 of file interface_style.cc.
References BLI_findstring(), and U.
Referenced by clip_draw_dopesheet_channels(), component_menu(), drw_text_cache_draw_ex(), ED_region_cache_draw_curfra_label(), ED_region_image_overlay_info_text_draw(), file_draw_list(), file_draw_string(), file_draw_string_mulitline_clipped(), file_draw_string_multiline(), file_font_pointsize(), file_string_width(), blender::ed::space_node::frame_node_draw_label(), blender::nodes::node_fn_input_string_cc::node_gather_link_searches(), radial_control_paint_cursor(), reset_exec(), slider_draw(), ui_block_bounds_calc_text(), ui_def_but_rna__menu(), UI_panel_category_draw_all(), ui_searchbox_create_generic_ex(), UI_style_get_dpi(), ui_textedit_set_cursor_pos(), UI_tooltip_color_field_add(), ui_tooltip_create_with_data(), ui_tooltip_region_draw_cb(), UI_view2d_region_reinit(), uiTemplateReportsBanner(), uiTemplateStatusInfo(), blender::ed::object::voxel_size_edit_draw(), widget_preview_tile(), WM_operator_confirm_ex(), and WM_operator_props_dialog_popup().
| const uiStyle * UI_style_get_dpi | ( | ) |
Read a style (with the current DPI applied).
Definition at line 421 of file interface_style.cc.
References uiStyle::boxspace, uiStyle::buttonspacex, uiStyle::buttonspacey, uiStyle::columnspace, uiStyle::grouplabel, uiStyle::panelouter, uiStyle::panelspace, uiStyle::paneltitle, uiFontStyle::shadx, uiFontStyle::shady, uiStyle::templatespace, uiStyle::tooltip, UI_SCALE_FAC, UI_style_get(), and uiStyle::widget.
Referenced by blender::ed::asset::shelf::add_tab_button(), block_create_autorun_warning(), button_section_bounds_calc(), colorband_tools_fn(), blender::ed::space_node::draw_tree_path(), ed_panel_draw(), ED_region_header_layout(), ED_region_image_metadata_draw(), ED_region_info_draw_multiline(), ED_region_property_search(), ED_time_scrub_channel_search_draw(), blender::ed::spreadsheet::get_index_column_width(), blender::ed::asset::shelf::main_region_padding_y(), menu_add_shortcut(), menu_change_shortcut(), menu_items_from_ui_create(), blender::ed::space_node::node_update_basis_buttons(), blender::ed::space_node::node_update_basis_from_declaration(), blender::ed::space_node::node_update_basis_socket(), blender::ui::padded_item_height(), blender::ed::asset::shelf::region_layout(), blender::ui::region_views_find_drop_target_at(), uiLayoutItemPanelBody::resolve_impl(), uiLayoutItemPanelHeader::resolve_impl(), blender::ed::spreadsheet::spreadsheet_footer_region_draw(), template_ID_tabs(), blender::ed::vse::text_size_get(), ui_alert_create(), UI_block_draw(), ui_offset_panel_block(), UI_pie_menu_begin(), ui_popover_create_block(), ui_popover_panel_create(), ui_popup_menu_create_block(), uiItemsAlertBox(), blender::ed::outliner::unused_message_popup_width_compute(), wm_block_about_create(), wm_block_create_redo(), wm_block_dialog_create(), wm_block_insert_unicode_create(), wm_block_splash_create(), and wm_operator_ui_create().
This is a complete set of layout rules, the 'state' of the Layout Engine. Multiple styles are possible, defined via C or Python. Styles get a name, and will typically get activated per region type, like Header, or Listview or Toolbar. Properties of Style definitions are:
Definition at line 61 of file interface_style.cc.
References BLI_addtail(), uiStyle::boxspace, uiStyle::buttonspacex, uiStyle::buttonspacey, uiFontStyle::character_weight, uiStyle::columnspace, uiStyle::grouplabel, MEM_callocN(), name, uiStyle::name, uiStyle::panelouter, uiStyle::panelspace, uiStyle::paneltitle, uiStyle::panelzoom, uiFontStyle::points, uiFontStyle::shadow, uiFontStyle::shadowalpha, uiFontStyle::shadowcolor, uiFontStyle::shadx, uiFontStyle::shady, STRNCPY_UTF8, uiStyle::templatespace, uiStyle::tooltip, UI_DEFAULT_TEXT_POINTS, UI_DEFAULT_TITLE_POINTS, UI_DEFAULT_TOOLTIP_POINTS, uiFontStyle::uifont_id, and uiStyle::widget.
Referenced by uiStyleInit().
|
static |
Definition at line 115 of file interface_style.cc.
References uiFont::next, U, and uiFont::uifont_id.
Referenced by fontstyle_set_ex().
| void uiStyleInit | ( | ) |
Called on each startup.blend read, reading without uiFont will create one.
Second for rendering else we get threading problems,
Definition at line 472 of file interface_style.cc.
References BLF_cache_flush_set_fn(), BLF_default_set(), BLF_default_size(), BLF_disable(), BLF_enable(), BLF_HINTING_FULL, BLF_HINTING_NONE, BLF_HINTING_SLIGHT, BLF_load(), BLF_load_default(), BLF_load_font_stack(), BLF_load_mono_default(), BLF_load_unique(), blf_mono_font, blf_mono_font_render, BLF_MONOCHROME, BLF_NONE, BLF_RENDER_SUBPIXELAA, BLF_unload_all(), BLI_addtail(), BLI_assert, CLAMP, CLOG_WARN, uiFont::filepath, G, G_DEBUG, LISTBASE_FOREACH, LOG, MEM_callocN(), uiFontStyle::points, STRNCPY(), U, ui_style_new(), UI_widgetbase_draw_cache_flush(), UIFONT_CUSTOM1, UIFONT_DEFAULT, uiFont::uifont_id, USER_TEXT_DISABLE_AA, USER_TEXT_HINTING_FULL, USER_TEXT_HINTING_NONE, USER_TEXT_HINTING_SLIGHT, USER_TEXT_RENDER_SUBPIXELAA, and uiStyle::widget.
Referenced by UI_init_userdef(), UI_reinit_font(), and UI_style_init_default().
|
static |
Definition at line 38 of file interface_style.cc.