Blender V4.3
interface_region_tooltip.cc File Reference
#include <algorithm>
#include <cstdarg>
#include <cstdlib>
#include <cstring>
#include <memory>
#include <fmt/format.h>
#include "MEM_guardedalloc.h"
#include "DNA_userdef_types.h"
#include "BLI_fileops.h"
#include "BLI_listbase.h"
#include "BLI_math_color.h"
#include "BLI_math_vector.h"
#include "BLI_path_utils.hh"
#include "BLI_rect.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "BKE_context.hh"
#include "BKE_idtype.hh"
#include "BKE_image.hh"
#include "BKE_paint.hh"
#include "BKE_screen.hh"
#include "BIF_glutil.hh"
#include "DNA_vfont_types.h"
#include "GPU_immediate.hh"
#include "GPU_immediate_util.hh"
#include "GPU_state.hh"
#include "IMB_imbuf.hh"
#include "IMB_imbuf_types.hh"
#include "IMB_thumbs.hh"
#include "WM_api.hh"
#include "WM_types.hh"
#include "RNA_access.hh"
#include "RNA_path.hh"
#include "RNA_prototypes.hh"
#include "UI_interface.hh"
#include "BLF_api.hh"
#include "BLT_translation.hh"
#include "ED_screen.hh"
#include "interface_intern.hh"
#include "interface_regions_intern.hh"

Go to the source code of this file.

Classes

struct  uiTooltipFormat
 
struct  uiTooltipField
 
struct  uiTooltipData
 

Macros

#define UI_TIP_SPACER   0.3f
 
#define UI_TIP_PADDING   int(1.3f * UI_UNIT_Y)
 
#define UI_TIP_MAXWIDTH   600
 
#define UI_TIP_MAXIMAGEWIDTH   500
 
#define UI_TIP_MAXIMAGEHEIGHT   300
 
#define UI_TIP_STR_MAX   1024
 
#define TIP_BORDER_X   (16.0f)
 
#define TIP_BORDER_Y   (6.0f)
 

Functions

 BLI_STATIC_ASSERT (int(UI_TIP_LC_MAX)==int(UI_TIP_LC_ALERT)+1, "invalid lc-max")
 
void UI_tooltip_text_field_add (uiTooltipData &data, std::string text, std::string suffix, const uiTooltipStyle style, const uiTooltipColorID color_id, const bool is_pad)
 
void UI_tooltip_image_field_add (uiTooltipData &data, const uiTooltipImage &image_data)
 
ToolTip Callbacks (Draw & Free)
static void rgb_tint (float col[3], float h, float h_strength, float v, float v_strength)
 
static void ui_tooltip_region_draw_cb (const bContext *, ARegion *region)
 
static void ui_tooltip_region_free_cb (ARegion *region)
 
ToolTip Creation Utility Functions
static std::string ui_tooltip_text_python_from_op (bContext *C, wmOperatorType *ot, PointerRNA *opptr)
 
ToolTip Creation
static bool ui_tooltip_period_needed (blender::StringRef tip)
 
static std::unique_ptr< uiTooltipDataui_tooltip_data_from_tool (bContext *C, uiBut *but, bool is_label)
 
static std::unique_ptr< uiTooltipDataui_tooltip_data_from_button_or_extra_icon (bContext *C, uiBut *but, uiButExtraOpIcon *extra_icon, const bool is_label)
 
static std::unique_ptr< uiTooltipDataui_tooltip_data_from_gizmo (bContext *C, wmGizmo *gz)
 
static std::unique_ptr< uiTooltipDataui_tooltip_data_from_custom_func (bContext *C, uiBut *but)
 
static ARegionui_tooltip_create_with_data (bContext *C, std::unique_ptr< uiTooltipData > data_uptr, const float init_position[2], const rcti *init_rect_overlap)
 
ToolTip Public API
ARegionUI_tooltip_create_from_button_or_extra_icon (bContext *C, ARegion *butregion, uiBut *but, uiButExtraOpIcon *extra_icon, bool is_label)
 
ARegionUI_tooltip_create_from_button (bContext *C, ARegion *butregion, uiBut *but, bool is_label)
 
ARegionUI_tooltip_create_from_gizmo (bContext *C, wmGizmo *gz)
 
static void ui_tooltip_from_image (Image &ima, uiTooltipData &data)
 
static void ui_tooltip_from_clip (MovieClip &clip, uiTooltipData &data)
 
static void ui_tooltip_from_vfont (const VFont &font, uiTooltipData &data)
 
static std::unique_ptr< uiTooltipDataui_tooltip_data_from_search_item_tooltip_data (ID *id)
 
ARegionUI_tooltip_create_from_search_item_generic (bContext *C, const ARegion *searchbox_region, const rcti *item_rect, ID *id)
 
void UI_tooltip_free (bContext *C, bScreen *screen, ARegion *region)
 

Detailed Description

ToolTip Region and Construction

Definition in file interface_region_tooltip.cc.

Macro Definition Documentation

◆ TIP_BORDER_X

#define TIP_BORDER_X   (16.0f)

◆ TIP_BORDER_Y

#define TIP_BORDER_Y   (6.0f)

◆ UI_TIP_MAXIMAGEHEIGHT

#define UI_TIP_MAXIMAGEHEIGHT   300

Definition at line 84 of file interface_region_tooltip.cc.

◆ UI_TIP_MAXIMAGEWIDTH

#define UI_TIP_MAXIMAGEWIDTH   500

Definition at line 83 of file interface_region_tooltip.cc.

◆ UI_TIP_MAXWIDTH

#define UI_TIP_MAXWIDTH   600

Definition at line 82 of file interface_region_tooltip.cc.

Referenced by ui_tooltip_create_with_data().

◆ UI_TIP_PADDING

#define UI_TIP_PADDING   int(1.3f * UI_UNIT_Y)

◆ UI_TIP_SPACER

#define UI_TIP_SPACER   0.3f

◆ UI_TIP_STR_MAX

#define UI_TIP_STR_MAX   1024

Definition at line 85 of file interface_region_tooltip.cc.

Function Documentation

◆ BLI_STATIC_ASSERT()

BLI_STATIC_ASSERT ( int(UI_TIP_LC_MAX) = =int(UI_TIP_LC_ALERT)+1,
"invalid lc-max"  )

◆ rgb_tint()

static void rgb_tint ( float col[3],
float h,
float h_strength,
float v,
float v_strength )
static

Definition at line 148 of file interface_region_tooltip.cc.

References col, hsv_to_rgb_v(), rgb_to_hsv_v(), and v.

Referenced by ui_tooltip_region_draw_cb().

◆ UI_tooltip_create_from_button()

ARegion * UI_tooltip_create_from_button ( bContext * C,
ARegion * butregion,
uiBut * but,
bool is_label )
Parameters
is_labelWhen true, show a small tip that only shows the name, otherwise show the full tooltip.

Definition at line 1550 of file interface_region_tooltip.cc.

References UI_tooltip_create_from_button_or_extra_icon().

Referenced by ui_search_menu_create_tooltip().

◆ UI_tooltip_create_from_button_or_extra_icon()

◆ UI_tooltip_create_from_gizmo()

◆ UI_tooltip_create_from_search_item_generic()

ARegion * UI_tooltip_create_from_search_item_generic ( bContext * C,
const ARegion * searchbox_region,
const rcti * item_rect,
ID * id )

Create a tooltip from search-item tooltip data item_tooltip data. To be called from a callback set with UI_but_func_search_set_tooltip().

Parameters
item_rectRectangle of the search item in search region space (ui_searchbox_butrect()) which is passed to the tooltip callback.

Definition at line 1777 of file interface_region_tooltip.cc.

References CTX_wm_window(), wmWindow::eventstate, UI_POPUP_MARGIN, ui_tooltip_create_with_data(), ui_tooltip_data_from_search_item_tooltip_data(), ARegion::winrct, wmEvent::xy, and rcti::ymin.

Referenced by template_ID_search_menu_item_tooltip().

◆ ui_tooltip_create_with_data()

◆ ui_tooltip_data_from_button_or_extra_icon()

static std::unique_ptr< uiTooltipData > ui_tooltip_data_from_button_or_extra_icon ( bContext * C,
uiBut * but,
uiButExtraOpIcon * extra_icon,
const bool is_label )
static

Definition at line 788 of file interface_region_tooltip.cc.

References uiTooltipImage::background, blf_mono_font, BLF_size(), BLF_width(), BLI_assert, uiBut::block, uiTooltipImage::border, Checkerboard_Fixed, CTX_wm_operator_poll_msg_clear(), CTX_wm_operator_poll_msg_get(), uiBut::disabled_info, uiBut::drawstr, ELEM, uiBut::flag, uiTooltipImage::height, IB_rect, uiTooltipImage::ibuf, ID_IS_LINKED, IMB_allocImBuf(), IMB_freeImBuf(), IMB_rectfill_area(), int, MEM_freeN(), None, uiBut::opcontext, wmOperatorCallParams::opcontext, uiBut::optype, wmOperatorCallParams::optype, uiButExtraOpIcon::optype_params, PointerRNA::owner_id, uiFontStyle::points, uiTooltipImage::premultiplied, PROP_ENUM_FLAG, PROP_FLOAT, PROP_PASSWORD, PROP_UNIT_ROTATION, rgb_to_hsv_v(), rgba_float_to_uchar(), RNA_path_full_property_py_ex(), RNA_path_full_struct_py(), RNA_property_array_check(), RNA_property_array_length(), RNA_property_flag(), RNA_property_float_get(), RNA_property_float_get_index(), RNA_property_subtype(), RNA_property_type(), uiBut::rnaindex, uiBut::rnapoin, uiBut::rnaprop, blender::StringRefBase::startswith(), str, TIP_, uiBut::tip_func, uiStyle::tooltip, uiBut::type, ui_block_cm_display_get(), ui_block_cm_to_display_space_v3(), ui_block_is_menu(), ui_block_is_pie_menu(), UI_BTYPE_COLOR, UI_BTYPE_ROW, UI_BTYPE_SEARCH_MENU, UI_BTYPE_TEXT, ui_but_anim_expression_get(), ui_but_context_poll_operator_ex(), UI_BUT_DISABLED, UI_BUT_DRIVEN, UI_but_extra_icon_string_get_label(), UI_but_extra_icon_string_get_operator_keymap(), UI_but_extra_icon_string_get_tooltip(), UI_but_extra_operator_icon_opptr_get(), UI_but_extra_operator_icon_optype_get(), ui_but_is_color_gamma(), UI_but_operator_ptr_ensure(), UI_but_rna_enum_item_get(), ui_but_string_get(), UI_but_string_get_label(), UI_but_string_get_operator_keymap(), UI_but_string_get_property_keymap(), UI_but_string_get_rna_property_identifier(), UI_but_string_get_rna_struct_identifier(), UI_but_string_get_tooltip(), UI_but_string_get_tooltip_label(), UI_but_unit_type_get(), ui_but_v3_get(), UI_SCALE_FAC, UI_style_get(), UI_TIP_LC_ALERT, UI_TIP_LC_NORMAL, UI_TIP_LC_PYTHON, UI_TIP_LC_VALUE, UI_TIP_STYLE_HEADER, UI_TIP_STYLE_MONO, UI_TIP_STYLE_NORMAL, UI_TIP_STYLE_SPACER, UI_tooltip_image_field_add(), ui_tooltip_period_needed(), UI_tooltip_text_field_add(), ui_tooltip_text_python_from_op(), USER_TOOLTIPS_PYTHON, w(), uiTooltipImage::width, and WM_operator_properties_sanitize().

Referenced by UI_tooltip_create_from_button_or_extra_icon().

◆ ui_tooltip_data_from_custom_func()

static std::unique_ptr< uiTooltipData > ui_tooltip_data_from_custom_func ( bContext * C,
uiBut * but )
static

◆ ui_tooltip_data_from_gizmo()

◆ ui_tooltip_data_from_search_item_tooltip_data()

static std::unique_ptr< uiTooltipData > ui_tooltip_data_from_search_item_tooltip_data ( ID * id)
static

◆ ui_tooltip_data_from_tool()

◆ UI_tooltip_free()

void UI_tooltip_free ( bContext * C,
bScreen * screen,
ARegion * region )

◆ ui_tooltip_from_clip()

◆ ui_tooltip_from_image()

◆ ui_tooltip_from_vfont()

◆ UI_tooltip_image_field_add()

void UI_tooltip_image_field_add ( uiTooltipData & data,
const uiTooltipImage & image_data )
Parameters
imageImage buffer (duplicated, ownership is not transferred to data).
image_sizeDisplay size for the image (pixels without UI scale applied).

Definition at line 135 of file interface_region_tooltip.cc.

References uiTooltipField::format, uiTooltipImage::ibuf, IMB_dupImBuf(), uiTooltipFormat::style, and UI_TIP_STYLE_IMAGE.

Referenced by file_draw_tooltip_custom_func(), ui_tooltip_data_from_button_or_extra_icon(), ui_tooltip_from_clip(), ui_tooltip_from_image(), ui_tooltip_from_vfont(), and uiTemplateRecentFiles_tooltip_func().

◆ ui_tooltip_period_needed()

◆ ui_tooltip_region_draw_cb()

static void ui_tooltip_region_draw_cb ( const bContext * ,
ARegion * region )
static

◆ ui_tooltip_region_free_cb()

static void ui_tooltip_region_free_cb ( ARegion * region)
static

Definition at line 352 of file interface_region_tooltip.cc.

References IMB_freeImBuf().

Referenced by ui_tooltip_create_with_data().

◆ UI_tooltip_text_field_add()

void UI_tooltip_text_field_add ( uiTooltipData & data,
std::string text,
std::string suffix,
const uiTooltipStyle style,
const uiTooltipColorID color_id,
const bool is_pad = false )

◆ ui_tooltip_text_python_from_op()

static std::string ui_tooltip_text_python_from_op ( bContext * C,
wmOperatorType * ot,
PointerRNA * opptr )
static