|
Blender V5.0
|
#include <algorithm>#include <cctype>#include <cstdio>#include <cstdlib>#include <cstring>#include <fmt/format.h>#include "DNA_object_types.h"#include "DNA_screen_types.h"#include "ED_screen.hh"#include "BLI_listbase.h"#include "BLI_string.h"#include "BLI_string_utf8.h"#include "BLI_utildefines.h"#include "BLT_translation.hh"#include "BKE_context.hh"#include "BKE_global.hh"#include "BKE_lib_id.hh"#include "BKE_screen.hh"#include "MEM_guardedalloc.h"#include "RNA_access.hh"#include "RNA_prototypes.hh"#include "ANIM_action.hh"#include "UI_interface_icons.hh"#include "UI_interface_layout.hh"#include "UI_resources.hh"#include "UI_string_search.hh"#include "UI_view2d.hh"#include "WM_api.hh"#include "WM_types.hh"#include "interface_intern.hh"Go to the source code of this file.
Classes | |
| struct | CollItemSearch |
| struct | uiButStore |
| struct | uiButStoreElem |
Functions | |
| uiBut * | uiDefAutoButR (uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int index, const std::optional< StringRef > name, int icon, int x, int y, int width, int height) |
| void | uiDefAutoButsArrayR (uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, const int icon, const int x, const int y, const int tot_width, const int height) |
| eAutoPropButsReturn | uiDefAutoButsRNA (uiLayout *layout, PointerRNA *ptr, bool(*check_prop)(PointerRNA *ptr, PropertyRNA *prop, void *user_data), void *user_data, PropertyRNA *prop_activate_init, const eButLabelAlign label_align, const bool compact) |
| void | UI_but_func_identity_compare_set (uiBut *but, uiButIdentityCompareFunc cmp_fn) |
| static bool | add_collection_search_item (CollItemSearch &cis, const bool requires_exact_data_name, const bool has_id_icon, uiSearchItems *items) |
| void | ui_rna_collection_search_update_fn (const bContext *C, void *arg, const char *str, uiSearchItems *items, const bool is_first) |
| int | UI_icon_from_id (const ID *id) |
| int | UI_icon_from_report_type (int type) |
| int | UI_icon_colorid_from_report_type (int type) |
| int | UI_text_colorid_from_report_type (int type) |
| int | UI_calc_float_precision (int prec, double value) |
| std::optional< std::string > | UI_but_online_manual_id (const uiBut *but) |
| std::optional< std::string > | UI_but_online_manual_id_from_active (const bContext *C) |
| static rctf | ui_but_rect_to_view (const uiBut *but, const ARegion *region, const View2D *v2d) |
| static bool | ui_view2d_cur_ensure_rect_in_view (View2D *v2d, const rctf *rect) |
| void | UI_but_ensure_in_view (const bContext *C, ARegion *region, const uiBut *but) |
Button Store | |
Modal Button Store API. Store for modal operators & handlers to register button pointers which are maintained while drawing or nullptr when removed. This is needed since button pointers are continuously freed and re-allocated. | |
| uiButStore * | UI_butstore_create (uiBlock *block) |
| void | UI_butstore_free (uiBlock *block, uiButStore *bs_handle) |
| bool | UI_butstore_is_valid (uiButStore *bs_handle) |
| bool | UI_butstore_is_registered (uiBlock *block, uiBut *but) |
| void | UI_butstore_register (uiButStore *bs_handle, uiBut **but_p) |
| void | UI_butstore_unregister (uiButStore *bs_handle, uiBut **but_p) |
| bool | UI_butstore_register_update (uiBlock *block, uiBut *but_dst, const uiBut *but_src) |
| void | UI_butstore_clear (uiBlock *block) |
| void | UI_butstore_update (uiBlock *block) |
|
static |
Definition at line 456 of file interface_utils.cc.
References BKE_id_full_name_ui_prefix_get(), CollItemSearch::data, CollItemSearch::has_sep_char, CollItemSearch::iconid, CollItemSearch::is_id, CollItemSearch::name, CollItemSearch::name_prefix_offset, UI_BUT_HAS_SEP_CHAR, UI_icon_from_library(), UI_MAX_DRAW_STR, UI_search_item_add(), and UI_SEP_CHAR.
Adjust the view so the rectangle of but is in view, with some extra margin.
It's important that this is only executed after buttons received their final uiBut.rect. E.g. UI_panels_end() modifies them, so if that is executed, this function must not be called before it.
| region | The region the button is placed in. Make sure this is actually the one the button is placed in, not just the context region. |
Definition at line 880 of file interface_utils.cc.
References BLI_rctf_pad(), C, ED_region_tag_redraw_no_rebuild(), View2D::flag, ui_but_rect_to_view(), UI_UNIT_X, ui_view2d_cur_ensure_rect_in_view(), UI_view2d_curRect_changed(), ARegion::v2d, and V2D_IS_INIT.
Referenced by ui_but_update_view_for_active(), and ui_textedit_begin().
| void UI_but_func_identity_compare_set | ( | uiBut * | but, |
| uiButIdentityCompareFunc | cmp_fn ) |
Callback to compare the identity of two buttons, used to identify buttons over redraws. If the callback returns true, the given buttons are considered to be matching and relevant state is preserved (copied from the old to the new button). If it returns false, it's considered non-matching and no further checks are done.
If this is set, it is always executed instead of the default comparisons. However it is only executed for buttons that have the same type and the same callback. So callbacks can assume the button types match.
Definition at line 439 of file interface_utils.cc.
References uiBut::identity_cmp_func.
Referenced by blender::ed::outliner::outliner_draw_overrides_restrictbuts().
| std::optional< std::string > UI_but_online_manual_id | ( | const uiBut * | but | ) |
Definition at line 795 of file interface_utils.cc.
References PointerRNA::data, wmOperatorType::idname, OP_MAX_TYPENAME, uiBut::optype, RNA_property_identifier(), RNA_struct_identifier(), uiBut::rnapoin, uiBut::rnaprop, PointerRNA::type, and WM_operator_py_idname().
Referenced by UI_but_online_manual_id_from_active(), and ui_popup_context_menu_for_button().
| std::optional< std::string > UI_but_online_manual_id_from_active | ( | const bContext * | C | ) |
Definition at line 810 of file interface_utils.cc.
References C, UI_but_online_manual_id(), and UI_context_active_but_get().
Referenced by doc_view_manual_ui_context_exec().
Definition at line 820 of file interface_utils.cc.
References uiBut::block, uiBut::rect, ui_block_to_region_rctf(), and UI_view2d_region_to_view_rctf().
Referenced by UI_but_ensure_in_view().
| void UI_butstore_clear | ( | uiBlock * | block | ) |
NULL all pointers, don't free since the owner needs to be able to inspect.
Definition at line 1009 of file interface_utils.cc.
References uiBlock::butstore, and LISTBASE_FOREACH.
Referenced by UI_block_free().
| uiButStore * UI_butstore_create | ( | uiBlock * | block | ) |
Create a new button store, the caller must manage and run UI_butstore_free
Definition at line 923 of file interface_utils.cc.
References BLI_addtail(), uiButStore::block, uiBlock::butstore, and MEM_callocN().
Referenced by ui_but_add_search(), and ui_multibut_states_create().
| void UI_butstore_free | ( | uiBlock * | block, |
| uiButStore * | bs_handle ) |
Definition at line 933 of file interface_utils.cc.
References BLI_assert, BLI_findindex(), BLI_freelistN(), BLI_remlink(), uiButStore::block, uiBlock::butstore, uiButStore::items, and MEM_freeN().
Referenced by ui_multibut_free(), and ui_rna_collection_search_arg_free_fn().
Definition at line 959 of file interface_utils.cc.
References uiBlock::butstore, and LISTBASE_FOREACH.
Referenced by ui_but_free().
| bool UI_butstore_is_valid | ( | uiButStore * | bs_handle | ) |
Definition at line 954 of file interface_utils.cc.
References uiButStore::block.
| void UI_butstore_register | ( | uiButStore * | bs_handle, |
| uiBut ** | but_p ) |
Definition at line 972 of file interface_utils.cc.
References BLI_addtail(), BLI_assert, uiButStoreElem::but_p, uiButStore::items, and MEM_callocN().
Referenced by ui_but_add_search(), and ui_multibut_add().
Update the pointer for a registered button.
Definition at line 993 of file interface_utils.cc.
References uiBlock::butstore, and LISTBASE_FOREACH.
Referenced by ui_but_update_from_old_block().
| void UI_butstore_unregister | ( | uiButStore * | bs_handle, |
| uiBut ** | but_p ) |
Definition at line 981 of file interface_utils.cc.
References BLI_assert, BLI_remlink(), uiButStore::items, LISTBASE_FOREACH_MUTABLE, and MEM_freeN().
| void UI_butstore_update | ( | uiBlock * | block | ) |
Map freed buttons from the old block and update pointers.
Definition at line 1019 of file interface_utils.cc.
References BLI_assert, BLI_movelisttolist(), uiBlock::butstore, ELEM, ListBase::first, LIKELY, LISTBASE_FOREACH, uiBlock::oldblock, and ui_but_find_new().
Referenced by UI_block_update_from_old().
| int UI_calc_float_precision | ( | int | prec, |
| double | value ) |
Returns the best "UI" precision for given floating value, so that e.g. 10.000001 rather gets drawn as '10'...
Definition at line 745 of file interface_utils.cc.
References BLI_assert, CLAMP, e, fabs(), i, pow, and UI_PRECISION_FLOAT_MAX.
Referenced by outputNumInput(), and ui_but_calc_float_precision().
| int UI_icon_colorid_from_report_type | ( | int | type | ) |
Definition at line 697 of file interface_utils.cc.
References RPT_DEBUG_ALL, RPT_ERROR_ALL, RPT_INFO_ALL, RPT_OPERATOR, RPT_PROPERTY, RPT_WARNING_ALL, TH_ERROR, TH_INFO, TH_INFO_DEBUG, TH_INFO_OPERATOR, TH_INFO_PROPERTY, and TH_WARNING.
Referenced by report_line_data(), and uiTemplateReportsBanner().
| int UI_icon_from_id | ( | const ID * | id | ) |
Definition at line 651 of file interface_utils.cc.
References Object::data, GS, ID_OB, ID::name, OB_EMPTY, ptr, RNA_id_pointer_create(), RNA_struct_ui_icon(), Object::type, and UI_icon_from_id().
Referenced by object_mouse_select_menu(), and UI_icon_from_id().
| int UI_icon_from_report_type | ( | int | type | ) |
See: BKE_report_type_str
Definition at line 674 of file interface_utils.cc.
References RPT_DEBUG_ALL, RPT_ERROR_ALL, RPT_INFO_ALL, RPT_OPERATOR, RPT_PROPERTY, and RPT_WARNING_ALL.
Referenced by report_line_data(), UI_popup_menu_reports(), and uiTemplateReportsBanner().
| void ui_rna_collection_search_update_fn | ( | const bContext * | C, |
| void * | arg, | ||
| const char * | str, | ||
| uiSearchItems * | items, | ||
| const bool | is_first ) |
Definition at line 481 of file interface_utils.cc.
References Vector< T, InlineBufferCapacity, Allocator >::append(), b, Vector< T, InlineBufferCapacity, Allocator >::begin(), BKE_id_full_name_ui_prefix_get(), BLI_assert, BLI_STATIC_ASSERT, C, data, ELEM, Vector< T, InlineBufferCapacity, Allocator >::end(), flag, G, i, StringPropertySearchVisitParams::icon_id, ID_IS_LINKED, ActionSlot::idtype, Vector< T, InlineBufferCapacity, Allocator >::index_range(), StringPropertySearchVisitParams::info, MAX_ID_FULL_NAME_UI, MEM_freeN(), name, PROP_ID_SELF_CHECK, PROP_POINTER, PROP_STRING, PROP_STRING_SEARCH_SORT, PROP_STRING_SEARCH_SUPPORTED, RNA_PROP_BEGIN, RNA_PROP_END, RNA_property_flag(), RNA_property_pointer_poll(), RNA_property_string_get_alloc(), RNA_property_string_search(), RNA_property_string_search_flag(), RNA_property_type(), RNA_struct_find_property(), RNA_struct_is_ID(), RNA_struct_name_get_alloc(), Vector< T, InlineBufferCapacity, Allocator >::size(), str, UI_icon_from_idcode(), ui_id_icon_get(), UI_MAX_DRAW_STR, UI_SEP_CHAR, and wrap().
Referenced by jump_to_target_button(), template_search_menu(), ui_but_add_search(), and ui_popup_context_menu_for_button().
| int UI_text_colorid_from_report_type | ( | int | type | ) |
Definition at line 720 of file interface_utils.cc.
References RPT_DEBUG_ALL, RPT_ERROR_ALL, RPT_INFO_ALL, RPT_OPERATOR, RPT_PROPERTY, RPT_WARNING_ALL, TH_INFO_DEBUG_TEXT, TH_INFO_ERROR_TEXT, TH_INFO_INFO_TEXT, TH_INFO_OPERATOR_TEXT, TH_INFO_PROPERTY_TEXT, and TH_INFO_WARNING_TEXT.
Referenced by report_line_data(), and uiTemplateReportsBanner().
To get a margin (typically wanted), add the margin to rect directly.
Based on file_ensure_inside_viewbounds(), could probably share code.
Definition at line 838 of file interface_utils.cc.
References BLI_assert, BLI_rctf_inside_rctf(), BLI_rctf_size_x(), BLI_rctf_size_y(), View2D::cur, rect_height(), rect_width(), rctf::xmax, rctf::xmin, rctf::ymax, and rctf::ymin.
Referenced by UI_but_ensure_in_view().
| uiBut * uiDefAutoButR | ( | uiBlock * | block, |
| PointerRNA * | ptr, | ||
| PropertyRNA * | prop, | ||
| int | index, | ||
| const std::optional< StringRef > | name, | ||
| int | icon, | ||
| int | x, | ||
| int | y, | ||
| int | width, | ||
| int | height ) |
Definition at line 56 of file interface_utils.cc.
References Checkbox, Color, ELEM, IconToggle, IFACE_, Label, Menu, name, Num, NumSlider, PROP_BOOLEAN, PROP_COLLECTION, PROP_COLOR, PROP_COLOR_GAMMA, PROP_ENUM, PROP_FACTOR, PROP_FLOAT, PROP_INT, PROP_PERCENTAGE, PROP_POINTER, PROP_STRING, PROP_TEXTEDIT_UPDATE, ptr, RNA_property_array_check(), RNA_property_collection_length(), RNA_property_flag(), RNA_property_pointer_get(), RNA_property_pointer_type(), RNA_property_subtype(), RNA_property_type(), RNA_struct_ui_icon(), SearchMenu, SNPRINTF_UTF8, Text, PointerRNA::type, ui_but_add_search(), UI_BUT_DISABLED, UI_but_flag_enable(), UI_BUT_TEXTEDIT_UPDATE, UI_BUT_VALUE_CLEAR, uiDefBut(), uiDefButR_prop(), uiDefIconButR_prop(), uiDefIconTextButR_prop(), x, and y.
Referenced by ANIM_channel_draw_widgets(), draw_grease_pencil_layer_widgets(), blender::ed::outliner::outliner_draw_overrides_rna_buts(), blender::ed::outliner::outliner_draw_rnabuts(), uiLayout::prop(), template_search_add_button_name(), ui_item_array(), ui_item_with_label(), uiDefAutoButsArrayR(), uiTemplateImage(), and uiTemplateLayers().
| void uiDefAutoButsArrayR | ( | uiBlock * | block, |
| PointerRNA * | ptr, | ||
| PropertyRNA * | prop, | ||
| const int | icon, | ||
| const int | x, | ||
| const int | y, | ||
| const int | tot_width, | ||
| const int | height ) |
Definition at line 340 of file interface_utils.cc.
References i, len, ptr, RNA_property_array_length(), UI_block_align_begin(), UI_block_align_end(), uiDefAutoButR(), x, and y.
Referenced by blender::ed::outliner::outliner_draw_overrides_rna_buts().
| eAutoPropButsReturn uiDefAutoButsRNA | ( | uiLayout * | layout, |
| PointerRNA * | ptr, | ||
| bool(* | check_prop )(PointerRNA *ptr, PropertyRNA *prop, void *user_data), | ||
| void * | user_data, | ||
| PropertyRNA * | prop_activate_init, | ||
| eButLabelAlign | label_align, | ||
| bool | compact ) |
check_prop callback filters functions to avoid drawing certain properties, in cases where PROP_HIDDEN flag can't be used for a property.
| prop_activate_init | Property to activate on initial popup (UI_BUT_ACTIVATE_ON_INIT). |
Definition at line 363 of file interface_utils.cc.
References BLI_assert, col, uiLayout::column(), ELEM, flag, name, PROP_BOOLEAN, PROP_FLOAT, PROP_HIDDEN, PROP_INT, PROP_STRING, ptr, RNA_property_array_check(), RNA_property_flag(), RNA_property_type(), RNA_property_ui_name(), RNA_STRUCT_BEGIN, RNA_STRUCT_END, UI_BUT_LABEL_ALIGN_COLUMN, UI_BUT_LABEL_ALIGN_NONE, UI_BUT_LABEL_ALIGN_SPLIT_COLUMN, UI_ITEM_NONE, UI_ITEM_R_COMPACT, UI_PROP_BUTS_ANY_FAILED_CHECK, and UI_PROP_BUTS_NONE_ADDED.
Referenced by edbm_average_normals_ui(), edbm_normals_tools_ui(), edbm_point_normals_ui(), image_open_draw(), image_save_as_draw(), screenshot_draw(), blender::ed::vse::sequencer_add_draw(), and template_operator_property_buts_draw_single().