Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/screen/screen_ops.c
| Show First 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | |||||
| /** \name Area Duplicate Operator | /** \name Area Duplicate Operator | ||||
| * | * | ||||
| * Create new window from area. | * Create new window from area. | ||||
| * \{ */ | * \{ */ | ||||
| /* 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) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | |||||
| wmWindow *win = CTX_wm_window(C); | |||||
| WorkSpace *workspace = WM_window_get_active_workspace(win); | |||||
| WorkSpaceLayout *layout_old = WM_window_get_active_layout(win); | |||||
| Scene *scene = CTX_data_scene(C); | |||||
| ScrArea *area = CTX_wm_area(C); | ScrArea *area = CTX_wm_area(C); | ||||
| /* XXX hrmf! */ | if (event && event->customdata) { | ||||
| if (event->type == EVT_ACTIONZONE_AREA) { | |||||
| sActionzoneData *sad = event->customdata; | sActionzoneData *sad = event->customdata; | ||||
| if (sad == NULL) { | if (sad == NULL) { | ||||
| return OPERATOR_PASS_THROUGH; | return OPERATOR_PASS_THROUGH; | ||||
| } | } | ||||
| area = sad->sa1; | area = sad->sa1; | ||||
| } | } | ||||
| /* adds window to WM */ | /* Create new window. No need to set space_type since it will be copied over. */ | ||||
| rcti rect = area->totrct; | wmWindow *newwin = WM_window_open(C, | ||||
| BLI_rcti_translate(&rect, win->posx, win->posy); | "Blender", | ||||
| rect.xmax = rect.xmin + BLI_rcti_size_x(&rect); | area->totrct.xmin, | ||||
| rect.ymax = rect.ymin + BLI_rcti_size_y(&rect); | area->totrct.ymin, | ||||
| area->winx, | |||||
| area->winy, | |||||
| SPACE_EMPTY, | |||||
| true, | |||||
| false, | |||||
| WIN_ALIGN_ABSOLUTE); | |||||
| wmWindow *newwin = WM_window_open(C, &rect); | if (newwin) { | ||||
| if (newwin == NULL) { | /* copy area to new screen */ | ||||
| bScreen *newsc = WM_window_get_active_screen(newwin); | |||||
| ED_area_data_copy((ScrArea *)newsc->areabase.first, area, true); | |||||
| ED_area_tag_redraw((ScrArea *)newsc->areabase.first); | |||||
| /* screen, areas init */ | |||||
| WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); | |||||
| } | |||||
| else { | |||||
| BKE_report(op->reports, RPT_ERROR, "Failed to open window!"); | BKE_report(op->reports, RPT_ERROR, "Failed to open window!"); | ||||
| goto finally; | |||||
| } | } | ||||
| *newwin->stereo3d_format = *win->stereo3d_format; | if (event && event->customdata) { | ||||
| newwin->scene = scene; | |||||
| STRNCPY(newwin->view_layer_name, win->view_layer_name); | |||||
| BKE_workspace_active_set(newwin->workspace_hook, workspace); | |||||
| /* allocs new screen and adds to newly created window, using window size */ | |||||
| WorkSpaceLayout *layout_new = ED_workspace_layout_add( | |||||
| bmain, workspace, newwin, BKE_workspace_layout_name_get(layout_old)); | |||||
| bScreen *newsc = BKE_workspace_layout_screen_get(layout_new); | |||||
| WM_window_set_active_layout(newwin, workspace, layout_new); | |||||
| /* copy area to new screen */ | |||||
| ED_area_data_copy((ScrArea *)newsc->areabase.first, area, true); | |||||
| ED_area_tag_redraw((ScrArea *)newsc->areabase.first); | |||||
| /* screen, areas init */ | |||||
| WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); | |||||
| finally: | |||||
| if (event->type == EVT_ACTIONZONE_AREA) { | |||||
| actionzone_exit(op); | actionzone_exit(op); | ||||
| } | } | ||||
| if (newwin) { | return newwin ? OPERATOR_FINISHED : OPERATOR_CANCELLED; | ||||
| return OPERATOR_FINISHED; | |||||
| } | |||||
| return OPERATOR_CANCELLED; | |||||
| } | } | ||||
| static void SCREEN_OT_area_dupli(wmOperatorType *ot) | static void SCREEN_OT_area_dupli(wmOperatorType *ot) | ||||
| { | { | ||||
| ot->name = "Duplicate Area into New Window"; | ot->name = "Duplicate Area into New Window"; | ||||
| ot->description = "Duplicate selected area into new window"; | ot->description = "Duplicate selected area into new window"; | ||||
| ot->idname = "SCREEN_OT_area_dupli"; | ot->idname = "SCREEN_OT_area_dupli"; | ||||
| ▲ Show 20 Lines • Show All 184 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| wmWindow *win_cur = CTX_wm_window(C); | wmWindow *win_cur = CTX_wm_window(C); | ||||
| /* Use eventstate, not event from _invoke, so this can be called through exec(). */ | /* Use eventstate, not event from _invoke, so this can be called through exec(). */ | ||||
| const wmEvent *event = win_cur->eventstate; | const wmEvent *event = win_cur->eventstate; | ||||
| int sizex = (500 + UI_NAVIGATION_REGION_WIDTH) * UI_DPI_FAC; | int sizex = (500 + UI_NAVIGATION_REGION_WIDTH) * UI_DPI_FAC; | ||||
| int sizey = 520 * UI_DPI_FAC; | int sizey = 520 * UI_DPI_FAC; | ||||
| /* changes context! */ | /* changes context! */ | ||||
| if (WM_window_open_temp(C, | if (WM_window_open(C, | ||||
| IFACE_("Blender Preferences"), | IFACE_("Blender Preferences"), | ||||
| event->x, | event->x, | ||||
| event->y, | event->y, | ||||
| sizex, | sizex, | ||||
| sizey, | sizey, | ||||
| SPACE_USERPREF, | SPACE_USERPREF, | ||||
| false) != NULL) { | false, | ||||
| true, | |||||
| WIN_ALIGN_LOCATION_CENTER) != NULL) { | |||||
| /* The header only contains the editor switcher and looks empty. | /* The header only contains the editor switcher and looks empty. | ||||
| * So hiding in the temp window makes sense. */ | * So hiding in the temp window makes sense. */ | ||||
| ScrArea *area = CTX_wm_area(C); | ScrArea *area = CTX_wm_area(C); | ||||
| ARegion *region = BKE_area_find_region_type(area, RGN_TYPE_HEADER); | ARegion *region = BKE_area_find_region_type(area, RGN_TYPE_HEADER); | ||||
| region->flag |= RGN_FLAG_HIDDEN; | region->flag |= RGN_FLAG_HIDDEN; | ||||
| ED_region_visibility_change_update(C, area, region); | ED_region_visibility_change_update(C, area, region); | ||||
| Show All 35 Lines | |||||
| * after we've created the window | * after we've created the window | ||||
| */ | */ | ||||
| int index; | int index; | ||||
| PointerRNA ptr; | PointerRNA ptr; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| uiBut *but = UI_context_active_but_prop_get(C, &ptr, &prop, &index); | uiBut *but = UI_context_active_but_prop_get(C, &ptr, &prop, &index); | ||||
| /* changes context! */ | /* changes context! */ | ||||
| if (WM_window_open_temp(C, | if (WM_window_open(C, | ||||
| IFACE_("Blender Drivers Editor"), | IFACE_("Blender Drivers Editor"), | ||||
| event->x, | event->x, | ||||
| event->y, | event->y, | ||||
| sizex, | sizex, | ||||
| sizey, | sizey, | ||||
| SPACE_GRAPH, | SPACE_GRAPH, | ||||
| false) != NULL) { | false, | ||||
| true, | |||||
| WIN_ALIGN_LOCATION_CENTER) != NULL) { | |||||
| ED_drivers_editor_init(C, CTX_wm_area(C)); | ED_drivers_editor_init(C, CTX_wm_area(C)); | ||||
| /* activate driver F-Curve for the property under the cursor */ | /* activate driver F-Curve for the property under the cursor */ | ||||
| if (but) { | if (but) { | ||||
| bool driven, special; | bool driven, special; | ||||
| FCurve *fcu = BKE_fcurve_find_by_rna_context_ui( | FCurve *fcu = BKE_fcurve_find_by_rna_context_ui( | ||||
| C, &ptr, prop, index, NULL, NULL, &driven, &special); | C, &ptr, prop, index, NULL, NULL, &driven, &special); | ||||
| ▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | |||||
| wmWindow *win_cur = CTX_wm_window(C); | wmWindow *win_cur = CTX_wm_window(C); | ||||
| /* Use eventstate, not event from _invoke, so this can be called through exec(). */ | /* Use eventstate, not event from _invoke, so this can be called through exec(). */ | ||||
| const wmEvent *event = win_cur->eventstate; | const wmEvent *event = win_cur->eventstate; | ||||
| int sizex = 900 * UI_DPI_FAC; | int sizex = 900 * UI_DPI_FAC; | ||||
| int sizey = 580 * UI_DPI_FAC; | int sizey = 580 * UI_DPI_FAC; | ||||
| int shift_y = 480; | int shift_y = 480; | ||||
| /* changes context! */ | /* changes context! */ | ||||
| if (WM_window_open_temp(C, | if (WM_window_open(C, | ||||
| IFACE_("Blender Info Log"), | IFACE_("Blender Info Log"), | ||||
| event->x, | event->x, | ||||
| event->y + shift_y, | event->y + shift_y, | ||||
| sizex, | sizex, | ||||
| sizey, | sizey, | ||||
| SPACE_INFO, | SPACE_INFO, | ||||
| false) != NULL) { | false, | ||||
| true, | |||||
| WIN_ALIGN_LOCATION_CENTER) != NULL) { | |||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| BKE_report(op->reports, RPT_ERROR, "Failed to open window!"); | BKE_report(op->reports, RPT_ERROR, "Failed to open window!"); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| static void SCREEN_OT_info_log_show(struct wmOperatorType *ot) | static void SCREEN_OT_info_log_show(struct wmOperatorType *ot) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines | |||||