diff --git a/modules/juce_gui_basics/components/juce_Component.h b/modules/juce_gui_basics/components/juce_Component.h index 4cb4288bc9..27b753d11c 100644 --- a/modules/juce_gui_basics/components/juce_Component.h +++ b/modules/juce_gui_basics/components/juce_Component.h @@ -2294,32 +2294,32 @@ private: uint8 componentTransparency; //============================================================================== - void internalMouseEnter (MouseInputSource& source, const Point& relativePos, const Time& time); - void internalMouseExit (MouseInputSource& source, const Point& relativePos, const Time& time); - void internalMouseDown (MouseInputSource& source, const Point& relativePos, const Time& time); - void internalMouseUp (MouseInputSource& source, const Point& relativePos, const Time& time, const ModifierKeys& oldModifiers); - void internalMouseDrag (MouseInputSource& source, const Point& relativePos, const Time& time); - void internalMouseMove (MouseInputSource& source, const Point& relativePos, const Time& time); - void internalMouseWheel (MouseInputSource& source, const Point& relativePos, const Time& time, float amountX, float amountY); + void internalMouseEnter (MouseInputSource&, const Point&, const Time&); + void internalMouseExit (MouseInputSource&, const Point&, const Time&); + void internalMouseDown (MouseInputSource&, const Point&, const Time&); + void internalMouseUp (MouseInputSource&, const Point&, const Time&, const ModifierKeys& oldModifiers); + void internalMouseDrag (MouseInputSource&, const Point&, const Time&); + void internalMouseMove (MouseInputSource&, const Point&, const Time&); + void internalMouseWheel (MouseInputSource&, const Point&, const Time&, float amountX, float amountY); void internalBroughtToFront(); - void internalFocusGain (const FocusChangeType cause, const WeakReference&); - void internalFocusGain (const FocusChangeType cause); - void internalFocusLoss (const FocusChangeType cause); - void internalChildFocusChange (FocusChangeType cause, const WeakReference&); + void internalFocusGain (const FocusChangeType, const WeakReference&); + void internalFocusGain (const FocusChangeType); + void internalFocusLoss (const FocusChangeType); + void internalChildFocusChange (FocusChangeType, const WeakReference&); void internalModalInputAttempt(); void internalModifierKeysChanged(); void internalChildrenChanged(); void internalHierarchyChanged(); Component* removeChildComponent (int index, bool sendParentEvents, bool sendChildEvents); void moveChildInternal (int sourceIndex, int destIndex); - void paintComponentAndChildren (Graphics& g); - void paintComponent (Graphics& g); - void paintWithinParentContext (Graphics& g); + void paintComponentAndChildren (Graphics&); + void paintComponent (Graphics&); + void paintWithinParentContext (Graphics&); void sendMovedResizedMessages (bool wasMoved, bool wasResized); void repaintParent(); void sendFakeMouseMove() const; - void takeKeyboardFocus (const FocusChangeType cause); - void grabFocusInternal (const FocusChangeType cause, bool canTryParent = true); + void takeKeyboardFocus (const FocusChangeType); + void grabFocusInternal (const FocusChangeType, bool canTryParent = true); static void giveAwayFocus (bool sendFocusLossEvent); void sendEnablementChangeMessage(); void sendVisibilityChangeMessage(); diff --git a/modules/juce_gui_basics/components/juce_Desktop.h b/modules/juce_gui_basics/components/juce_Desktop.h index ee5fd3b50b..48f990d70b 100644 --- a/modules/juce_gui_basics/components/juce_Desktop.h +++ b/modules/juce_gui_basics/components/juce_Desktop.h @@ -391,13 +391,13 @@ private: int getNumDisplayMonitors() const noexcept; const Rectangle getDisplayMonitorCoordinates (int index, bool clippedToWorkArea) const noexcept; - static void getCurrentMonitorPositions (Array >& monitorCoords, const bool clipToWorkArea); + static void getCurrentMonitorPositions (Array >&, const bool clipToWorkArea); - void addDesktopComponent (Component* c); - void removeDesktopComponent (Component* c); - void componentBroughtToFront (Component* c); + void addDesktopComponent (Component*); + void removeDesktopComponent (Component*); + void componentBroughtToFront (Component*); - static void setKioskComponent (Component* kioskModeComponent, bool enableOrDisable, bool allowMenusAndBars); + static void setKioskComponent (Component*, bool enableOrDisable, bool allowMenusAndBars); void triggerFocusCallback(); void handleAsyncUpdate(); diff --git a/modules/juce_gui_basics/components/juce_ModalComponentManager.h b/modules/juce_gui_basics/components/juce_ModalComponentManager.h index 54c4632a93..c76019f4cf 100644 --- a/modules/juce_gui_basics/components/juce_ModalComponentManager.h +++ b/modules/juce_gui_basics/components/juce_ModalComponentManager.h @@ -139,9 +139,9 @@ private: friend class OwnedArray ; OwnedArray stack; - void startModal (Component* component); - void endModal (Component* component, int returnValue); - void endModal (Component* component); + void startModal (Component*); + void endModal (Component*, int returnValue); + void endModal (Component*); JUCE_DECLARE_NON_COPYABLE (ModalComponentManager); }; diff --git a/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp b/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp index b426b0ff91..9558d23d31 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp +++ b/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp @@ -205,8 +205,11 @@ const File& FileBrowserComponent::getRoot() const void FileBrowserComponent::setRoot (const File& newRootDirectory) { + bool callListeners = false; + if (currentRoot != newRootDirectory) { + callListeners = true; fileListComponent->scrollToTop(); String path (newRootDirectory.getFullPathName()); @@ -246,6 +249,12 @@ void FileBrowserComponent::setRoot (const File& newRootDirectory) goUpButton->setEnabled (currentRoot.getParentDirectory().isDirectory() && currentRoot.getParentDirectory() != currentRoot); + + if (callListeners) + { + Component::BailOutChecker checker (this); + listeners.callChecked (checker, &FileBrowserListener::browserRootChanged, currentRoot); + } } void FileBrowserComponent::resetRecentPaths() @@ -367,6 +376,8 @@ void FileBrowserComponent::fileDoubleClicked (const File& f) } } +void FileBrowserComponent::browserRootChanged (const File&) {} + bool FileBrowserComponent::keyPressed (const KeyPress& key) { (void) key; diff --git a/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.h b/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.h index 330f9d8712..614f74e4cb 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.h +++ b/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.h @@ -177,27 +177,29 @@ public: /** @internal */ void resized(); /** @internal */ - void buttonClicked (Button* b); + void buttonClicked (Button*); /** @internal */ void comboBoxChanged (ComboBox*); /** @internal */ - void textEditorTextChanged (TextEditor& editor); + void textEditorTextChanged (TextEditor&); /** @internal */ - void textEditorReturnKeyPressed (TextEditor& editor); + void textEditorReturnKeyPressed (TextEditor&); /** @internal */ - void textEditorEscapeKeyPressed (TextEditor& editor); + void textEditorEscapeKeyPressed (TextEditor&); /** @internal */ - void textEditorFocusLost (TextEditor& editor); + void textEditorFocusLost (TextEditor&); /** @internal */ - bool keyPressed (const KeyPress& key); + bool keyPressed (const KeyPress&); /** @internal */ void selectionChanged(); /** @internal */ - void fileClicked (const File& f, const MouseEvent& e); + void fileClicked (const File&, const MouseEvent&); /** @internal */ - void fileDoubleClicked (const File& f); + void fileDoubleClicked (const File&); /** @internal */ - bool isFileSuitable (const File& file) const; + void browserRootChanged (const File&); + /** @internal */ + bool isFileSuitable (const File&) const; /** @internal */ bool isDirectorySuitable (const File&) const; diff --git a/modules/juce_gui_basics/filebrowser/juce_FileBrowserListener.h b/modules/juce_gui_basics/filebrowser/juce_FileBrowserListener.h index 23d979e0b1..ad26be4fbd 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileBrowserListener.h +++ b/modules/juce_gui_basics/filebrowser/juce_FileBrowserListener.h @@ -51,6 +51,9 @@ public: /** Callback when the user double-clicks on a file in the browser. */ virtual void fileDoubleClicked (const File& file) = 0; + + /** Callback when the browser's root folder changes. */ + virtual void browserRootChanged (const File& newRoot) = 0; }; diff --git a/modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.cpp b/modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.cpp index 62f6c3cdf8..89b6fe86a8 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.cpp +++ b/modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.cpp @@ -190,16 +190,15 @@ void FileChooserDialogBox::selectionChanged() && content->chooserComponent.getRoot().isDirectory()); } -void FileChooserDialogBox::fileClicked (const File&, const MouseEvent&) -{ -} - void FileChooserDialogBox::fileDoubleClicked (const File&) { selectionChanged(); content->okButton.triggerClick(); } +void FileChooserDialogBox::fileClicked (const File&, const MouseEvent&) {} +void FileChooserDialogBox::browserRootChanged (const File&) {} + void FileChooserDialogBox::okToOverwriteFileCallback (int result, FileChooserDialogBox* box) { if (result != 0 && box != nullptr) diff --git a/modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.h b/modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.h index 11bd4ca4e7..4a3bba7e0b 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.h +++ b/modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.h @@ -138,15 +138,17 @@ public: //============================================================================== /** @internal */ - void buttonClicked (Button* button); + void buttonClicked (Button*); /** @internal */ void closeButtonPressed(); /** @internal */ void selectionChanged(); /** @internal */ - void fileClicked (const File& file, const MouseEvent& e); + void fileClicked (const File&, const MouseEvent&); /** @internal */ - void fileDoubleClicked (const File& file); + void fileDoubleClicked (const File&); + /** @internal */ + void browserRootChanged (const File&); private: class ContentComponent; diff --git a/modules/juce_gui_basics/keyboard/juce_TextEditorKeyMapper.h b/modules/juce_gui_basics/keyboard/juce_TextEditorKeyMapper.h index e8bacae01a..88ddbab7f5 100644 --- a/modules/juce_gui_basics/keyboard/juce_TextEditorKeyMapper.h +++ b/modules/juce_gui_basics/keyboard/juce_TextEditorKeyMapper.h @@ -43,59 +43,33 @@ struct TextEditorKeyMapper */ static bool invokeKeyFunction (CallbackClass& target, const KeyPress& key) { - const bool isShiftDown = key.getModifiers().isShiftDown(); + const bool isShiftDown = key.getModifiers().isShiftDown(); const bool ctrlOrAltDown = key.getModifiers().isCtrlDown() || key.getModifiers().isAltDown(); - if (key == KeyPress (KeyPress::downKey, ModifierKeys::ctrlModifier, 0) - && target.scrollUp()) - return true; - - if (key == KeyPress (KeyPress::upKey, ModifierKeys::ctrlModifier, 0) - && target.scrollDown()) - return true; + if (key == KeyPress (KeyPress::downKey, ModifierKeys::ctrlModifier, 0) && target.scrollUp()) return true; + if (key == KeyPress (KeyPress::upKey, ModifierKeys::ctrlModifier, 0) && target.scrollDown()) return true; #if JUCE_MAC if (key.getModifiers().isCommandDown()) { - if (key.isKeyCode (KeyPress::upKey)) - return target.moveCaretToTop (isShiftDown); - - if (key.isKeyCode (KeyPress::downKey)) - return target.moveCaretToEnd (isShiftDown); - - if (key.isKeyCode (KeyPress::leftKey)) - return target.moveCaretToStartOfLine (isShiftDown); - - if (key.isKeyCode (KeyPress::rightKey)) - return target.moveCaretToEndOfLine (isShiftDown); + if (key.isKeyCode (KeyPress::upKey)) return target.moveCaretToTop (isShiftDown); + if (key.isKeyCode (KeyPress::downKey)) return target.moveCaretToEnd (isShiftDown); + if (key.isKeyCode (KeyPress::leftKey)) return target.moveCaretToStartOfLine (isShiftDown); + if (key.isKeyCode (KeyPress::rightKey)) return target.moveCaretToEndOfLine (isShiftDown); } #endif - if (key.isKeyCode (KeyPress::upKey)) - return target.moveCaretUp (isShiftDown); - - if (key.isKeyCode (KeyPress::downKey)) - return target.moveCaretDown (isShiftDown); - - if (key.isKeyCode (KeyPress::leftKey)) - return target.moveCaretLeft (ctrlOrAltDown, isShiftDown); + if (key.isKeyCode (KeyPress::upKey)) return target.moveCaretUp (isShiftDown); + if (key.isKeyCode (KeyPress::downKey)) return target.moveCaretDown (isShiftDown); + if (key.isKeyCode (KeyPress::leftKey)) return target.moveCaretLeft (ctrlOrAltDown, isShiftDown); + if (key.isKeyCode (KeyPress::rightKey)) return target.moveCaretRight (ctrlOrAltDown, isShiftDown); + if (key.isKeyCode (KeyPress::pageUpKey)) return target.pageUp (isShiftDown); + if (key.isKeyCode (KeyPress::pageDownKey)) return target.pageDown (isShiftDown); - if (key.isKeyCode (KeyPress::rightKey)) - return target.moveCaretRight (ctrlOrAltDown, isShiftDown); - - if (key.isKeyCode (KeyPress::pageUpKey)) - return target.pageUp (isShiftDown); - - if (key.isKeyCode (KeyPress::pageDownKey)) - return target.pageDown (isShiftDown); - - if (key.isKeyCode (KeyPress::homeKey)) - return ctrlOrAltDown ? target.moveCaretToTop (isShiftDown) - : target.moveCaretToStartOfLine (isShiftDown); - - if (key.isKeyCode (KeyPress::endKey)) - return ctrlOrAltDown ? target.moveCaretToEnd (isShiftDown) - : target.moveCaretToEndOfLine (isShiftDown); + if (key.isKeyCode (KeyPress::homeKey)) return ctrlOrAltDown ? target.moveCaretToTop (isShiftDown) + : target.moveCaretToStartOfLine (isShiftDown); + if (key.isKeyCode (KeyPress::endKey)) return ctrlOrAltDown ? target.moveCaretToEnd (isShiftDown) + : target.moveCaretToEndOfLine (isShiftDown); if (key == KeyPress ('c', ModifierKeys::commandModifier, 0) || key == KeyPress (KeyPress::insertKey, ModifierKeys::ctrlModifier, 0)) @@ -109,11 +83,8 @@ struct TextEditorKeyMapper || key == KeyPress (KeyPress::insertKey, ModifierKeys::shiftModifier, 0)) return target.pasteFromClipboard(); - if (key.isKeyCode (KeyPress::backspaceKey)) - return target.deleteBackwards (ctrlOrAltDown); - - if (key.isKeyCode (KeyPress::deleteKey)) - return target.deleteForwards (ctrlOrAltDown); + if (key.isKeyCode (KeyPress::backspaceKey)) return target.deleteBackwards (ctrlOrAltDown); + if (key.isKeyCode (KeyPress::deleteKey)) return target.deleteForwards (ctrlOrAltDown); if (key == KeyPress ('a', ModifierKeys::commandModifier, 0)) return target.selectAll();