Browse Source

Fix for osx10.5 window resizing. Misc Jucer tweaks.

tags/2021-05-28
Julian Storer 15 years ago
parent
commit
1577be257c
6 changed files with 52 additions and 10 deletions
  1. +3
    -1
      extras/Jucer (experimental)/Source/Project/jucer_TreeViewTypes.h
  2. +38
    -2
      extras/Jucer (experimental)/Source/Utility/jucer_JucerTreeViewBase.cpp
  3. +3
    -1
      extras/Jucer (experimental)/Source/Utility/jucer_JucerTreeViewBase.h
  4. +4
    -3
      juce_amalgamated.cpp
  5. +2
    -2
      src/gui/components/menus/juce_PopupMenu.cpp
  6. +2
    -1
      src/native/mac/juce_mac_NSViewComponentPeer.mm

+ 3
- 1
extras/Jucer (experimental)/Source/Project/jucer_TreeViewTypes.h View File

@@ -36,9 +36,10 @@ public:
SourceFileTreeViewItem (const Project::Item& item);
~SourceFileTreeViewItem();
bool acceptsFileDrop (const StringArray& files) const { return false; }
bool acceptsFileDrop (const StringArray& files) const { return false; }
bool acceptsDragItems (const OwnedArray <Project::Item>& selectedNodes) { return false; }
ProjectTreeViewBase* createSubItem (const Project::Item& child);
void createLeftEdgeComponents (Array<Component*>& components) {}
void showDocument();
void showPopupMenu();
const String getDisplayName() const;
@@ -58,6 +59,7 @@ public:
void checkFileStatus();
void moveSelectedItemsTo (OwnedArray <Project::Item>& selectedNodes, int insertIndex);
ProjectTreeViewBase* createSubItem (const Project::Item& child);
void createLeftEdgeComponents (Array<Component*>& components) {}
void showDocument();
void showPopupMenu();


+ 38
- 2
extras/Jucer (experimental)/Source/Utility/jucer_JucerTreeViewBase.cpp View File

@@ -28,6 +28,7 @@
//==============================================================================
JucerTreeViewBase::JucerTreeViewBase()
: numLeftHandComps (0)
{
setLinesDrawnForSubItems (false);
}
@@ -43,7 +44,7 @@ const Font JucerTreeViewBase::getFont() const
int JucerTreeViewBase::getTextX() const
{
return getItemHeight() + 6;
return (numLeftHandComps + 1) * getItemHeight() + 8;
}
void JucerTreeViewBase::paintItem (Graphics& g, int width, int height)
@@ -55,7 +56,7 @@ void JucerTreeViewBase::paintItem (Graphics& g, int width, int height)
g.setColour (isMissing() ? Colours::red : Colours::black);
g.drawImageWithin (getIcon(), 2, 2, x - 4, height - 4,
g.drawImageWithin (getIcon(), 0, 2, height + 6, height - 4,
RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize,
false);
@@ -76,6 +77,41 @@ void JucerTreeViewBase::paintOpenCloseButton (Graphics& g, int width, int height
g.fillPath (p);
}
//==============================================================================
class TreeLeftHandButtonHolderComponent : public Component
{
public:
TreeLeftHandButtonHolderComponent (const Array<Component*>& comps)
{
components.addArray (comps);
setInterceptsMouseClicks (false, true);
for (int i = 0; i < comps.size(); ++i)
addAndMakeVisible (comps.getUnchecked(i));
}
void resized()
{
const int edge = 1;
const int itemSize = getHeight() - edge * 2;
for (int i = 0; i < components.size(); ++i)
components.getUnchecked(i)->setBounds (5 + (i + 1) * getHeight(), edge, itemSize, itemSize);
}
private:
OwnedArray<Component> components;
};
Component* JucerTreeViewBase::createItemComponent()
{
Array<Component*> components;
createLeftEdgeComponents (components);
numLeftHandComps = components.size();
return numLeftHandComps == 0 ? 0 : new TreeLeftHandButtonHolderComponent (components);
}
//==============================================================================
void JucerTreeViewBase::showRenameBox()
{


+ 3
- 1
extras/Jucer (experimental)/Source/Utility/jucer_JucerTreeViewBase.h View File

@@ -42,10 +42,10 @@ public:
//==============================================================================
int getItemWidth() const { return -1; }
int getItemHeight() const { return 20; }
Component* createItemComponent() { return 0; }
void paintItem (Graphics& g, int width, int height);
void paintOpenCloseButton (Graphics& g, int width, int height, bool isMouseOver);
Component* createItemComponent();
//==============================================================================
virtual const String getRenamingName() const = 0;
@@ -53,6 +53,7 @@ public:
virtual void setName (const String& newName) = 0;
virtual bool isMissing() = 0;
virtual const Image getIcon() const = 0;
virtual void createLeftEdgeComponents (Array<Component*>& components) = 0;
virtual void showRenameBox();
@@ -64,6 +65,7 @@ public:
//==============================================================================
private:
int numLeftHandComps;
const Font getFont() const;
int getTextX() const;
};


+ 4
- 3
juce_amalgamated.cpp View File

@@ -70558,14 +70558,14 @@ int PopupMenu::showMenu (const Rectangle<int>& target,
if (callback->component == 0)
return 0;

callbackDeleter.release();

callback->component->enterModalState (false, userCallbackDeleter.release());
callback->component->toFront (false); // need to do this after making it modal, or it could
// be stuck behind other comps that are already modal..

ModalComponentManager::getInstance()->attachCallback (callback->component, callback);

callbackDeleter.release();

if (userCallback != 0)
return 0;

@@ -273245,7 +273245,8 @@ NSRect NSViewComponentPeer::constrainRect (NSRect r)
#if defined (MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MIN_ALLOWED >= MAC_OS_X_VERSION_10_6
if ([window inLiveResize])
#else
if ([window performSelector: @selector (inLiveResize)])
if ([window respondsToSelector: @selector (inLiveResize)]
&& [window performSelector: @selector (inLiveResize)])
#endif
{
constrainer->checkBounds (pos, original,


+ 2
- 2
src/gui/components/menus/juce_PopupMenu.cpp View File

@@ -1546,14 +1546,14 @@ int PopupMenu::showMenu (const Rectangle<int>& target,
if (callback->component == 0)
return 0;
callbackDeleter.release();
callback->component->enterModalState (false, userCallbackDeleter.release());
callback->component->toFront (false); // need to do this after making it modal, or it could
// be stuck behind other comps that are already modal..
ModalComponentManager::getInstance()->attachCallback (callback->component, callback);
callbackDeleter.release();
if (userCallback != 0)
return 0;


+ 2
- 1
src/native/mac/juce_mac_NSViewComponentPeer.mm View File

@@ -1075,7 +1075,8 @@ NSRect NSViewComponentPeer::constrainRect (NSRect r)
#if defined (MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MIN_ALLOWED >= MAC_OS_X_VERSION_10_6
if ([window inLiveResize])
#else
if ([window performSelector: @selector (inLiveResize)])
if ([window respondsToSelector: @selector (inLiveResize)]
&& [window performSelector: @selector (inLiveResize)])
#endif
{
constrainer->checkBounds (pos, original,


Loading…
Cancel
Save