Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/armature/pose_slide.c
| Show First 20 Lines • Show All 96 Lines • ▼ Show 20 Lines | |||||
| /* A) Push & Relax, Breakdowner */ | /* A) Push & Relax, Breakdowner */ | ||||
| /* Temporary data shared between these operators */ | /* Temporary data shared between these operators */ | ||||
| typedef struct tPoseSlideOp { | typedef struct tPoseSlideOp { | ||||
| /** current scene */ | /** current scene */ | ||||
| Scene *scene; | Scene *scene; | ||||
| /** area that we're operating in (needed for modal()) */ | /** area that we're operating in (needed for modal()) */ | ||||
| ScrArea *area; | ScrArea *area; | ||||
| /** region that we're operating in (needed for modal()) */ | /** Header of the region used for drawing the slider. */ | ||||
| ARegion *region; | ARegion *region_header; | ||||
| /** len of the PoseSlideObject array. */ | /** len of the PoseSlideObject array. */ | ||||
| uint objects_len; | uint objects_len; | ||||
| /** links between posechannels and f-curves for all the pose objects. */ | /** links between posechannels and f-curves for all the pose objects. */ | ||||
| ListBase pfLinks; | ListBase pfLinks; | ||||
| /** binary tree for quicker searching for keyframes (when applicable) */ | /** binary tree for quicker searching for keyframes (when applicable) */ | ||||
| DLRBT_Tree keys; | DLRBT_Tree keys; | ||||
| ▲ Show 20 Lines • Show All 239 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| /* Draw an on screen Slider for a Pose Slide Operator. */ | /* Draw an on screen Slider for a Pose Slide Operator. */ | ||||
| static void pose_slide_draw_2d_slider(const struct bContext *UNUSED(C), ARegion *region, void *arg) | static void pose_slide_draw_2d_slider(const struct bContext *UNUSED(C), ARegion *region, void *arg) | ||||
| { | { | ||||
| tPoseSlideOp *pso = arg; | tPoseSlideOp *pso = arg; | ||||
| /* Only draw in region from which the Operator was started. */ | /* Only draw in region from which the Operator was started. */ | ||||
| if (region != pso->region) { | if (region != pso->region_header) { | ||||
| return; | return; | ||||
| } | } | ||||
| uint8_t color_text[4]; | uint8_t color_text[4]; | ||||
| uint8_t color_line[4]; | uint8_t color_line[4]; | ||||
| uint8_t color_handle[4]; | uint8_t color_handle[4]; | ||||
| uint8_t color_overshoot[4]; | uint8_t color_overshoot[4]; | ||||
| float color_bg[4]; | float color_bg[4]; | ||||
| Show All 30 Lines | static void pose_slide_draw_2d_slider(const struct bContext *UNUSED(C), ARegion *region, void *arg) | ||||
| if (pso->overshoot) { | if (pso->overshoot) { | ||||
| main_line_rect.xmin = main_line_rect.xmin - SLIDE_PIXEL_DISTANCE * OVERSHOOT_RANGE_DELTA; | main_line_rect.xmin = main_line_rect.xmin - SLIDE_PIXEL_DISTANCE * OVERSHOOT_RANGE_DELTA; | ||||
| main_line_rect.xmax = main_line_rect.xmax + SLIDE_PIXEL_DISTANCE * OVERSHOOT_RANGE_DELTA; | main_line_rect.xmax = main_line_rect.xmax + SLIDE_PIXEL_DISTANCE * OVERSHOOT_RANGE_DELTA; | ||||
| line_start_percentage = pso->percentage - 0.5f - OVERSHOOT_RANGE_DELTA; | line_start_percentage = pso->percentage - 0.5f - OVERSHOOT_RANGE_DELTA; | ||||
| handle_pos_x = region->winx / 2; | handle_pos_x = region->winx / 2; | ||||
| } | } | ||||
| draw_backdrop(fontid, main_line_rect, color_bg, pso->region->winy, base_tick_height); | draw_backdrop(fontid, main_line_rect, color_bg, pso->region_header->winy, base_tick_height); | ||||
| draw_main_line(main_line_rect, pso->percentage, pso->overshoot, color_overshoot, color_line); | draw_main_line(main_line_rect, pso->percentage, pso->overshoot, color_overshoot, color_line); | ||||
| const float percentage_range = pso->overshoot ? 1 + OVERSHOOT_RANGE_DELTA * 2 : 1; | const float percentage_range = pso->overshoot ? 1 + OVERSHOOT_RANGE_DELTA * 2 : 1; | ||||
| const struct vec2f line_start_position = {.x = main_line_rect.xmin, .y = line_y}; | const struct vec2f line_start_position = {.x = main_line_rect.xmin, .y = line_y}; | ||||
| draw_ticks(line_start_percentage, | draw_ticks(line_start_percentage, | ||||
| line_start_percentage + percentage_range, | line_start_percentage + percentage_range, | ||||
| line_start_position, | line_start_position, | ||||
| ▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| tPoseSlideOp *pso; | tPoseSlideOp *pso; | ||||
| /* init slide-op data */ | /* init slide-op data */ | ||||
| pso = op->customdata = MEM_callocN(sizeof(tPoseSlideOp), "tPoseSlideOp"); | pso = op->customdata = MEM_callocN(sizeof(tPoseSlideOp), "tPoseSlideOp"); | ||||
| /* get info from context */ | /* get info from context */ | ||||
| pso->scene = CTX_data_scene(C); | pso->scene = CTX_data_scene(C); | ||||
| pso->area = CTX_wm_area(C); /* only really needed when doing modal() */ | pso->area = CTX_wm_area(C); /* only really needed when doing modal() */ | ||||
| pso->region = CTX_wm_region(C); /* only really needed when doing modal() */ | |||||
| /* Register UI drawing callback. */ | |||||
| ARegion *region_header = BKE_area_find_region_type(pso->area, RGN_TYPE_HEADER); | |||||
| if (region_header != NULL) { | |||||
| pso->region_header = region_header; | |||||
| pso->draw_handle = ED_region_draw_cb_activate( | |||||
| region_header->type, pose_slide_draw_2d_slider, pso, REGION_DRAW_POST_PIXEL); | |||||
| } | |||||
sybren: This code move is not just "rename `region` to `region_header`", so it shouldn't be done in… | |||||
| pso->cframe = pso->scene->r.cfra; | pso->cframe = pso->scene->r.cfra; | ||||
| pso->mode = mode; | pso->mode = mode; | ||||
| /* set range info from property values - these may get overridden for the invoke() */ | /* set range info from property values - these may get overridden for the invoke() */ | ||||
| pso->percentage = RNA_float_get(op->ptr, "percentage"); | pso->percentage = RNA_float_get(op->ptr, "percentage"); | ||||
| pso->raw_percentage = pso->percentage; | pso->raw_percentage = pso->percentage; | ||||
| pso->prevFrame = RNA_int_get(op->ptr, "prev_frame"); | pso->prevFrame = RNA_int_get(op->ptr, "prev_frame"); | ||||
| ▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | static int pose_slide_init(bContext *C, wmOperator *op, ePoseSlide_Modes mode) | ||||
| BLI_dlrbTree_init(&pso->keys); | BLI_dlrbTree_init(&pso->keys); | ||||
| /* Initialize numeric input. */ | /* Initialize numeric input. */ | ||||
| initNumInput(&pso->num); | initNumInput(&pso->num); | ||||
| pso->num.idx_max = 0; /* one axis */ | pso->num.idx_max = 0; /* one axis */ | ||||
| pso->num.val_flag[0] |= NUM_NO_NEGATIVE; | pso->num.val_flag[0] |= NUM_NO_NEGATIVE; | ||||
| pso->num.unit_type[0] = B_UNIT_NONE; /* percentages don't have any units... */ | pso->num.unit_type[0] = B_UNIT_NONE; /* percentages don't have any units... */ | ||||
| /* Register UI drawing callback. */ | |||||
| ARegion *region_header = BKE_area_find_region_type(pso->area, RGN_TYPE_HEADER); | |||||
| if (region_header != NULL) { | |||||
| pso->region = region_header; | |||||
| pso->draw_handle = ED_region_draw_cb_activate( | |||||
| region_header->type, pose_slide_draw_2d_slider, pso, REGION_DRAW_POST_PIXEL); | |||||
| } | |||||
| /* return status is whether we've got all the data we were requested to get */ | /* return status is whether we've got all the data we were requested to get */ | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| /* exiting the operator - free data */ | /* exiting the operator - free data */ | ||||
| static void pose_slide_exit(wmOperator *op) | static void pose_slide_exit(wmOperator *op) | ||||
| { | { | ||||
| tPoseSlideOp *pso = op->customdata; | tPoseSlideOp *pso = op->customdata; | ||||
| /* Hide Bone Overlay. */ | /* Hide Bone Overlay. */ | ||||
| View3D *v3d = pso->area->spacedata.first; | View3D *v3d = pso->area->spacedata.first; | ||||
| v3d->overlay.flag = pso->overlay_flag; | v3d->overlay.flag = pso->overlay_flag; | ||||
| /* Remove UI drawing callback. */ | /* Remove UI drawing callback. */ | ||||
| ED_region_draw_cb_exit(pso->region->type, pso->draw_handle); | ED_region_draw_cb_exit(pso->region_header->type, pso->draw_handle); | ||||
| /* if data exists, clear its data and exit */ | /* if data exists, clear its data and exit */ | ||||
| if (pso) { | if (pso) { | ||||
| /* free the temp pchan links and their data */ | /* free the temp pchan links and their data */ | ||||
| poseAnim_mapping_free(&pso->pfLinks); | poseAnim_mapping_free(&pso->pfLinks); | ||||
| /* free RB-BST for keyframes (if it contained data) */ | /* free RB-BST for keyframes (if it contained data) */ | ||||
| BLI_dlrbTree_free(&pso->keys); | BLI_dlrbTree_free(&pso->keys); | ||||
| ▲ Show 20 Lines • Show All 508 Lines • ▼ Show 20 Lines | |||||
| static void pose_slide_reset(tPoseSlideOp *pso) | static void pose_slide_reset(tPoseSlideOp *pso) | ||||
| { | { | ||||
| /* wrapper around the generic call, so that custom stuff can be added later */ | /* wrapper around the generic call, so that custom stuff can be added later */ | ||||
| poseAnim_mapping_reset(&pso->pfLinks); | poseAnim_mapping_reset(&pso->pfLinks); | ||||
| } | } | ||||
| /* ------------------------------------ */ | /* ------------------------------------ */ | ||||
| /* Draw percentage indicator in workspace footer. */ | /* Draw percentage indicator in status bar. */ | ||||
sybrenUnsubmitted Not Done Inline ActionsThis is also a different change than "rename X to Y", so should be in a separate commit. sybren: This is also a different change than "rename X to Y", so should be in a separate commit. | |||||
| /* TODO: Include hints about locks here... */ | /* TODO: Include hints about locks here... */ | ||||
| static void pose_slide_draw_status(bContext *C, tPoseSlideOp *pso) | static void pose_slide_draw_status(bContext *C, tPoseSlideOp *pso) | ||||
| { | { | ||||
| char status_str[UI_MAX_DRAW_STR]; | char status_str[UI_MAX_DRAW_STR]; | ||||
| char limits_str[UI_MAX_DRAW_STR]; | char limits_str[UI_MAX_DRAW_STR]; | ||||
| char axis_str[50]; | char axis_str[50]; | ||||
| char mode_str[32]; | char mode_str[32]; | ||||
| char overshoot_str[50]; | char overshoot_str[50]; | ||||
| ▲ Show 20 Lines • Show All 992 Lines • Show Last 20 Lines | |||||
This code move is not just "rename region to region_header", so it shouldn't be done in this patch.