Changeset View
Changeset View
Standalone View
Standalone View
source/blender/windowmanager/intern/wm_operators.c
| Show First 20 Lines • Show All 1,067 Lines • ▼ Show 20 Lines | printf("%s: %s \"%s\" is not an enum property\n", | ||||
| __func__, op->type->idname, RNA_property_identifier(prop)); | __func__, op->type->idname, RNA_property_identifier(prop)); | ||||
| } | } | ||||
| else if (RNA_property_is_set(op->ptr, prop)) { | else if (RNA_property_is_set(op->ptr, prop)) { | ||||
| const int retval = op->type->exec(C, op); | const int retval = op->type->exec(C, op); | ||||
| OPERATOR_RETVAL_CHECK(retval); | OPERATOR_RETVAL_CHECK(retval); | ||||
| return retval; | return retval; | ||||
| } | } | ||||
| else { | else { | ||||
| pup = uiPupMenuBegin(C, RNA_struct_ui_name(op->type->srna), ICON_NONE); | pup = UI_popup_menu_begin(C, RNA_struct_ui_name(op->type->srna), ICON_NONE); | ||||
| layout = uiPupMenuLayout(pup); | layout = UI_popup_menu_layout(pup); | ||||
| /* set this so the default execution context is the same as submenus */ | /* set this so the default execution context is the same as submenus */ | ||||
| uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_REGION_WIN); | uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_REGION_WIN); | ||||
| uiItemsFullEnumO(layout, op->type->idname, RNA_property_identifier(prop), op->ptr->data, WM_OP_EXEC_REGION_WIN, 0); | uiItemsFullEnumO(layout, op->type->idname, RNA_property_identifier(prop), op->ptr->data, WM_OP_EXEC_REGION_WIN, 0); | ||||
| uiPupMenuEnd(C, pup); | UI_popup_menu_end(C, pup); | ||||
| return OPERATOR_INTERFACE; | return OPERATOR_INTERFACE; | ||||
| } | } | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| /* generic enum search invoke popup */ | /* generic enum search invoke popup */ | ||||
| static uiBlock *wm_enum_search_menu(bContext *C, ARegion *ar, void *arg_op) | static uiBlock *wm_enum_search_menu(bContext *C, ARegion *ar, void *arg_op) | ||||
| { | { | ||||
| static char search[256] = ""; | static char search[256] = ""; | ||||
| wmEvent event; | wmEvent event; | ||||
| wmWindow *win = CTX_wm_window(C); | wmWindow *win = CTX_wm_window(C); | ||||
| uiBlock *block; | uiBlock *block; | ||||
| uiBut *but; | uiBut *but; | ||||
| wmOperator *op = (wmOperator *)arg_op; | wmOperator *op = (wmOperator *)arg_op; | ||||
| block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS); | block = UI_block_begin(C, ar, "_popup", UI_EMBOSS); | ||||
| uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_MOVEMOUSE_QUIT | UI_BLOCK_SEARCH_MENU); | UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_MOVEMOUSE_QUIT | UI_BLOCK_SEARCH_MENU); | ||||
| #if 0 /* ok, this isn't so easy... */ | #if 0 /* ok, this isn't so easy... */ | ||||
| uiDefBut(block, LABEL, 0, RNA_struct_ui_name(op->type->srna), 10, 10, uiSearchBoxWidth(), UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); | uiDefBut(block, UI_BTYPE_LABEL, 0, RNA_struct_ui_name(op->type->srna), 10, 10, UI_searchbox_size_x(), UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); | ||||
| #endif | #endif | ||||
| but = uiDefSearchButO_ptr(block, op->type, op->ptr->data, search, 0, ICON_VIEWZOOM, sizeof(search), | but = uiDefSearchButO_ptr(block, op->type, op->ptr->data, search, 0, ICON_VIEWZOOM, sizeof(search), | ||||
| 10, 10, uiSearchBoxWidth(), UI_UNIT_Y, 0, 0, ""); | 10, 10, UI_searchbox_size_x(), UI_UNIT_Y, 0, 0, ""); | ||||
| /* fake button, it holds space for search items */ | /* fake button, it holds space for search items */ | ||||
| uiDefBut(block, LABEL, 0, "", 10, 10 - uiSearchBoxHeight(), uiSearchBoxWidth(), uiSearchBoxHeight(), NULL, 0, 0, 0, 0, NULL); | uiDefBut(block, UI_BTYPE_LABEL, 0, "", 10, 10 - UI_searchbox_size_y(), UI_searchbox_size_x(), UI_searchbox_size_y(), NULL, 0, 0, 0, 0, NULL); | ||||
| uiPopupBoundsBlock(block, 6, 0, -UI_UNIT_Y); /* move it downwards, mouse over button */ | UI_block_bounds_set_popup(block, 6, 0, -UI_UNIT_Y); /* move it downwards, mouse over button */ | ||||
| wm_event_init_from_window(win, &event); | wm_event_init_from_window(win, &event); | ||||
| event.type = EVT_BUT_OPEN; | event.type = EVT_BUT_OPEN; | ||||
| event.val = KM_PRESS; | event.val = KM_PRESS; | ||||
| event.customdata = but; | event.customdata = but; | ||||
| event.customdatafree = false; | event.customdatafree = false; | ||||
| wm_event_add(win, &event); | wm_event_add(win, &event); | ||||
| return block; | return block; | ||||
| } | } | ||||
| int WM_enum_search_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) | int WM_enum_search_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) | ||||
| { | { | ||||
| uiPupBlock(C, wm_enum_search_menu, op); | UI_popup_block_invoke(C, wm_enum_search_menu, op); | ||||
| return OPERATOR_INTERFACE; | return OPERATOR_INTERFACE; | ||||
| } | } | ||||
| /* Can't be used as an invoke directly, needs message arg (can be NULL) */ | /* Can't be used as an invoke directly, needs message arg (can be NULL) */ | ||||
| int WM_operator_confirm_message_ex(bContext *C, wmOperator *op, | int WM_operator_confirm_message_ex(bContext *C, wmOperator *op, | ||||
| const char *title, const int icon, | const char *title, const int icon, | ||||
| const char *message) | const char *message) | ||||
| { | { | ||||
| uiPopupMenu *pup; | uiPopupMenu *pup; | ||||
| uiLayout *layout; | uiLayout *layout; | ||||
| IDProperty *properties = op->ptr->data; | IDProperty *properties = op->ptr->data; | ||||
| if (properties && properties->len) | if (properties && properties->len) | ||||
| properties = IDP_CopyProperty(op->ptr->data); | properties = IDP_CopyProperty(op->ptr->data); | ||||
| else | else | ||||
| properties = NULL; | properties = NULL; | ||||
| pup = uiPupMenuBegin(C, title, icon); | pup = UI_popup_menu_begin(C, title, icon); | ||||
| layout = uiPupMenuLayout(pup); | layout = UI_popup_menu_layout(pup); | ||||
| uiItemFullO_ptr(layout, op->type, message, ICON_NONE, properties, WM_OP_EXEC_REGION_WIN, 0); | uiItemFullO_ptr(layout, op->type, message, ICON_NONE, properties, WM_OP_EXEC_REGION_WIN, 0); | ||||
| uiPupMenuEnd(C, pup); | UI_popup_menu_end(C, pup); | ||||
| return OPERATOR_INTERFACE; | return OPERATOR_INTERFACE; | ||||
| } | } | ||||
| int WM_operator_confirm_message(bContext *C, wmOperator *op, const char *message) | int WM_operator_confirm_message(bContext *C, wmOperator *op, const char *message) | ||||
| { | { | ||||
| return WM_operator_confirm_message_ex(C, op, IFACE_("OK?"), ICON_QUESTION, message); | return WM_operator_confirm_message_ex(C, op, IFACE_("OK?"), ICON_QUESTION, message); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 267 Lines • ▼ Show 20 Lines | if (op != WM_operator_last_redo(C)) | ||||
| WM_operator_free(op); | WM_operator_free(op); | ||||
| } | } | ||||
| static uiBlock *wm_block_create_redo(bContext *C, ARegion *ar, void *arg_op) | static uiBlock *wm_block_create_redo(bContext *C, ARegion *ar, void *arg_op) | ||||
| { | { | ||||
| wmOperator *op = arg_op; | wmOperator *op = arg_op; | ||||
| uiBlock *block; | uiBlock *block; | ||||
| uiLayout *layout; | uiLayout *layout; | ||||
| uiStyle *style = UI_GetStyle(); | uiStyle *style = UI_style_get(); | ||||
| int width = 15 * UI_UNIT_X; | int width = 15 * UI_UNIT_X; | ||||
| block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); | block = UI_block_begin(C, ar, __func__, UI_EMBOSS); | ||||
| uiBlockClearFlag(block, UI_BLOCK_LOOP); | UI_block_flag_disable(block, UI_BLOCK_LOOP); | ||||
| uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_MOVEMOUSE_QUIT); | UI_block_flag_enable(block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_MOVEMOUSE_QUIT); | ||||
| /* if register is not enabled, the operator gets freed on OPERATOR_FINISHED | /* if register is not enabled, the operator gets freed on OPERATOR_FINISHED | ||||
| * ui_apply_but_funcs_after calls ED_undo_operator_repeate_cb and crashes */ | * ui_apply_but_funcs_after calls ED_undo_operator_repeate_cb and crashes */ | ||||
| assert(op->type->flag & OPTYPE_REGISTER); | assert(op->type->flag & OPTYPE_REGISTER); | ||||
| uiBlockSetHandleFunc(block, wm_block_redo_cb, arg_op); | UI_block_func_handle_set(block, wm_block_redo_cb, arg_op); | ||||
| layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, width, UI_UNIT_Y, 0, style); | layout = UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, width, UI_UNIT_Y, 0, style); | ||||
| if (op == WM_operator_last_redo(C)) | if (op == WM_operator_last_redo(C)) | ||||
| if (!WM_operator_check_ui_enabled(C, op->type->name)) | if (!WM_operator_check_ui_enabled(C, op->type->name)) | ||||
| uiLayoutSetEnabled(layout, false); | uiLayoutSetEnabled(layout, false); | ||||
| if (op->type->flag & OPTYPE_MACRO) { | if (op->type->flag & OPTYPE_MACRO) { | ||||
| for (op = op->macro.first; op; op = op->next) { | for (op = op->macro.first; op; op = op->next) { | ||||
| uiLayoutOperatorButs(C, layout, op, NULL, 'H', UI_LAYOUT_OP_SHOW_TITLE); | uiLayoutOperatorButs(C, layout, op, NULL, 'H', UI_LAYOUT_OP_SHOW_TITLE); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| uiLayoutOperatorButs(C, layout, op, NULL, 'H', UI_LAYOUT_OP_SHOW_TITLE); | uiLayoutOperatorButs(C, layout, op, NULL, 'H', UI_LAYOUT_OP_SHOW_TITLE); | ||||
| } | } | ||||
| uiPopupBoundsBlock(block, 4, 0, 0); | UI_block_bounds_set_popup(block, 4, 0, 0); | ||||
| return block; | return block; | ||||
| } | } | ||||
| typedef struct wmOpPopUp { | typedef struct wmOpPopUp { | ||||
| wmOperator *op; | wmOperator *op; | ||||
| int width; | int width; | ||||
| int height; | int height; | ||||
| Show All 10 Lines | static void dialog_exec_cb(bContext *C, void *arg1, void *arg2) | ||||
| /* let execute handle freeing it */ | /* let execute handle freeing it */ | ||||
| //data->free_op = false; | //data->free_op = false; | ||||
| //data->op = NULL; | //data->op = NULL; | ||||
| /* in this case, wm_operator_ui_popup_cancel wont run */ | /* in this case, wm_operator_ui_popup_cancel wont run */ | ||||
| MEM_freeN(data); | MEM_freeN(data); | ||||
| uiPupBlockClose(C, block); | UI_popup_block_close(C, block); | ||||
| } | } | ||||
| static void dialog_check_cb(bContext *C, void *op_ptr, void *UNUSED(arg)) | static void dialog_check_cb(bContext *C, void *op_ptr, void *UNUSED(arg)) | ||||
| { | { | ||||
| wmOperator *op = op_ptr; | wmOperator *op = op_ptr; | ||||
| if (op->type->check) { | if (op->type->check) { | ||||
| if (op->type->check(C, op)) { | if (op->type->check(C, op)) { | ||||
| /* check for popup and re-layout buttons */ | /* check for popup and re-layout buttons */ | ||||
| ARegion *ar_menu = CTX_wm_menu(C); | ARegion *ar_menu = CTX_wm_menu(C); | ||||
| if (ar_menu) { | if (ar_menu) { | ||||
| ED_region_tag_refresh_ui(ar_menu); | ED_region_tag_refresh_ui(ar_menu); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* Dialogs are popups that require user verification (click OK) before exec */ | /* Dialogs are popups that require user verification (click OK) before exec */ | ||||
| static uiBlock *wm_block_dialog_create(bContext *C, ARegion *ar, void *userData) | static uiBlock *wm_block_dialog_create(bContext *C, ARegion *ar, void *userData) | ||||
| { | { | ||||
| wmOpPopUp *data = userData; | wmOpPopUp *data = userData; | ||||
| wmOperator *op = data->op; | wmOperator *op = data->op; | ||||
| uiBlock *block; | uiBlock *block; | ||||
| uiLayout *layout; | uiLayout *layout; | ||||
| uiStyle *style = UI_GetStyle(); | uiStyle *style = UI_style_get(); | ||||
| block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); | block = UI_block_begin(C, ar, __func__, UI_EMBOSS); | ||||
| uiBlockClearFlag(block, UI_BLOCK_LOOP); | UI_block_flag_disable(block, UI_BLOCK_LOOP); | ||||
| /* intentionally don't use 'UI_BLOCK_MOVEMOUSE_QUIT', some dialogues have many items | /* intentionally don't use 'UI_BLOCK_MOVEMOUSE_QUIT', some dialogues have many items | ||||
| * where quitting by accident is very annoying */ | * where quitting by accident is very annoying */ | ||||
| uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN); | UI_block_flag_enable(block, UI_BLOCK_KEEP_OPEN); | ||||
| layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, data->width, data->height, 0, style); | layout = UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, data->width, data->height, 0, style); | ||||
| uiBlockSetFunc(block, dialog_check_cb, op, NULL); | UI_block_func_set(block, dialog_check_cb, op, NULL); | ||||
| uiLayoutOperatorButs(C, layout, op, NULL, 'H', UI_LAYOUT_OP_SHOW_TITLE); | uiLayoutOperatorButs(C, layout, op, NULL, 'H', UI_LAYOUT_OP_SHOW_TITLE); | ||||
| /* clear so the OK button is left alone */ | /* clear so the OK button is left alone */ | ||||
| uiBlockSetFunc(block, NULL, NULL, NULL); | UI_block_func_set(block, NULL, NULL, NULL); | ||||
| /* new column so as not to interfere with custom layouts [#26436] */ | /* new column so as not to interfere with custom layouts [#26436] */ | ||||
| { | { | ||||
| uiBlock *col_block; | uiBlock *col_block; | ||||
| uiLayout *col; | uiLayout *col; | ||||
| uiBut *btn; | uiBut *btn; | ||||
| col = uiLayoutColumn(layout, false); | col = uiLayoutColumn(layout, false); | ||||
| col_block = uiLayoutGetBlock(col); | col_block = uiLayoutGetBlock(col); | ||||
| /* Create OK button, the callback of which will execute op */ | /* Create OK button, the callback of which will execute op */ | ||||
| btn = uiDefBut(col_block, BUT, 0, IFACE_("OK"), 0, -30, 0, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); | btn = uiDefBut(col_block, UI_BTYPE_BUT, 0, IFACE_("OK"), 0, -30, 0, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); | ||||
| uiButSetFunc(btn, dialog_exec_cb, data, col_block); | UI_but_func_set(btn, dialog_exec_cb, data, col_block); | ||||
| } | } | ||||
| /* center around the mouse */ | /* center around the mouse */ | ||||
| uiPopupBoundsBlock(block, 4, data->width / -2, data->height / 2); | UI_block_bounds_set_popup(block, 4, data->width / -2, data->height / 2); | ||||
| return block; | return block; | ||||
| } | } | ||||
| static uiBlock *wm_operator_ui_create(bContext *C, ARegion *ar, void *userData) | static uiBlock *wm_operator_ui_create(bContext *C, ARegion *ar, void *userData) | ||||
| { | { | ||||
| wmOpPopUp *data = userData; | wmOpPopUp *data = userData; | ||||
| wmOperator *op = data->op; | wmOperator *op = data->op; | ||||
| uiBlock *block; | uiBlock *block; | ||||
| uiLayout *layout; | uiLayout *layout; | ||||
| uiStyle *style = UI_GetStyle(); | uiStyle *style = UI_style_get(); | ||||
| block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); | block = UI_block_begin(C, ar, __func__, UI_EMBOSS); | ||||
| uiBlockClearFlag(block, UI_BLOCK_LOOP); | UI_block_flag_disable(block, UI_BLOCK_LOOP); | ||||
| uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_MOVEMOUSE_QUIT); | UI_block_flag_enable(block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_MOVEMOUSE_QUIT); | ||||
| layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, data->width, data->height, 0, style); | layout = UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, data->width, data->height, 0, style); | ||||
| /* since ui is defined the auto-layout args are not used */ | /* since ui is defined the auto-layout args are not used */ | ||||
| uiLayoutOperatorButs(C, layout, op, NULL, 'V', 0); | uiLayoutOperatorButs(C, layout, op, NULL, 'V', 0); | ||||
| uiPopupBoundsBlock(block, 4, 0, 0); | UI_block_bounds_set_popup(block, 4, 0, 0); | ||||
| return block; | return block; | ||||
| } | } | ||||
| static void wm_operator_ui_popup_cancel(struct bContext *C, void *userData) | static void wm_operator_ui_popup_cancel(struct bContext *C, void *userData) | ||||
| { | { | ||||
| wmOpPopUp *data = userData; | wmOpPopUp *data = userData; | ||||
| wmOperator *op = data->op; | wmOperator *op = data->op; | ||||
| Show All 24 Lines | |||||
| int WM_operator_ui_popup(bContext *C, wmOperator *op, int width, int height) | int WM_operator_ui_popup(bContext *C, wmOperator *op, int width, int height) | ||||
| { | { | ||||
| wmOpPopUp *data = MEM_callocN(sizeof(wmOpPopUp), "WM_operator_ui_popup"); | wmOpPopUp *data = MEM_callocN(sizeof(wmOpPopUp), "WM_operator_ui_popup"); | ||||
| data->op = op; | data->op = op; | ||||
| data->width = width; | data->width = width; | ||||
| data->height = height; | data->height = height; | ||||
| data->free_op = true; /* if this runs and gets registered we may want not to free it */ | data->free_op = true; /* if this runs and gets registered we may want not to free it */ | ||||
| uiPupBlockEx(C, wm_operator_ui_create, NULL, wm_operator_ui_popup_cancel, data); | UI_popup_block_ex(C, wm_operator_ui_create, NULL, wm_operator_ui_popup_cancel, data); | ||||
| return OPERATOR_RUNNING_MODAL; | return OPERATOR_RUNNING_MODAL; | ||||
| } | } | ||||
| /** | /** | ||||
| * For use by #WM_operator_props_popup_call, #WM_operator_props_popup only. | * For use by #WM_operator_props_popup_call, #WM_operator_props_popup only. | ||||
| * | * | ||||
| * \note operator menu needs undo flag enabled , for redo callback */ | * \note operator menu needs undo flag enabled , for redo callback */ | ||||
| static int wm_operator_props_popup_ex(bContext *C, wmOperator *op, | static int wm_operator_props_popup_ex(bContext *C, wmOperator *op, | ||||
| Show All 13 Lines | if (do_redo) { | ||||
| } | } | ||||
| } | } | ||||
| /* if we don't have global undo, we can't do undo push for automatic redo, | /* if we don't have global undo, we can't do undo push for automatic redo, | ||||
| * so we require manual OK clicking in this popup */ | * so we require manual OK clicking in this popup */ | ||||
| if (!do_redo || !(U.uiflag & USER_GLOBALUNDO)) | if (!do_redo || !(U.uiflag & USER_GLOBALUNDO)) | ||||
| return WM_operator_props_dialog_popup(C, op, 15 * UI_UNIT_X, UI_UNIT_Y); | return WM_operator_props_dialog_popup(C, op, 15 * UI_UNIT_X, UI_UNIT_Y); | ||||
| uiPupBlockEx(C, wm_block_create_redo, NULL, wm_block_redo_cancel_cb, op); | UI_popup_block_ex(C, wm_block_create_redo, NULL, wm_block_redo_cancel_cb, op); | ||||
| if (do_call) | if (do_call) | ||||
| wm_block_redo_cb(C, op, 0); | wm_block_redo_cb(C, op, 0); | ||||
| return OPERATOR_RUNNING_MODAL; | return OPERATOR_RUNNING_MODAL; | ||||
| } | } | ||||
| /* Same as WM_operator_props_popup but don't use operator redo. | /* Same as WM_operator_props_popup but don't use operator redo. | ||||
| Show All 23 Lines | int WM_operator_props_dialog_popup(bContext *C, wmOperator *op, int width, int height) | ||||
| wmOpPopUp *data = MEM_callocN(sizeof(wmOpPopUp), "WM_operator_props_dialog_popup"); | wmOpPopUp *data = MEM_callocN(sizeof(wmOpPopUp), "WM_operator_props_dialog_popup"); | ||||
| data->op = op; | data->op = op; | ||||
| data->width = width; | data->width = width; | ||||
| data->height = height; | data->height = height; | ||||
| data->free_op = true; /* if this runs and gets registered we may want not to free it */ | data->free_op = true; /* if this runs and gets registered we may want not to free it */ | ||||
| /* op is not executed until popup OK but is clicked */ | /* op is not executed until popup OK but is clicked */ | ||||
| uiPupBlockEx(C, wm_block_dialog_create, wm_operator_ui_popup_ok, wm_operator_ui_popup_cancel, data); | UI_popup_block_ex(C, wm_block_dialog_create, wm_operator_ui_popup_ok, wm_operator_ui_popup_cancel, data); | ||||
| return OPERATOR_RUNNING_MODAL; | return OPERATOR_RUNNING_MODAL; | ||||
| } | } | ||||
| int WM_operator_redo_popup(bContext *C, wmOperator *op) | int WM_operator_redo_popup(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| /* CTX_wm_reports(C) because operator is on stack, not active in event system */ | /* CTX_wm_reports(C) because operator is on stack, not active in event system */ | ||||
| if ((op->type->flag & OPTYPE_REGISTER) == 0) { | if ((op->type->flag & OPTYPE_REGISTER) == 0) { | ||||
| BKE_reportf(CTX_wm_reports(C), RPT_ERROR, | BKE_reportf(CTX_wm_reports(C), RPT_ERROR, | ||||
| "Operator redo '%s' does not have register enabled, incorrect invoke function", op->type->idname); | "Operator redo '%s' does not have register enabled, incorrect invoke function", op->type->idname); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| if (op->type->poll && op->type->poll(C) == 0) { | if (op->type->poll && op->type->poll(C) == 0) { | ||||
| BKE_reportf(CTX_wm_reports(C), RPT_ERROR, "Operator redo '%s': wrong context", op->type->idname); | BKE_reportf(CTX_wm_reports(C), RPT_ERROR, "Operator redo '%s': wrong context", op->type->idname); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| uiPupBlock(C, wm_block_create_redo, op); | UI_popup_block_invoke(C, wm_block_create_redo, op); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| /* ***************** Debug menu ************************* */ | /* ***************** Debug menu ************************* */ | ||||
| static int wm_debug_menu_exec(bContext *C, wmOperator *op) | static int wm_debug_menu_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | static void WM_OT_operator_defaults(wmOperatorType *ot) | ||||
| ot->flag = OPTYPE_INTERNAL; | ot->flag = OPTYPE_INTERNAL; | ||||
| } | } | ||||
| /* ***************** Splash Screen ************************* */ | /* ***************** Splash Screen ************************* */ | ||||
| static void wm_block_splash_close(bContext *C, void *arg_block, void *UNUSED(arg)) | static void wm_block_splash_close(bContext *C, void *arg_block, void *UNUSED(arg)) | ||||
| { | { | ||||
| uiPupBlockClose(C, arg_block); | UI_popup_block_close(C, arg_block); | ||||
| } | } | ||||
| static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *arg_unused); | static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *arg_unused); | ||||
| /* XXX: hack to refresh splash screen with updated preset menu name, | /* XXX: hack to refresh splash screen with updated preset menu name, | ||||
| * since popup blocks don't get regenerated like panels do */ | * since popup blocks don't get regenerated like panels do */ | ||||
| static void wm_block_splash_refreshmenu(bContext *UNUSED(C), void *UNUSED(arg_block), void *UNUSED(arg)) | static void wm_block_splash_refreshmenu(bContext *UNUSED(C), void *UNUSED(arg_block), void *UNUSED(arg)) | ||||
| { | { | ||||
| /* ugh, causes crashes in other buttons, disabling for now until | /* ugh, causes crashes in other buttons, disabling for now until | ||||
| * a better fix */ | * a better fix */ | ||||
| #if 0 | #if 0 | ||||
| uiPupBlockClose(C, arg_block); | UI_popup_block_close(C, arg_block); | ||||
| uiPupBlock(C, wm_block_create_splash, NULL); | UI_popup_block_invoke(C, wm_block_create_splash, NULL); | ||||
| #endif | #endif | ||||
| } | } | ||||
| static int wm_resource_check_prev(void) | static int wm_resource_check_prev(void) | ||||
| { | { | ||||
| const char *res = BLI_get_folder_version(BLENDER_RESOURCE_PATH_USER, BLENDER_VERSION, true); | const char *res = BLI_get_folder_version(BLENDER_RESOURCE_PATH_USER, BLENDER_VERSION, true); | ||||
| Show All 15 Lines | #endif | ||||
| } | } | ||||
| } | } | ||||
| static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(arg)) | static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(arg)) | ||||
| { | { | ||||
| uiBlock *block; | uiBlock *block; | ||||
| uiBut *but; | uiBut *but; | ||||
| uiLayout *layout, *split, *col; | uiLayout *layout, *split, *col; | ||||
| uiStyle *style = UI_GetStyle(); | uiStyle *style = UI_style_get(); | ||||
| const struct RecentFile *recent; | const struct RecentFile *recent; | ||||
| int i; | int i; | ||||
| MenuType *mt = WM_menutype_find("USERPREF_MT_splash", true); | MenuType *mt = WM_menutype_find("USERPREF_MT_splash", true); | ||||
| char url[96]; | char url[96]; | ||||
| const char *version_suffix = NULL; | const char *version_suffix = NULL; | ||||
| #ifndef WITH_HEADLESS | #ifndef WITH_HEADLESS | ||||
| extern char datatoc_splash_png[]; | extern char datatoc_splash_png[]; | ||||
| Show All 29 Lines | ibuf = IMB_ibImageFromMemory((unsigned char *)datatoc_splash_2x_png, | ||||
| datatoc_splash_2x_png_size, IB_rect, NULL, "<splash screen>"); | datatoc_splash_2x_png_size, IB_rect, NULL, "<splash screen>"); | ||||
| } | } | ||||
| else { | else { | ||||
| ibuf = IMB_ibImageFromMemory((unsigned char *)datatoc_splash_png, | ibuf = IMB_ibImageFromMemory((unsigned char *)datatoc_splash_png, | ||||
| datatoc_splash_png_size, IB_rect, NULL, "<splash screen>"); | datatoc_splash_png_size, IB_rect, NULL, "<splash screen>"); | ||||
| } | } | ||||
| #endif | #endif | ||||
| block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS); | block = UI_block_begin(C, ar, "_popup", UI_EMBOSS); | ||||
| /* note on UI_BLOCK_NO_WIN_CLIP, the window size is not always synchronized | /* note on UI_BLOCK_NO_WIN_CLIP, the window size is not always synchronized | ||||
| * with the OS when the splash shows, window clipping in this case gives | * with the OS when the splash shows, window clipping in this case gives | ||||
| * ugly results and clipping the splash isn't useful anyway, just disable it [#32938] */ | * ugly results and clipping the splash isn't useful anyway, just disable it [#32938] */ | ||||
| uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_NO_WIN_CLIP); | UI_block_flag_enable(block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_NO_WIN_CLIP); | ||||
| /* XXX splash scales with pixelsize, should become widget-units */ | /* XXX splash scales with pixelsize, should become widget-units */ | ||||
| but = uiDefBut(block, BUT_IMAGE, 0, "", 0, 0.5f * U.widget_unit, U.pixelsize * 501, U.pixelsize * 282, ibuf, 0.0, 0.0, 0, 0, ""); /* button owns the imbuf now */ | but = uiDefBut(block, UI_BTYPE_IMAGE, 0, "", 0, 0.5f * U.widget_unit, U.pixelsize * 501, U.pixelsize * 282, ibuf, 0.0, 0.0, 0, 0, ""); /* button owns the imbuf now */ | ||||
| uiButSetFunc(but, wm_block_splash_close, block, NULL); | UI_but_func_set(but, wm_block_splash_close, block, NULL); | ||||
| uiBlockSetFunc(block, wm_block_splash_refreshmenu, block, NULL); | UI_block_func_set(block, wm_block_splash_refreshmenu, block, NULL); | ||||
| /* label for 'a' bugfix releases, or 'Release Candidate 1'... | /* label for 'a' bugfix releases, or 'Release Candidate 1'... | ||||
| * avoids recreating splash for version updates */ | * avoids recreating splash for version updates */ | ||||
| if (STREQ(STRINGIFY(BLENDER_VERSION_CYCLE), "rc")) { | if (STREQ(STRINGIFY(BLENDER_VERSION_CYCLE), "rc")) { | ||||
| version_suffix = "Release Candidate"; | version_suffix = "Release Candidate"; | ||||
| } | } | ||||
| else if (STREQ(STRINGIFY(BLENDER_VERSION_CYCLE), "release")) { | else if (STREQ(STRINGIFY(BLENDER_VERSION_CYCLE), "release")) { | ||||
| version_suffix = STRINGIFY(BLENDER_VERSION_CHAR); | version_suffix = STRINGIFY(BLENDER_VERSION_CHAR); | ||||
| } | } | ||||
| if (version_suffix != NULL && version_suffix[0]) { | if (version_suffix != NULL && version_suffix[0]) { | ||||
| /* placed after the version number in the image, | /* placed after the version number in the image, | ||||
| * placing y is tricky to match baseline */ | * placing y is tricky to match baseline */ | ||||
| int x = 260 - (2 * UI_DPI_WINDOW_FAC); | int x = 260 - (2 * UI_DPI_WINDOW_FAC); | ||||
| int y = 242 + (4 * UI_DPI_WINDOW_FAC); | int y = 242 + (4 * UI_DPI_WINDOW_FAC); | ||||
| int w = 240; | int w = 240; | ||||
| /* hack to have text draw 'text_sel' */ | /* hack to have text draw 'text_sel' */ | ||||
| uiBlockSetEmboss(block, UI_EMBOSSN); | UI_block_emboss_set(block, UI_EMBOSS_NONE); | ||||
| but = uiDefBut(block, LABEL, 0, version_suffix, x * U.pixelsize, y * U.pixelsize, w * U.pixelsize, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); | but = uiDefBut(block, UI_BTYPE_LABEL, 0, version_suffix, x * U.pixelsize, y * U.pixelsize, w * U.pixelsize, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); | ||||
| /* XXX, set internal flag - UI_SELECT */ | /* XXX, set internal flag - UI_SELECT */ | ||||
| uiButSetFlag(but, 1); | UI_but_flag_enable(but, 1); | ||||
| uiBlockSetEmboss(block, UI_EMBOSS); | UI_block_emboss_set(block, UI_EMBOSS); | ||||
| } | } | ||||
| #ifdef WITH_BUILDINFO | #ifdef WITH_BUILDINFO | ||||
| if (build_commit_timestamp != 0) { | if (build_commit_timestamp != 0) { | ||||
| uiDefBut(block, LABEL, 0, date_buf, U.pixelsize * 494 - date_width, U.pixelsize * 270, date_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); | uiDefBut(block, UI_BTYPE_LABEL, 0, date_buf, U.pixelsize * 494 - date_width, U.pixelsize * 270, date_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); | ||||
| label_delta = 12; | label_delta = 12; | ||||
| } | } | ||||
| uiDefBut(block, LABEL, 0, hash_buf, U.pixelsize * 494 - hash_width, U.pixelsize * (270 - label_delta), hash_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); | uiDefBut(block, UI_BTYPE_LABEL, 0, hash_buf, U.pixelsize * 494 - hash_width, U.pixelsize * (270 - label_delta), hash_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); | ||||
| if (!STREQ(build_branch, "master")) { | if (!STREQ(build_branch, "master")) { | ||||
| char branch_buf[128] = "\0"; | char branch_buf[128] = "\0"; | ||||
| int branch_width; | int branch_width; | ||||
| BLI_snprintf(branch_buf, sizeof(branch_buf), "Branch: %s", build_branch); | BLI_snprintf(branch_buf, sizeof(branch_buf), "Branch: %s", build_branch); | ||||
| branch_width = (int)BLF_width(style->widgetlabel.uifont_id, branch_buf, sizeof(branch_buf)) + U.widget_unit; | branch_width = (int)BLF_width(style->widgetlabel.uifont_id, branch_buf, sizeof(branch_buf)) + U.widget_unit; | ||||
| uiDefBut(block, LABEL, 0, branch_buf, U.pixelsize * 494 - branch_width, U.pixelsize * (258 - label_delta), branch_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); | uiDefBut(block, UI_BTYPE_LABEL, 0, branch_buf, U.pixelsize * 494 - branch_width, U.pixelsize * (258 - label_delta), branch_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); | ||||
| } | } | ||||
| #endif /* WITH_BUILDINFO */ | #endif /* WITH_BUILDINFO */ | ||||
| layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 10, 2, U.pixelsize * 480, U.pixelsize * 110, 0, style); | layout = UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 10, 2, U.pixelsize * 480, U.pixelsize * 110, 0, style); | ||||
| uiBlockSetEmboss(block, UI_EMBOSS); | UI_block_emboss_set(block, UI_EMBOSS); | ||||
| /* show the splash menu (containing interaction presets), using python */ | /* show the splash menu (containing interaction presets), using python */ | ||||
| if (mt) { | if (mt) { | ||||
| Menu menu = {NULL}; | Menu menu = {NULL}; | ||||
| menu.layout = layout; | menu.layout = layout; | ||||
| menu.type = mt; | menu.type = mt; | ||||
| mt->draw(C, &menu); | mt->draw(C, &menu); | ||||
| // wmWindowManager *wm = CTX_wm_manager(C); | // wmWindowManager *wm = CTX_wm_manager(C); | ||||
| // uiItemM(layout, C, "USERPREF_MT_keyconfigs", U.keyconfigstr, ICON_NONE); | // uiItemM(layout, C, "USERPREF_MT_keyconfigs", U.keyconfigstr, ICON_NONE); | ||||
| } | } | ||||
| uiBlockSetEmboss(block, UI_EMBOSSP); | UI_block_emboss_set(block, UI_EMBOSS_PULLDOWN); | ||||
| uiLayoutSetOperatorContext(layout, WM_OP_EXEC_REGION_WIN); | uiLayoutSetOperatorContext(layout, WM_OP_EXEC_REGION_WIN); | ||||
| split = uiLayoutSplit(layout, 0.0f, false); | split = uiLayoutSplit(layout, 0.0f, false); | ||||
| col = uiLayoutColumn(split, false); | col = uiLayoutColumn(split, false); | ||||
| uiItemL(col, IFACE_("Links"), ICON_NONE); | uiItemL(col, IFACE_("Links"), ICON_NONE); | ||||
| uiItemStringO(col, IFACE_("Support an Open Animation Movie"), ICON_URL, "WM_OT_url_open", "url", | uiItemStringO(col, IFACE_("Support an Open Animation Movie"), ICON_URL, "WM_OT_url_open", "url", | ||||
| "https://cloud.blender.org/join"); | "https://cloud.blender.org/join"); | ||||
| uiItemStringO(col, IFACE_("Donations"), ICON_URL, "WM_OT_url_open", "url", | uiItemStringO(col, IFACE_("Donations"), ICON_URL, "WM_OT_url_open", "url", | ||||
| Show All 32 Lines | uiItemStringO(col, filename, | ||||
| BLO_has_bfile_extension(filename) ? ICON_FILE_BLEND : ICON_FILE_BACKUP, | BLO_has_bfile_extension(filename) ? ICON_FILE_BLEND : ICON_FILE_BACKUP, | ||||
| "WM_OT_open_mainfile", "filepath", recent->filepath); | "WM_OT_open_mainfile", "filepath", recent->filepath); | ||||
| } | } | ||||
| uiItemS(col); | uiItemS(col); | ||||
| uiItemO(col, NULL, ICON_RECOVER_LAST, "WM_OT_recover_last_session"); | uiItemO(col, NULL, ICON_RECOVER_LAST, "WM_OT_recover_last_session"); | ||||
| uiItemL(col, "", ICON_NONE); | uiItemL(col, "", ICON_NONE); | ||||
| uiCenteredBoundsBlock(block, 0); | UI_block_bounds_set_centered(block, 0); | ||||
| return block; | return block; | ||||
| } | } | ||||
| static int wm_splash_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event)) | static int wm_splash_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event)) | ||||
| { | { | ||||
| uiPupBlock(C, wm_block_create_splash, NULL); | UI_popup_block_invoke(C, wm_block_create_splash, NULL); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| static void WM_OT_splash(wmOperatorType *ot) | static void WM_OT_splash(wmOperatorType *ot) | ||||
| { | { | ||||
| ot->name = "Splash Screen"; | ot->name = "Splash Screen"; | ||||
| ot->idname = "WM_OT_splash"; | ot->idname = "WM_OT_splash"; | ||||
| ot->description = "Open the splash screen with release info"; | ot->description = "Open the splash screen with release info"; | ||||
| ot->invoke = wm_splash_invoke; | ot->invoke = wm_splash_invoke; | ||||
| ot->poll = WM_operator_winactive; | ot->poll = WM_operator_winactive; | ||||
| } | } | ||||
| /* ***************** Search menu ************************* */ | /* ***************** Search menu ************************* */ | ||||
| static uiBlock *wm_block_search_menu(bContext *C, ARegion *ar, void *UNUSED(arg_op)) | static uiBlock *wm_block_search_menu(bContext *C, ARegion *ar, void *UNUSED(arg_op)) | ||||
| { | { | ||||
| static char search[256] = ""; | static char search[256] = ""; | ||||
| wmEvent event; | wmEvent event; | ||||
| wmWindow *win = CTX_wm_window(C); | wmWindow *win = CTX_wm_window(C); | ||||
| uiBlock *block; | uiBlock *block; | ||||
| uiBut *but; | uiBut *but; | ||||
| block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS); | block = UI_block_begin(C, ar, "_popup", UI_EMBOSS); | ||||
| uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_MOVEMOUSE_QUIT | UI_BLOCK_SEARCH_MENU); | UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_MOVEMOUSE_QUIT | UI_BLOCK_SEARCH_MENU); | ||||
| but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 10, uiSearchBoxWidth(), UI_UNIT_Y, 0, 0, ""); | but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 10, UI_searchbox_size_x(), UI_UNIT_Y, 0, 0, ""); | ||||
| uiOperatorSearch_But(but); | UI_but_func_operator_search(but); | ||||
| /* fake button, it holds space for search items */ | /* fake button, it holds space for search items */ | ||||
| uiDefBut(block, LABEL, 0, "", 10, 10 - uiSearchBoxHeight(), uiSearchBoxWidth(), uiSearchBoxHeight(), NULL, 0, 0, 0, 0, NULL); | uiDefBut(block, UI_BTYPE_LABEL, 0, "", 10, 10 - UI_searchbox_size_y(), UI_searchbox_size_x(), UI_searchbox_size_y(), NULL, 0, 0, 0, 0, NULL); | ||||
| uiPopupBoundsBlock(block, 6, 0, -UI_UNIT_Y); /* move it downwards, mouse over button */ | UI_block_bounds_set_popup(block, 6, 0, -UI_UNIT_Y); /* move it downwards, mouse over button */ | ||||
| wm_event_init_from_window(win, &event); | wm_event_init_from_window(win, &event); | ||||
| event.type = EVT_BUT_OPEN; | event.type = EVT_BUT_OPEN; | ||||
| event.val = KM_PRESS; | event.val = KM_PRESS; | ||||
| event.customdata = but; | event.customdata = but; | ||||
| event.customdatafree = false; | event.customdatafree = false; | ||||
| wm_event_add(win, &event); | wm_event_add(win, &event); | ||||
| return block; | return block; | ||||
| } | } | ||||
| static int wm_search_menu_exec(bContext *UNUSED(C), wmOperator *UNUSED(op)) | static int wm_search_menu_exec(bContext *UNUSED(C), wmOperator *UNUSED(op)) | ||||
| { | { | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| static int wm_search_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) | static int wm_search_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) | ||||
| { | { | ||||
| uiPupBlock(C, wm_block_search_menu, op); | UI_popup_block_invoke(C, wm_block_search_menu, op); | ||||
| return OPERATOR_INTERFACE; | return OPERATOR_INTERFACE; | ||||
| } | } | ||||
| /* op->poll */ | /* op->poll */ | ||||
| static int wm_search_menu_poll(bContext *C) | static int wm_search_menu_poll(bContext *C) | ||||
| { | { | ||||
| if (CTX_wm_window(C) == NULL) { | if (CTX_wm_window(C) == NULL) { | ||||
| Show All 24 Lines | static void WM_OT_search_menu(wmOperatorType *ot) | ||||
| ot->poll = wm_search_menu_poll; | ot->poll = wm_search_menu_poll; | ||||
| } | } | ||||
| static int wm_call_menu_exec(bContext *C, wmOperator *op) | static int wm_call_menu_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| char idname[BKE_ST_MAXNAME]; | char idname[BKE_ST_MAXNAME]; | ||||
| RNA_string_get(op->ptr, "name", idname); | RNA_string_get(op->ptr, "name", idname); | ||||
| return uiPupMenuInvoke(C, idname, op->reports); | return UI_popup_menu_invoke(C, idname, op->reports); | ||||
| } | } | ||||
| static void WM_OT_call_menu(wmOperatorType *ot) | static void WM_OT_call_menu(wmOperatorType *ot) | ||||
| { | { | ||||
| ot->name = "Call Menu"; | ot->name = "Call Menu"; | ||||
| ot->idname = "WM_OT_call_menu"; | ot->idname = "WM_OT_call_menu"; | ||||
| ot->description = "Call (draw) a pre-defined menu"; | ot->description = "Call (draw) a pre-defined menu"; | ||||
| ot->exec = wm_call_menu_exec; | ot->exec = wm_call_menu_exec; | ||||
| ot->poll = WM_operator_winactive; | ot->poll = WM_operator_winactive; | ||||
| ot->flag = OPTYPE_INTERNAL; | ot->flag = OPTYPE_INTERNAL; | ||||
| RNA_def_string(ot->srna, "name", NULL, BKE_ST_MAXNAME, "Name", "Name of the menu"); | RNA_def_string(ot->srna, "name", NULL, BKE_ST_MAXNAME, "Name", "Name of the menu"); | ||||
| } | } | ||||
| static int wm_call_pie_menu_invoke(bContext *C, wmOperator *op, const wmEvent *event) | static int wm_call_pie_menu_invoke(bContext *C, wmOperator *op, const wmEvent *event) | ||||
| { | { | ||||
| char idname[BKE_ST_MAXNAME]; | char idname[BKE_ST_MAXNAME]; | ||||
| RNA_string_get(op->ptr, "name", idname); | RNA_string_get(op->ptr, "name", idname); | ||||
| return uiPieMenuInvoke(C, idname, event); | return UI_pie_menu_invoke(C, idname, event); | ||||
| } | } | ||||
| static int wm_call_pie_menu_exec(bContext *C, wmOperator *op) | static int wm_call_pie_menu_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| char idname[BKE_ST_MAXNAME]; | char idname[BKE_ST_MAXNAME]; | ||||
| RNA_string_get(op->ptr, "name", idname); | RNA_string_get(op->ptr, "name", idname); | ||||
| return uiPieMenuInvoke(C, idname, CTX_wm_window(C)->eventstate); | return UI_pie_menu_invoke(C, idname, CTX_wm_window(C)->eventstate); | ||||
| } | } | ||||
| static void WM_OT_call_menu_pie(wmOperatorType *ot) | static void WM_OT_call_menu_pie(wmOperatorType *ot) | ||||
| { | { | ||||
| ot->name = "Call Pie Menu"; | ot->name = "Call Pie Menu"; | ||||
| ot->idname = "WM_OT_call_menu_pie"; | ot->idname = "WM_OT_call_menu_pie"; | ||||
| ot->description = "Call (draw) a pre-defined pie menu"; | ot->description = "Call (draw) a pre-defined pie menu"; | ||||
| ▲ Show 20 Lines • Show All 1,749 Lines • ▼ Show 20 Lines | else { | ||||
| glutil_draw_filled_arc(0, M_PI * 2, radius, 40); | glutil_draw_filled_arc(0, M_PI * 2, radius, 40); | ||||
| } | } | ||||
| } | } | ||||
| static void radial_control_paint_cursor(bContext *C, int x, int y, void *customdata) | static void radial_control_paint_cursor(bContext *C, int x, int y, void *customdata) | ||||
| { | { | ||||
| RadialControl *rc = customdata; | RadialControl *rc = customdata; | ||||
| ARegion *ar = CTX_wm_region(C); | ARegion *ar = CTX_wm_region(C); | ||||
| uiStyle *style = UI_GetStyle(); | uiStyle *style = UI_style_get(); | ||||
| const uiFontStyle *fstyle = &style->widget; | const uiFontStyle *fstyle = &style->widget; | ||||
| const int fontid = fstyle->uifont_id; | const int fontid = fstyle->uifont_id; | ||||
| short fstyle_points = fstyle->points; | short fstyle_points = fstyle->points; | ||||
| char str[WM_RADIAL_MAX_STR]; | char str[WM_RADIAL_MAX_STR]; | ||||
| short strdrawlen = 0; | short strdrawlen = 0; | ||||
| float strwidth, strheight; | float strwidth, strheight; | ||||
| float r1 = 0.0f, r2 = 0.0f, rmin = 0.0, tex_radius, alpha; | float r1 = 0.0f, r2 = 0.0f, rmin = 0.0, tex_radius, alpha; | ||||
| float zoom[2], col[3] = {1, 1, 1}; | float zoom[2], col[3] = {1, 1, 1}; | ||||
| ▲ Show 20 Lines • Show All 1,123 Lines • Show Last 20 Lines | |||||