Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_handlers.c
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
| Show First 20 Lines • Show All 6,753 Lines • ▼ Show 20 Lines | |||||
| static bool ui_but_menu(bContext *C, uiBut *but) | static bool ui_but_menu(bContext *C, uiBut *but) | ||||
| { | { | ||||
| uiPopupMenu *pup; | uiPopupMenu *pup; | ||||
| uiLayout *layout; | uiLayout *layout; | ||||
| MenuType *mt = WM_menutype_find("WM_MT_button_context", true); | MenuType *mt = WM_menutype_find("WM_MT_button_context", true); | ||||
| bool is_array, is_array_component; | bool is_array, is_array_component; | ||||
| uiStringInfo label = {BUT_GET_LABEL, NULL}; | uiStringInfo label = {BUT_GET_LABEL, NULL}; | ||||
| wmOperatorType *ot; | |||||
| PointerRNA op_ptr; | |||||
| /* if ((but->rnapoin.data && but->rnaprop) == 0 && but->optype == NULL)*/ | /* if ((but->rnapoin.data && but->rnaprop) == 0 && but->optype == NULL)*/ | ||||
| /* return 0;*/ | /* return 0;*/ | ||||
| /* having this menu for some buttons makes no sense */ | /* having this menu for some buttons makes no sense */ | ||||
| if (but->type == UI_BTYPE_IMAGE) { | if (but->type == UI_BTYPE_IMAGE) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| Show All 10 Lines | /* return 0;*/ | ||||
| if (but->rnapoin.data && but->rnaprop) { | if (but->rnapoin.data && but->rnaprop) { | ||||
| PointerRNA *ptr = &but->rnapoin; | PointerRNA *ptr = &but->rnapoin; | ||||
| PropertyRNA *prop = but->rnaprop; | PropertyRNA *prop = but->rnaprop; | ||||
| const PropertyType type = RNA_property_type(prop); | const PropertyType type = RNA_property_type(prop); | ||||
| const PropertySubType subtype = RNA_property_subtype(prop); | const PropertySubType subtype = RNA_property_subtype(prop); | ||||
| bool is_anim = RNA_property_animateable(ptr, prop); | bool is_anim = RNA_property_animateable(ptr, prop); | ||||
| bool is_editable = RNA_property_editable(ptr, prop); | bool is_editable = RNA_property_editable(ptr, prop); | ||||
| bool is_overridable; | |||||
| /*bool is_idprop = RNA_property_is_idprop(prop);*/ /* XXX does not work as expected, not strictly needed */ | /*bool is_idprop = RNA_property_is_idprop(prop);*/ /* XXX does not work as expected, not strictly needed */ | ||||
| bool is_set = RNA_property_is_set(ptr, prop); | bool is_set = RNA_property_is_set(ptr, prop); | ||||
| /* Set the (button_pointer, button_prop) and pointer data for Python access to the hovered ui element. */ | RNA_property_override_status(ptr, prop, -1, &is_overridable, NULL, NULL, NULL); | ||||
| uiLayoutSetContextFromBut(layout, but); | |||||
| /* second slower test, saved people finding keyframe items in menus when its not possible */ | /* second slower test, saved people finding keyframe items in menus when its not possible */ | ||||
| if (is_anim) | if (is_anim) | ||||
| is_anim = RNA_property_path_from_ID_check(&but->rnapoin, but->rnaprop); | is_anim = RNA_property_path_from_ID_check(&but->rnapoin, but->rnaprop); | ||||
| /* determine if we can key a single component of an array */ | /* determine if we can key a single component of an array */ | ||||
| is_array = RNA_property_array_length(&but->rnapoin, but->rnaprop) != 0; | is_array = RNA_property_array_length(&but->rnapoin, but->rnaprop) != 0; | ||||
| is_array_component = (is_array && but->rnaindex != -1); | is_array_component = (is_array && but->rnaindex != -1); | ||||
| ▲ Show 20 Lines • Show All 112 Lines • ▼ Show 20 Lines | if (is_anim) { | ||||
| } | } | ||||
| else { | else { | ||||
| uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add to Keying Set"), | uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add to Keying Set"), | ||||
| ICON_KEYINGSET, "ANIM_OT_keyingset_button_add", "all", 1); | ICON_KEYINGSET, "ANIM_OT_keyingset_button_add", "all", 1); | ||||
| uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Remove from Keying Set"), | uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Remove from Keying Set"), | ||||
| ICON_NONE, "ANIM_OT_keyingset_button_remove"); | ICON_NONE, "ANIM_OT_keyingset_button_remove"); | ||||
| } | } | ||||
| } | } | ||||
| if (is_overridable) { | |||||
| /* Override Operators */ | |||||
| uiItemS(layout); | |||||
| if (but->flag & UI_BUT_OVERRIDEN) { | |||||
| if (is_array_component) { | |||||
| ot = WM_operatortype_find("UI_OT_override_type_set_button", false); | |||||
| uiItemFullO_ptr(layout, ot, "Overrides Type", ICON_NONE, | |||||
| NULL, WM_OP_INVOKE_DEFAULT, 0, &op_ptr); | |||||
| RNA_boolean_set(&op_ptr, "all", true); | |||||
| uiItemFullO_ptr(layout, ot, "Single Override Type", ICON_NONE, | |||||
| NULL, WM_OP_INVOKE_DEFAULT, 0, &op_ptr); | |||||
| RNA_boolean_set(&op_ptr, "all", false); | |||||
| uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Remove Overrides"), | |||||
| ICON_X, "UI_OT_override_remove_button", "all", true); | |||||
| uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Remove Single Override"), | |||||
| ICON_X, "UI_OT_override_remove_button", "all", false); | |||||
| } | |||||
| else { | |||||
| uiItemFullO(layout, "UI_OT_override_type_set_button", "Override Type", ICON_NONE, | |||||
| NULL, WM_OP_INVOKE_DEFAULT, 0, &op_ptr); | |||||
| RNA_boolean_set(&op_ptr, "all", false); | |||||
| uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Remove Override"), | |||||
| ICON_X, "UI_OT_override_remove_button", "all", true); | |||||
| } | |||||
| } | |||||
| else { | |||||
| if (is_array_component) { | |||||
| ot = WM_operatortype_find("UI_OT_override_type_set_button", false); | |||||
| uiItemFullO_ptr(layout, ot, "Define Overrides", ICON_NONE, | |||||
| NULL, WM_OP_INVOKE_DEFAULT, 0, &op_ptr); | |||||
| RNA_boolean_set(&op_ptr, "all", true); | |||||
| uiItemFullO_ptr(layout, ot, "Define Single Override", ICON_NONE, | |||||
| NULL, WM_OP_INVOKE_DEFAULT, 0, &op_ptr); | |||||
| RNA_boolean_set(&op_ptr, "all", false); | |||||
| } | |||||
| else { | |||||
| uiItemFullO(layout, "UI_OT_override_type_set_button", "Define Override", ICON_NONE, | |||||
| NULL, WM_OP_INVOKE_DEFAULT, 0, &op_ptr); | |||||
| RNA_boolean_set(&op_ptr, "all", false); | |||||
| } | |||||
| } | |||||
| } | |||||
| uiItemS(layout); | uiItemS(layout); | ||||
| /* Property Operators */ | /* Property Operators */ | ||||
| /* Copy Property Value | /* Copy Property Value | ||||
| * Paste Property Value */ | * Paste Property Value */ | ||||
| if (is_array_component) { | if (is_array_component) { | ||||
| uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Reset All to Default Values"), | uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Reset All to Default Values"), | ||||
| ICON_LOOP_BACK, "UI_OT_reset_default_button", "all", 1); | ICON_LOOP_BACK, "UI_OT_reset_default_button", "all", 1); | ||||
| uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Reset Single to Default Value"), | uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Reset Single to Default Value"), | ||||
| ICON_NONE, "UI_OT_reset_default_button", "all", 0); | ICON_NONE, "UI_OT_reset_default_button", "all", 0); | ||||
| ▲ Show 20 Lines • Show All 1,262 Lines • ▼ Show 20 Lines | void UI_context_update_anim_flag(const bContext *C) | ||||
| while (ar) { | while (ar) { | ||||
| /* find active button */ | /* find active button */ | ||||
| activebut = NULL; | activebut = NULL; | ||||
| for (block = ar->uiblocks.first; block; block = block->next) { | for (block = ar->uiblocks.first; block; block = block->next) { | ||||
| for (but = block->buttons.first; but; but = but->next) { | for (but = block->buttons.first; but; but = but->next) { | ||||
| ui_but_anim_flag(but, (scene) ? scene->r.cfra : 0.0f); | ui_but_anim_flag(but, (scene) ? scene->r.cfra : 0.0f); | ||||
| ui_but_override_flag(but); | |||||
| ED_region_tag_redraw(ar); | ED_region_tag_redraw(ar); | ||||
| if (but->active) { | if (but->active) { | ||||
| activebut = but; | activebut = but; | ||||
| } | } | ||||
| else if (!activebut && (but->flag & UI_BUT_LAST_ACTIVE)) { | else if (!activebut && (but->flag & UI_BUT_LAST_ACTIVE)) { | ||||
| activebut = but; | activebut = but; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 2,132 Lines • Show Last 20 Lines | |||||