Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_spreadsheet/spreadsheet_context.cc
| Show First 20 Lines • Show All 367 Lines • ▼ Show 20 Lines | void ED_spreadsheet_context_path_set_evaluated_object(SpaceSpreadsheet *sspreadsheet, | ||||
| using namespace blender::ed::spreadsheet; | using namespace blender::ed::spreadsheet; | ||||
| ED_spreadsheet_context_path_clear(sspreadsheet); | ED_spreadsheet_context_path_clear(sspreadsheet); | ||||
| SpreadsheetContextObject *context = spreadsheet_context_object_new(); | SpreadsheetContextObject *context = spreadsheet_context_object_new(); | ||||
| context->object = object; | context->object = object; | ||||
| BLI_addtail(&sspreadsheet->context_path, context); | BLI_addtail(&sspreadsheet->context_path, context); | ||||
| } | } | ||||
| static bScreen *find_screen_to_search_for_context(wmWindow *window, | |||||
| SpaceSpreadsheet *current_space) | |||||
| { | |||||
| bScreen *screen = BKE_workspace_active_screen_get(window->workspace_hook); | |||||
| if (ELEM(screen->state, SCREENMAXIMIZED, SCREENFULL)) { | |||||
| /* If the spreadsheet is maximized, try to find the context in the unmaximized screen. */ | |||||
| ScrArea *main_area = (ScrArea *)screen->areabase.first; | |||||
| SpaceLink *sl = (SpaceLink *)main_area->spacedata.first; | |||||
| if (sl == (SpaceLink *)current_space) { | |||||
| return main_area->full; | |||||
| } | |||||
| } | |||||
| return screen; | |||||
| } | |||||
| void ED_spreadsheet_context_path_guess(const bContext *C, SpaceSpreadsheet *sspreadsheet) | void ED_spreadsheet_context_path_guess(const bContext *C, SpaceSpreadsheet *sspreadsheet) | ||||
| { | { | ||||
| ED_spreadsheet_context_path_clear(sspreadsheet); | ED_spreadsheet_context_path_clear(sspreadsheet); | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| wmWindowManager *wm = (wmWindowManager *)bmain->wm.first; | wmWindowManager *wm = (wmWindowManager *)bmain->wm.first; | ||||
| if (wm == nullptr) { | if (wm == nullptr) { | ||||
| return; | return; | ||||
| } | } | ||||
| if (sspreadsheet->object_eval_state == SPREADSHEET_OBJECT_EVAL_STATE_VIEWER_NODE) { | if (sspreadsheet->object_eval_state == SPREADSHEET_OBJECT_EVAL_STATE_VIEWER_NODE) { | ||||
| LISTBASE_FOREACH (wmWindow *, window, &wm->windows) { | LISTBASE_FOREACH (wmWindow *, window, &wm->windows) { | ||||
| bScreen *screen = BKE_workspace_active_screen_get(window->workspace_hook); | bScreen *screen = find_screen_to_search_for_context(window, sspreadsheet); | ||||
| LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { | LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { | ||||
| SpaceLink *sl = (SpaceLink *)area->spacedata.first; | SpaceLink *sl = (SpaceLink *)area->spacedata.first; | ||||
| if (sl == nullptr) { | |||||
| continue; | |||||
| } | |||||
| if (sl->spacetype == SPACE_NODE) { | if (sl->spacetype == SPACE_NODE) { | ||||
| SpaceNode *snode = (SpaceNode *)sl; | SpaceNode *snode = (SpaceNode *)sl; | ||||
| if (snode->edittree != nullptr) { | if (snode->edittree != nullptr) { | ||||
| if (snode->edittree->type == NTREE_GEOMETRY) { | if (snode->edittree->type == NTREE_GEOMETRY) { | ||||
| LISTBASE_FOREACH (bNode *, node, &snode->edittree->nodes) { | LISTBASE_FOREACH (bNode *, node, &snode->edittree->nodes) { | ||||
| if (node->type == GEO_NODE_VIEWER) { | if (node->type == GEO_NODE_VIEWER) { | ||||
| if (node->flag & NODE_DO_OUTPUT) { | if (node->flag & NODE_DO_OUTPUT) { | ||||
| ED_spreadsheet_context_path_set_geometry_node(sspreadsheet, snode, node); | ED_spreadsheet_context_path_set_geometry_node(sspreadsheet, snode, node); | ||||
| ▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | if (root_node_tree == nullptr) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| const Span<SpreadsheetContext *> node_context_path = context_path.as_span().drop_front(2); | const Span<SpreadsheetContext *> node_context_path = context_path.as_span().drop_front(2); | ||||
| if (node_context_path.is_empty()) { | if (node_context_path.is_empty()) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| LISTBASE_FOREACH (wmWindow *, window, &wm->windows) { | LISTBASE_FOREACH (wmWindow *, window, &wm->windows) { | ||||
| bScreen *screen = BKE_workspace_active_screen_get(window->workspace_hook); | bScreen *screen = find_screen_to_search_for_context(window, sspreadsheet); | ||||
| LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { | LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { | ||||
| SpaceLink *sl = (SpaceLink *)area->spacedata.first; | SpaceLink *sl = (SpaceLink *)area->spacedata.first; | ||||
| if (sl == nullptr) { | |||||
| continue; | |||||
| } | |||||
| if (sl->spacetype != SPACE_NODE) { | if (sl->spacetype != SPACE_NODE) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| SpaceNode *snode = (SpaceNode *)sl; | SpaceNode *snode = (SpaceNode *)sl; | ||||
| if (snode->nodetree != root_node_tree) { | if (snode->nodetree != root_node_tree) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| if (snode->id != &object->id) { | if (snode->id != &object->id) { | ||||
| ▲ Show 20 Lines • Show All 104 Lines • Show Last 20 Lines | |||||