Changeset View
Changeset View
Standalone View
Standalone View
source/blender/windowmanager/intern/wm_operators.c
| Show First 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | |||||
| #include "GPU_immediate.h" | #include "GPU_immediate.h" | ||||
| #include "GPU_immediate_util.h" | #include "GPU_immediate_util.h" | ||||
| #include "GPU_matrix.h" | #include "GPU_matrix.h" | ||||
| #include "GPU_state.h" | #include "GPU_state.h" | ||||
| #include "IMB_imbuf_types.h" | #include "IMB_imbuf_types.h" | ||||
| #include "ED_fileselect.h" | #include "ED_fileselect.h" | ||||
| #include "ED_gpencil.h" | |||||
| #include "ED_numinput.h" | #include "ED_numinput.h" | ||||
| #include "ED_screen.h" | #include "ED_screen.h" | ||||
| #include "ED_undo.h" | #include "ED_undo.h" | ||||
| #include "ED_view3d.h" | #include "ED_view3d.h" | ||||
| #include "RNA_access.h" | #include "RNA_access.h" | ||||
| #include "RNA_define.h" | #include "RNA_define.h" | ||||
| #include "RNA_enum_types.h" | #include "RNA_enum_types.h" | ||||
| ▲ Show 20 Lines • Show All 2,102 Lines • ▼ Show 20 Lines | typedef struct { | ||||
| PropertyRNA *prop, *col_prop, *fill_col_prop, *rot_prop, *zoom_prop; | PropertyRNA *prop, *col_prop, *fill_col_prop, *rot_prop, *zoom_prop; | ||||
| PropertyRNA *fill_col_override_prop, *fill_col_override_test_prop; | PropertyRNA *fill_col_override_prop, *fill_col_override_test_prop; | ||||
| StructRNA *image_id_srna; | StructRNA *image_id_srna; | ||||
| float initial_value, current_value, min_value, max_value; | float initial_value, current_value, min_value, max_value; | ||||
| int initial_mouse[2]; | int initial_mouse[2]; | ||||
| int initial_co[2]; | int initial_co[2]; | ||||
| int slow_mouse[2]; | int slow_mouse[2]; | ||||
| bool slow_mode; | bool slow_mode; | ||||
| float scale_fac; | |||||
| Dial *dial; | Dial *dial; | ||||
| GPUTexture *texture; | GPUTexture *texture; | ||||
| ListBase orig_paintcursors; | ListBase orig_paintcursors; | ||||
| bool use_secondary_tex; | bool use_secondary_tex; | ||||
| void *cursor; | void *cursor; | ||||
| NumInput num_input; | NumInput num_input; | ||||
| int init_event; | int init_event; | ||||
| } RadialControl; | } RadialControl; | ||||
| Show All 37 Lines | switch (rc->subtype) { | ||||
| BLI_snprintf(msg, sizeof(msg), "%s", ui_name); /* XXX: No value? */ | BLI_snprintf(msg, sizeof(msg), "%s", ui_name); /* XXX: No value? */ | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| ED_area_status_text(area, msg); | ED_area_status_text(area, msg); | ||||
| } | } | ||||
| static void radial_control_set_initial_mouse(RadialControl *rc, const wmEvent *event) | static void radial_control_set_initial_mouse(bContext *C, RadialControl *rc, const wmEvent *event) | ||||
| { | { | ||||
| float d[2] = {0, 0}; | float d[2] = {0, 0}; | ||||
| float zoom[2] = {1, 1}; | float zoom[2] = {1, 1}; | ||||
| copy_v2_v2_int(rc->initial_mouse, event->xy); | copy_v2_v2_int(rc->initial_mouse, event->xy); | ||||
| copy_v2_v2_int(rc->initial_co, event->xy); | copy_v2_v2_int(rc->initial_co, event->xy); | ||||
| switch (rc->subtype) { | switch (rc->subtype) { | ||||
| Show All 18 Lines | default: | ||||
| return; | return; | ||||
| } | } | ||||
| if (rc->zoom_prop) { | if (rc->zoom_prop) { | ||||
| RNA_property_float_get_array(&rc->zoom_ptr, rc->zoom_prop, zoom); | RNA_property_float_get_array(&rc->zoom_ptr, rc->zoom_prop, zoom); | ||||
| d[0] *= zoom[0]; | d[0] *= zoom[0]; | ||||
| d[1] *= zoom[1]; | d[1] *= zoom[1]; | ||||
| } | } | ||||
| /* Grease pencil draw tool needs to rescale the cursor size. If we don't do that | |||||
| * the size of the radial is not equals to the actual stroke size. */ | |||||
| if (rc->ptr.owner_id && GS(rc->ptr.owner_id->name) == ID_BR && rc->prop == &rna_Brush_size) { | |||||
brecht: You can't assume this is a brush, and that it's modifying the size.
You can include… | |||||
Done Inline ActionsThanks for the info, I didn't know that. I have used GS instead of ID because I could include the header file. I guess is the same. antoniov: Thanks for the info, I didn't know that. I have used GS instead of ID because I could include… | |||||
| rc->scale_fac = ED_gpencil_radial_control_scale( | |||||
| C, (Brush *)rc->ptr.owner_id, rc->initial_value, event->mval); | |||||
| } | |||||
| else { | |||||
| rc->scale_fac = 1.0f; | |||||
| } | |||||
| rc->initial_mouse[0] -= d[0]; | rc->initial_mouse[0] -= d[0]; | ||||
| rc->initial_mouse[1] -= d[1]; | rc->initial_mouse[1] -= d[1]; | ||||
| } | } | ||||
| static void radial_control_set_tex(RadialControl *rc) | static void radial_control_set_tex(RadialControl *rc) | ||||
| { | { | ||||
| ImBuf *ibuf; | ImBuf *ibuf; | ||||
| ▲ Show 20 Lines • Show All 188 Lines • ▼ Show 20 Lines | static void radial_control_paint_cursor(bContext *UNUSED(C), int x, int y, void *customdata) | ||||
| GPU_line_smooth(true); | GPU_line_smooth(true); | ||||
| /* apply zoom if available */ | /* apply zoom if available */ | ||||
| if (rc->zoom_prop) { | if (rc->zoom_prop) { | ||||
| RNA_property_float_get_array(&rc->zoom_ptr, rc->zoom_prop, zoom); | RNA_property_float_get_array(&rc->zoom_ptr, rc->zoom_prop, zoom); | ||||
| GPU_matrix_scale_2fv(zoom); | GPU_matrix_scale_2fv(zoom); | ||||
| } | } | ||||
| /* Apply scale correction (used by grease pencil brushes). */ | |||||
| GPU_matrix_scale_2f(rc->scale_fac, rc->scale_fac); | |||||
| /* draw rotated texture */ | /* draw rotated texture */ | ||||
| radial_control_paint_tex(rc, tex_radius, alpha); | radial_control_paint_tex(rc, tex_radius, alpha); | ||||
| /* set line color */ | /* set line color */ | ||||
| if (rc->col_prop) { | if (rc->col_prop) { | ||||
| RNA_property_float_get_array(&rc->col_ptr, rc->col_prop, col); | RNA_property_float_get_array(&rc->col_ptr, rc->col_prop, col); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 317 Lines • ▼ Show 20 Lines | if (!ELEM(rc->subtype, | ||||
| BKE_report(op->reports, | BKE_report(op->reports, | ||||
| RPT_ERROR, | RPT_ERROR, | ||||
| "Property must be a none, distance, factor, percentage, angle, or pixel"); | "Property must be a none, distance, factor, percentage, angle, or pixel"); | ||||
| MEM_freeN(rc); | MEM_freeN(rc); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| rc->current_value = rc->initial_value; | rc->current_value = rc->initial_value; | ||||
| radial_control_set_initial_mouse(rc, event); | radial_control_set_initial_mouse(C, rc, event); | ||||
| radial_control_set_tex(rc); | radial_control_set_tex(rc); | ||||
| rc->init_event = WM_userdef_event_type_from_keymap_type(event->type); | rc->init_event = WM_userdef_event_type_from_keymap_type(event->type); | ||||
| /* temporarily disable other paint cursors */ | /* temporarily disable other paint cursors */ | ||||
| wm = CTX_wm_manager(C); | wm = CTX_wm_manager(C); | ||||
| rc->orig_paintcursors = wm->paintcursors; | rc->orig_paintcursors = wm->paintcursors; | ||||
| BLI_listbase_clear(&wm->paintcursors); | BLI_listbase_clear(&wm->paintcursors); | ||||
| ▲ Show 20 Lines • Show All 498 Lines • ▼ Show 20 Lines | static int redraw_timer_exec(bContext *C, wmOperator *op) | ||||
| ARegion *region = CTX_wm_region(C); | ARegion *region = CTX_wm_region(C); | ||||
| wmWindowManager *wm = CTX_wm_manager(C); | wmWindowManager *wm = CTX_wm_manager(C); | ||||
| const int type = RNA_enum_get(op->ptr, "type"); | const int type = RNA_enum_get(op->ptr, "type"); | ||||
| const int iter = RNA_int_get(op->ptr, "iterations"); | const int iter = RNA_int_get(op->ptr, "iterations"); | ||||
| const double time_limit = (double)RNA_float_get(op->ptr, "time_limit"); | const double time_limit = (double)RNA_float_get(op->ptr, "time_limit"); | ||||
| const int cfra = scene->r.cfra; | const int cfra = scene->r.cfra; | ||||
| const char *infostr = ""; | const char *infostr = ""; | ||||
| /* NOTE: Depsgraph is used to update scene for a new state, so no need to ensure evaluation here. | /* NOTE: Depsgraph is used to update scene for a new state, so no need to ensure evaluation | ||||
| * here. | |||||
| */ | */ | ||||
| struct Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); | struct Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); | ||||
| WM_cursor_wait(true); | WM_cursor_wait(true); | ||||
| double time_start = PIL_check_seconds_timer(); | double time_start = PIL_check_seconds_timer(); | ||||
| wm_window_make_drawable(wm, win); | wm_window_make_drawable(wm, win); | ||||
| ▲ Show 20 Lines • Show All 829 Lines • Show Last 20 Lines | |||||
You can't assume this is a brush, and that it's modifying the size.
You can include RNA_property_types.h and then do something like this:
if (rc->ptr.owner_id && ID(rc->ptr.owner_id) == ID_BR && rc->prop == &rna_Brush_size) { ... }