Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface.c
| Show All 15 Lines | |||||
| * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. | * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. | ||||
| * All rights reserved. | * All rights reserved. | ||||
| */ | */ | ||||
| /** \file | /** \file | ||||
| * \ingroup edinterface | * \ingroup edinterface | ||||
| */ | */ | ||||
| #include <CLG_log.h> | |||||
| #include <ctype.h> | #include <ctype.h> | ||||
| #include <float.h> | #include <float.h> | ||||
| #include <limits.h> | #include <limits.h> | ||||
| #include <math.h> | #include <math.h> | ||||
| #include <stddef.h> /* offsetof() */ | #include <stddef.h> /* offsetof() */ | ||||
| #include <string.h> | #include <string.h> | ||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| ▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | |||||
| #include "ED_screen.h" | #include "ED_screen.h" | ||||
| #include "IMB_colormanagement.h" | #include "IMB_colormanagement.h" | ||||
| #include "DEG_depsgraph_query.h" | #include "DEG_depsgraph_query.h" | ||||
| #include "interface_intern.h" | #include "interface_intern.h" | ||||
| static CLG_LogRef LOG = {"interface"}; | |||||
| /* prototypes. */ | /* prototypes. */ | ||||
| static void ui_but_to_pixelrect(struct rcti *rect, | static void ui_but_to_pixelrect(struct rcti *rect, | ||||
| const struct ARegion *region, | const struct ARegion *region, | ||||
| struct uiBlock *block, | struct uiBlock *block, | ||||
| struct uiBut *but); | struct uiBut *but); | ||||
| static void ui_def_but_rna__menu(bContext *UNUSED(C), uiLayout *layout, void *but_p); | static void ui_def_but_rna__menu(bContext *UNUSED(C), uiLayout *layout, void *but_p); | ||||
| static void ui_def_but_rna__panel_type(bContext *UNUSED(C), uiLayout *layout, void *but_p); | static void ui_def_but_rna__panel_type(bContext *UNUSED(C), uiLayout *layout, void *but_p); | ||||
| static void ui_def_but_rna__menu_type(bContext *UNUSED(C), uiLayout *layout, void *but_p); | static void ui_def_but_rna__menu_type(bContext *UNUSED(C), uiLayout *layout, void *but_p); | ||||
| ▲ Show 20 Lines • Show All 1,240 Lines • ▼ Show 20 Lines | if (ptr->owner_id) { | ||||
| else { | else { | ||||
| /* scene property */ | /* scene property */ | ||||
| char *path = RNA_path_from_ID_to_property(ptr, prop); | char *path = RNA_path_from_ID_to_property(ptr, prop); | ||||
| if (path) { | if (path) { | ||||
| data_path = BLI_sprintfN("scene.%s", path); | data_path = BLI_sprintfN("scene.%s", path); | ||||
| MEM_freeN(path); | MEM_freeN(path); | ||||
| } | } | ||||
| #if 0 | |||||
| else { | else { | ||||
| printf("ERROR in %s(): Couldn't get path for scene property - %s\n", | CLOG_ERROR( | ||||
| __func__, | &LOG, "Couldn't get path for scene property - %s", RNA_property_identifier(prop)); | ||||
| RNA_property_identifier(prop)); | |||||
| } | } | ||||
| #endif | |||||
| } | } | ||||
| } | } | ||||
| else { | |||||
| // puts("other id"); | |||||
| } | |||||
| // printf("prop shortcut: '%s' (%s)\n", RNA_property_identifier(prop), data_path); | CLOG_VERBOSE(&LOG, 4, "prop shortcut: '%s' (%s)", RNA_property_identifier(prop), data_path); | ||||
| } | } | ||||
| /* we have a datapath! */ | /* we have a datapath! */ | ||||
| if (data_path || (prop_enum_value_ok && prop_enum_value_id)) { | if (data_path || (prop_enum_value_ok && prop_enum_value_id)) { | ||||
| /* create a property to host the "datapath" property we're sending to the operators */ | /* create a property to host the "datapath" property we're sending to the operators */ | ||||
| IDProperty *prop_path; | IDProperty *prop_path; | ||||
| IDPropertyTemplate val = {0}; | IDPropertyTemplate val = {0}; | ||||
| ▲ Show 20 Lines • Show All 792 Lines • ▼ Show 20 Lines | else if (but->pointype == UI_BUT_POIN_CHAR) { | ||||
| vec[2] = ((float)cp[2]) / 255.0f; | vec[2] = ((float)cp[2]) / 255.0f; | ||||
| } | } | ||||
| else if (but->pointype == UI_BUT_POIN_FLOAT) { | else if (but->pointype == UI_BUT_POIN_FLOAT) { | ||||
| const float *fp = (float *)but->poin; | const float *fp = (float *)but->poin; | ||||
| copy_v3_v3(vec, fp); | copy_v3_v3(vec, fp); | ||||
| } | } | ||||
| else { | else { | ||||
| if (but->editvec == NULL) { | if (but->editvec == NULL) { | ||||
| fprintf(stderr, "%s: can't get color, should never happen\n", __func__); | CLOG_ERROR(&LOG, "can not get color, should never happen"); | ||||
| zero_v3(vec); | zero_v3(vec); | ||||
| } | } | ||||
| } | } | ||||
| if (but->type == UI_BTYPE_UNITVEC) { | if (but->type == UI_BTYPE_UNITVEC) { | ||||
| normalize_v3(vec); | normalize_v3(vec); | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 133 Lines • ▼ Show 20 Lines | bool ui_but_is_compatible(const uiBut *but_a, const uiBut *but_b) | ||||
| return true; | return true; | ||||
| } | } | ||||
| bool ui_but_is_rna_valid(uiBut *but) | bool ui_but_is_rna_valid(uiBut *but) | ||||
| { | { | ||||
| if (but->rnaprop == NULL || RNA_struct_contains_property(&but->rnapoin, but->rnaprop)) { | if (but->rnaprop == NULL || RNA_struct_contains_property(&but->rnapoin, but->rnaprop)) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| printf("property removed %s: %p\n", but->drawstr, but->rnaprop); | CLOG_INFO(&LOG, "property removed %s: %p", but->drawstr, but->rnaprop); | ||||
| return false; | return false; | ||||
| } | } | ||||
| /** | /** | ||||
| * Checks if the button supports cycling next/previous menu items (ctrl+mouse-wheel). | * Checks if the button supports cycling next/previous menu items (ctrl+mouse-wheel). | ||||
| */ | */ | ||||
| bool ui_but_supports_cycling(const uiBut *but) | bool ui_but_supports_cycling(const uiBut *but) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 4,205 Lines • ▼ Show 20 Lines | void UI_but_func_search_set(uiBut *but, | ||||
| search_but->popup_create_fn = search_create_fn; | search_but->popup_create_fn = search_create_fn; | ||||
| search_but->items_update_fn = search_update_fn; | search_but->items_update_fn = search_update_fn; | ||||
| search_but->item_active = active; | search_but->item_active = active; | ||||
| search_but->arg = arg; | search_but->arg = arg; | ||||
| search_but->arg_free_fn = search_arg_free_fn; | search_but->arg_free_fn = search_arg_free_fn; | ||||
| if (search_exec_fn) { | if (search_exec_fn) { | ||||
| #ifdef DEBUG | |||||
| if (search_but->but.func) { | if (search_but->but.func) { | ||||
| /* watch this, can be cause of much confusion, see: T47691 */ | /* watch this, can be cause of much confusion, see: T47691 */ | ||||
| printf("%s: warning, overwriting button callback with search function callback!\n", | CLOG_STR_WARN(&LOG, "overwriting button callback with search function callback!"); | ||||
| __func__); | |||||
| } | } | ||||
| #endif | |||||
| /* Handling will pass the active item as arg2 later, so keep it NULL here. */ | /* Handling will pass the active item as arg2 later, so keep it NULL here. */ | ||||
| UI_but_func_set(but, search_exec_fn, search_but->arg, NULL); | UI_but_func_set(but, search_exec_fn, search_but->arg, NULL); | ||||
| } | } | ||||
| /* search buttons show red-alert if item doesn't exist, not for menus */ | /* search buttons show red-alert if item doesn't exist, not for menus */ | ||||
| if (0 == (but->block->flag & UI_BLOCK_LOOP)) { | if (0 == (but->block->flag & UI_BLOCK_LOOP)) { | ||||
| /* skip empty buttons, not all buttons need input, we only show invalid */ | /* skip empty buttons, not all buttons need input, we only show invalid */ | ||||
| if (but->drawstr[0]) { | if (but->drawstr[0]) { | ||||
| Show All 35 Lines | static void operator_enum_search_update_fn(const struct bContext *C, | ||||
| void *but, | void *but, | ||||
| const char *str, | const char *str, | ||||
| uiSearchItems *items) | uiSearchItems *items) | ||||
| { | { | ||||
| wmOperatorType *ot = ((uiBut *)but)->optype; | wmOperatorType *ot = ((uiBut *)but)->optype; | ||||
| PropertyRNA *prop = ot->prop; | PropertyRNA *prop = ot->prop; | ||||
| if (prop == NULL) { | if (prop == NULL) { | ||||
| printf("%s: %s has no enum property set\n", __func__, ot->idname); | CLOG_ERROR(&LOG, "%s has no enum property set", ot->idname); | ||||
| } | } | ||||
| else if (RNA_property_type(prop) != PROP_ENUM) { | else if (RNA_property_type(prop) != PROP_ENUM) { | ||||
| printf("%s: %s \"%s\" is not an enum property\n", | CLOG_ERROR( | ||||
| __func__, | &LOG, "%s \"%s\" is not an enum property", ot->idname, RNA_property_identifier(prop)); | ||||
| ot->idname, | |||||
| RNA_property_identifier(prop)); | |||||
| } | } | ||||
| else { | else { | ||||
| PointerRNA *ptr = UI_but_operator_ptr_get(but); /* Will create it if needed! */ | PointerRNA *ptr = UI_but_operator_ptr_get(but); /* Will create it if needed! */ | ||||
| const EnumPropertyItem *item, *item_array; | const EnumPropertyItem *item, *item_array; | ||||
| bool do_free; | bool do_free; | ||||
| RNA_property_enum_items_gettexted((bContext *)C, ptr, prop, &item_array, NULL, &do_free); | RNA_property_enum_items_gettexted((bContext *)C, ptr, prop, &item_array, NULL, &do_free); | ||||
| Show All 23 Lines | if (ot) { | ||||
| if (ot->prop) { | if (ot->prop) { | ||||
| RNA_property_enum_set(opptr, ot->prop, POINTER_AS_INT(arg2)); | RNA_property_enum_set(opptr, ot->prop, POINTER_AS_INT(arg2)); | ||||
| /* We do not call op from here, will be called by button code. | /* We do not call op from here, will be called by button code. | ||||
| * ui_apply_but_funcs_after() (in interface_handlers.c) | * ui_apply_but_funcs_after() (in interface_handlers.c) | ||||
| * called this func before checking operators, | * called this func before checking operators, | ||||
| * because one of its parameters is the button itself! */ | * because one of its parameters is the button itself! */ | ||||
| } | } | ||||
| else { | else { | ||||
| printf("%s: op->prop for '%s' is NULL\n", __func__, ot->idname); | CLOG_INFO(&LOG, "op->prop for '%s' is NULL", ot->idname); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /** | /** | ||||
| * Same parameters as for uiDefSearchBut, with additional operator type and properties, | * Same parameters as for uiDefSearchBut, with additional operator type and properties, | ||||
| * used by callback to call again the right op with the right options (properties values). | * used by callback to call again the right op with the right options (properties values). | ||||
| */ | */ | ||||
| ▲ Show 20 Lines • Show All 334 Lines • Show Last 20 Lines | |||||