MCPcopy Create free account
hub / github.com/LibreSprite/LibreSprite / setActiveView

Method setActiveView

src/app/ui_context.cpp:79–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77}
78
79void UIContext::setActiveView(DocumentView* docView)
80{
81 MainWindow* mainWin = App::instance()->mainWindow();
82
83 // mainWin returns nullptr when closing down the app whilst the home view is open
84 if (!mainWin)
85 return;
86
87 // Prioritize workspace for user input.
88 App::instance()->inputChain().prioritize(mainWin->getWorkspace());
89
90 // Do nothing cases: 1) the view is already selected, or 2) the view
91 // is the a preview.
92 if (m_lastSelectedView == docView ||
93 (docView && docView->isPreview()))
94 return;
95
96 if (docView) {
97 mainWin->getTabsBar()->selectTab(docView);
98
99 if (mainWin->getWorkspace()->activeView() != docView)
100 mainWin->getWorkspace()->setActiveView(docView);
101 }
102
103 current_editor = (docView ? docView->editor(): nullptr);
104
105 if (current_editor)
106 current_editor->requestFocus();
107
108 mainWin->getPreviewEditor()->updateUsingEditor(current_editor);
109 mainWin->getTimeline()->updateUsingEditor(current_editor);
110
111 // Change the image-type of color bar.
112 ColorBar::instance()->setPixelFormat(app_get_current_pixel_format());
113
114 // Restore the palette of the selected document.
115 app_refresh_screen();
116
117 // Change the main frame title.
118 App::instance()->updateDisplayTitleBar();
119
120 m_lastSelectedView = docView;
121
122 // TODO all the calls to functions like updateUsingEditor(),
123 // setPixelFormat(), app_refresh_screen(), updateDisplayTitleBar()
124 // Can be replaced with a ContextObserver listening to the
125 // onActiveSiteChange() event.
126 notifyActiveSiteChanged();
127}
128
129void UIContext::setActiveDocument(Document* document)
130{

Callers

nothing calls this directly

Calls 15

instanceFunction · 0.85
app_refresh_screenFunction · 0.85
mainWindowMethod · 0.80
prioritizeMethod · 0.80
isPreviewMethod · 0.80
selectTabMethod · 0.80
getTabsBarMethod · 0.80
requestFocusMethod · 0.80
getPreviewEditorMethod · 0.80
getTimelineMethod · 0.80
updateDisplayTitleBarMethod · 0.80

Tested by

no test coverage detected