diff options
author | Ton Roosendaal <ton@blender.org> | 2008-12-03 22:33:42 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2008-12-03 22:33:42 +0300 |
commit | a9374c5941641b8f7322b6b2c7ad83892b5b214d (patch) | |
tree | 9e73695a85b608ff28201a9e8fb45c6a2f728b9e /source/blender/editors | |
parent | 757fe56314d469608668aee0d8e57f054e41a48e (diff) |
2.5
Fun commit for test: the Repeat Last option.
Only the split-area Operator is now added on stack, so that's the only
one that works. Just split an area, and press F4 to repeat it anywhere.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/include/ED_screen.h | 2 | ||||
-rw-r--r-- | source/blender/editors/screen/area.c | 2 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_ops.c | 41 | ||||
-rw-r--r-- | source/blender/editors/space_time/time_ops.c | 2 |
4 files changed, 42 insertions, 5 deletions
diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index a8e39f51ed4..2514c4c90fd 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -43,7 +43,7 @@ void ED_region_do_listen(ARegion *ar, struct wmNotifier *note); void ED_region_do_draw(struct bContext *C, ARegion *ar); void ED_region_do_refresh(struct bContext *C, ARegion *ar); void ED_region_exit(struct bContext *C, ARegion *ar); -void ED_region_pixelspace(struct bContext *C, ARegion *ar); +void ED_region_pixelspace(const struct bContext *C, ARegion *ar); /* spaces */ void ED_spacetypes_init(void); diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 62876cfbbf0..7a5fa0cb727 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -90,7 +90,7 @@ static void region_draw_emboss(ARegion *ar) glDisable( GL_BLEND ); } -void ED_region_pixelspace(bContext *C, ARegion *ar) +void ED_region_pixelspace(const bContext *C, ARegion *ar) { int width= ar->winrct.xmax-ar->winrct.xmin+1; int height= ar->winrct.ymax-ar->winrct.ymin+1; diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 881f7719e1e..0066ee5736b 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -678,7 +678,8 @@ typedef struct sAreaSplitData int origval; /* for move areas */ int bigger, smaller; /* constraints for moving new edge */ int delta; /* delta move edge */ - + int origmin, origsize; /* to calculate fac, for property storage */ + ScrEdge *nedge; /* new edge */ ScrArea *sarea; /* start area */ ScrArea *narea; /* new area */ @@ -705,6 +706,8 @@ static int area_split_init(bContext *C, wmOperator *op) op->customdata= sd; sd->sarea= C->area; + sd->origsize= dir=='v' ? C->area->winx:C->area->winy; + sd->origmin = dir=='v' ? C->area->totrct.xmin:C->area->totrct.ymin; return 1; } @@ -877,6 +880,7 @@ static int area_split_cancel(bContext *C, wmOperator *op) static int area_split_modal(bContext *C, wmOperator *op, wmEvent *event) { sAreaSplitData *sd= (sAreaSplitData *)op->customdata; + float fac; int dir; /* execute the events */ @@ -887,6 +891,9 @@ static int area_split_modal(bContext *C, wmOperator *op, wmEvent *event) sd->delta= (dir == 'v')? event->x - sd->origval: event->y - sd->origval; area_move_apply_do(C, sd->origval, sd->delta, dir, sd->bigger, sd->smaller); + fac= (dir == 'v') ? event->x-sd->origmin : event->y-sd->origmin; + RNA_float_set(op->ptr, "fac", fac / (float)sd->origsize); + WM_event_add_notifier(C, WM_NOTE_SCREEN_CHANGED, 0, NULL); break; @@ -920,7 +927,8 @@ void ED_SCR_OT_area_split(wmOperatorType *ot) ot->modal= area_split_modal; ot->poll= ED_operator_areaactive; - + ot->flag= OPTYPE_REGISTER; + /* rna */ prop= RNA_def_property(ot->srna, "dir", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, prop_direction_items); @@ -1210,6 +1218,33 @@ void ED_SCR_OT_area_join(wmOperatorType *ot) RNA_def_property_int_default(prop, -100); } +/* ************** repeat last operator ***************************** */ + +static int repeat_last_exec(bContext *C, wmOperator *op) +{ + wmOperator *lastop= C->wm->operators.last; + + if(lastop) { + printf("repeat %s\n", op->type->idname); + lastop->type->exec(C, lastop); + } + + return OPERATOR_FINISHED; +} + +void ED_SCR_OT_repeat_last(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Repeat Last"; + ot->idname= "ED_SCR_OT_repeat_last"; + + /* api callbacks */ + ot->exec= repeat_last_exec; + + ot->poll= ED_operator_screenactive; + +} + /* ************** border select operator (template) ***************************** */ /* operator state vars used: (added by default WM callbacks) @@ -1276,6 +1311,7 @@ void ED_operatortypes_screen(void) /* generic UI stuff */ WM_operatortype_append(ED_SCR_OT_cursor_type); WM_operatortype_append(ED_SCR_OT_actionzone); + WM_operatortype_append(ED_SCR_OT_repeat_last); /* screen tools */ WM_operatortype_append(ED_SCR_OT_area_move); @@ -1302,5 +1338,6 @@ void ED_keymap_screen(wmWindowManager *wm) WM_keymap_verify_item(&wm->screenkeymap, "ED_SCR_OT_area_join", EVT_ACTIONZONE, 0, 0, 0); /* action tria */ WM_keymap_verify_item(&wm->screenkeymap, "ED_SCR_OT_area_rip", RKEY, KM_PRESS, KM_ALT, 0); + WM_keymap_verify_item(&wm->screenkeymap, "ED_SCR_OT_repeat_last", F4KEY, KM_PRESS, 0, 0); } diff --git a/source/blender/editors/space_time/time_ops.c b/source/blender/editors/space_time/time_ops.c index 207804dae3e..86ff9d9b0ab 100644 --- a/source/blender/editors/space_time/time_ops.c +++ b/source/blender/editors/space_time/time_ops.c @@ -85,7 +85,7 @@ static void change_frame_apply(bContext *C, wmOperator *op) if(cfra!=CFRA) CFRA= cfra; - WM_event_add_notifier(C, WM_NOTE_SCREEN_CHANGED, 0, NULL); + WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL); /* XXX: add WM_NOTE_TIME_CHANGED? */ } |