| @@ -98,7 +98,9 @@ public: | |||
| { | |||
| const CodeDocument::Position pos (getCaretPos()); | |||
| if ((newText == "{" || newText == "}") && pos.getLineNumber() > 0) | |||
| if ((newText == "{" || newText == "}") | |||
| && pos.getLineNumber() > 0 | |||
| && pos.getLineText().trim().isEmpty()) | |||
| { | |||
| moveCaretToStartOfLine (true); | |||
| CodeEditorComponent::insertTextAtCaret (getIndentForCurrentBlock (pos)); | |||
| @@ -52,6 +52,11 @@ void JucerTreeViewBase::paintItem (Graphics& g, int width, int height) | |||
| g.fillAll (Colour (0x401111ee)); | |||
| } | |||
| float JucerTreeViewBase::getIconSize() const | |||
| { | |||
| return jmin (getItemHeight() - 4.0f, 18.0f); | |||
| } | |||
| void JucerTreeViewBase::paintOpenCloseButton (Graphics& g, int width, int height, bool isMouseOver) | |||
| { | |||
| Path p; | |||
| @@ -65,60 +70,15 @@ void JucerTreeViewBase::paintOpenCloseButton (Graphics& g, int width, int height | |||
| g.fillPath (p); | |||
| } | |||
| //============================================================================== | |||
| class TreeItemComponent : public Component | |||
| void JucerTreeViewBase::paintContent (Graphics& g, const Rectangle<int>& area) | |||
| { | |||
| public: | |||
| TreeItemComponent (JucerTreeViewBase& item_) | |||
| : item (item_) | |||
| { | |||
| setInterceptsMouseClicks (false, true); | |||
| item.createLeftEdgeComponents (leftComps); | |||
| for (int i = 0; i < leftComps.size(); ++i) | |||
| addAndMakeVisible (leftComps.getUnchecked(i)); | |||
| addAndMakeVisible (rightHandComponent = item.createRightEdgeComponent()); | |||
| } | |||
| void paint (Graphics& g) | |||
| { | |||
| g.setColour (Colours::black); | |||
| const int height = getHeight(); | |||
| g.setFont (getFont()); | |||
| g.setColour (isMissing() ? Colours::red : Colours::black); | |||
| item.getIcon()->drawWithin (g, Rectangle<float> (0.0f, 2.0f, height + 6.0f, height - 4.0f), | |||
| RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize, 1.0f); | |||
| g.setFont (item.getFont()); | |||
| g.setColour (item.isMissing() ? Colours::red : Colours::black); | |||
| const int right = rightHandComponent != nullptr ? rightHandComponent->getX() - 2 | |||
| : getWidth(); | |||
| g.drawFittedText (item.getDisplayName(), | |||
| item.textX, 0, right - item.textX, height, Justification::centredLeft, 1, 0.8f); | |||
| } | |||
| void resized() | |||
| { | |||
| const int edge = 1; | |||
| const int itemSize = getHeight() - edge * 2; | |||
| item.textX = (leftComps.size() + 1) * getHeight() + 8; | |||
| for (int i = 0; i < leftComps.size(); ++i) | |||
| leftComps.getUnchecked(i)->setBounds (5 + (i + 1) * getHeight(), edge, itemSize, itemSize); | |||
| if (rightHandComponent != nullptr) | |||
| rightHandComponent->setBounds (getWidth() - itemSize - edge, edge, itemSize, itemSize); | |||
| } | |||
| private: | |||
| JucerTreeViewBase& item; | |||
| OwnedArray<Component> leftComps; | |||
| ScopedPointer<Component> rightHandComponent; | |||
| }; | |||
| g.drawFittedText (getDisplayName(), | |||
| area.getX(), area.getY(), area.getWidth(), area.getHeight(), | |||
| Justification::centredLeft, 1, 0.8f); | |||
| } | |||
| Component* JucerTreeViewBase::createItemComponent() | |||
| { | |||
| @@ -53,8 +53,8 @@ public: | |||
| virtual void setName (const String& newName) = 0; | |||
| virtual bool isMissing() = 0; | |||
| virtual const Drawable* getIcon() const = 0; | |||
| virtual void createLeftEdgeComponents (OwnedArray<Component>&) {} | |||
| virtual Component* createRightEdgeComponent() { return nullptr; } | |||
| virtual float getIconSize() const; | |||
| virtual void paintContent (Graphics& g, const Rectangle<int>& area); | |||
| virtual int getMillisecsAllowedForDragGesture() { return 120; }; | |||
| void refreshSubItems(); | |||
| @@ -157,5 +157,36 @@ private: | |||
| String opennessStateKey; | |||
| }; | |||
| //============================================================================== | |||
| class TreeItemComponent : public Component | |||
| { | |||
| public: | |||
| TreeItemComponent (JucerTreeViewBase& item_) : item (item_) | |||
| { | |||
| setInterceptsMouseClicks (false, true); | |||
| } | |||
| void paint (Graphics& g) | |||
| { | |||
| g.setColour (Colours::black); | |||
| paintIcon (g); | |||
| item.paintContent (g, Rectangle<int> (item.textX, 0, getWidth() - item.textX, getHeight())); | |||
| } | |||
| void paintIcon (Graphics& g) | |||
| { | |||
| const float iconSize = item.getIconSize(); | |||
| item.getIcon()->drawWithin (g, Rectangle<float> (4.0f, 2.0f, iconSize, getHeight() - 4.0f), | |||
| RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize, 1.0f); | |||
| } | |||
| void resized() | |||
| { | |||
| item.textX = item.getIconSize() + 8; | |||
| } | |||
| JucerTreeViewBase& item; | |||
| }; | |||
| #endif | |||
| @@ -247,6 +247,8 @@ void Icons::reload (const Colour& /*backgroundColour*/) | |||
| drawables.add (graph = createDrawableFromSVGPath (Colours::darkred, "M6.812,17.202l7.396-3.665v-2.164h-0.834c-0.414,0-0.808-0.084-1.167-0.237v1.159l-7.396,3.667v2.912h2V17.202zM26.561,18.875v-2.913l-7.396-3.666v-1.158c-0.358,0.152-0.753,0.236-1.166,0.236h-0.832l-0.001,2.164l7.396,3.666v1.672H26.561zM16.688,18.875v-7.501h-2v7.501H16.688zM27.875,19.875H23.25c-1.104,0-2,0.896-2,2V26.5c0,1.104,0.896,2,2,2h4.625c1.104,0,2-0.896,2-2v-4.625C29.875,20.771,28.979,19.875,27.875,19.875zM8.125,19.875H3.5c-1.104,0-2,0.896-2,2V26.5c0,1.104,0.896,2,2,2h4.625c1.104,0,2-0.896,2-2v-4.625C10.125,20.771,9.229,19.875,8.125,19.875zM13.375,10.375H18c1.104,0,2-0.896,2-2V3.75c0-1.104-0.896-2-2-2h-4.625c-1.104,0-2,0.896-2,2v4.625C11.375,9.479,12.271,10.375,13.375,10.375zM18,19.875h-4.625c-1.104,0-2,0.896-2,2V26.5c0,1.104,0.896,2,2,2H18c1.104,0,2-0.896,2-2v-4.625C20,20.771,19.104,19.875,18,19.875z")); | |||
| drawables.add (exporter = createDrawableFromSVGPath (Colours::darkgrey, "M15.067,2.25c-5.979,0-11.035,3.91-12.778,9.309h3.213c1.602-3.705,5.271-6.301,9.565-6.309c5.764,0.01,10.428,4.674,10.437,10.437c-0.009,5.764-4.673,10.428-10.437,10.438c-4.294-0.007-7.964-2.605-9.566-6.311H2.289c1.744,5.399,6.799,9.31,12.779,9.312c7.419-0.002,13.437-6.016,13.438-13.438C28.504,8.265,22.486,2.252,15.067,2.25zM10.918,19.813l7.15-4.126l-7.15-4.129v2.297H-0.057v3.661h10.975V19.813z")); | |||
| drawables.add (jigsaw = createDrawableFromSVGPath (Colours::darkgrey, "M3.739,13.619c0,0,3.516-4.669,5.592-3.642c2.077,1.027-0.414,2.795,1.598,3.719c2.011,0.924,5.048-0.229,4.376-2.899c-0.672-2.67-1.866-0.776-2.798-2.208c-0.934-1.432,4.586-4.59,4.586-4.59s3.361,6.651,4.316,4.911c1.157-2.105,3.193-4.265,5.305-1.025c0,0,1.814,2.412,0.246,3.434s-2.917,0.443-3.506,1.553c-0.586,1.112,3.784,4.093,3.784,4.093s-2.987,4.81-4.926,3.548c-1.939-1.262,0.356-3.364-2.599-3.989c-1.288-0.23-3.438,0.538-3.818,2.34c-0.13,2.709,1.604,2.016,2.797,3.475c1.191,1.457-4.484,4.522-4.484,4.522s-1.584-3.923-3.811-4.657c-2.227-0.735-0.893,2.135-2.917,2.531c-2.024,0.396-4.816-2.399-3.46-4.789c1.358-2.391,3.275-0.044,3.441-1.951C7.629,16.087,3.739,13.619,3.739,13.619z")); | |||
| drawables.add (info = createDrawableFromSVGPath (Colours::yellow.darker(1.0f), "M16,1.466C7.973,1.466,1.466,7.973,1.466,16c0,8.027,6.507,14.534,14.534,14.534c8.027,0,14.534-6.507,14.534-14.534C30.534,7.973,24.027,1.466,16,1.466z M14.757,8h2.42v2.574h-2.42V8z M18.762,23.622H16.1c-1.034,0-1.475-0.44-1.475-1.496v-6.865c0-0.33-0.176-0.484-0.484-0.484h-0.88V12.4h2.662c1.035,0,1.474,0.462,1.474,1.496v6.887c0,0.309,0.176,0.484,0.484,0.484h0.88V23.622z")); | |||
| drawables.add (warning = createDrawableFromSVGPath (Colours::darkred, "M29.225,23.567l-3.778-6.542c-1.139-1.972-3.002-5.2-4.141-7.172l-3.778-6.542c-1.14-1.973-3.003-1.973-4.142,0L9.609,9.853c-1.139,1.972-3.003,5.201-4.142,7.172L1.69,23.567c-1.139,1.974-0.207,3.587,2.071,3.587h23.391C29.432,27.154,30.363,25.541,29.225,23.567zM16.536,24.58h-2.241v-2.151h2.241V24.58zM16.428,20.844h-2.023l-0.201-9.204h2.407L16.428,20.844z")); | |||
| DrawableImage* juceImage = new DrawableImage(); | |||
| juceImage->setImage (ImageCache::getFromMemory (BinaryData::juce_icon_png, BinaryData::juce_icon_pngSize)); | |||
| @@ -96,6 +96,8 @@ public: | |||
| const Drawable* juceLogo; | |||
| const Drawable* graph; | |||
| const Drawable* jigsaw; | |||
| const Drawable* info; | |||
| const Drawable* warning; | |||
| private: | |||
| OwnedArray<Drawable> drawables; | |||