diff --git a/extras/Introjucer/Source/Application/jucer_Application.h b/extras/Introjucer/Source/Application/jucer_Application.h index 69ec4b7e68..1c131b606e 100644 --- a/extras/Introjucer/Source/Application/jucer_Application.h +++ b/extras/Introjucer/Source/Application/jucer_Application.h @@ -438,18 +438,7 @@ public: bool closeAllDocuments (bool askUserToSave) { - for (int i = OpenDocumentManager::getInstance()->getNumOpenDocuments(); --i >= 0;) - { - OpenDocumentManager::Document* doc = OpenDocumentManager::getInstance()->getOpenDocument (i); - - for (int j = mainWindows.size(); --j >= 0;) - mainWindows.getUnchecked(j)->getProjectContentComponent()->hideDocument (doc); - - if (! OpenDocumentManager::getInstance()->closeDocument (i, askUserToSave)) - return false; - } - - return true; + return OpenDocumentManager::getInstance()->closeAll (askUserToSave); } void updateRecentProjectList() diff --git a/extras/Introjucer/Source/Application/jucer_OpenDocumentManager.cpp b/extras/Introjucer/Source/Application/jucer_OpenDocumentManager.cpp index dd2dbc137b..c14a1276d7 100644 --- a/extras/Introjucer/Source/Application/jucer_OpenDocumentManager.cpp +++ b/extras/Introjucer/Source/Application/jucer_OpenDocumentManager.cpp @@ -41,11 +41,8 @@ public: } //============================================================================== - class Type : public OpenDocumentManager::DocumentType + struct Type : public OpenDocumentManager::DocumentType { - public: - Type() {} - bool canOpenFile (const File& file) { return SourceCodeEditor::isTextFile (file); } Document* openFile (Project*, const File& file) { return new SourceCodeDocument (file); } }; @@ -123,12 +120,8 @@ public: } //============================================================================== - class Type : public OpenDocumentManager::DocumentType + struct Type : public OpenDocumentManager::DocumentType { - public: - Type() {} - ~Type() {} - bool canOpenFile (const File&) { return true; } Document* openFile (Project* project, const File& file) { return new UnknownDocument (project, file); } }; @@ -208,7 +201,7 @@ bool OpenDocumentManager::canOpenFile (const File& file) return false; } -OpenDocumentManager::Document* OpenDocumentManager::getDocumentForFile (Project* project, const File& file) +OpenDocumentManager::Document* OpenDocumentManager::openFile (Project* project, const File& file) { for (int i = documents.size(); --i >= 0;) if (documents.getUnchecked(i)->isForFile (file)) @@ -225,11 +218,9 @@ OpenDocumentManager::Document* OpenDocumentManager::getDocumentForFile (Project* } } - jassert (d != nullptr); - - if (d != nullptr) - documents.add (d); + jassert (d != nullptr); // should always at least have been picked up by UnknownDocument + documents.add (d); commandManager->commandStatusChanged(); return d; } @@ -324,6 +315,15 @@ void OpenDocumentManager::closeFile (const File& f, bool saveIfNeeded) } } +bool OpenDocumentManager::closeAll (bool askUserToSave) +{ + for (int i = getNumOpenDocuments(); --i >= 0;) + if (! closeDocument (i, askUserToSave)) + return false; + + return true; +} + bool OpenDocumentManager::closeAllDocumentsUsingProject (Project& project, bool saveIfNeeded) { for (int i = documents.size(); --i >= 0;) diff --git a/extras/Introjucer/Source/Application/jucer_OpenDocumentManager.h b/extras/Introjucer/Source/Application/jucer_OpenDocumentManager.h index ab5763024b..5d6dfa0a6f 100644 --- a/extras/Introjucer/Source/Application/jucer_OpenDocumentManager.h +++ b/extras/Introjucer/Source/Application/jucer_OpenDocumentManager.h @@ -65,16 +65,16 @@ public: virtual void fileHasBeenRenamed (const File& newFile) = 0; }; - Document* getDocumentForFile (Project* project, const File& file); - bool canOpenFile (const File& file); - //============================================================================== int getNumOpenDocuments() const; Document* getOpenDocument (int index) const; void moveDocumentToTopOfStack (Document* doc); + bool canOpenFile (const File& file); + Document* openFile (Project* project, const File& file); bool closeDocument (int index, bool saveIfNeeded); bool closeDocument (Document* document, bool saveIfNeeded); + bool closeAll (bool askUserToSave); bool closeAllDocumentsUsingProject (Project& project, bool saveIfNeeded); void closeFile (const File& f, bool saveIfNeeded); bool anyFilesNeedSaving() const; diff --git a/extras/Introjucer/Source/Project Saving/jucer_ProjectSaver.h b/extras/Introjucer/Source/Project Saving/jucer_ProjectSaver.h index 7583c0b00f..8274679654 100644 --- a/extras/Introjucer/Source/Project Saving/jucer_ProjectSaver.h +++ b/extras/Introjucer/Source/Project Saving/jucer_ProjectSaver.h @@ -110,13 +110,11 @@ public: { Project::Item item (generatedFilesGroup.findItemForFile (file)); - if (! item.isValid()) - { - generatedFilesGroup.addFile (file, -1, true); - item = generatedFilesGroup.findItemForFile (file); - } + if (item.isValid()) + return item; - return item; + generatedFilesGroup.addFile (file, -1, true); + return generatedFilesGroup.findItemForFile (file); } void setExtraAppConfigFileContent (const String& content) @@ -413,7 +411,7 @@ private: void writeProjects (const OwnedArray& modules) { // keep a copy of the basic generated files group, as each exporter may modify it. - const ValueTree originalGeneratedGroup (generatedFilesGroup.getNode().createCopy()); + const ValueTree originalGeneratedGroup (generatedFilesGroup.state.createCopy()); for (int i = project.getNumExporters(); --i >= 0;) { @@ -424,7 +422,7 @@ private: { exporter->addToExtraSearchPaths (RelativePath ("JuceLibraryCode", RelativePath::projectFolder)); - generatedFilesGroup.getNode() = originalGeneratedGroup.createCopy(); + generatedFilesGroup.state = originalGeneratedGroup.createCopy(); project.getProjectType().prepareExporter (*exporter); for (int j = 0; j < modules.size(); ++j) diff --git a/extras/Introjucer/Source/Project/jucer_GroupInformationComponent.cpp b/extras/Introjucer/Source/Project/jucer_GroupInformationComponent.cpp index f483418b15..e9a90f7601 100644 --- a/extras/Introjucer/Source/Project/jucer_GroupInformationComponent.cpp +++ b/extras/Introjucer/Source/Project/jucer_GroupInformationComponent.cpp @@ -34,12 +34,12 @@ GroupInformationComponent::GroupInformationComponent (const Project::Item& item_ addAndMakeVisible (&list); list.updateContent(); list.setRowHeight (20); - item.getNode().addListener (this); + item.state.addListener (this); } GroupInformationComponent::~GroupInformationComponent() { - item.getNode().removeListener (this); + item.state.removeListener (this); } void GroupInformationComponent::resized() diff --git a/extras/Introjucer/Source/Project/jucer_Module.cpp b/extras/Introjucer/Source/Project/jucer_Module.cpp index 49a7451487..0396dd9e0f 100644 --- a/extras/Introjucer/Source/Project/jucer_Module.cpp +++ b/extras/Introjucer/Source/Project/jucer_Module.cpp @@ -675,5 +675,5 @@ void LibraryModule::addBrowsableCode (ProjectExporter& exporter, const Array& items) } //============================================================================== -Project::Item::Item (Project& project_, const ValueTree& node_) - : project (&project_), node (node_) +Project::Item::Item (Project& project_, const ValueTree& state_) + : project (project_), state (state_) { } Project::Item::Item (const Item& other) - : project (other.project), node (other.node) + : project (other.project), state (other.state) { } -Project::Item& Project::Item::operator= (const Project::Item& other) -{ - project = other.project; - node = other.node; - return *this; -} +Project::Item Project::Item::createCopy() { Item i (*this); i.state = i.state.createCopy(); return i; } -Project::Item::~Item() -{ -} - -Project::Item Project::Item::createCopy() { Item i (*this); i.node = i.node.createCopy(); return i; } - -String Project::Item::getID() const { return node [ComponentBuilder::idProperty]; } -void Project::Item::setID (const String& newID) { node.setProperty (ComponentBuilder::idProperty, newID, nullptr); } +String Project::Item::getID() const { return state [ComponentBuilder::idProperty]; } +void Project::Item::setID (const String& newID) { state.setProperty (ComponentBuilder::idProperty, newID, nullptr); } String Project::Item::getImageFileID() const { return "id:" + getID(); } +Image Project::Item::loadAsImageFile() const +{ + return isValid() ? ImageCache::getFromFile (getFile()) + : Image::null; +} + Project::Item Project::Item::createGroup (Project& project, const String& name, const String& uid) { Item group (project, ValueTree (Tags::group)); group.setID (uid); - group.initialiseNodeValues(); + group.initialiseMissingProperties(); group.getName() = name; return group; } -bool Project::Item::isFile() const { return node.hasType (Tags::file); } -bool Project::Item::isGroup() const { return node.hasType (Tags::group) || isMainGroup(); } -bool Project::Item::isMainGroup() const { return node.hasType (Tags::projectMainGroup); } +bool Project::Item::isFile() const { return state.hasType (Tags::file); } +bool Project::Item::isGroup() const { return state.hasType (Tags::group) || isMainGroup(); } +bool Project::Item::isMainGroup() const { return state.hasType (Tags::projectMainGroup); } bool Project::Item::isImageFile() const { return isFile() && getFile().hasFileExtension ("png;jpg;jpeg;gif;drawable"); } Project::Item Project::Item::findItemWithID (const String& targetId) const { - if (node [ComponentBuilder::idProperty] == targetId) + if (state [ComponentBuilder::idProperty] == targetId) return *this; if (isGroup()) @@ -464,7 +449,7 @@ Project::Item Project::Item::findItemWithID (const String& targetId) const } } - return Item (*project, ValueTree::invalid); + return Item (project, ValueTree::invalid); } bool Project::Item::canContain (const Item& child) const @@ -479,24 +464,21 @@ bool Project::Item::canContain (const Item& child) const return false; } -bool Project::Item::shouldBeAddedToTargetProject() const -{ - return isFile(); -} +bool Project::Item::shouldBeAddedToTargetProject() const { return isFile(); } bool Project::Item::shouldBeCompiled() const { return getShouldCompileValue().getValue(); } -Value Project::Item::getShouldCompileValue() const { return node.getPropertyAsValue (Ids::compile, getUndoManager()); } +Value Project::Item::getShouldCompileValue() const { return state.getPropertyAsValue (Ids::compile, getUndoManager()); } bool Project::Item::shouldBeAddedToBinaryResources() const { return getShouldAddToResourceValue().getValue(); } -Value Project::Item::getShouldAddToResourceValue() const { return node.getPropertyAsValue (Ids::resource, getUndoManager()); } +Value Project::Item::getShouldAddToResourceValue() const { return state.getPropertyAsValue (Ids::resource, getUndoManager()); } -Value Project::Item::getShouldInhibitWarningsValue() const { return node.getPropertyAsValue (Ids::noWarnings, getUndoManager()); } -Value Project::Item::getShouldUseStdCallValue() const { return node.getPropertyAsValue (Ids::useStdCall, nullptr); } +Value Project::Item::getShouldInhibitWarningsValue() const { return state.getPropertyAsValue (Ids::noWarnings, getUndoManager()); } +Value Project::Item::getShouldUseStdCallValue() const { return state.getPropertyAsValue (Ids::useStdCall, nullptr); } String Project::Item::getFilePath() const { if (isFile()) - return node [Ids::file].toString(); + return state [Ids::file].toString(); else return String::empty; } @@ -504,14 +486,14 @@ String Project::Item::getFilePath() const File Project::Item::getFile() const { if (isFile()) - return getProject().resolveFilename (node [Ids::file].toString()); + return project.resolveFilename (state [Ids::file].toString()); else return File::nonexistent; } void Project::Item::setFile (const File& file) { - setFile (RelativePath (getProject().getRelativePathForFile (file), RelativePath::projectFolder)); + setFile (RelativePath (project.getRelativePathForFile (file), RelativePath::projectFolder)); jassert (getFile() == file); } @@ -519,8 +501,8 @@ void Project::Item::setFile (const RelativePath& file) { jassert (file.getRoot() == RelativePath::projectFolder); jassert (isFile()); - node.setProperty (Ids::file, file.toUnixStyle(), getUndoManager()); - node.setProperty (Ids::name, file.getFileName(), getUndoManager()); + state.setProperty (Ids::file, file.toUnixStyle(), getUndoManager()); + state.setProperty (Ids::name, file.getFileName(), getUndoManager()); } bool Project::Item::renameFile (const File& newFile) @@ -539,7 +521,7 @@ bool Project::Item::renameFile (const File& newFile) bool Project::Item::containsChildForFile (const RelativePath& file) const { - return node.getChildWithProperty (Ids::file, file.toUnixStyle()).isValid(); + return state.getChildWithProperty (Ids::file, file.toUnixStyle()).isValid(); } Project::Item Project::Item::findItemForFile (const File& file) const @@ -558,7 +540,7 @@ Project::Item Project::Item::findItemForFile (const File& file) const } } - return Item (getProject(), ValueTree::invalid); + return Item (project, ValueTree::invalid); } File Project::Item::determineGroupFolder() const @@ -584,7 +566,7 @@ File Project::Item::determineGroupFolder() const } else { - f = getProject().getFile().getParentDirectory(); + f = project.getFile().getParentDirectory(); if (f.getChildFile ("Source").isDirectory()) f = f.getChildFile ("Source"); @@ -593,35 +575,35 @@ File Project::Item::determineGroupFolder() const return f; } -void Project::Item::initialiseNodeValues() +void Project::Item::initialiseMissingProperties() { - if (! node.hasProperty (ComponentBuilder::idProperty)) + if (! state.hasProperty (ComponentBuilder::idProperty)) setID (createAlphaNumericUID()); if (isFile()) { - node.setProperty (Ids::name, getFile().getFileName(), 0); + state.setProperty (Ids::name, getFile().getFileName(), 0); } else if (isGroup()) { for (int i = getNumChildren(); --i >= 0;) - getChild(i).initialiseNodeValues(); + getChild(i).initialiseMissingProperties(); } } Value Project::Item::getName() const { - return node.getPropertyAsValue (Ids::name, getUndoManager()); + return state.getPropertyAsValue (Ids::name, getUndoManager()); } void Project::Item::addChild (const Item& newChild, int insertIndex) { - node.addChild (newChild.getNode(), insertIndex, getUndoManager()); + state.addChild (newChild.state, insertIndex, getUndoManager()); } void Project::Item::removeItemFromProject() { - node.getParent().removeChild (node, getUndoManager()); + state.getParent().removeChild (state, getUndoManager()); } Project::Item Project::Item::getParent() const @@ -629,7 +611,7 @@ Project::Item Project::Item::getParent() const if (isMainGroup() || ! isGroup()) return *this; - return Item (getProject(), node.getParent()); + return Item (project, state.getParent()); } struct ItemSorter @@ -659,22 +641,22 @@ void Project::Item::sortAlphabetically (bool keepGroupsAtStart) if (keepGroupsAtStart) { ItemSorterWithGroupsAtStart sorter; - node.sort (sorter, getUndoManager(), true); + state.sort (sorter, getUndoManager(), true); } else { ItemSorter sorter; - node.sort (sorter, getUndoManager(), true); + state.sort (sorter, getUndoManager(), true); } } Project::Item Project::Item::getOrCreateSubGroup (const String& name) { - for (int i = node.getNumChildren(); --i >= 0;) + for (int i = state.getNumChildren(); --i >= 0;) { - const ValueTree child (node.getChild (i)); + const ValueTree child (state.getChild (i)); if (child.getProperty (Ids::name) == name && child.hasType (Tags::group)) - return Item (getProject(), child); + return Item (project, child); } return addNewSubGroup (name, -1); @@ -682,7 +664,7 @@ Project::Item Project::Item::getOrCreateSubGroup (const String& name) Project::Item Project::Item::addNewSubGroup (const String& name, int insertIndex) { - Item group (createGroup (getProject(), name, createGUID (getID() + name + String (getNumChildren())))); + Item group (createGroup (project, name, createGUID (getID() + name + String (getNumChildren())))); jassert (canContain (group)); addChild (group, insertIndex); @@ -701,7 +683,7 @@ bool Project::Item::addFile (const File& file, int insertIndex, const bool shoul DirectoryIterator iter (file, false, "*", File::findFilesAndDirectories); while (iter.next()) { - if (! getProject().getMainGroup().findItemForFile (iter.getFile()).isValid()) + if (! project.getMainGroup().findItemForFile (iter.getFile()).isValid()) group.addFile (iter.getFile(), -1, shouldCompile); } @@ -709,7 +691,7 @@ bool Project::Item::addFile (const File& file, int insertIndex, const bool shoul } else if (file.existsAsFile()) { - if (! getProject().getMainGroup().findItemForFile (file).isValid()) + if (! project.getMainGroup().findItemForFile (file).isValid()) addFileUnchecked (file, insertIndex, shouldCompile); } else @@ -722,11 +704,11 @@ bool Project::Item::addFile (const File& file, int insertIndex, const bool shoul void Project::Item::addFileUnchecked (const File& file, int insertIndex, const bool shouldCompile) { - Item item (getProject(), ValueTree (Tags::file)); - item.initialiseNodeValues(); + Item item (project, ValueTree (Tags::file)); + item.initialiseMissingProperties(); item.getName() = file.getFileName(); item.getShouldCompileValue() = shouldCompile && file.hasFileExtension ("cpp;mm;c;m;cc;cxx;r"); - item.getShouldAddToResourceValue() = getProject().shouldBeAddedToBinaryResourcesByDefault (file); + item.getShouldAddToResourceValue() = project.shouldBeAddedToBinaryResourcesByDefault (file); if (canContain (item)) { @@ -737,11 +719,11 @@ void Project::Item::addFileUnchecked (const File& file, int insertIndex, const b bool Project::Item::addRelativeFile (const RelativePath& file, int insertIndex, bool shouldCompile) { - Item item (getProject(), ValueTree (Tags::file)); - item.initialiseNodeValues(); + Item item (project, ValueTree (Tags::file)); + item.initialiseMissingProperties(); item.getName() = file.getFileName(); item.getShouldCompileValue() = shouldCompile; - item.getShouldAddToResourceValue() = getProject().shouldBeAddedToBinaryResourcesByDefault (file); + item.getShouldAddToResourceValue() = project.shouldBeAddedToBinaryResourcesByDefault (file); if (canContain (item)) { @@ -764,7 +746,7 @@ const Drawable* Project::Item::getIcon() const } else if (isMainGroup()) { - return &(getProject().mainProjectIcon); + return &(project.mainProjectIcon); } return LookAndFeel::getDefaultLookAndFeel().getDefaultFolderImage(); diff --git a/extras/Introjucer/Source/Project/jucer_Project.h b/extras/Introjucer/Source/Project/jucer_Project.h index be3b2301f4..f1f646322b 100644 --- a/extras/Introjucer/Source/Project/jucer_Project.h +++ b/extras/Introjucer/Source/Project/jucer_Project.h @@ -113,18 +113,13 @@ public: //============================================================================== Item (Project& project, const ValueTree& itemNode); Item (const Item& other); - Item& operator= (const Item& other); - ~Item(); static Item createGroup (Project& project, const String& name, const String& uid); - void initialiseNodeValues(); + void initialiseMissingProperties(); //============================================================================== - bool isValid() const { return node.isValid(); } - const ValueTree& getNode() const noexcept { return node; } - ValueTree& getNode() noexcept { return node; } - Project& getProject() const noexcept { return *project; } - bool operator== (const Item& other) const { return node == other.node && project == other.project; } + bool isValid() const { return state.isValid(); } + bool operator== (const Item& other) const { return state == other.state && &project == &other.project; } bool operator!= (const Item& other) const { return ! operator== (other); } //============================================================================== @@ -134,9 +129,11 @@ public: bool isImageFile() const; String getID() const; - Item findItemWithID (const String& targetId) const; // (recursive search) - String getImageFileID() const; void setID (const String& newID); + Item findItemWithID (const String& targetId) const; // (recursive search) + + String getImageFileID() const; + Image loadAsImageFile() const; //============================================================================== Value getName() const; @@ -157,8 +154,8 @@ public: //============================================================================== bool canContain (const Item& child) const; - int getNumChildren() const { return node.getNumChildren(); } - Item getChild (int index) const { return Item (getProject(), node.getChild (index)); } + int getNumChildren() const { return state.getNumChildren(); } + Item getChild (int index) const { return Item (project, state.getChild (index)); } Item addNewSubGroup (const String& name, int insertIndex); Item getOrCreateSubGroup (const String& name); @@ -174,14 +171,15 @@ public: Item getParent() const; Item createCopy(); + UndoManager* getUndoManager() const { return project.getUndoManagerFor (state); } + const Drawable* getIcon() const; - private: - //============================================================================== - Project* project; - ValueTree node; + Project& project; + ValueTree state; - UndoManager* getUndoManager() const { return getProject().getUndoManagerFor (node); } + private: + Item& operator= (const Item&); }; Item getMainGroup(); diff --git a/extras/Introjucer/Source/Project/jucer_ProjectContentComponent.cpp b/extras/Introjucer/Source/Project/jucer_ProjectContentComponent.cpp index db0d74c5ff..588047628b 100644 --- a/extras/Introjucer/Source/Project/jucer_ProjectContentComponent.cpp +++ b/extras/Introjucer/Source/Project/jucer_ProjectContentComponent.cpp @@ -125,8 +125,7 @@ void ProjectContentComponent::updateMissingFileStatuses() bool ProjectContentComponent::showEditorForFile (const File& f) { - return showDocument (OpenDocumentManager::getInstance() - ->getDocumentForFile (project, f)); + return showDocument (OpenDocumentManager::getInstance()->openFile (project, f)); } bool ProjectContentComponent::showDocument (OpenDocumentManager::Document* doc) diff --git a/extras/Introjucer/Source/Project/jucer_ProjectTreeViewBase.cpp b/extras/Introjucer/Source/Project/jucer_ProjectTreeViewBase.cpp index d50abb3d85..70f0c8038b 100644 --- a/extras/Introjucer/Source/Project/jucer_ProjectTreeViewBase.cpp +++ b/extras/Introjucer/Source/Project/jucer_ProjectTreeViewBase.cpp @@ -31,12 +31,12 @@ ProjectTreeViewBase::ProjectTreeViewBase (const Project::Item& item_) : item (item_), isFileMissing (false) { - item.getNode().addListener (this); + item.state.addListener (this); } ProjectTreeViewBase::~ProjectTreeViewBase() { - item.getNode().removeListener (this); + item.state.removeListener (this); } //============================================================================== @@ -48,7 +48,7 @@ String ProjectTreeViewBase::getDisplayName() const void ProjectTreeViewBase::setName (const String& newName) { if (item.isMainGroup()) - item.getProject().setTitle (newName); + item.project.setTitle (newName); else item.getName() = newName; } @@ -268,7 +268,7 @@ void ProjectTreeViewBase::moveItems (OwnedArray & selectedNodes, { Project::Item* const n = selectedNodes.getUnchecked(i); - if (destNode == *n || destNode.getNode().isAChildOf (n->getNode())) // Check for recursion. + if (destNode == *n || destNode.state.isAChildOf (n->state)) // Check for recursion. return; if (! destNode.canContain (*n)) @@ -282,7 +282,7 @@ void ProjectTreeViewBase::moveItems (OwnedArray & selectedNodes, for (int j = selectedNodes.size(); --j >= 0;) { - if (j != i && n->getNode().isAChildOf (selectedNodes.getUnchecked(j)->getNode())) + if (j != i && n->state.isAChildOf (selectedNodes.getUnchecked(j)->state)) { selectedNodes.remove (i); break; @@ -295,8 +295,8 @@ void ProjectTreeViewBase::moveItems (OwnedArray & selectedNodes, { Project::Item* selectedNode = selectedNodes.getUnchecked(i); - if (selectedNode->getNode().getParent() == destNode.getNode() - && indexOfNode (destNode.getNode(), selectedNode->getNode()) < insertIndex) + if (selectedNode->state.getParent() == destNode.state + && indexOfNode (destNode.state, selectedNode->state) < insertIndex) --insertIndex; selectedNode->removeItemFromProject(); @@ -367,7 +367,7 @@ void ProjectTreeViewBase::itemDropped (const DragAndDropTarget::SourceDetails& d //============================================================================== void ProjectTreeViewBase::treeChildrenChanged (const ValueTree& parentTree) { - if (parentTree == item.getNode()) + if (parentTree == item.state) { refreshSubItems(); treeHasChanged(); @@ -377,7 +377,7 @@ void ProjectTreeViewBase::treeChildrenChanged (const ValueTree& parentTree) void ProjectTreeViewBase::valueTreePropertyChanged (ValueTree& tree, const Identifier& property) { - if (tree == item.getNode()) + if (tree == item.state) repaintItem(); } diff --git a/extras/Introjucer/Source/Project/jucer_TreeViewTypes.cpp b/extras/Introjucer/Source/Project/jucer_TreeViewTypes.cpp index 61e5c6c3dd..ce3f632f72 100644 --- a/extras/Introjucer/Source/Project/jucer_TreeViewTypes.cpp +++ b/extras/Introjucer/Source/Project/jucer_TreeViewTypes.cpp @@ -102,7 +102,7 @@ void GroupTreeViewItem::showDocument() if (pcc != nullptr) { if (isRoot()) - pcc->setEditorComponent (new ProjectInformationComponent (item.getProject()), 0); + pcc->setEditorComponent (new ProjectInformationComponent (item.project), 0); else pcc->setEditorComponent (new GroupInformationComponent (item), 0); } @@ -194,7 +194,7 @@ void SourceFileTreeViewItem::setName (const String& newName) if (correspondingFile.exists() && newFile.hasFileExtension (oldFile.getFileExtension())) { - Project::Item correspondingItem (item.getProject().getMainGroup().findItemForFile (correspondingFile)); + Project::Item correspondingItem (item.project.getMainGroup().findItemForFile (correspondingFile)); if (correspondingItem.isValid()) { diff --git a/modules/juce_gui_basics/windows/juce_CallOutBox.cpp b/modules/juce_gui_basics/windows/juce_CallOutBox.cpp index b9936a945d..e2377771b7 100644 --- a/modules/juce_gui_basics/windows/juce_CallOutBox.cpp +++ b/modules/juce_gui_basics/windows/juce_CallOutBox.cpp @@ -158,12 +158,12 @@ void CallOutBox::updatePosition (const Rectangle& newAreaToPointTo, const R const float arrowIndent = borderSpace - arrowSize; Point targets[4] = { Point ((float) targetArea.getCentreX(), (float) targetArea.getBottom()), - Point ((float) targetArea.getRight(), (float) targetArea.getCentreY()), - Point ((float) targetArea.getX(), (float) targetArea.getCentreY()), + Point ((float) targetArea.getRight(), (float) targetArea.getCentreY()), + Point ((float) targetArea.getX(), (float) targetArea.getCentreY()), Point ((float) targetArea.getCentreX(), (float) targetArea.getY()) }; - Line lines[4] = { Line (targets[0].translated (-hwReduced, hh - arrowIndent), targets[0].translated (hwReduced, hh - arrowIndent)), - Line (targets[1].translated (hw - arrowIndent, -hhReduced), targets[1].translated (hw - arrowIndent, hhReduced)), + Line lines[4] = { Line (targets[0].translated (-hwReduced, hh - arrowIndent), targets[0].translated (hwReduced, hh - arrowIndent)), + Line (targets[1].translated (hw - arrowIndent, -hhReduced), targets[1].translated (hw - arrowIndent, hhReduced)), Line (targets[2].translated (-(hw - arrowIndent), -hhReduced), targets[2].translated (-(hw - arrowIndent), hhReduced)), Line (targets[3].translated (-hwReduced, -(hh - arrowIndent)), targets[3].translated (hwReduced, -(hh - arrowIndent))) }; @@ -205,50 +205,60 @@ void CallOutBox::refreshPath() const float cornerSize = 9.0f; const float cornerSize2 = 2.0f * cornerSize; const float arrowBaseWidth = arrowSize * 0.7f; - const float left = content.getX() - gap, top = content.getY() - gap, right = content.getRight() + gap, bottom = content.getBottom() + gap; - const float targetX = targetPoint.getX() - getX(), targetY = targetPoint.getY() - getY(); - outline.startNewSubPath (left + cornerSize, top); + const Rectangle area (content.getBounds().toFloat().expanded (gap, gap)); + const Point target (targetPoint - getPosition().toFloat()); - if (targetY <= top) + outline.startNewSubPath (area.getX() + cornerSize, area.getY()); + + const float targetLimitX = area.getX() + cornerSize + arrowBaseWidth; + const float targetLimitW = area.getWidth() - cornerSize2 - arrowBaseWidth * 2.0f; + + const float targetLimitY = area.getY() + cornerSize + arrowBaseWidth; + const float targetLimitH = area.getHeight() - cornerSize2 - arrowBaseWidth * 2.0f; + + if (Rectangle (targetLimitX, 1.0f, + targetLimitW, area.getY() - 2.0f).contains (target)) { - outline.lineTo (targetX - arrowBaseWidth, top); - outline.lineTo (targetX, targetY); - outline.lineTo (targetX + arrowBaseWidth, top); + outline.lineTo (target.x - arrowBaseWidth, area.getY()); + outline.lineTo (target.x, target.y); + outline.lineTo (target.x + arrowBaseWidth, area.getY()); } - outline.lineTo (right - cornerSize, top); - outline.addArc (right - cornerSize2, top, cornerSize2, cornerSize2, 0, float_Pi * 0.5f); + outline.lineTo (area.getRight() - cornerSize, area.getY()); + outline.addArc (area.getRight() - cornerSize2, area.getY(), cornerSize2, cornerSize2, 0, float_Pi * 0.5f); - if (targetX >= right) + if (Rectangle (area.getRight() + 1.0f, targetLimitY, + getWidth() - area.getRight() - 2.0f, targetLimitH).contains (target)) { - outline.lineTo (right, targetY - arrowBaseWidth); - outline.lineTo (targetX, targetY); - outline.lineTo (right, targetY + arrowBaseWidth); + outline.lineTo (area.getRight(), target.y - arrowBaseWidth); + outline.lineTo (target.x, target.y); + outline.lineTo (area.getRight(), target.y + arrowBaseWidth); } - outline.lineTo (right, bottom - cornerSize); - outline.addArc (right - cornerSize2, bottom - cornerSize2, cornerSize2, cornerSize2, float_Pi * 0.5f, float_Pi); + outline.lineTo (area.getRight(), area.getBottom() - cornerSize); + outline.addArc (area.getRight() - cornerSize2, area.getBottom() - cornerSize2, cornerSize2, cornerSize2, float_Pi * 0.5f, float_Pi); - if (targetY >= bottom) + if (Rectangle (targetLimitX, area.getBottom() + 1.0f, + targetLimitW, getHeight() - area.getBottom() - 2.0f).contains (target)) { - outline.lineTo (targetX + arrowBaseWidth, bottom); - outline.lineTo (targetX, targetY); - outline.lineTo (targetX - arrowBaseWidth, bottom); + outline.lineTo (target.x + arrowBaseWidth, area.getBottom()); + outline.lineTo (target.x, target.y); + outline.lineTo (target.x - arrowBaseWidth, area.getBottom()); } - outline.lineTo (left + cornerSize, bottom); - outline.addArc (left, bottom - cornerSize2, cornerSize2, cornerSize2, float_Pi, float_Pi * 1.5f); + outline.lineTo (area.getX() + cornerSize, area.getBottom()); + outline.addArc (area.getX(), area.getBottom() - cornerSize2, cornerSize2, cornerSize2, float_Pi, float_Pi * 1.5f); - if (targetX <= left) + if (Rectangle (1.0f, targetLimitY, area.getX() - 2.0f, targetLimitH).contains (target)) { - outline.lineTo (left, targetY + arrowBaseWidth); - outline.lineTo (targetX, targetY); - outline.lineTo (left, targetY - arrowBaseWidth); + outline.lineTo (area.getX(), target.y + arrowBaseWidth); + outline.lineTo (target.x, target.y); + outline.lineTo (area.getX(), target.y - arrowBaseWidth); } - outline.lineTo (left, top + cornerSize); - outline.addArc (left, top, cornerSize2, cornerSize2, float_Pi * 1.5f, float_Pi * 2.0f - 0.05f); + outline.lineTo (area.getX(), area.getY() + cornerSize); + outline.addArc (area.getX(), area.getY(), cornerSize2, cornerSize2, float_Pi * 1.5f, float_Pi * 2.0f - 0.05f); outline.closeSubPath(); }