static int editsource_exec(bContext *C, wmOperator *op) { uiBut *but = UI_context_active_but_get(C); if (but) { GHashIterator ghi; struct uiEditSourceButStore *but_store = NULL; ARegion *ar = CTX_wm_region(C); int ret; /* needed else the active button does not get tested */ UI_screen_free_active_but(C, CTX_wm_screen(C)); // printf("%s: begin\n", __func__); /* take care not to return before calling ui_editsource_active_but_clear */ ui_editsource_active_but_set(but); /* redraw and get active button python info */ ED_region_do_layout(C, ar); ED_region_do_draw(C, ar); ar->do_draw = false; for (BLI_ghashIterator_init(&ghi, ui_editsource_info->hash); BLI_ghashIterator_done(&ghi) == false; BLI_ghashIterator_step(&ghi)) { uiBut *but_key = BLI_ghashIterator_getKey(&ghi); if (but_key && ui_editsource_uibut_match(&ui_editsource_info->but_orig, but_key)) { but_store = BLI_ghashIterator_getValue(&ghi); break; } } if (but_store) { if (but_store->py_dbg_ln != -1) { ret = editsource_text_edit(C, op, but_store->py_dbg_fn, but_store->py_dbg_ln); } else { BKE_report( op->reports, RPT_ERROR, "Active button is not from a script, cannot edit source"); ret = OPERATOR_CANCELLED; } } else { BKE_report(op->reports, RPT_ERROR, "Active button match cannot be found"); ret = OPERATOR_CANCELLED; } ui_editsource_active_but_clear(); // printf("%s: end\n", __func__); return ret; } else { BKE_report(op->reports, RPT_ERROR, "Active button not found"); return OPERATOR_CANCELLED; } }
static void wm_method_draw_full(bContext *C, wmWindow *win) { bScreen *screen = win->screen; ScrArea *sa; ARegion *ar; /* draw area regions */ for (sa = screen->areabase.first; sa; sa = sa->next) { CTX_wm_area_set(C, sa); for (ar = sa->regionbase.first; ar; ar = ar->next) { if (ar->swinid) { CTX_wm_region_set(C, ar); ED_region_do_draw(C, ar); ar->do_draw = false; wm_paintcursor_draw(C, ar); CTX_wm_region_set(C, NULL); } } wm_area_mark_invalid_backbuf(sa); CTX_wm_area_set(C, NULL); } ED_screen_draw(win); win->screen->do_draw = false; /* draw overlapping regions */ for (ar = screen->regionbase.first; ar; ar = ar->next) { if (ar->swinid) { CTX_wm_menu_set(C, ar); ED_region_do_draw(C, ar); ar->do_draw = false; CTX_wm_menu_set(C, NULL); } } if (screen->do_draw_gesture) wm_gesture_draw(win); }
static void wm_method_draw_triple(bContext *C, wmWindow *win) { wmWindowManager *wm = CTX_wm_manager(C); wmDrawTriple *triple; bScreen *screen = win->screen; ScrArea *sa; ARegion *ar; int copytex = 0, paintcursor = 1; if (win->drawdata) { glClearColor(0, 0, 0, 0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); wmSubWindowSet(win, screen->mainwin); wm_triple_draw_textures(win, win->drawdata, 1.0f); } else { win->drawdata = MEM_callocN(sizeof(wmDrawTriple), "wmDrawTriple"); if (!wm_triple_gen_textures(win, win->drawdata)) { wm_draw_triple_fail(C, win); return; } } triple = win->drawdata; /* draw marked area regions */ for (sa = screen->areabase.first; sa; sa = sa->next) { CTX_wm_area_set(C, sa); for (ar = sa->regionbase.first; ar; ar = ar->next) { if (ar->swinid && ar->do_draw) { if (ar->overlap == 0) { CTX_wm_region_set(C, ar); ED_region_do_draw(C, ar); CTX_wm_region_set(C, NULL); copytex = 1; } } } wm_area_mark_invalid_backbuf(sa); CTX_wm_area_set(C, NULL); } if (copytex) { wmSubWindowSet(win, screen->mainwin); wm_triple_copy_textures(win, triple); } if (paintcursor && wm->paintcursors.first) { for (sa = screen->areabase.first; sa; sa = sa->next) { for (ar = sa->regionbase.first; ar; ar = ar->next) { if (ar->swinid && ar->swinid == screen->subwinactive) { CTX_wm_area_set(C, sa); CTX_wm_region_set(C, ar); /* make region ready for draw, scissor, pixelspace */ ED_region_set(C, ar); wm_paintcursor_draw(C, ar); CTX_wm_region_set(C, NULL); CTX_wm_area_set(C, NULL); } } } wmSubWindowSet(win, screen->mainwin); } /* draw overlapping area regions (always like popups) */ for (sa = screen->areabase.first; sa; sa = sa->next) { CTX_wm_area_set(C, sa); for (ar = sa->regionbase.first; ar; ar = ar->next) { if (ar->swinid && ar->overlap) { CTX_wm_region_set(C, ar); ED_region_do_draw(C, ar); CTX_wm_region_set(C, NULL); wm_draw_region_blend(win, ar); } } CTX_wm_area_set(C, NULL); } /* after area regions so we can do area 'overlay' drawing */ ED_screen_draw(win); /* draw floating regions (menus) */ for (ar = screen->regionbase.first; ar; ar = ar->next) { if (ar->swinid) { CTX_wm_menu_set(C, ar); ED_region_do_draw(C, ar); CTX_wm_menu_set(C, NULL); /* when a menu is being drawn, don't do the paint cursors */ paintcursor = 0; } } /* always draw, not only when screen tagged */ if (win->gesture.first) wm_gesture_draw(win); /* needs pixel coords in screen */ if (wm->drags.first) { wm_drags_draw(C, win, NULL); } }
static void wm_method_draw_overlap_all(bContext *C, wmWindow *win, int exchange) { wmWindowManager *wm = CTX_wm_manager(C); bScreen *screen = win->screen; ScrArea *sa; ARegion *ar; static rcti rect = {0, 0, 0, 0}; /* after backbuffer selection draw, we need to redraw */ for (sa = screen->areabase.first; sa; sa = sa->next) for (ar = sa->regionbase.first; ar; ar = ar->next) if (ar->swinid && !wm_area_test_invalid_backbuf(sa)) ED_region_tag_redraw(ar); /* flush overlapping regions */ if (screen->regionbase.first) { /* flush redraws of area regions up to overlapping regions */ for (sa = screen->areabase.first; sa; sa = sa->next) for (ar = sa->regionbase.first; ar; ar = ar->next) if (ar->swinid && ar->do_draw) wm_flush_regions_up(screen, &ar->winrct); /* flush between overlapping regions */ for (ar = screen->regionbase.last; ar; ar = ar->prev) if (ar->swinid && ar->do_draw) wm_flush_regions_up(screen, &ar->winrct); /* flush redraws of overlapping regions down to area regions */ for (ar = screen->regionbase.last; ar; ar = ar->prev) if (ar->swinid && ar->do_draw) wm_flush_regions_down(screen, &ar->winrct); } /* flush drag item */ if (rect.xmin != rect.xmax) { wm_flush_regions_down(screen, &rect); rect.xmin = rect.xmax = 0; } if (wm->drags.first) { /* doesnt draw, fills rect with boundbox */ wm_drags_draw(C, win, &rect); } /* draw marked area regions */ for (sa = screen->areabase.first; sa; sa = sa->next) { CTX_wm_area_set(C, sa); for (ar = sa->regionbase.first; ar; ar = ar->next) { if (ar->swinid) { if (ar->do_draw) { CTX_wm_region_set(C, ar); ED_region_do_draw(C, ar); wm_paintcursor_draw(C, ar); CTX_wm_region_set(C, NULL); if (exchange) ar->swap = WIN_FRONT_OK; } else if (exchange) { if (ar->swap == WIN_FRONT_OK) { CTX_wm_region_set(C, ar); ED_region_do_draw(C, ar); wm_paintcursor_draw(C, ar); CTX_wm_region_set(C, NULL); ar->swap = WIN_BOTH_OK; } else if (ar->swap == WIN_BACK_OK) ar->swap = WIN_FRONT_OK; else if (ar->swap == WIN_BOTH_OK) ar->swap = WIN_BOTH_OK; } } } wm_area_mark_invalid_backbuf(sa); CTX_wm_area_set(C, NULL); } /* after area regions so we can do area 'overlay' drawing */ if (screen->do_draw) { ED_screen_draw(win); if (exchange) screen->swap = WIN_FRONT_OK; } else if (exchange) { if (screen->swap == WIN_FRONT_OK) { ED_screen_draw(win); screen->swap = WIN_BOTH_OK; } else if (screen->swap == WIN_BACK_OK) screen->swap = WIN_FRONT_OK; else if (screen->swap == WIN_BOTH_OK) screen->swap = WIN_BOTH_OK; } /* draw marked overlapping regions */ for (ar = screen->regionbase.first; ar; ar = ar->next) { if (ar->swinid && ar->do_draw) { CTX_wm_menu_set(C, ar); ED_region_do_draw(C, ar); CTX_wm_menu_set(C, NULL); } } if (screen->do_draw_gesture) wm_gesture_draw(win); /* needs pixel coords in screen */ if (wm->drags.first) { wm_drags_draw(C, win, NULL); } }
static void wm_draw_window_offscreen(bContext *C, wmWindow *win, bool stereo) { Main *bmain = CTX_data_main(C); wmWindowManager *wm = CTX_wm_manager(C); bScreen *screen = WM_window_get_active_screen(win); /* Draw screen areas into own frame buffer. */ ED_screen_areas_iter(win, screen, sa) { CTX_wm_area_set(C, sa); /* Compute UI layouts for dynamically size regions. */ for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) { if (ar->visible && ar->do_draw && ar->type && ar->type->layout) { CTX_wm_region_set(C, ar); ED_region_do_layout(C, ar); CTX_wm_region_set(C, NULL); } } ED_area_update_region_sizes(wm, win, sa); if (sa->flag & AREA_FLAG_ACTIVE_TOOL_UPDATE) { if ((1 << sa->spacetype) & WM_TOOLSYSTEM_SPACE_MASK) { WM_toolsystem_update_from_context(C, CTX_wm_workspace(C), CTX_data_view_layer(C), sa); } sa->flag &= ~AREA_FLAG_ACTIVE_TOOL_UPDATE; } /* Then do actual drawing of regions. */ for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) { if (ar->visible && ar->do_draw) { CTX_wm_region_set(C, ar); bool use_viewport = wm_region_use_viewport(sa, ar); if (stereo && wm_draw_region_stereo_set(bmain, sa, ar, STEREO_LEFT_ID)) { wm_draw_region_buffer_create(ar, true, use_viewport); for (int view = 0; view < 2; view++) { eStereoViews sview; if (view == 0) { sview = STEREO_LEFT_ID; } else { sview = STEREO_RIGHT_ID; wm_draw_region_stereo_set(bmain, sa, ar, sview); } wm_draw_region_bind(ar, view); ED_region_do_draw(C, ar); wm_draw_region_unbind(ar, view); } } else { wm_draw_region_buffer_create(ar, false, use_viewport); wm_draw_region_bind(ar, 0); ED_region_do_draw(C, ar); wm_draw_region_unbind(ar, 0); } ar->do_draw = false; CTX_wm_region_set(C, NULL); } } wm_area_mark_invalid_backbuf(sa); CTX_wm_area_set(C, NULL); }
static void wm_method_draw_triple_multiview(bContext *C, wmWindow *win, StereoViews sview) { wmWindowManager *wm = CTX_wm_manager(C); wmDrawData *drawdata; wmDrawTriple *triple_data, *triple_all; bScreen *screen = win->screen; ScrArea *sa; ARegion *ar; int copytex = false; int id; /* we store the triple_data in sequence to triple_all */ for (id = 0; id < 2; id++) { drawdata = BLI_findlink(&win->drawdata, (sview * 2) + id); if (drawdata && drawdata->triple) { if (id == 0) { glClearColor(0, 0, 0, 0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); wmSubWindowSet(win, screen->mainwin); wm_triple_draw_textures(win, drawdata->triple, 1.0f); } } else { /* we run it when we start OR when we turn stereo on */ if (drawdata == NULL) { drawdata = MEM_callocN(sizeof(wmDrawData), "wmDrawData"); BLI_addtail(&win->drawdata, drawdata); } drawdata->triple = MEM_callocN(sizeof(wmDrawTriple), "wmDrawTriple"); if (!wm_triple_gen_textures(win, drawdata->triple)) { wm_draw_triple_fail(C, win); return; } } } triple_data = ((wmDrawData *) BLI_findlink(&win->drawdata, sview * 2))->triple; triple_all = ((wmDrawData *) BLI_findlink(&win->drawdata, (sview * 2) + 1))->triple; /* draw marked area regions */ for (sa = screen->areabase.first; sa; sa = sa->next) { CTX_wm_area_set(C, sa); switch (sa->spacetype) { case SPACE_IMAGE: { SpaceImage *sima = sa->spacedata.first; sima->iuser.multiview_eye = sview; break; } case SPACE_VIEW3D: { View3D *v3d = sa->spacedata.first; BGpic *bgpic = v3d->bgpicbase.first; v3d->multiview_eye = sview; if (bgpic) bgpic->iuser.multiview_eye = sview; break; } case SPACE_NODE: { SpaceNode *snode = sa->spacedata.first; if ((snode->flag & SNODE_BACKDRAW) && ED_node_is_compositor(snode)) { Image *ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); ima->eye = sview; } break; } case SPACE_SEQ: { SpaceSeq *sseq = sa->spacedata.first; sseq->multiview_eye = sview; break; } } /* draw marked area regions */ for (ar = sa->regionbase.first; ar; ar = ar->next) { if (ar->swinid && ar->do_draw) { if (ar->overlap == false) { CTX_wm_region_set(C, ar); ED_region_do_draw(C, ar); if (sview == STEREO_RIGHT_ID) ar->do_draw = false; CTX_wm_region_set(C, NULL); copytex = true; } } } wm_area_mark_invalid_backbuf(sa); CTX_wm_area_set(C, NULL); } if (copytex) { wmSubWindowSet(win, screen->mainwin); wm_triple_copy_textures(win, triple_data); } if (wm->paintcursors.first) { for (sa = screen->areabase.first; sa; sa = sa->next) { for (ar = sa->regionbase.first; ar; ar = ar->next) { if (ar->swinid && ar->swinid == screen->subwinactive) { CTX_wm_area_set(C, sa); CTX_wm_region_set(C, ar); /* make region ready for draw, scissor, pixelspace */ ED_region_set(C, ar); wm_paintcursor_draw(C, ar); CTX_wm_region_set(C, NULL); CTX_wm_area_set(C, NULL); } } } wmSubWindowSet(win, screen->mainwin); } /* draw overlapping area regions (always like popups) */ for (sa = screen->areabase.first; sa; sa = sa->next) { CTX_wm_area_set(C, sa); for (ar = sa->regionbase.first; ar; ar = ar->next) { if (ar->swinid && ar->overlap) { CTX_wm_region_set(C, ar); ED_region_do_draw(C, ar); if (sview == STEREO_RIGHT_ID) ar->do_draw = false; CTX_wm_region_set(C, NULL); wm_draw_region_blend(win, ar, triple_data); } } CTX_wm_area_set(C, NULL); } /* after area regions so we can do area 'overlay' drawing */ ED_screen_draw(win); if (sview == STEREO_RIGHT_ID) win->screen->do_draw = false; /* draw floating regions (menus) */ for (ar = screen->regionbase.first; ar; ar = ar->next) { if (ar->swinid) { CTX_wm_menu_set(C, ar); ED_region_do_draw(C, ar); if (sview == STEREO_RIGHT_ID) ar->do_draw = false; CTX_wm_menu_set(C, NULL); } } /* always draw, not only when screen tagged */ if (win->gesture.first) wm_gesture_draw(win); /* needs pixel coords in screen */ if (wm->drags.first) { wm_drags_draw(C, win, NULL); } /* copy the ui + overlays */ wmSubWindowSet(win, screen->mainwin); wm_triple_copy_textures(win, triple_all); }
static void wm_method_draw_triple(bContext *C, wmWindow *win) { wmWindowManager *wm = CTX_wm_manager(C); wmDrawTriple *triple; wmDrawData *dd, *dd_next, *drawdata = win->drawdata.first; bScreen *screen = win->screen; ScrArea *sa; ARegion *ar; int copytex = false; if (drawdata && drawdata->triple) { glClearColor(0, 0, 0, 0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); wmSubWindowSet(win, screen->mainwin); wm_triple_draw_textures(win, drawdata->triple, 1.0f); } else { /* we run it when we start OR when we turn stereo on */ if (drawdata == NULL) { drawdata = MEM_callocN(sizeof(wmDrawData), "wmDrawData"); BLI_addhead(&win->drawdata, drawdata); } drawdata->triple = MEM_callocN(sizeof(wmDrawTriple), "wmDrawTriple"); if (!wm_triple_gen_textures(win, drawdata->triple)) { wm_draw_triple_fail(C, win); return; } } /* it means stereo was just turned off */ /* note: we are removing all drawdatas that are not the first */ for (dd = drawdata->next; dd; dd = dd_next) { dd_next = dd->next; BLI_remlink(&win->drawdata, dd); wm_draw_triple_free(dd->triple); MEM_freeN(dd); } triple = drawdata->triple; /* draw marked area regions */ for (sa = screen->areabase.first; sa; sa = sa->next) { CTX_wm_area_set(C, sa); for (ar = sa->regionbase.first; ar; ar = ar->next) { if (ar->swinid && ar->do_draw) { if (ar->overlap == false) { CTX_wm_region_set(C, ar); ED_region_do_draw(C, ar); ar->do_draw = false; CTX_wm_region_set(C, NULL); copytex = true; } } } wm_area_mark_invalid_backbuf(sa); CTX_wm_area_set(C, NULL); } if (copytex) { wmSubWindowSet(win, screen->mainwin); wm_triple_copy_textures(win, triple); } if (wm->paintcursors.first) { for (sa = screen->areabase.first; sa; sa = sa->next) { for (ar = sa->regionbase.first; ar; ar = ar->next) { if (ar->swinid && ar->swinid == screen->subwinactive) { CTX_wm_area_set(C, sa); CTX_wm_region_set(C, ar); /* make region ready for draw, scissor, pixelspace */ ED_region_set(C, ar); wm_paintcursor_draw(C, ar); CTX_wm_region_set(C, NULL); CTX_wm_area_set(C, NULL); } } } wmSubWindowSet(win, screen->mainwin); } /* draw overlapping area regions (always like popups) */ for (sa = screen->areabase.first; sa; sa = sa->next) { CTX_wm_area_set(C, sa); for (ar = sa->regionbase.first; ar; ar = ar->next) { if (ar->swinid && ar->overlap) { CTX_wm_region_set(C, ar); ED_region_do_draw(C, ar); ar->do_draw = false; CTX_wm_region_set(C, NULL); wm_draw_region_blend(win, ar, triple); } } CTX_wm_area_set(C, NULL); } /* after area regions so we can do area 'overlay' drawing */ ED_screen_draw(win); win->screen->do_draw = false; /* draw floating regions (menus) */ for (ar = screen->regionbase.first; ar; ar = ar->next) { if (ar->swinid) { CTX_wm_menu_set(C, ar); ED_region_do_draw(C, ar); ar->do_draw = false; CTX_wm_menu_set(C, NULL); } } /* always draw, not only when screen tagged */ if (win->gesture.first) wm_gesture_draw(win); /* needs pixel coords in screen */ if (wm->drags.first) { wm_drags_draw(C, win, NULL); } }