mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-30 02:50:05 +00:00
Introjucer: tweaked document focus behaviour.
This commit is contained in:
parent
2329cfa286
commit
baecac82d9
7 changed files with 30 additions and 20 deletions
|
|
@ -144,6 +144,8 @@ public:
|
|||
}
|
||||
|
||||
Rectangle<int> getPropertyComponentContentPosition (PropertyComponent&);
|
||||
|
||||
bool areScrollbarButtonsVisible() { return false; }
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ public:
|
|||
OpenDocumentManager::Document* doc = getApp().openDocumentManager.getOpenDocument (menuItemID - activeDocumentsBaseID);
|
||||
jassert (doc != nullptr);
|
||||
|
||||
getApp().mainWindowList.openDocument (doc);
|
||||
getApp().mainWindowList.openDocument (doc, true);
|
||||
}
|
||||
else if (menuItemID >= colourSchemeBaseID && menuItemID < colourSchemeBaseID + 200)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -199,7 +199,7 @@ bool MainWindow::openFile (const File& file)
|
|||
}
|
||||
else if (file.exists())
|
||||
{
|
||||
return getProjectContentComponent()->showEditorForFile (file);
|
||||
return getProjectContentComponent()->showEditorForFile (file, true);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
@ -349,10 +349,10 @@ void MainWindowList::closeWindow (MainWindow* w)
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindowList::openDocument (OpenDocumentManager::Document* doc)
|
||||
void MainWindowList::openDocument (OpenDocumentManager::Document* doc, bool grabFocus)
|
||||
{
|
||||
MainWindow* w = getOrCreateFrontmostWindow();
|
||||
w->getProjectContentComponent()->showDocument (doc);
|
||||
w->getProjectContentComponent()->showDocument (doc, grabFocus);
|
||||
}
|
||||
|
||||
bool MainWindowList::openFile (const File& file)
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ public:
|
|||
void closeWindow (MainWindow*);
|
||||
|
||||
void createWindowIfNoneAreOpen();
|
||||
void openDocument (OpenDocumentManager::Document*);
|
||||
void openDocument (OpenDocumentManager::Document*, bool grabFocus);
|
||||
bool openFile (const File& file);
|
||||
|
||||
MainWindow* createNewMainWindow();
|
||||
|
|
|
|||
|
|
@ -274,7 +274,7 @@ void ProjectContentComponent::reloadLastOpenDocuments()
|
|||
if (xml != nullptr)
|
||||
{
|
||||
recentDocumentList.restoreFromXML (*project, *xml);
|
||||
showDocument (recentDocumentList.getCurrentDocument());
|
||||
showDocument (recentDocumentList.getCurrentDocument(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -297,10 +297,10 @@ void ProjectContentComponent::updateMissingFileStatuses()
|
|||
p->checkFileStatus();
|
||||
}
|
||||
|
||||
bool ProjectContentComponent::showEditorForFile (const File& f)
|
||||
bool ProjectContentComponent::showEditorForFile (const File& f, bool grabFocus)
|
||||
{
|
||||
return getCurrentFile() == f
|
||||
|| showDocument (JucerApplication::getApp().openDocumentManager.openFile (project, f));
|
||||
|| showDocument (JucerApplication::getApp().openDocumentManager.openFile (project, f), grabFocus);
|
||||
}
|
||||
|
||||
File ProjectContentComponent::getCurrentFile() const
|
||||
|
|
@ -309,7 +309,7 @@ File ProjectContentComponent::getCurrentFile() const
|
|||
: File::nonexistent;
|
||||
}
|
||||
|
||||
bool ProjectContentComponent::showDocument (OpenDocumentManager::Document* doc)
|
||||
bool ProjectContentComponent::showDocument (OpenDocumentManager::Document* doc, bool grabFocus)
|
||||
{
|
||||
if (doc == nullptr)
|
||||
return false;
|
||||
|
|
@ -319,13 +319,21 @@ bool ProjectContentComponent::showDocument (OpenDocumentManager::Document* doc)
|
|||
|
||||
if (doc == getCurrentDocument() && contentView != nullptr)
|
||||
{
|
||||
contentView->grabKeyboardFocus();
|
||||
if (grabFocus)
|
||||
contentView->grabKeyboardFocus();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
recentDocumentList.newDocumentOpened (doc);
|
||||
|
||||
return setEditorComponent (doc->createEditor(), doc);
|
||||
bool opened = setEditorComponent (doc->createEditor(), doc);
|
||||
|
||||
if (opened && grabFocus)
|
||||
contentView->grabKeyboardFocus();
|
||||
|
||||
return opened;
|
||||
|
||||
}
|
||||
|
||||
void ProjectContentComponent::hideEditor()
|
||||
|
|
@ -343,13 +351,14 @@ void ProjectContentComponent::hideDocument (OpenDocumentManager::Document* doc)
|
|||
OpenDocumentManager::Document* replacement = recentDocumentList.getClosestPreviousDocOtherThan (doc);
|
||||
|
||||
if (replacement != nullptr)
|
||||
showDocument (replacement);
|
||||
showDocument (replacement, true);
|
||||
else
|
||||
hideEditor();
|
||||
}
|
||||
}
|
||||
|
||||
bool ProjectContentComponent::setEditorComponent (Component* editor, OpenDocumentManager::Document* doc)
|
||||
bool ProjectContentComponent::setEditorComponent (Component* editor,
|
||||
OpenDocumentManager::Document* doc)
|
||||
{
|
||||
if (editor != nullptr)
|
||||
{
|
||||
|
|
@ -361,7 +370,6 @@ bool ProjectContentComponent::setEditorComponent (Component* editor, OpenDocumen
|
|||
|
||||
updateMainWindowTitle();
|
||||
commandManager->commandStatusChanged();
|
||||
editor->grabKeyboardFocus();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -374,14 +382,14 @@ bool ProjectContentComponent::goToPreviousFile()
|
|||
OpenDocumentManager::Document* currentSourceDoc = recentDocumentList.getCurrentDocument();
|
||||
|
||||
if (currentSourceDoc != nullptr && currentSourceDoc != getCurrentDocument())
|
||||
return showDocument (currentSourceDoc);
|
||||
return showDocument (currentSourceDoc, true);
|
||||
else
|
||||
return showDocument (recentDocumentList.getPrevious());
|
||||
return showDocument (recentDocumentList.getPrevious(), true);
|
||||
}
|
||||
|
||||
bool ProjectContentComponent::goToNextFile()
|
||||
{
|
||||
return showDocument (recentDocumentList.getNext());
|
||||
return showDocument (recentDocumentList.getNext(), true);
|
||||
}
|
||||
|
||||
void ProjectContentComponent::updateMainWindowTitle()
|
||||
|
|
|
|||
|
|
@ -50,10 +50,10 @@ public:
|
|||
void saveOpenDocumentList();
|
||||
void reloadLastOpenDocuments();
|
||||
|
||||
bool showEditorForFile (const File& f);
|
||||
bool showEditorForFile (const File& f, bool grabFocus);
|
||||
File getCurrentFile() const;
|
||||
|
||||
bool showDocument (OpenDocumentManager::Document* doc);
|
||||
bool showDocument (OpenDocumentManager::Document* doc, bool grabFocus);
|
||||
void hideDocument (OpenDocumentManager::Document* doc);
|
||||
OpenDocumentManager::Document* getCurrentDocument() const { return currentDocument; }
|
||||
|
||||
|
|
|
|||
|
|
@ -236,7 +236,7 @@ void SourceFileTreeViewItem::showDocument()
|
|||
const File f (getFile());
|
||||
|
||||
if (pcc != nullptr && f.exists())
|
||||
pcc->showEditorForFile (f);
|
||||
pcc->showEditorForFile (f, false);
|
||||
}
|
||||
|
||||
void SourceFileTreeViewItem::showPopupMenu()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue