Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/workspace/screen_ops.c
- This file was moved from source/blender/editors/screen/screen_ops.c.
| Show All 16 Lines | |||||
| * | * | ||||
| * The Original Code is Copyright (C) 2008 Blender Foundation. | * The Original Code is Copyright (C) 2008 Blender Foundation. | ||||
| * All rights reserved. | * All rights reserved. | ||||
| * | * | ||||
| * | * | ||||
| * ***** END GPL LICENSE BLOCK ***** | * ***** END GPL LICENSE BLOCK ***** | ||||
| */ | */ | ||||
| /** \file blender/editors/screen/screen_ops.c | /** \file blender/editors/workspace/screen_ops.c | ||||
| * \ingroup edscr | * \ingroup edworkspace | ||||
| */ | */ | ||||
| #include <math.h> | #include <math.h> | ||||
| #include <string.h> | #include <string.h> | ||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| Show All 22 Lines | |||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_object.h" | #include "BKE_object.h" | ||||
| #include "BKE_report.h" | #include "BKE_report.h" | ||||
| #include "BKE_scene.h" | #include "BKE_scene.h" | ||||
| #include "BKE_screen.h" | #include "BKE_screen.h" | ||||
| #include "BKE_editmesh.h" | #include "BKE_editmesh.h" | ||||
| #include "BKE_sound.h" | #include "BKE_sound.h" | ||||
| #include "BKE_mask.h" | #include "BKE_mask.h" | ||||
| #include "BKE_workspace.h" | |||||
| #include "WM_api.h" | #include "WM_api.h" | ||||
| #include "WM_types.h" | #include "WM_types.h" | ||||
| #include "ED_armature.h" | #include "ED_armature.h" | ||||
| #include "ED_clip.h" | #include "ED_clip.h" | ||||
| #include "ED_image.h" | #include "ED_image.h" | ||||
| #include "ED_keyframes_draw.h" | #include "ED_keyframes_draw.h" | ||||
| ▲ Show 20 Lines • Show All 868 Lines • ▼ Show 20 Lines | case LEFTMOUSE: /* release LMB */ | ||||
| ED_area_tag_redraw(sad->sa1); | ED_area_tag_redraw(sad->sa1); | ||||
| ED_area_tag_redraw(sad->sa2); | ED_area_tag_redraw(sad->sa2); | ||||
| ED_area_swapspace(C, sad->sa1, sad->sa2); | ED_area_swapspace(C, sad->sa1, sad->sa2); | ||||
| area_swap_exit(C, op); | area_swap_exit(C, op); | ||||
| WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); | WM_event_add_notifier(C, NC_WORKSPACE | NA_EDITED, NULL); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| break; | break; | ||||
| case ESCKEY: | case ESCKEY: | ||||
| area_swap_cancel(C, op); | area_swap_cancel(C, op); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| Show All 15 Lines | static void SCREEN_OT_area_swap(wmOperatorType *ot) | ||||
| ot->flag = OPTYPE_BLOCKING; | ot->flag = OPTYPE_BLOCKING; | ||||
| } | } | ||||
| /* *********** Duplicate area as new window operator ****************** */ | /* *********** Duplicate area as new window operator ****************** */ | ||||
| /* operator callback */ | /* operator callback */ | ||||
| static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event) | static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event) | ||||
| { | { | ||||
| wmWindow *newwin, *win; | wmWindow *newwin, *win = CTX_wm_window(C); | ||||
| Scene *scene; | |||||
| WorkSpace *workspace_old = WM_window_get_active_workspace(win); | |||||
| WorkSpace *workspace_new; | |||||
| WorkSpaceLayout *layout_new; | |||||
| bScreen *newsc, *sc; | bScreen *newsc, *sc; | ||||
| ScrArea *sa; | ScrArea *sa; | ||||
| rcti rect; | rcti rect; | ||||
| win = CTX_wm_window(C); | win = CTX_wm_window(C); | ||||
| scene = CTX_data_scene(C); | |||||
| sc = CTX_wm_screen(C); | sc = CTX_wm_screen(C); | ||||
| sa = CTX_wm_area(C); | sa = CTX_wm_area(C); | ||||
| /* XXX hrmf! */ | /* XXX hrmf! */ | ||||
| if (event->type == EVT_ACTIONZONE_AREA) { | if (event->type == EVT_ACTIONZONE_AREA) { | ||||
| sActionzoneData *sad = event->customdata; | sActionzoneData *sad = event->customdata; | ||||
| if (sad == NULL) | if (sad == NULL) | ||||
| Show All 10 Lines | static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event) | ||||
| newwin = WM_window_open(C, &rect); | newwin = WM_window_open(C, &rect); | ||||
| if (newwin == NULL) { | if (newwin == NULL) { | ||||
| BKE_report(op->reports, RPT_ERROR, "Failed to open window!"); | BKE_report(op->reports, RPT_ERROR, "Failed to open window!"); | ||||
| goto finally; | goto finally; | ||||
| } | } | ||||
| *newwin->stereo3d_format = *win->stereo3d_format; | *newwin->stereo3d_format = *win->stereo3d_format; | ||||
| newwin->scene = scene; | |||||
| workspace_new = BKE_workspace_add(CTX_data_main(C), BKE_workspace_name_get(workspace_old)); | |||||
| WM_window_set_active_workspace(newwin, workspace_new); | |||||
| /* allocs new screen and adds to newly created window, using window size */ | /* allocs new screen and adds to newly created window, using window size */ | ||||
| newsc = ED_screen_add(newwin, CTX_data_scene(C), sc->id.name + 2); | layout_new = ED_workspace_layout_add(workspace_new, newwin, sc->id.name + 2); | ||||
| newwin->screen = newsc; | newsc = BKE_workspace_layout_screen_get(layout_new); | ||||
| WM_window_set_active_layout(newwin, layout_new); | |||||
| /* copy area to new screen */ | /* copy area to new screen */ | ||||
| ED_area_data_copy((ScrArea *)newsc->areabase.first, sa, true); | ED_area_data_copy((ScrArea *)newsc->areabase.first, sa, true); | ||||
| ED_area_tag_redraw((ScrArea *)newsc->areabase.first); | ED_area_tag_redraw((ScrArea *)newsc->areabase.first); | ||||
| /* screen, areas init */ | /* screen, areas init */ | ||||
| WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); | WM_event_add_notifier(C, NC_WORKSPACE | NA_EDITED, NULL); | ||||
| finally: | finally: | ||||
| if (event->type == EVT_ACTIONZONE_AREA) | if (event->type == EVT_ACTIONZONE_AREA) | ||||
| actionzone_exit(op); | actionzone_exit(op); | ||||
| if (newwin) { | if (newwin) { | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| ▲ Show 20 Lines • Show All 182 Lines • ▼ Show 20 Lines | static void area_move_apply_do(bContext *C, int origval, int delta, int dir, int bigger, int smaller) | ||||
| /* only redraw if we actually moved a screen vert, for AREAGRID */ | /* only redraw if we actually moved a screen vert, for AREAGRID */ | ||||
| if (doredraw) { | if (doredraw) { | ||||
| for (sa = sc->areabase.first; sa; sa = sa->next) { | for (sa = sc->areabase.first; sa; sa = sa->next) { | ||||
| if (sa->v1->editflag || sa->v2->editflag || sa->v3->editflag || sa->v4->editflag) | if (sa->v1->editflag || sa->v2->editflag || sa->v3->editflag || sa->v4->editflag) | ||||
| ED_area_tag_redraw(sa); | ED_area_tag_redraw(sa); | ||||
| } | } | ||||
| WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); /* redraw everything */ | WM_event_add_notifier(C, NC_WORKSPACE | NA_EDITED, NULL); /* redraw everything */ | ||||
| /* Update preview thumbnail */ | /* Update preview thumbnail */ | ||||
| BKE_icon_changed(sc->id.icon_id); | BKE_icon_changed(sc->id.icon_id); | ||||
| } | } | ||||
| } | } | ||||
| static void area_move_apply(bContext *C, wmOperator *op) | static void area_move_apply(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| sAreaMoveData *md = op->customdata; | sAreaMoveData *md = op->customdata; | ||||
| ▲ Show 20 Lines • Show All 273 Lines • ▼ Show 20 Lines | if (sd->narea) { | ||||
| sd->nedge->v2->editflag = 1; | sd->nedge->v2->editflag = 1; | ||||
| if (dir == 'h') sd->origval = sd->nedge->v1->vec.y; | if (dir == 'h') sd->origval = sd->nedge->v1->vec.y; | ||||
| else sd->origval = sd->nedge->v1->vec.x; | else sd->origval = sd->nedge->v1->vec.x; | ||||
| ED_area_tag_redraw(sd->sarea); | ED_area_tag_redraw(sd->sarea); | ||||
| ED_area_tag_redraw(sd->narea); | ED_area_tag_redraw(sd->narea); | ||||
| WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); | WM_event_add_notifier(C, NC_WORKSPACE | NA_EDITED, NULL); | ||||
| /* Update preview thumbnail */ | /* Update preview thumbnail */ | ||||
| BKE_icon_changed(sc->id.icon_id); | BKE_icon_changed(sc->id.icon_id); | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| static void area_split_exit(bContext *C, wmOperator *op) | static void area_split_exit(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| if (op->customdata) { | if (op->customdata) { | ||||
| sAreaSplitData *sd = (sAreaSplitData *)op->customdata; | sAreaSplitData *sd = (sAreaSplitData *)op->customdata; | ||||
| if (sd->sarea) ED_area_tag_redraw(sd->sarea); | if (sd->sarea) ED_area_tag_redraw(sd->sarea); | ||||
| if (sd->narea) ED_area_tag_redraw(sd->narea); | if (sd->narea) ED_area_tag_redraw(sd->narea); | ||||
| if (sd->sarea) | if (sd->sarea) | ||||
| sd->sarea->flag &= ~(AREA_FLAG_DRAWSPLIT_H | AREA_FLAG_DRAWSPLIT_V); | sd->sarea->flag &= ~(AREA_FLAG_DRAWSPLIT_H | AREA_FLAG_DRAWSPLIT_V); | ||||
| MEM_freeN(op->customdata); | MEM_freeN(op->customdata); | ||||
| op->customdata = NULL; | op->customdata = NULL; | ||||
| } | } | ||||
| WM_cursor_modal_restore(CTX_wm_window(C)); | WM_cursor_modal_restore(CTX_wm_window(C)); | ||||
| WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); | WM_event_add_notifier(C, NC_WORKSPACE | NA_EDITED, NULL); | ||||
| /* this makes sure aligned edges will result in aligned grabbing */ | /* this makes sure aligned edges will result in aligned grabbing */ | ||||
| removedouble_scrverts(CTX_wm_screen(C)); | removedouble_scrverts(CTX_wm_screen(C)); | ||||
| removedouble_scredges(CTX_wm_screen(C)); | removedouble_scredges(CTX_wm_screen(C)); | ||||
| } | } | ||||
| /* UI callback, adds new handler */ | /* UI callback, adds new handler */ | ||||
| ▲ Show 20 Lines • Show All 162 Lines • ▼ Show 20 Lines | case MOUSEMOVE: | ||||
| } | } | ||||
| else { | else { | ||||
| sd->origsize = sd->sarea->winy; | sd->origsize = sd->sarea->winy; | ||||
| sd->origmin = sd->sarea->totrct.ymin; | sd->origmin = sd->sarea->totrct.ymin; | ||||
| sd->sarea->flag |= AREA_FLAG_DRAWSPLIT_H; | sd->sarea->flag |= AREA_FLAG_DRAWSPLIT_H; | ||||
| } | } | ||||
| } | } | ||||
| CTX_wm_window(C)->screen->do_draw = true; | CTX_wm_screen(C)->do_draw = true; | ||||
| } | } | ||||
| fac = (dir == 'v') ? event->x - sd->origmin : event->y - sd->origmin; | fac = (dir == 'v') ? event->x - sd->origmin : event->y - sd->origmin; | ||||
| RNA_float_set(op->ptr, "factor", fac / (float)sd->origsize); | RNA_float_set(op->ptr, "factor", fac / (float)sd->origsize); | ||||
| break; | break; | ||||
| ▲ Show 20 Lines • Show All 290 Lines • ▼ Show 20 Lines | case MOUSEMOVE: | ||||
| region_scale_toggle_hidden(C, rmd); | region_scale_toggle_hidden(C, rmd); | ||||
| } | } | ||||
| else if (maxsize > 0 && (rmd->ar->sizey > maxsize)) | else if (maxsize > 0 && (rmd->ar->sizey > maxsize)) | ||||
| rmd->ar->sizey = maxsize; | rmd->ar->sizey = maxsize; | ||||
| else if (rmd->ar->flag & RGN_FLAG_HIDDEN) | else if (rmd->ar->flag & RGN_FLAG_HIDDEN) | ||||
| region_scale_toggle_hidden(C, rmd); | region_scale_toggle_hidden(C, rmd); | ||||
| } | } | ||||
| ED_area_tag_redraw(rmd->sa); | ED_area_tag_redraw(rmd->sa); | ||||
| WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); | WM_event_add_notifier(C, NC_WORKSPACE | NA_EDITED, NULL); | ||||
| break; | break; | ||||
| case LEFTMOUSE: | case LEFTMOUSE: | ||||
| if (event->val == KM_RELEASE) { | if (event->val == KM_RELEASE) { | ||||
| if (ABS(event->x - rmd->origx) < 2 && ABS(event->y - rmd->origy) < 2) { | if (ABS(event->x - rmd->origx) < 2 && ABS(event->y - rmd->origy) < 2) { | ||||
| if (rmd->ar->flag & RGN_FLAG_HIDDEN) { | if (rmd->ar->flag & RGN_FLAG_HIDDEN) { | ||||
| region_scale_toggle_hidden(C, rmd); | region_scale_toggle_hidden(C, rmd); | ||||
| } | } | ||||
| else if (rmd->ar->flag & RGN_FLAG_TOO_SMALL) { | else if (rmd->ar->flag & RGN_FLAG_TOO_SMALL) { | ||||
| region_scale_validate_size(rmd); | region_scale_validate_size(rmd); | ||||
| } | } | ||||
| ED_area_tag_redraw(rmd->sa); | ED_area_tag_redraw(rmd->sa); | ||||
| WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); | WM_event_add_notifier(C, NC_WORKSPACE | NA_EDITED, NULL); | ||||
| } | } | ||||
| MEM_freeN(op->customdata); | MEM_freeN(op->customdata); | ||||
| op->customdata = NULL; | op->customdata = NULL; | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| break; | break; | ||||
| Show All 30 Lines | |||||
| /* ************** frame change operator ***************************** */ | /* ************** frame change operator ***************************** */ | ||||
| static void areas_do_frame_follow(bContext *C, bool middle) | static void areas_do_frame_follow(bContext *C, bool middle) | ||||
| { | { | ||||
| bScreen *scr = CTX_wm_screen(C); | bScreen *scr = CTX_wm_screen(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| wmWindowManager *wm = CTX_wm_manager(C); | wmWindowManager *wm = CTX_wm_manager(C); | ||||
| wmWindow *window; | for (wmWindow *window = wm->windows.first; window; window = window->next) { | ||||
| for (window = wm->windows.first; window; window = window->next) { | const bScreen *screen = WM_window_get_active_screen(window); | ||||
| ScrArea *sa; | |||||
| for (sa = window->screen->areabase.first; sa; sa = sa->next) { | for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { | ||||
| ARegion *ar; | for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) { | ||||
| for (ar = sa->regionbase.first; ar; ar = ar->next) { | |||||
| /* do follow here if editor type supports it */ | /* do follow here if editor type supports it */ | ||||
| if ((scr->redraws_flag & TIME_FOLLOW)) { | if ((scr->redraws_flag & TIME_FOLLOW)) { | ||||
| if ((ar->regiontype == RGN_TYPE_WINDOW && | if ((ar->regiontype == RGN_TYPE_WINDOW && | ||||
| ELEM(sa->spacetype, SPACE_SEQ, SPACE_TIME, SPACE_IPO, SPACE_ACTION, SPACE_NLA)) || | ELEM(sa->spacetype, SPACE_SEQ, SPACE_TIME, SPACE_IPO, SPACE_ACTION, SPACE_NLA)) || | ||||
| (sa->spacetype == SPACE_CLIP && ar->regiontype == RGN_TYPE_PREVIEW)) | (sa->spacetype == SPACE_CLIP && ar->regiontype == RGN_TYPE_PREVIEW)) | ||||
| { | { | ||||
| float w = BLI_rctf_size_x(&ar->v2d.cur); | float w = BLI_rctf_size_x(&ar->v2d.cur); | ||||
| ▲ Show 20 Lines • Show All 279 Lines • ▼ Show 20 Lines | static void SCREEN_OT_marker_jump(wmOperatorType *ot) | ||||
| ot->undo_group = "FRAME_CHANGE"; | ot->undo_group = "FRAME_CHANGE"; | ||||
| /* properties */ | /* properties */ | ||||
| RNA_def_boolean(ot->srna, "next", true, "Next Marker", ""); | RNA_def_boolean(ot->srna, "next", true, "Next Marker", ""); | ||||
| } | } | ||||
| /* ************** switch screen operator ***************************** */ | /* ************** switch screen operator ***************************** */ | ||||
| static bool screen_set_is_ok(bScreen *screen, bScreen *screen_prev) | |||||
| { | |||||
| return ((screen->winid == 0) && | |||||
| /* in typical usage these should have a nonzero winid | |||||
| * (all temp screens should be used, or closed & freed). */ | |||||
| (screen->temp == false) && | |||||
| (screen->state == SCREENNORMAL) && | |||||
| (screen != screen_prev) && | |||||
| (screen->id.name[2] != '.' || !(U.uiflag & USER_HIDE_DOT))); | |||||
| } | |||||
| /* function to be called outside UI context, or for redo */ | /* function to be called outside UI context, or for redo */ | ||||
| static int screen_set_exec(bContext *C, wmOperator *op) | static int screen_set_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | WorkSpace *workspace = CTX_wm_workspace(C); | ||||
| bScreen *screen = CTX_wm_screen(C); | |||||
| bScreen *screen_prev = screen; | |||||
| ScrArea *sa = CTX_wm_area(C); | |||||
| int tot = BLI_listbase_count(&bmain->screen); | |||||
| int delta = RNA_int_get(op->ptr, "delta"); | int delta = RNA_int_get(op->ptr, "delta"); | ||||
| /* temp screens are for userpref or render display */ | if (ED_workspace_layout_cycle(C, workspace, delta)) { | ||||
| if (screen->temp || (sa && sa->full && sa->full->temp)) { | |||||
| return OPERATOR_CANCELLED; | |||||
| } | |||||
| if (delta == 1) { | |||||
| while (tot--) { | |||||
| screen = screen->id.next; | |||||
| if (screen == NULL) screen = bmain->screen.first; | |||||
| if (screen_set_is_ok(screen, screen_prev)) { | |||||
| break; | |||||
| } | |||||
| } | |||||
| } | |||||
| else if (delta == -1) { | |||||
| while (tot--) { | |||||
| screen = screen->id.prev; | |||||
| if (screen == NULL) screen = bmain->screen.last; | |||||
| if (screen_set_is_ok(screen, screen_prev)) { | |||||
| break; | |||||
| } | |||||
| } | |||||
| } | |||||
| else { | |||||
| screen = NULL; | |||||
| } | |||||
| if (screen && screen_prev != screen) { | |||||
| /* return to previous state before switching screens */ | |||||
| if (sa && sa->full) { | |||||
| ED_screen_full_restore(C, sa); /* may free 'screen_prev' */ | |||||
| } | |||||
| ED_screen_set(C, screen); | |||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| static void SCREEN_OT_screen_set(wmOperatorType *ot) | static void SCREEN_OT_screen_set(wmOperatorType *ot) | ||||
| { | { | ||||
| ot->name = "Set Screen"; | ot->name = "Set Screen"; | ||||
| ot->description = "Cycle through available screens"; | ot->description = "Cycle through available screens"; | ||||
| ot->idname = "SCREEN_OT_screen_set"; | ot->idname = "SCREEN_OT_screen_set"; | ||||
| ▲ Show 20 Lines • Show All 306 Lines • ▼ Show 20 Lines | case MOUSEMOVE: | ||||
| break; | break; | ||||
| } | } | ||||
| case LEFTMOUSE: | case LEFTMOUSE: | ||||
| if (event->val == KM_RELEASE) { | if (event->val == KM_RELEASE) { | ||||
| ED_area_tag_redraw(jd->sa1); | ED_area_tag_redraw(jd->sa1); | ||||
| ED_area_tag_redraw(jd->sa2); | ED_area_tag_redraw(jd->sa2); | ||||
| area_join_apply(C, op); | area_join_apply(C, op); | ||||
| WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); | WM_event_add_notifier(C, NC_WORKSPACE | NA_EDITED, NULL); | ||||
| area_join_exit(C, op); | area_join_exit(C, op); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| break; | break; | ||||
| case RIGHTMOUSE: | case RIGHTMOUSE: | ||||
| case ESCKEY: | case ESCKEY: | ||||
| area_join_cancel(C, op); | area_join_cancel(C, op); | ||||
| ▲ Show 20 Lines • Show All 317 Lines • ▼ Show 20 Lines | for (ar = sa->regionbase.first; ar; ar = arn) { | ||||
| if (ar->alignment == RGN_ALIGN_QSPLIT) { | if (ar->alignment == RGN_ALIGN_QSPLIT) { | ||||
| ED_region_exit(C, ar); | ED_region_exit(C, ar); | ||||
| BKE_area_region_free(sa->type, ar); | BKE_area_region_free(sa->type, ar); | ||||
| BLI_remlink(&sa->regionbase, ar); | BLI_remlink(&sa->regionbase, ar); | ||||
| MEM_freeN(ar); | MEM_freeN(ar); | ||||
| } | } | ||||
| } | } | ||||
| ED_area_tag_redraw(sa); | ED_area_tag_redraw(sa); | ||||
| WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); | WM_event_add_notifier(C, NC_WORKSPACE | NA_EDITED, NULL); | ||||
| } | } | ||||
| else if (ar->next) { | else if (ar->next) { | ||||
| BKE_report(op->reports, RPT_ERROR, "Only last region can be 4-splitted"); | BKE_report(op->reports, RPT_ERROR, "Only last region can be 4-splitted"); | ||||
| } | } | ||||
| else { | else { | ||||
| /* Enter quad-view */ | /* Enter quad-view */ | ||||
| ScrArea *sa = CTX_wm_area(C); | ScrArea *sa = CTX_wm_area(C); | ||||
| ARegion *newar; | ARegion *newar; | ||||
| Show All 28 Lines | |||||
| #if 0 | #if 0 | ||||
| if (v3d->camera) region_quadview_init_rv3d(sa, (ar = ar->next), 0, RV3D_VIEW_CAMERA, RV3D_CAMOB); | if (v3d->camera) region_quadview_init_rv3d(sa, (ar = ar->next), 0, RV3D_VIEW_CAMERA, RV3D_CAMOB); | ||||
| else region_quadview_init_rv3d(sa, (ar = ar->next), 0, RV3D_VIEW_USER, RV3D_PERSP); | else region_quadview_init_rv3d(sa, (ar = ar->next), 0, RV3D_VIEW_USER, RV3D_PERSP); | ||||
| #else | #else | ||||
| (void)v3d; | (void)v3d; | ||||
| #endif | #endif | ||||
| } | } | ||||
| ED_area_tag_redraw(sa); | ED_area_tag_redraw(sa); | ||||
| WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); | WM_event_add_notifier(C, NC_WORKSPACE | NA_EDITED, NULL); | ||||
| } | } | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| static void SCREEN_OT_region_quadview(wmOperatorType *ot) | static void SCREEN_OT_region_quadview(wmOperatorType *ot) | ||||
| { | { | ||||
| Show All 24 Lines | static int region_flip_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| else if (ar->alignment == RGN_ALIGN_BOTTOM) | else if (ar->alignment == RGN_ALIGN_BOTTOM) | ||||
| ar->alignment = RGN_ALIGN_TOP; | ar->alignment = RGN_ALIGN_TOP; | ||||
| else if (ar->alignment == RGN_ALIGN_LEFT) | else if (ar->alignment == RGN_ALIGN_LEFT) | ||||
| ar->alignment = RGN_ALIGN_RIGHT; | ar->alignment = RGN_ALIGN_RIGHT; | ||||
| else if (ar->alignment == RGN_ALIGN_RIGHT) | else if (ar->alignment == RGN_ALIGN_RIGHT) | ||||
| ar->alignment = RGN_ALIGN_LEFT; | ar->alignment = RGN_ALIGN_LEFT; | ||||
| ED_area_tag_redraw(CTX_wm_area(C)); | ED_area_tag_redraw(CTX_wm_area(C)); | ||||
| WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); | WM_event_add_notifier(C, NC_WORKSPACE | NA_EDITED, NULL); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| static void SCREEN_OT_region_flip(wmOperatorType *ot) | static void SCREEN_OT_region_flip(wmOperatorType *ot) | ||||
| { | { | ||||
| /* identifiers */ | /* identifiers */ | ||||
| Show All 15 Lines | static int header_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| if (ar == NULL) { | if (ar == NULL) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| ar->flag ^= RGN_FLAG_HIDDEN; | ar->flag ^= RGN_FLAG_HIDDEN; | ||||
| ED_area_tag_redraw(CTX_wm_area(C)); | ED_area_tag_redraw(CTX_wm_area(C)); | ||||
| WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); | WM_event_add_notifier(C, NC_WORKSPACE | NA_EDITED, NULL); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| static void SCREEN_OT_header(wmOperatorType *ot) | static void SCREEN_OT_header(wmOperatorType *ot) | ||||
| { | { | ||||
| /* identifiers */ | /* identifiers */ | ||||
| ot->name = "Toggle Header"; | ot->name = "Toggle Header"; | ||||
| Show All 22 Lines | else if (ar->alignment == RGN_ALIGN_BOTTOM) | ||||
| ar->alignment = RGN_ALIGN_TOP; | ar->alignment = RGN_ALIGN_TOP; | ||||
| else if (ar->alignment == RGN_ALIGN_LEFT) | else if (ar->alignment == RGN_ALIGN_LEFT) | ||||
| ar->alignment = RGN_ALIGN_RIGHT; | ar->alignment = RGN_ALIGN_RIGHT; | ||||
| else if (ar->alignment == RGN_ALIGN_RIGHT) | else if (ar->alignment == RGN_ALIGN_RIGHT) | ||||
| ar->alignment = RGN_ALIGN_LEFT; | ar->alignment = RGN_ALIGN_LEFT; | ||||
| ED_area_tag_redraw(CTX_wm_area(C)); | ED_area_tag_redraw(CTX_wm_area(C)); | ||||
| WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); | WM_event_add_notifier(C, NC_WORKSPACE | NA_EDITED, NULL); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| static void SCREEN_OT_header_flip(wmOperatorType *ot) | static void SCREEN_OT_header_flip(wmOperatorType *ot) | ||||
| { | { | ||||
| /* identifiers */ | /* identifiers */ | ||||
| Show All 15 Lines | |||||
| /* show/hide header text menus */ | /* show/hide header text menus */ | ||||
| static int header_toggle_menus_exec(bContext *C, wmOperator *UNUSED(op)) | static int header_toggle_menus_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| { | { | ||||
| ScrArea *sa = CTX_wm_area(C); | ScrArea *sa = CTX_wm_area(C); | ||||
| sa->flag = sa->flag ^ HEADER_NO_PULLDOWN; | sa->flag = sa->flag ^ HEADER_NO_PULLDOWN; | ||||
| ED_area_tag_redraw(sa); | ED_area_tag_redraw(sa); | ||||
| WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); | WM_event_add_notifier(C, NC_WORKSPACE | NA_EDITED, NULL); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| static void SCREEN_OT_header_toggle_menus(wmOperatorType *ot) | static void SCREEN_OT_header_toggle_menus(wmOperatorType *ot) | ||||
| { | { | ||||
| /* identifiers */ | /* identifiers */ | ||||
| ▲ Show 20 Lines • Show All 280 Lines • ▼ Show 20 Lines | #ifdef PROFILE_AUDIO_SYNCH | ||||
| old_frame = CFRA; | old_frame = CFRA; | ||||
| #endif | #endif | ||||
| } | } | ||||
| /* since we follow drawflags, we can't send notifier but tag regions ourselves */ | /* since we follow drawflags, we can't send notifier but tag regions ourselves */ | ||||
| ED_update_for_newframe(bmain, scene, 1); | ED_update_for_newframe(bmain, scene, 1); | ||||
| for (window = wm->windows.first; window; window = window->next) { | for (window = wm->windows.first; window; window = window->next) { | ||||
| for (sa = window->screen->areabase.first; sa; sa = sa->next) { | const bScreen *win_screen = WM_window_get_active_screen(window); | ||||
| for (sa = win_screen->areabase.first; sa; sa = sa->next) { | |||||
| ARegion *ar; | ARegion *ar; | ||||
| for (ar = sa->regionbase.first; ar; ar = ar->next) { | for (ar = sa->regionbase.first; ar; ar = ar->next) { | ||||
| bool redraw = false; | bool redraw = false; | ||||
| if (ar == sad->ar) { | if (ar == sad->ar) { | ||||
| redraw = true; | redraw = true; | ||||
| } | } | ||||
| else if (match_region_with_redraws(sa->spacetype, ar->regiontype, sad->redraws, sad->from_anim_edit)) { | else if (match_region_with_redraws(sa->spacetype, ar->regiontype, sad->redraws, sad->from_anim_edit)) { | ||||
| redraw = true; | redraw = true; | ||||
| ▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| /* ****************** anim player, starts or ends timer ***************** */ | /* ****************** anim player, starts or ends timer ***************** */ | ||||
| /* find window that owns the animation timer */ | /* find window that owns the animation timer */ | ||||
| bScreen *ED_screen_animation_playing(const wmWindowManager *wm) | bScreen *ED_screen_animation_playing(const wmWindowManager *wm) | ||||
| { | { | ||||
| wmWindow *win; | for (wmWindow *win = wm->windows.first; win; win = win->next) { | ||||
| bScreen *screen = WM_window_get_active_screen(win); | |||||
| for (win = wm->windows.first; win; win = win->next) { | if (screen->animtimer || screen->scrubbing) { | ||||
| if (win->screen->animtimer || win->screen->scrubbing) { | return screen; | ||||
| return win->screen; | |||||
| } | } | ||||
| } | } | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| bScreen *ED_screen_animation_no_scrub(const wmWindowManager *wm) | bScreen *ED_screen_animation_no_scrub(const wmWindowManager *wm) | ||||
| { | { | ||||
| wmWindow *win; | for (wmWindow *win = wm->windows.first; win; win = win->next) { | ||||
| bScreen *screen = WM_window_get_active_screen(win); | |||||
| for (win = wm->windows.first; win; win = win->next) { | if (screen->animtimer) { | ||||
| if (win->screen->animtimer) { | return screen; | ||||
| return win->screen; | |||||
| } | } | ||||
| } | } | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| /* toggle operator */ | /* toggle operator */ | ||||
| ▲ Show 20 Lines • Show All 228 Lines • ▼ Show 20 Lines | static void SCREEN_OT_userpref_show(struct wmOperatorType *ot) | ||||
| ot->poll = ED_operator_screenactive; | ot->poll = ED_operator_screenactive; | ||||
| } | } | ||||
| /********************* new screen operator *********************/ | /********************* new screen operator *********************/ | ||||
| static int screen_new_exec(bContext *C, wmOperator *UNUSED(op)) | static int screen_new_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| { | { | ||||
| wmWindow *win = CTX_wm_window(C); | wmWindow *win = CTX_wm_window(C); | ||||
| bScreen *sc = CTX_wm_screen(C); | WorkSpace *workspace = CTX_wm_workspace(C); | ||||
| WorkSpaceLayout *layout_old = BKE_workspace_active_layout_get(workspace); | |||||
| WorkSpaceLayout *layout_new; | |||||
| sc = ED_screen_duplicate(win, sc); | layout_new = ED_workspace_layout_duplicate(workspace, layout_old, win); | ||||
| WM_event_add_notifier(C, NC_SCREEN | ND_SCREENBROWSE, sc); | WM_event_add_notifier(C, NC_WORKSPACE | ND_SCREENBROWSE, layout_new); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| static void SCREEN_OT_new(wmOperatorType *ot) | static void SCREEN_OT_new(wmOperatorType *ot) | ||||
| { | { | ||||
| /* identifiers */ | /* identifiers */ | ||||
| ot->name = "New Screen"; | ot->name = "New Screen"; | ||||
| ot->description = "Add a new screen"; | ot->description = "Add a new screen"; | ||||
| ot->idname = "SCREEN_OT_new"; | ot->idname = "SCREEN_OT_new"; | ||||
| /* api callbacks */ | /* api callbacks */ | ||||
| ot->exec = screen_new_exec; | ot->exec = screen_new_exec; | ||||
| ot->poll = WM_operator_winactive; | ot->poll = WM_operator_winactive; | ||||
| } | } | ||||
| /********************* delete screen operator *********************/ | /********************* delete screen operator *********************/ | ||||
| static int screen_delete_exec(bContext *C, wmOperator *UNUSED(op)) | static int screen_delete_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| { | { | ||||
| bScreen *sc = CTX_wm_screen(C); | bScreen *sc = CTX_wm_screen(C); | ||||
| WorkSpace *workspace = CTX_wm_workspace(C); | |||||
| WorkSpaceLayout *layout = BKE_workspace_layout_find(workspace, sc); | |||||
| WM_event_add_notifier(C, NC_SCREEN | ND_SCREENDELETE, sc); | WM_event_add_notifier(C, NC_WORKSPACE | ND_SCREENDELETE, layout); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| static void SCREEN_OT_delete(wmOperatorType *ot) | static void SCREEN_OT_delete(wmOperatorType *ot) | ||||
| { | { | ||||
| /* identifiers */ | /* identifiers */ | ||||
| ot->name = "Delete Screen"; | ot->name = "Delete Screen"; | ||||
| ot->description = "Delete active screen"; | ot->description = "Delete active screen"; | ||||
| ot->idname = "SCREEN_OT_delete"; | ot->idname = "SCREEN_OT_delete"; | ||||
| /* api callbacks */ | /* api callbacks */ | ||||
| ot->exec = screen_delete_exec; | ot->exec = screen_delete_exec; | ||||
| } | } | ||||
| /********************* new scene operator *********************/ | |||||
| static int scene_new_exec(bContext *C, wmOperator *op) | |||||
| { | |||||
| Scene *newscene, *scene = CTX_data_scene(C); | |||||
| Main *bmain = CTX_data_main(C); | |||||
| int type = RNA_enum_get(op->ptr, "type"); | |||||
| if (type == SCE_COPY_NEW) { | |||||
| newscene = BKE_scene_add(bmain, DATA_("Scene")); | |||||
| } | |||||
| else { /* different kinds of copying */ | |||||
| newscene = BKE_scene_copy(bmain, scene, type); | |||||
| /* these can't be handled in blenkernel currently, so do them here */ | |||||
| if (type == SCE_COPY_LINK_DATA) { | |||||
| ED_object_single_users(bmain, newscene, false, true); | |||||
| } | |||||
| else if (type == SCE_COPY_FULL) { | |||||
| ED_editors_flush_edits(C, false); | |||||
| ED_object_single_users(bmain, newscene, true, true); | |||||
| } | |||||
| } | |||||
| ED_screen_set_scene(C, CTX_wm_screen(C), newscene); | |||||
| WM_event_add_notifier(C, NC_SCENE | ND_SCENEBROWSE, newscene); | |||||
| return OPERATOR_FINISHED; | |||||
| } | |||||
| static void SCENE_OT_new(wmOperatorType *ot) | |||||
| { | |||||
| static EnumPropertyItem type_items[] = { | |||||
| {SCE_COPY_NEW, "NEW", 0, "New", "Add new scene"}, | |||||
| {SCE_COPY_EMPTY, "EMPTY", 0, "Copy Settings", "Make a copy without any objects"}, | |||||
| {SCE_COPY_LINK_OB, "LINK_OBJECTS", 0, "Link Objects", "Link to the objects from the current scene"}, | |||||
| {SCE_COPY_LINK_DATA, "LINK_OBJECT_DATA", 0, "Link Object Data", "Copy objects linked to data from the current scene"}, | |||||
| {SCE_COPY_FULL, "FULL_COPY", 0, "Full Copy", "Make a full copy of the current scene"}, | |||||
| {0, NULL, 0, NULL, NULL}}; | |||||
| /* identifiers */ | |||||
| ot->name = "New Scene"; | |||||
| ot->description = "Add new scene by type"; | |||||
| ot->idname = "SCENE_OT_new"; | |||||
| /* api callbacks */ | |||||
| ot->exec = scene_new_exec; | |||||
| ot->invoke = WM_menu_invoke; | |||||
| /* flags */ | |||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | |||||
| /* properties */ | |||||
| ot->prop = RNA_def_enum(ot->srna, "type", type_items, 0, "Type", ""); | |||||
| } | |||||
| /********************* delete scene operator *********************/ | |||||
| static int scene_delete_exec(bContext *C, wmOperator *UNUSED(op)) | |||||
| { | |||||
| Scene *scene = CTX_data_scene(C); | |||||
| if (ED_screen_delete_scene(C, scene) == false) { | |||||
| return OPERATOR_CANCELLED; | |||||
| } | |||||
| if (G.debug & G_DEBUG) | |||||
| printf("scene delete %p\n", scene); | |||||
| WM_event_add_notifier(C, NC_SCENE | NA_REMOVED, scene); | |||||
| return OPERATOR_FINISHED; | |||||
| } | |||||
| static void SCENE_OT_delete(wmOperatorType *ot) | |||||
| { | |||||
| /* identifiers */ | |||||
| ot->name = "Delete Scene"; | |||||
| ot->description = "Delete active scene"; | |||||
| ot->idname = "SCENE_OT_delete"; | |||||
| /* api callbacks */ | |||||
| ot->exec = scene_delete_exec; | |||||
| /* flags */ | |||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | |||||
| } | |||||
| /* ***************** region alpha blending ***************** */ | /* ***************** region alpha blending ***************** */ | ||||
| /* implementation note: a disappearing region needs at least 1 last draw with 100% backbuffer | /* implementation note: a disappearing region needs at least 1 last draw with 100% backbuffer | ||||
| * texture over it- then triple buffer will clear it entirely. | * texture over it- then triple buffer will clear it entirely. | ||||
| * This because flag RGN_HIDDEN is set in end - region doesnt draw at all then */ | * This because flag RGN_HIDDEN is set in end - region doesnt draw at all then */ | ||||
| typedef struct RegionAlphaInfo { | typedef struct RegionAlphaInfo { | ||||
| ScrArea *sa; | ScrArea *sa; | ||||
| ▲ Show 20 Lines • Show All 209 Lines • ▼ Show 20 Lines | static void SCREEN_OT_space_context_cycle(wmOperatorType *ot) | ||||
| ot->poll = space_context_cycle_poll; | ot->poll = space_context_cycle_poll; | ||||
| ot->flag = 0; | ot->flag = 0; | ||||
| RNA_def_enum(ot->srna, "direction", space_context_cycle_direction, SPACE_CONTEXT_CYCLE_NEXT, "Direction", | RNA_def_enum(ot->srna, "direction", space_context_cycle_direction, SPACE_CONTEXT_CYCLE_NEXT, "Direction", | ||||
| "Direction to cycle through"); | "Direction to cycle through"); | ||||
| } | } | ||||
| /* **** Workspaces **** */ | |||||
| /* For now here, should later get its own module */ | |||||
| /* **************** Assigning operatortypes to global list, adding handlers **************** */ | /* **************** Assigning operatortypes to global list, adding handlers **************** */ | ||||
| /* called in spacetypes.c */ | /* called in spacetypes.c */ | ||||
| void ED_operatortypes_screen(void) | void ED_operatortypes_screen(void) | ||||
| { | { | ||||
| /* generic UI stuff */ | /* generic UI stuff */ | ||||
| Show All 30 Lines | void ED_operatortypes_screen(void) | ||||
| WM_operatortype_append(SCREEN_OT_frame_offset); | WM_operatortype_append(SCREEN_OT_frame_offset); | ||||
| WM_operatortype_append(SCREEN_OT_frame_jump); | WM_operatortype_append(SCREEN_OT_frame_jump); | ||||
| WM_operatortype_append(SCREEN_OT_keyframe_jump); | WM_operatortype_append(SCREEN_OT_keyframe_jump); | ||||
| WM_operatortype_append(SCREEN_OT_marker_jump); | WM_operatortype_append(SCREEN_OT_marker_jump); | ||||
| WM_operatortype_append(SCREEN_OT_animation_step); | WM_operatortype_append(SCREEN_OT_animation_step); | ||||
| WM_operatortype_append(SCREEN_OT_animation_play); | WM_operatortype_append(SCREEN_OT_animation_play); | ||||
| WM_operatortype_append(SCREEN_OT_animation_cancel); | WM_operatortype_append(SCREEN_OT_animation_cancel); | ||||
| /* new/delete */ | /* new/delete */ | ||||
| WM_operatortype_append(SCREEN_OT_new); | WM_operatortype_append(SCREEN_OT_new); | ||||
| WM_operatortype_append(SCREEN_OT_delete); | WM_operatortype_append(SCREEN_OT_delete); | ||||
| WM_operatortype_append(SCENE_OT_new); | |||||
| WM_operatortype_append(SCENE_OT_delete); | |||||
| /* tools shared by more space types */ | /* tools shared by more space types */ | ||||
| WM_operatortype_append(ED_OT_undo); | WM_operatortype_append(ED_OT_undo); | ||||
| WM_operatortype_append(ED_OT_undo_push); | WM_operatortype_append(ED_OT_undo_push); | ||||
| WM_operatortype_append(ED_OT_redo); | WM_operatortype_append(ED_OT_redo); | ||||
| WM_operatortype_append(ED_OT_undo_redo); | WM_operatortype_append(ED_OT_undo_redo); | ||||
| WM_operatortype_append(ED_OT_undo_history); | WM_operatortype_append(ED_OT_undo_history); | ||||
| WM_operatortype_append(ED_OT_flush_edits); | WM_operatortype_append(ED_OT_flush_edits); | ||||
| ▲ Show 20 Lines • Show All 204 Lines • Show Last 20 Lines | |||||