Browse Source

Introjucer: added a button for changing the copying mode of all modules. Added support for kiosk mode in iOS.

tags/2021-05-28
jules 13 years ago
parent
commit
16f5684bd9
4 changed files with 232 additions and 297 deletions
  1. +56
    -12
      extras/Introjucer/Source/Project/jucer_ProjectInformationComponent.cpp
  2. +163
    -278
      modules/juce_gui_basics/components/juce_Component.cpp
  3. +4
    -6
      modules/juce_gui_basics/components/juce_Component.h
  4. +9
    -1
      modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm

+ 56
- 12
extras/Introjucer/Source/Project/jucer_ProjectInformationComponent.cpp View File

@@ -393,19 +393,29 @@ public:
};
//==============================================================================
class ModuleCopyingMessage : public Component
class ModuleCopyingInfo : public Component,
public ButtonListener,
public Timer
{
public:
ModuleCopyingMessage (Project& project_, ModuleList& list_)
: project (project_), list (list_)
ModuleCopyingInfo (Project& project_, ModuleList& list_)
: project (project_), list (list_),
copyModeButton ("Set Copying Mode...")
{
addAndMakeVisible (&copyModeButton);
copyModeButton.setBounds ("4, parent.height / 2 - 10, 160, parent.height / 2 + 10");
copyModeButton.addListener (this);
startTimer (1500);
}
void paint (Graphics& g)
{
g.setFont (13.0f);
g.setFont (11.0f);
g.setColour (Colours::darkred);
g.drawFittedText (getName(), 4, 0, getWidth() - 8, getHeight(), Justification::centredRight, 4);
g.drawFittedText (getName(), copyModeButton.getRight() + 10, 0,
getWidth() - copyModeButton.getRight() - 16, getHeight(),
Justification::centredRight, 4);
}
void refresh()
@@ -413,14 +423,18 @@ public:
int numCopied, numNonCopied;
countCopiedModules (numCopied, numNonCopied);
String newName;
if (numCopied > 0 && numNonCopied > 0)
setName ("Warning! Some of your modules are set to use local copies, and others are using remote references.\n"
"This may create problems if some modules expect to share the same parent folder, so you may "
"want to make sure that they are all either copied or not.");
else
setName (String::empty);
newName = "Warning! Some of your modules are set to use local copies, and others are using remote references.\n"
"This may create problems if some modules expect to share the same parent folder, so you may "
"want to make sure that they are all either copied or not.";
repaint();
if (newName != getName())
{
setName (newName);
repaint();
}
}
void countCopiedModules (int& numCopied, int& numNonCopied)
@@ -441,9 +455,39 @@ public:
}
}
void buttonClicked (Button*)
{
PopupMenu menu;
menu.addItem (1, "Enable local copying for all modules");
menu.addItem (2, "Disable local copying for all modules");
menu.showMenuAsync (PopupMenu::Options().withTargetComponent (&copyModeButton),
ModalCallbackFunction::forComponent (copyMenuItemChosen, this));
}
static void copyMenuItemChosen (int resultCode, ModuleCopyingInfo* comp)
{
if (resultCode > 0 && comp != nullptr)
comp->setCopyModeForAllModules (resultCode == 1);
}
void setCopyModeForAllModules (bool copyEnabled)
{
for (int i = list.modules.size(); --i >= 0;)
project.shouldCopyModuleFilesLocally (list.modules.getUnchecked(i)->uid) = copyEnabled;
refresh();
}
void timerCallback()
{
refresh();
}
private:
Project& project;
ModuleList& list;
TextButton copyModeButton;
};
private:
@@ -453,7 +497,7 @@ private:
Label modulesLabel;
TextButton updateModulesButton;
ModuleSelectionListBox moduleListBox;
ModuleCopyingMessage copyingMessage;
ModuleCopyingInfo copyingMessage;
ScopedPointer<ModuleSettingsPanel> settings;
};


+ 163
- 278
modules/juce_gui_basics/components/juce_Component.cpp View File

@@ -89,9 +89,7 @@ public:
}
}
Component* p = comp.parentComponent;
while (p != nullptr)
for (Component* p = comp.parentComponent; p != nullptr; p = p->parentComponent)
{
MouseListenerList* const list = p->mouseListeners;
@@ -109,8 +107,6 @@ public:
i = jmin (i, list->numDeepMouseListeners);
}
}
p = p->parentComponent;
}
}
@@ -134,9 +130,7 @@ public:
}
}
Component* p = comp.parentComponent;
while (p != nullptr)
for (Component* p = comp.parentComponent; p != nullptr; p = p->parentComponent)
{
MouseListenerList* const list = p->mouseListeners;
@@ -154,8 +148,6 @@ public:
i = jmin (i, list->numDeepMouseListeners);
}
}
p = p->parentComponent;
}
}
@@ -336,8 +328,7 @@ struct Component::ComponentHelpers
}
static void subtractObscuredRegions (const Component& comp, RectangleList& result,
const Point<int>& delta,
const Rectangle<int>& clipRect,
const Point<int>& delta, const Rectangle<int>& clipRect,
const Component* const compToAvoid)
{
for (int i = comp.childComponentList.size(); --i >= 0;)
@@ -372,74 +363,6 @@ struct Component::ComponentHelpers
}
};
//==============================================================================
class StandardCachedComponentImage : public CachedComponentImage
{
public:
StandardCachedComponentImage (Component& owner_) noexcept : owner (owner_) {}
void paint (Graphics& g)
{
const Rectangle<int> bounds (owner.getLocalBounds());
if (image.isNull() || image.getBounds() != bounds)
{
image = Image (owner.isOpaque() ? Image::RGB : Image::ARGB,
jmax (1, bounds.getWidth()), jmax (1, bounds.getHeight()), ! owner.isOpaque());
validArea.clear();
}
{
Graphics imG (image);
LowLevelGraphicsContext* const lg = imG.getInternalContext();
for (RectangleList::Iterator i (validArea); i.next();)
lg->excludeClipRectangle (*i.getRectangle());
if (! lg->isClipEmpty())
{
if (! owner.isOpaque())
{
lg->setFill (Colours::transparentBlack);
lg->fillRect (bounds, true);
lg->setFill (Colours::black);
}
owner.paintEntireComponent (imG, true);
}
}
validArea = bounds;
g.setColour (Colours::black.withAlpha (owner.getAlpha()));
g.drawImageAt (image, 0, 0);
}
void invalidateAll()
{
validArea.clear();
}
void invalidate (const Rectangle<int>& area)
{
validArea.subtract (area);
}
void releaseResources()
{
image = Image::null;
}
private:
Image image;
RectangleList validArea;
Component& owner;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (StandardCachedComponentImage);
};
//==============================================================================
Component::Component()
: parentComponent (nullptr),
@@ -564,14 +487,11 @@ void Component::setVisible (bool shouldBeVisible)
}
}
void Component::visibilityChanged()
{
}
void Component::visibilityChanged() {}
void Component::sendVisibilityChangeMessage()
{
BailOutChecker checker (this);
visibilityChanged();
if (! checker.shouldBailOut())
@@ -580,21 +500,14 @@ void Component::sendVisibilityChangeMessage()
bool Component::isShowing() const
{
if (flags.visibleFlag)
{
if (parentComponent != nullptr)
{
return parentComponent->isShowing();
}
else
{
const ComponentPeer* const peer = getPeer();
if (! flags.visibleFlag)
return false;
return peer != nullptr && ! peer->isMinimised();
}
}
if (parentComponent != nullptr)
return parentComponent->isShowing();
return false;
const ComponentPeer* const peer = getPeer();
return peer != nullptr && ! peer->isMinimised();
}
@@ -657,7 +570,6 @@ void Component::addToDesktop (int styleWanted, void* nativeWindowToAttachTo)
oldNonFullScreenBounds = peer->getNonFullScreenBounds();
removeFromDesktop();
setTopLeftPosition (topLeft);
}
@@ -711,10 +623,9 @@ void Component::removeFromDesktop()
if (flags.hasHeavyweightPeerFlag)
{
ComponentPeer* const peer = ComponentPeer::getPeerFor (this);
jassert (peer != nullptr);
flags.hasHeavyweightPeerFlag = false;
jassert (peer != nullptr);
delete peer;
Desktop::getInstance().removeDesktopComponent (this);
@@ -726,6 +637,16 @@ bool Component::isOnDesktop() const noexcept
return flags.hasHeavyweightPeerFlag;
}
ComponentPeer* Component::getPeer() const
{
if (flags.hasHeavyweightPeerFlag)
return ComponentPeer::getPeerFor (this);
else if (parentComponent == nullptr)
return nullptr;
return parentComponent->getPeer();
}
void Component::userTriedToCloseWindow()
{
/* This means that the user's trying to get rid of your window with the 'close window' system
@@ -738,9 +659,7 @@ void Component::userTriedToCloseWindow()
jassertfalse;
}
void Component::minimisationStateChanged (bool)
{
}
void Component::minimisationStateChanged (bool) {}
//==============================================================================
void Component::setOpaque (const bool shouldBeOpaque)
@@ -770,6 +689,61 @@ bool Component::isOpaque() const noexcept
}
//==============================================================================
class StandardCachedComponentImage : public CachedComponentImage
{
public:
StandardCachedComponentImage (Component& owner_) noexcept : owner (owner_) {}
void paint (Graphics& g)
{
const Rectangle<int> bounds (owner.getLocalBounds());
if (image.isNull() || image.getBounds() != bounds)
{
image = Image (owner.isOpaque() ? Image::RGB : Image::ARGB,
jmax (1, bounds.getWidth()), jmax (1, bounds.getHeight()), ! owner.isOpaque());
validArea.clear();
}
{
Graphics imG (image);
LowLevelGraphicsContext* const lg = imG.getInternalContext();
for (RectangleList::Iterator i (validArea); i.next();)
lg->excludeClipRectangle (*i.getRectangle());
if (! lg->isClipEmpty())
{
if (! owner.isOpaque())
{
lg->setFill (Colours::transparentBlack);
lg->fillRect (bounds, true);
lg->setFill (Colours::black);
}
owner.paintEntireComponent (imG, true);
}
}
validArea = bounds;
g.setColour (Colours::black.withAlpha (owner.getAlpha()));
g.drawImageAt (image, 0, 0);
}
void invalidateAll() { validArea.clear(); }
void invalidate (const Rectangle<int>& area) { validArea.subtract (area); }
void releaseResources() { image = Image::null; }
private:
Image image;
RectangleList validArea;
Component& owner;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (StandardCachedComponentImage);
};
void Component::setCachedComponentImage (CachedComponentImage* newCachedImage)
{
cachedImage = newCachedImage;
@@ -795,7 +769,7 @@ void Component::setBufferedToImage (const bool shouldBeBuffered)
}
//==============================================================================
void Component::moveChildInternal (const int sourceIndex, const int destIndex)
void Component::reorderChildInternal (const int sourceIndex, const int destIndex)
{
if (sourceIndex != destIndex)
{
@@ -848,7 +822,7 @@ void Component::toFront (const bool setAsForeground)
--insertIndex;
}
parentComponent->moveChildInternal (index, insertIndex);
parentComponent->reorderChildInternal (index, insertIndex);
}
}
@@ -881,7 +855,7 @@ void Component::toBehind (Component* const other)
if (index < otherIndex)
--otherIndex;
parentComponent->moveChildInternal (index, otherIndex);
parentComponent->reorderChildInternal (index, otherIndex);
}
}
}
@@ -924,7 +898,7 @@ void Component::toBack()
while (insertIndex < childList.size() && ! childList.getUnchecked (insertIndex)->isAlwaysOnTop())
++insertIndex;
parentComponent->moveChildInternal (index, insertIndex);
parentComponent->reorderChildInternal (index, insertIndex);
}
}
}
@@ -970,15 +944,8 @@ bool Component::isAlwaysOnTop() const noexcept
}
//==============================================================================
int Component::proportionOfWidth (const float proportion) const noexcept
{
return roundToInt (proportion * bounds.getWidth());
}
int Component::proportionOfHeight (const float proportion) const noexcept
{
return roundToInt (proportion * bounds.getHeight());
}
int Component::proportionOfWidth (const float proportion) const noexcept { return roundToInt (proportion * bounds.getWidth()); }
int Component::proportionOfHeight (const float proportion) const noexcept { return roundToInt (proportion * bounds.getHeight()); }
int Component::getParentWidth() const noexcept
{
@@ -1018,7 +985,7 @@ Rectangle<int> Component::localAreaToGlobal (const Rectangle<int>& area) const
return ComponentHelpers::convertCoordinate (nullptr, this, area);
}
/* Deprecated methods... */
// Deprecated methods...
Point<int> Component::relativePositionToGlobal (const Point<int>& relativePosition) const
{
return localPointToGlobal (relativePosition);
@@ -1522,7 +1489,6 @@ void Component::deleteAllChildren()
delete (removeChildComponent (childComponentList.size() - 1));
}
//==============================================================================
int Component::getNumChildComponents() const noexcept
{
return childComponentList.size();
@@ -1574,13 +1540,8 @@ bool Component::isParentOf (const Component* possibleChild) const noexcept
}
//==============================================================================
void Component::parentHierarchyChanged()
{
}
void Component::childrenChanged()
{
}
void Component::parentHierarchyChanged() {}
void Component::childrenChanged() {}
void Component::internalChildrenChanged()
{
@@ -1861,6 +1822,19 @@ void Component::internalRepaintUnchecked (const Rectangle<int>& area, const bool
}
}
//==============================================================================
void Component::paint (Graphics&)
{
// all painting is done in the subclasses
jassert (! isOpaque()); // if your component's opaque, you've gotta paint it!
}
void Component::paintOverChildren (Graphics&)
{
// all painting is done in the subclasses
}
//==============================================================================
void Component::paintWithinParentContext (Graphics& g)
{
@@ -2041,16 +2015,13 @@ void Component::setLookAndFeel (LookAndFeel* const newLookAndFeel)
}
}
void Component::lookAndFeelChanged()
{
}
void Component::lookAndFeelChanged() {}
void Component::colourChanged() {}
void Component::sendLookAndFeelChange()
{
repaint();
const WeakReference<Component> safePointer (this);
repaint();
lookAndFeelChanged();
if (safePointer != nullptr)
@@ -2115,10 +2086,6 @@ void Component::copyAllExplicitColoursTo (Component& target) const
target.colourChanged();
}
void Component::colourChanged()
{
}
//==============================================================================
MarkerList* Component::getMarkers (bool /*xAxis*/)
{
@@ -2178,45 +2145,17 @@ void Component::getVisibleArea (RectangleList& result, const bool includeSibling
}
//==============================================================================
void Component::mouseEnter (const MouseEvent&)
{
// base class does nothing
}
void Component::mouseExit (const MouseEvent&)
{
// base class does nothing
}
void Component::mouseDown (const MouseEvent&)
{
// base class does nothing
}
void Component::mouseUp (const MouseEvent&)
{
// base class does nothing
}
void Component::mouseDrag (const MouseEvent&)
{
// base class does nothing
}
void Component::mouseMove (const MouseEvent&)
{
// base class does nothing
}
void Component::mouseDoubleClick (const MouseEvent&)
{
// base class does nothing
}
void Component::mouseEnter (const MouseEvent&) {}
void Component::mouseExit (const MouseEvent&) {}
void Component::mouseDown (const MouseEvent&) {}
void Component::mouseUp (const MouseEvent&) {}
void Component::mouseDrag (const MouseEvent&) {}
void Component::mouseMove (const MouseEvent&) {}
void Component::mouseDoubleClick (const MouseEvent&) {}
void Component::mouseWheelMove (const MouseEvent& e, float wheelIncrementX, float wheelIncrementY)
{
// the base class just passes this event up to its parent..
if (parentComponent != nullptr)
parentComponent->mouseWheelMove (e.getEventRelativeTo (parentComponent),
wheelIncrementX, wheelIncrementY);
@@ -2224,25 +2163,10 @@ void Component::mouseWheelMove (const MouseEvent& e, float wheelIncrementX, floa
//==============================================================================
void Component::resized()
{
// base class does nothing
}
void Component::moved()
{
// base class does nothing
}
void Component::childBoundsChanged (Component*)
{
// base class does nothing
}
void Component::parentSizeChanged()
{
// base class does nothing
}
void Component::resized() {}
void Component::moved() {}
void Component::childBoundsChanged (Component*) {}
void Component::parentSizeChanged() {}
void Component::addComponentListener (ComponentListener* const newListener)
{
@@ -2278,20 +2202,6 @@ void Component::internalModalInputAttempt()
current->inputAttemptWhenModal();
}
//==============================================================================
void Component::paint (Graphics&)
{
// all painting is done in the subclasses
jassert (! isOpaque()); // if your component's opaque, you've gotta paint it!
}
void Component::paintOverChildren (Graphics&)
{
// all painting is done in the subclasses
}
//==============================================================================
void Component::postCommandMessage (const int commandId)
{
@@ -2395,7 +2305,6 @@ void Component::internalMouseExit (MouseInputSource& source, const Point<int>& r
MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseExit, me);
}
//==============================================================================
void Component::internalMouseDown (MouseInputSource& source, const Point<int>& relativePos, const Time& time)
{
Desktop& desktop = Desktop::getInstance();
@@ -2458,7 +2367,6 @@ void Component::internalMouseDown (MouseInputSource& source, const Point<int>& r
MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseDown, me);
}
//==============================================================================
void Component::internalMouseUp (MouseInputSource& source, const Point<int>& relativePos, const Time& time, const ModifierKeys& oldModifiers)
{
BailOutChecker checker (this);
@@ -2590,6 +2498,7 @@ void Component::beginDragAutoRepeat (const int interval)
Desktop::getInstance().beginDragAutoRepeat (interval);
}
//==============================================================================
void Component::broughtToFront()
{
}
@@ -2620,10 +2529,10 @@ void Component::internalBroughtToFront()
// active, and therefore can't receive mouse-clicks
}
void Component::focusGained (FocusChangeType)
{
// base class does nothing
}
//==============================================================================
void Component::focusGained (FocusChangeType) {}
void Component::focusLost (FocusChangeType) {}
void Component::focusOfChildComponentChanged (FocusChangeType) {}
void Component::internalFocusGain (const FocusChangeType cause)
{
@@ -2638,11 +2547,6 @@ void Component::internalFocusGain (const FocusChangeType cause, const WeakRefere
internalChildFocusChange (cause, safePointer);
}
void Component::focusLost (FocusChangeType)
{
// base class does nothing
}
void Component::internalFocusLoss (const FocusChangeType cause)
{
const WeakReference<Component> safePointer (this);
@@ -2653,11 +2557,6 @@ void Component::internalFocusLoss (const FocusChangeType cause)
internalChildFocusChange (cause, safePointer);
}
void Component::focusOfChildComponentChanged (FocusChangeType /*cause*/)
{
// base class does nothing
}
void Component::internalChildFocusChange (FocusChangeType cause, const WeakReference<Component>& safePointer)
{
const bool childIsNowFocused = hasKeyboardFocus (true);
@@ -2676,54 +2575,6 @@ void Component::internalChildFocusChange (FocusChangeType cause, const WeakRefer
parentComponent->internalChildFocusChange (cause, WeakReference<Component> (parentComponent));
}
//==============================================================================
bool Component::isEnabled() const noexcept
{
return (! flags.isDisabledFlag)
&& (parentComponent == nullptr || parentComponent->isEnabled());
}
void Component::setEnabled (const bool shouldBeEnabled)
{
if (flags.isDisabledFlag == shouldBeEnabled)
{
flags.isDisabledFlag = ! shouldBeEnabled;
// if any parent components are disabled, setting our flag won't make a difference,
// so no need to send a change message
if (parentComponent == nullptr || parentComponent->isEnabled())
sendEnablementChangeMessage();
}
}
void Component::sendEnablementChangeMessage()
{
const WeakReference<Component> safePointer (this);
enablementChanged();
if (safePointer == nullptr)
return;
for (int i = getNumChildComponents(); --i >= 0;)
{
Component* const c = getChildComponent (i);
if (c != nullptr)
{
c->sendEnablementChangeMessage();
if (safePointer == nullptr)
return;
}
}
}
void Component::enablementChanged()
{
}
//==============================================================================
void Component::setWantsKeyboardFocus (const bool wantsFocus) noexcept
{
flags.wantsFocusFlag = wantsFocus;
@@ -2916,6 +2767,51 @@ void Component::giveAwayFocus (const bool sendFocusLossEvent)
Desktop::getInstance().triggerFocusCallback();
}
//==============================================================================
bool Component::isEnabled() const noexcept
{
return (! flags.isDisabledFlag)
&& (parentComponent == nullptr || parentComponent->isEnabled());
}
void Component::setEnabled (const bool shouldBeEnabled)
{
if (flags.isDisabledFlag == shouldBeEnabled)
{
flags.isDisabledFlag = ! shouldBeEnabled;
// if any parent components are disabled, setting our flag won't make a difference,
// so no need to send a change message
if (parentComponent == nullptr || parentComponent->isEnabled())
sendEnablementChangeMessage();
}
}
void Component::enablementChanged() {}
void Component::sendEnablementChangeMessage()
{
const WeakReference<Component> safePointer (this);
enablementChanged();
if (safePointer == nullptr)
return;
for (int i = getNumChildComponents(); --i >= 0;)
{
Component* const c = getChildComponent (i);
if (c != nullptr)
{
c->sendEnablementChangeMessage();
if (safePointer == nullptr)
return;
}
}
}
//==============================================================================
bool Component::isMouseOver (const bool includeChildren) const
{
@@ -3015,17 +2911,6 @@ void Component::internalModifierKeysChanged()
modifierKeysChanged (ModifierKeys::getCurrentModifiers());
}
//==============================================================================
ComponentPeer* Component::getPeer() const
{
if (flags.hasHeavyweightPeerFlag)
return ComponentPeer::getPeerFor (this);
else if (parentComponent == nullptr)
return nullptr;
return parentComponent->getPeer();
}
//==============================================================================
Component::BailOutChecker::BailOutChecker (Component* const component)
: safePointer (component)


+ 4
- 6
modules/juce_gui_basics/components/juce_Component.h View File

@@ -792,14 +792,12 @@ public:
TargetClass* findParentComponentOfClass (TargetClass* const dummyParameter = nullptr) const
{
(void) dummyParameter;
Component* p = parentComponent;
while (p != nullptr)
for (Component* p = parentComponent; p != nullptr; p = p->parentComponent)
{
TargetClass* target = dynamic_cast <TargetClass*> (p);
TargetClass* const target = dynamic_cast <TargetClass*> (p);
if (target != nullptr)
return target;
p = p->parentComponent;
}
return nullptr;
@@ -2337,7 +2335,7 @@ private:
void internalRepaint (const Rectangle<int>&);
void internalRepaintUnchecked (const Rectangle<int>&, bool);
Component* removeChildComponent (int index, bool sendParentEvents, bool sendChildEvents);
void moveChildInternal (int sourceIndex, int destIndex);
void reorderChildInternal (int sourceIndex, int destIndex);
void paintComponentAndChildren (Graphics&);
void paintWithinParentContext (Graphics&);
void sendMovedResizedMessages (bool wasMoved, bool wasResized);


+ 9
- 1
modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm View File

@@ -915,7 +915,15 @@ void UIViewComponentPeer::redirectMovedOrResized()
//==============================================================================
void Desktop::setKioskComponent (Component* kioskModeComponent, bool enableOrDisable, bool allowMenusAndBars)
{
// TODO
[[UIApplication sharedApplication] setStatusBarHidden: enableOrDisable
withAnimation: UIStatusBarAnimationSlide];
Desktop::getInstance().refreshMonitorSizes();
ComponentPeer* const peer = kioskModeComponent->getPeer();
if (peer != nullptr)
peer->setFullScreen (enableOrDisable);
}
//==============================================================================


Loading…
Cancel
Save