Changeset View
Changeset View
Standalone View
Standalone View
source/blender/windowmanager/intern/wm_operators.c
| Show First 20 Lines • Show All 1,511 Lines • ▼ Show 20 Lines | 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_style_get(); | uiStyle *style = UI_style_get(); | ||||
| int width = 15 * UI_UNIT_X; | int width = 15 * UI_UNIT_X; | ||||
| block = UI_block_begin(C, ar, __func__, UI_EMBOSS); | block = UI_block_begin(C, ar, __func__, UI_EMBOSS); | ||||
| UI_block_flag_disable(block, UI_BLOCK_LOOP); | UI_block_flag_disable(block, UI_BLOCK_LOOP); | ||||
| UI_block_flag_enable(block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_MOVEMOUSE_QUIT); | /* UI_BLOCK_NUMSELECT for layer buttons */ | ||||
| UI_block_flag_enable(block, UI_BLOCK_NUMSELECT | 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); | ||||
| UI_block_func_handle_set(block, wm_block_redo_cb, arg_op); | UI_block_func_handle_set(block, wm_block_redo_cb, arg_op); | ||||
| layout = UI_block_layout(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); | ||||
| ▲ Show 20 Lines • Show All 422 Lines • ▼ Show 20 Lines | 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 = 254 - (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' */ | ||||
| UI_block_emboss_set(block, UI_EMBOSS_NONE); | UI_block_emboss_set(block, UI_EMBOSS_NONE); | ||||
| 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); | 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 */ | ||||
| UI_but_flag_enable(but, 1); | UI_but_flag_enable(but, 1); | ||||
| ▲ Show 20 Lines • Show All 2,282 Lines • ▼ Show 20 Lines | static int radial_control_get_properties(bContext *C, wmOperator *op) | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| static int radial_control_invoke(bContext *C, wmOperator *op, const wmEvent *event) | static int radial_control_invoke(bContext *C, wmOperator *op, const wmEvent *event) | ||||
| { | { | ||||
| wmWindowManager *wm; | wmWindowManager *wm; | ||||
| RadialControl *rc; | RadialControl *rc; | ||||
| int min_value_int, max_value_int, step_int; | |||||
| float step_float, precision; | |||||
| if (!(op->customdata = rc = MEM_callocN(sizeof(RadialControl), "RadialControl"))) | if (!(op->customdata = rc = MEM_callocN(sizeof(RadialControl), "RadialControl"))) | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| if (!radial_control_get_properties(C, op)) { | if (!radial_control_get_properties(C, op)) { | ||||
| MEM_freeN(rc); | MEM_freeN(rc); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| /* get type, initial, min, and max values of the property */ | /* get type, initial, min, and max values of the property */ | ||||
| switch ((rc->type = RNA_property_type(rc->prop))) { | switch ((rc->type = RNA_property_type(rc->prop))) { | ||||
| case PROP_INT: | case PROP_INT: | ||||
| rc->initial_value = RNA_property_int_get(&rc->ptr, rc->prop); | { | ||||
| RNA_property_int_ui_range(&rc->ptr, rc->prop, &min_value_int, | int value, min, max, step; | ||||
| &max_value_int, &step_int); | |||||
| rc->min_value = min_value_int; | value = RNA_property_int_get(&rc->ptr, rc->prop); | ||||
| rc->max_value = max_value_int; | RNA_property_int_ui_range(&rc->ptr, rc->prop, &min, &max, &step); | ||||
| rc->initial_value = value; | |||||
| rc->min_value = min_ii(value, min); | |||||
| rc->max_value = max_ii(value, max); | |||||
| break; | break; | ||||
| } | |||||
| case PROP_FLOAT: | case PROP_FLOAT: | ||||
| rc->initial_value = RNA_property_float_get(&rc->ptr, rc->prop); | { | ||||
| RNA_property_float_ui_range(&rc->ptr, rc->prop, &rc->min_value, | float value, min, max, step, precision; | ||||
| &rc->max_value, &step_float, &precision); | |||||
| value = RNA_property_float_get(&rc->ptr, rc->prop); | |||||
| RNA_property_float_ui_range(&rc->ptr, rc->prop, &min, &max, &step, &precision); | |||||
| rc->initial_value = value; | |||||
| rc->min_value = min_ff(value, min); | |||||
| rc->max_value = max_ff(value, max); | |||||
| break; | break; | ||||
| } | |||||
| default: | default: | ||||
| BKE_report(op->reports, RPT_ERROR, "Property must be an integer or a float"); | BKE_report(op->reports, RPT_ERROR, "Property must be an integer or a float"); | ||||
| MEM_freeN(rc); | MEM_freeN(rc); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| /* initialize numerical input */ | /* initialize numerical input */ | ||||
| initNumInput(&rc->num_input); | initNumInput(&rc->num_input); | ||||
| ▲ Show 20 Lines • Show All 481 Lines • ▼ Show 20 Lines | static void WM_OT_dependency_relations(wmOperatorType *ot) | ||||
| ot->description = "Print dependency graph relations to the console"; | ot->description = "Print dependency graph relations to the console"; | ||||
| ot->exec = dependency_relations_exec; | ot->exec = dependency_relations_exec; | ||||
| } | } | ||||
| /* *************************** Mat/tex/etc. previews generation ************* */ | /* *************************** Mat/tex/etc. previews generation ************* */ | ||||
| typedef struct PreviewsIDEnsureStack { | typedef struct PreviewsIDEnsureStack { | ||||
| bContext *C; | |||||
| Scene *scene; | Scene *scene; | ||||
| BLI_LINKSTACK_DECLARE(id_stack, ID *); | BLI_LINKSTACK_DECLARE(id_stack, ID *); | ||||
| } PreviewsIDEnsureStack; | } PreviewsIDEnsureStack; | ||||
| static void previews_id_ensure(bContext *C, Scene *scene, ID *id) | static void previews_id_ensure(bContext *C, Scene *scene, ID *id) | ||||
| { | { | ||||
| BLI_assert(ELEM(GS(id->name), ID_MA, ID_TE, ID_IM, ID_WO, ID_LA)); | BLI_assert(ELEM(GS(id->name), ID_MA, ID_TE, ID_IM, ID_WO, ID_LA)); | ||||
| /* Only preview non-library datablocks, lib ones do not pertain to this .blend file! | /* Only preview non-library datablocks, lib ones do not pertain to this .blend file! | ||||
| * Same goes for ID with no user. */ | * Same goes for ID with no user. */ | ||||
| if (!id->lib && (id->us != 0)) { | if (!id->lib && (id->us != 0)) { | ||||
| UI_id_icon_render(C, scene, id, false, false); | UI_id_icon_render(C, scene, id, false, false); | ||||
| UI_id_icon_render(C, scene, id, true, false); | UI_id_icon_render(C, scene, id, true, false); | ||||
| } | } | ||||
| } | } | ||||
| static bool previews_id_ensure_callback(void *todo_v, ID **idptr, int UNUSED(cd_flag)) | static bool previews_id_ensure_callback(void *todo_v, ID **idptr, int UNUSED(cd_flag)) | ||||
| { | { | ||||
| PreviewsIDEnsureStack *todo = todo_v; | PreviewsIDEnsureStack *todo = todo_v; | ||||
| ID *id = *idptr; | ID *id = *idptr; | ||||
| if (id && (id->flag & LIB_DOIT)) { | if (id && (id->flag & LIB_DOIT)) { | ||||
| if (ELEM(GS(id->name), ID_MA, ID_TE, ID_IM, ID_WO, ID_LA)) { | if (ELEM(GS(id->name), ID_MA, ID_TE, ID_IM, ID_WO, ID_LA)) { | ||||
| previews_id_ensure(NULL, todo->scene, id); | previews_id_ensure(todo->C, todo->scene, id); | ||||
| } | } | ||||
| id->flag &= ~LIB_DOIT; /* Tag the ID as done in any case. */ | id->flag &= ~LIB_DOIT; /* Tag the ID as done in any case. */ | ||||
| BLI_LINKSTACK_PUSH(todo->id_stack, id); | BLI_LINKSTACK_PUSH(todo->id_stack, id); | ||||
| } | } | ||||
| return true; | return true; | ||||
| } | } | ||||
| static int previews_ensure_exec(bContext *C, wmOperator *UNUSED(op)) | static int previews_ensure_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| ListBase *lb[] = {&bmain->mat, &bmain->tex, &bmain->image, &bmain->world, &bmain->lamp, NULL}; | ListBase *lb[] = {&bmain->mat, &bmain->tex, &bmain->image, &bmain->world, &bmain->lamp, NULL}; | ||||
| PreviewsIDEnsureStack preview_id_stack; | PreviewsIDEnsureStack preview_id_stack; | ||||
| Scene *scene; | Scene *scene; | ||||
| ID *id; | ID *id; | ||||
| int i; | int i; | ||||
| /* We use LIB_DOIT to check whether we have already handled a given ID or not. */ | /* We use LIB_DOIT to check whether we have already handled a given ID or not. */ | ||||
| BKE_main_id_flag_all(bmain, LIB_DOIT, true); | BKE_main_id_flag_all(bmain, LIB_DOIT, true); | ||||
| BLI_LINKSTACK_INIT(preview_id_stack.id_stack); | BLI_LINKSTACK_INIT(preview_id_stack.id_stack); | ||||
| for (scene = bmain->scene.first; scene; scene = scene->id.next) { | for (scene = bmain->scene.first; scene; scene = scene->id.next) { | ||||
| preview_id_stack.scene = scene; | preview_id_stack.scene = scene; | ||||
| preview_id_stack.C = C; | |||||
| id = (ID *)scene; | id = (ID *)scene; | ||||
| do { | do { | ||||
| /* This will loop over all IDs linked by current one, render icons for them if needed, | /* This will loop over all IDs linked by current one, render icons for them if needed, | ||||
| * and add them to 'todo' preview_id_stack. */ | * and add them to 'todo' preview_id_stack. */ | ||||
| BKE_library_foreach_ID_link(id, previews_id_ensure_callback, &preview_id_stack, IDWALK_READONLY); | BKE_library_foreach_ID_link(id, previews_id_ensure_callback, &preview_id_stack, IDWALK_READONLY); | ||||
| } while ((id = BLI_LINKSTACK_POP(preview_id_stack.id_stack))); | } while ((id = BLI_LINKSTACK_POP(preview_id_stack.id_stack))); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 539 Lines • Show Last 20 Lines | |||||