Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_image/image_ops.c
| Show First 20 Lines • Show All 2,791 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| /* Get property in advance, it doesn't work after WM_operator_props_dialog_popup. */ | /* Get property in advance, it doesn't work after WM_operator_props_dialog_popup. */ | ||||
| ImageNewData *data; | ImageNewData *data; | ||||
| op->customdata = data = MEM_callocN(sizeof(ImageNewData), __func__); | op->customdata = data = MEM_callocN(sizeof(ImageNewData), __func__); | ||||
| UI_context_active_but_prop_get_templateID(C, &data->pprop.ptr, &data->pprop.prop); | UI_context_active_but_prop_get_templateID(C, &data->pprop.ptr, &data->pprop.prop); | ||||
| /* Better for user feedback. */ | /* Better for user feedback. */ | ||||
| RNA_string_set(op->ptr, "name", DATA_(IMA_DEF_NAME)); | RNA_string_set(op->ptr, "name", DATA_(IMA_DEF_NAME)); | ||||
| return WM_operator_props_dialog_popup(C, op, 300, 100); | return WM_operator_props_dialog_popup(C, op, 300); | ||||
| } | } | ||||
| static void image_new_draw(bContext *UNUSED(C), wmOperator *op) | static void image_new_draw(bContext *UNUSED(C), wmOperator *op) | ||||
| { | { | ||||
| uiLayout *split, *col[2]; | uiLayout *split, *col[2]; | ||||
| uiLayout *layout = op->layout; | uiLayout *layout = op->layout; | ||||
| PointerRNA ptr; | PointerRNA ptr; | ||||
| #if 0 | #if 0 | ||||
| ▲ Show 20 Lines • Show All 229 Lines • ▼ Show 20 Lines | static int image_scale_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) | ||||
| Image *ima = image_from_context(C); | Image *ima = image_from_context(C); | ||||
| PropertyRNA *prop = RNA_struct_find_property(op->ptr, "size"); | PropertyRNA *prop = RNA_struct_find_property(op->ptr, "size"); | ||||
| if (!RNA_property_is_set(op->ptr, prop)) { | if (!RNA_property_is_set(op->ptr, prop)) { | ||||
| ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL); | ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL); | ||||
| const int size[2] = {ibuf->x, ibuf->y}; | const int size[2] = {ibuf->x, ibuf->y}; | ||||
| RNA_property_int_set_array(op->ptr, prop, size); | RNA_property_int_set_array(op->ptr, prop, size); | ||||
| BKE_image_release_ibuf(ima, ibuf, NULL); | BKE_image_release_ibuf(ima, ibuf, NULL); | ||||
| } | } | ||||
| return WM_operator_props_dialog_popup(C, op, 200, 200); | return WM_operator_props_dialog_popup(C, op, 200); | ||||
| } | } | ||||
| static int image_scale_exec(bContext *C, wmOperator *op) | static int image_scale_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Image *ima = image_from_context(C); | Image *ima = image_from_context(C); | ||||
| ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL); | ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL); | ||||
| SpaceImage *sima = CTX_wm_space_image(C); | SpaceImage *sima = CTX_wm_space_image(C); | ||||
| const bool is_paint = ((sima != NULL) && (sima->mode == SI_MODE_PAINT)); | const bool is_paint = ((sima != NULL) && (sima->mode == SI_MODE_PAINT)); | ||||
| ▲ Show 20 Lines • Show All 1,335 Lines • ▼ Show 20 Lines | static int tile_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) | ||||
| ImageTile *tile = BLI_findlink(&ima->tiles, ima->active_tile_index); | ImageTile *tile = BLI_findlink(&ima->tiles, ima->active_tile_index); | ||||
| initialize_fill_tile(op->ptr, ima, tile); | initialize_fill_tile(op->ptr, ima, tile); | ||||
| RNA_int_set(op->ptr, "number", next_number); | RNA_int_set(op->ptr, "number", next_number); | ||||
| RNA_int_set(op->ptr, "count", 1); | RNA_int_set(op->ptr, "count", 1); | ||||
| RNA_string_set(op->ptr, "label", ""); | RNA_string_set(op->ptr, "label", ""); | ||||
| return WM_operator_props_dialog_popup(C, op, 10 * UI_UNIT_X, 5 * UI_UNIT_Y); | return WM_operator_props_dialog_popup(C, op, 10 * UI_UNIT_X); | ||||
| } | } | ||||
| static void tile_add_draw(bContext *UNUSED(C), wmOperator *op) | static void tile_add_draw(bContext *UNUSED(C), wmOperator *op) | ||||
| { | { | ||||
| uiLayout *split, *col[2]; | uiLayout *split, *col[2]; | ||||
| uiLayout *layout = op->layout; | uiLayout *layout = op->layout; | ||||
| PointerRNA ptr; | PointerRNA ptr; | ||||
| ▲ Show 20 Lines • Show All 110 Lines • ▼ Show 20 Lines | static int tile_fill_exec(bContext *C, wmOperator *op) | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| static int tile_fill_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) | static int tile_fill_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) | ||||
| { | { | ||||
| initialize_fill_tile(op->ptr, CTX_data_edit_image(C), NULL); | initialize_fill_tile(op->ptr, CTX_data_edit_image(C), NULL); | ||||
| return WM_operator_props_dialog_popup(C, op, 15 * UI_UNIT_X, 5 * UI_UNIT_Y); | return WM_operator_props_dialog_popup(C, op, 15 * UI_UNIT_X); | ||||
| } | } | ||||
| static void tile_fill_draw(bContext *UNUSED(C), wmOperator *op) | static void tile_fill_draw(bContext *UNUSED(C), wmOperator *op) | ||||
| { | { | ||||
| PointerRNA ptr; | PointerRNA ptr; | ||||
| RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr); | RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr); | ||||
| draw_fill_tile(&ptr, op->layout); | draw_fill_tile(&ptr, op->layout); | ||||
| Show All 20 Lines | |||||