| 77 | } |
| 78 | |
| 79 | void 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 | |
| 129 | void UIContext::setActiveDocument(Document* document) |
| 130 | { |
nothing calls this directly
no test coverage detected