mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-24 01:54:22 +00:00
Introjucer: misc minor fixes + tweaks.
This commit is contained in:
parent
a204ea7ae8
commit
365e4611fa
8 changed files with 91 additions and 47 deletions
|
|
@ -430,7 +430,7 @@ void JucerDocument::fillInGeneratedCode (GeneratedCode& code) const
|
|||
code.initialisers.addLines (variableInitialisers);
|
||||
|
||||
if (! componentName.isEmpty())
|
||||
code.parentClassInitialiser = "Component (" + quotedString (code.componentName) + ")";
|
||||
code.constructorCode << "setName (" + quotedString (componentName) + ")\n";
|
||||
|
||||
// call these now, just to make sure they're the first two methods in the list.
|
||||
code.getCallbackCode (String::empty, "void", "paint (Graphics& g)", false)
|
||||
|
|
@ -454,8 +454,7 @@ void JucerDocument::fillInGeneratedCode (GeneratedCode& code) const
|
|||
"//[/UserPreSize]\n";
|
||||
|
||||
if (initialWidth > 0 || initialHeight > 0)
|
||||
code.constructorCode
|
||||
<< "\nsetSize (" << initialWidth << ", " << initialHeight << ");\n";
|
||||
code.constructorCode << "\nsetSize (" << initialWidth << ", " << initialHeight << ");\n";
|
||||
|
||||
code.getCallbackCode (String::empty, "void", "paint (Graphics& g)", false)
|
||||
<< "//[UserPaint] Add your own custom painting code here..\n//[/UserPaint]";
|
||||
|
|
@ -471,7 +470,12 @@ void JucerDocument::fillInGeneratedCode (GeneratedCode& code) const
|
|||
{
|
||||
if (isOptionalMethodEnabled (methods[i]))
|
||||
{
|
||||
String& s = code.getCallbackCode (baseClasses[i], returnValues[i], methods[i], false);
|
||||
String baseClassToAdd (baseClasses[i]);
|
||||
|
||||
if (baseClassToAdd == "Component" || baseClassToAdd == "Button")
|
||||
baseClassToAdd = String::empty;
|
||||
|
||||
String& s = code.getCallbackCode (baseClassToAdd, returnValues[i], methods[i], false);
|
||||
|
||||
if (! s.contains ("//["))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -357,9 +357,9 @@ void ComponentLayoutEditor::filesDropped (const StringArray& filenames, int x, i
|
|||
JucerComponentHandler jucerDocHandler;
|
||||
layout.getDocument()->beginTransaction();
|
||||
|
||||
if (TestComponent* newOne = dynamic_cast <TestComponent*> (layout.addNewComponent (&jucerDocHandler,
|
||||
x - subCompHolder->getX(),
|
||||
y - subCompHolder->getY())))
|
||||
if (TestComponent* newOne = dynamic_cast<TestComponent*> (layout.addNewComponent (&jucerDocHandler,
|
||||
x - subCompHolder->getX(),
|
||||
y - subCompHolder->getY())))
|
||||
{
|
||||
JucerComponentHandler::setJucerComponentFile (*layout.getDocument(), newOne,
|
||||
f.getRelativePathFrom (document.getCppFile().getParentDirectory()));
|
||||
|
|
@ -370,6 +370,31 @@ void ComponentLayoutEditor::filesDropped (const StringArray& filenames, int x, i
|
|||
}
|
||||
}
|
||||
|
||||
bool ComponentLayoutEditor::isInterestedInDragSource (const SourceDetails& dragSourceDetails)
|
||||
{
|
||||
if (dragSourceDetails.description != projectItemDragType)
|
||||
return false;
|
||||
|
||||
OwnedArray<Project::Item> selectedNodes;
|
||||
ProjectContentComponent::getSelectedProjectItemsBeingDragged (dragSourceDetails, selectedNodes);
|
||||
|
||||
return selectedNodes.size() > 0;
|
||||
}
|
||||
|
||||
void ComponentLayoutEditor::itemDropped (const SourceDetails& dragSourceDetails)
|
||||
{
|
||||
OwnedArray <Project::Item> selectedNodes;
|
||||
ProjectContentComponent::getSelectedProjectItemsBeingDragged (dragSourceDetails, selectedNodes);
|
||||
|
||||
StringArray filenames;
|
||||
|
||||
for (int i = 0; i < selectedNodes.size(); ++i)
|
||||
if (selectedNodes.getUnchecked(i)->getFile().hasFileExtension (".cpp"))
|
||||
filenames.add (selectedNodes.getUnchecked(i)->getFile().getFullPathName());
|
||||
|
||||
filesDropped (filenames, dragSourceDetails.localPosition.x, dragSourceDetails.localPosition.y);
|
||||
}
|
||||
|
||||
ComponentOverlayComponent* ComponentLayoutEditor::getOverlayCompFor (Component* compToFind) const
|
||||
{
|
||||
for (int i = getNumChildComponents(); --i >= 0;)
|
||||
|
|
|
|||
|
|
@ -36,7 +36,8 @@
|
|||
class ComponentLayoutEditor : public Component,
|
||||
public ChangeListener,
|
||||
public FileDragAndDropTarget,
|
||||
public LassoSource <Component*>
|
||||
public DragAndDropTarget,
|
||||
public LassoSource<Component*>
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
|
|
@ -44,24 +45,28 @@ public:
|
|||
~ComponentLayoutEditor();
|
||||
|
||||
//==============================================================================
|
||||
void paint (Graphics& g);
|
||||
void resized();
|
||||
void visibilityChanged();
|
||||
void changeListenerCallback (ChangeBroadcaster*);
|
||||
void paint (Graphics&) override;
|
||||
void resized() override;
|
||||
void visibilityChanged() override;
|
||||
void changeListenerCallback (ChangeBroadcaster*) override;
|
||||
|
||||
void mouseDown (const MouseEvent& e);
|
||||
void mouseDrag (const MouseEvent& e);
|
||||
void mouseUp (const MouseEvent& e);
|
||||
bool keyPressed (const KeyPress& key);
|
||||
void mouseDown (const MouseEvent&) override;
|
||||
void mouseDrag (const MouseEvent&) override;
|
||||
void mouseUp (const MouseEvent&) override;
|
||||
bool keyPressed (const KeyPress&) override;
|
||||
|
||||
bool isInterestedInFileDrag (const StringArray& files) override;
|
||||
void filesDropped (const StringArray& filenames, int x, int y) override;
|
||||
|
||||
bool isInterestedInDragSource (const SourceDetails& dragSourceDetails) override;
|
||||
void itemDropped (const SourceDetails& dragSourceDetails) override;
|
||||
|
||||
bool isInterestedInFileDrag (const StringArray& files);
|
||||
void filesDropped (const StringArray& filenames, int x, int y);
|
||||
|
||||
ComponentLayout& getLayout() const noexcept { return layout; }
|
||||
|
||||
void findLassoItemsInArea (Array <Component*>& results, const Rectangle<int>& area);
|
||||
|
||||
SelectedItemSet <Component*>& getLassoSelection();
|
||||
SelectedItemSet<Component*>& getLassoSelection();
|
||||
|
||||
//==============================================================================
|
||||
void refreshAllComponents();
|
||||
|
|
@ -77,7 +82,7 @@ private:
|
|||
ComponentLayout& layout;
|
||||
Component* subCompHolder;
|
||||
|
||||
LassoComponent <Component*> lassoComp;
|
||||
LassoComponent<Component*> lassoComp;
|
||||
SnapGridPainter grid;
|
||||
bool firstResize;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ public:
|
|||
return ((ComponentLayoutEditor*) editor)->createComponentLayerSnapshot();
|
||||
}
|
||||
|
||||
ComponentLayout& getLayout() const noexcept { return layout;}
|
||||
ComponentLayout& layout;
|
||||
|
||||
private:
|
||||
class LayoutPropsPanel : public Component,
|
||||
|
|
@ -115,8 +115,6 @@ private:
|
|||
ComponentLayout& layout;
|
||||
PropertyPanel propsPanel;
|
||||
};
|
||||
|
||||
ComponentLayout& layout;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -438,7 +438,7 @@ ApplicationCommandTarget* JucerDocumentEditor::getNextCommandTarget()
|
|||
ComponentLayout* JucerDocumentEditor::getCurrentLayout() const
|
||||
{
|
||||
if (ComponentLayoutPanel* panel = dynamic_cast <ComponentLayoutPanel*> (tabbedComponent.getCurrentContentComponent()))
|
||||
return &(panel->getLayout());
|
||||
return &(panel->layout);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
|
@ -577,8 +577,8 @@ void JucerDocumentEditor::addComponent (const int index)
|
|||
|
||||
panel->xyToTargetXY (x, y);
|
||||
|
||||
if (Component* newOne = panel->getLayout().addNewComponent (ObjectTypes::componentTypeHandlers [index], x, y))
|
||||
panel->getLayout().getSelectedSet().selectOnly (newOne);
|
||||
if (Component* newOne = panel->layout.addNewComponent (ObjectTypes::componentTypeHandlers [index], x, y))
|
||||
panel->layout.getSelectedSet().selectOnly (newOne);
|
||||
|
||||
document->beginTransaction();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,6 @@ public:
|
|||
p->checkFileStatus();
|
||||
}
|
||||
|
||||
private:
|
||||
#include "jucer_ProjectTree_Base.h"
|
||||
#include "jucer_ProjectTree_Group.h"
|
||||
#include "jucer_ProjectTree_File.h"
|
||||
|
|
@ -911,3 +910,9 @@ bool ProjectContentComponent::perform (const InvocationInfo& info)
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ProjectContentComponent::getSelectedProjectItemsBeingDragged (const DragAndDropTarget::SourceDetails& dragSourceDetails,
|
||||
OwnedArray<Project::Item>& selectedNodes)
|
||||
{
|
||||
FileTreePanel::ProjectTreeItemBase::getSelectedProjectItemsBeingDragged (dragSourceDetails, selectedNodes);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,6 +92,9 @@ public:
|
|||
|
||||
StringArray getExportersWhichCanLaunch() const;
|
||||
|
||||
static void getSelectedProjectItemsBeingDragged (const DragAndDropTarget::SourceDetails& dragSourceDetails,
|
||||
OwnedArray<Project::Item>& selectedNodes);
|
||||
|
||||
//==============================================================================
|
||||
ApplicationCommandTarget* getNextCommandTarget() override;
|
||||
void getAllCommands (Array <CommandID>& commands) override;
|
||||
|
|
|
|||
|
|
@ -261,29 +261,29 @@ public:
|
|||
|
||||
void filesDropped (const StringArray& files, int insertIndex) override
|
||||
{
|
||||
addFiles (files, insertIndex);
|
||||
if (files.size() == 1 && File (files[0]).hasFileExtension (Project::projectFileExtension))
|
||||
IntrojucerApp::getApp().openFile (files[0]);
|
||||
else
|
||||
addFiles (files, insertIndex);
|
||||
}
|
||||
|
||||
bool isInterestedInDragSource (const DragAndDropTarget::SourceDetails& dragSourceDetails) override
|
||||
{
|
||||
if (dragSourceDetails.description != projectItemDragType)
|
||||
return false;
|
||||
|
||||
OwnedArray <Project::Item> selectedNodes;
|
||||
getAllSelectedNodesInTree (dragSourceDetails.sourceComponent, selectedNodes);
|
||||
OwnedArray<Project::Item> selectedNodes;
|
||||
getSelectedProjectItemsBeingDragged (dragSourceDetails, selectedNodes);
|
||||
|
||||
return selectedNodes.size() > 0 && acceptsDragItems (selectedNodes);
|
||||
}
|
||||
|
||||
void itemDropped (const DragAndDropTarget::SourceDetails& dragSourceDetails, int insertIndex) override
|
||||
{
|
||||
OwnedArray <Project::Item> selectedNodes;
|
||||
getAllSelectedNodesInTree (dragSourceDetails.sourceComponent, selectedNodes);
|
||||
OwnedArray<Project::Item> selectedNodes;
|
||||
getSelectedProjectItemsBeingDragged (dragSourceDetails, selectedNodes);
|
||||
|
||||
if (selectedNodes.size() > 0)
|
||||
{
|
||||
TreeView* tree = getOwnerView();
|
||||
ScopedPointer <XmlElement> oldOpenness (tree->getOpennessState (false));
|
||||
ScopedPointer<XmlElement> oldOpenness (tree->getOpennessState (false));
|
||||
|
||||
moveSelectedItemsTo (selectedNodes, insertIndex);
|
||||
|
||||
|
|
@ -299,20 +299,24 @@ public:
|
|||
return item.isImageFile() ? 250 : JucerTreeViewBase::getMillisecsAllowedForDragGesture();
|
||||
}
|
||||
|
||||
static void getAllSelectedNodesInTree (Component* componentInTree, OwnedArray <Project::Item>& selectedNodes)
|
||||
static void getSelectedProjectItemsBeingDragged (const DragAndDropTarget::SourceDetails& dragSourceDetails,
|
||||
OwnedArray<Project::Item>& selectedNodes)
|
||||
{
|
||||
TreeView* tree = dynamic_cast<TreeView*> (componentInTree);
|
||||
|
||||
if (tree == nullptr)
|
||||
tree = componentInTree->findParentComponentOfClass<TreeView>();
|
||||
|
||||
if (tree != nullptr)
|
||||
if (dragSourceDetails.description == projectItemDragType)
|
||||
{
|
||||
const int numSelected = tree->getNumSelectedItems();
|
||||
TreeView* tree = dynamic_cast<TreeView*> (dragSourceDetails.sourceComponent.get());
|
||||
|
||||
for (int i = 0; i < numSelected; ++i)
|
||||
if (const ProjectTreeItemBase* const p = dynamic_cast<ProjectTreeItemBase*> (tree->getSelectedItem (i)))
|
||||
selectedNodes.add (new Project::Item (p->item));
|
||||
if (tree == nullptr)
|
||||
tree = dragSourceDetails.sourceComponent->findParentComponentOfClass<TreeView>();
|
||||
|
||||
if (tree != nullptr)
|
||||
{
|
||||
const int numSelected = tree->getNumSelectedItems();
|
||||
|
||||
for (int i = 0; i < numSelected; ++i)
|
||||
if (const ProjectTreeItemBase* const p = dynamic_cast<ProjectTreeItemBase*> (tree->getSelectedItem (i)))
|
||||
selectedNodes.add (new Project::Item (p->item));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue