Browse Source

Added a callback method to FileBrowserListener.

tags/2021-05-28
Julian Storer 13 years ago
parent
commit
89455b18cb
9 changed files with 76 additions and 88 deletions
  1. +16
    -16
      modules/juce_gui_basics/components/juce_Component.h
  2. +5
    -5
      modules/juce_gui_basics/components/juce_Desktop.h
  3. +3
    -3
      modules/juce_gui_basics/components/juce_ModalComponentManager.h
  4. +11
    -0
      modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp
  5. +11
    -9
      modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.h
  6. +3
    -0
      modules/juce_gui_basics/filebrowser/juce_FileBrowserListener.h
  7. +3
    -4
      modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.cpp
  8. +5
    -3
      modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.h
  9. +19
    -48
      modules/juce_gui_basics/keyboard/juce_TextEditorKeyMapper.h

+ 16
- 16
modules/juce_gui_basics/components/juce_Component.h View File

@@ -2294,32 +2294,32 @@ private:
uint8 componentTransparency;
//==============================================================================
void internalMouseEnter (MouseInputSource& source, const Point<int>& relativePos, const Time& time);
void internalMouseExit (MouseInputSource& source, const Point<int>& relativePos, const Time& time);
void internalMouseDown (MouseInputSource& source, const Point<int>& relativePos, const Time& time);
void internalMouseUp (MouseInputSource& source, const Point<int>& relativePos, const Time& time, const ModifierKeys& oldModifiers);
void internalMouseDrag (MouseInputSource& source, const Point<int>& relativePos, const Time& time);
void internalMouseMove (MouseInputSource& source, const Point<int>& relativePos, const Time& time);
void internalMouseWheel (MouseInputSource& source, const Point<int>& relativePos, const Time& time, float amountX, float amountY);
void internalMouseEnter (MouseInputSource&, const Point<int>&, const Time&);
void internalMouseExit (MouseInputSource&, const Point<int>&, const Time&);
void internalMouseDown (MouseInputSource&, const Point<int>&, const Time&);
void internalMouseUp (MouseInputSource&, const Point<int>&, const Time&, const ModifierKeys& oldModifiers);
void internalMouseDrag (MouseInputSource&, const Point<int>&, const Time&);
void internalMouseMove (MouseInputSource&, const Point<int>&, const Time&);
void internalMouseWheel (MouseInputSource&, const Point<int>&, const Time&, float amountX, float amountY);
void internalBroughtToFront();
void internalFocusGain (const FocusChangeType cause, const WeakReference<Component>&);
void internalFocusGain (const FocusChangeType cause);
void internalFocusLoss (const FocusChangeType cause);
void internalChildFocusChange (FocusChangeType cause, const WeakReference<Component>&);
void internalFocusGain (const FocusChangeType, const WeakReference<Component>&);
void internalFocusGain (const FocusChangeType);
void internalFocusLoss (const FocusChangeType);
void internalChildFocusChange (FocusChangeType, const WeakReference<Component>&);
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();


+ 5
- 5
modules/juce_gui_basics/components/juce_Desktop.h View File

@@ -391,13 +391,13 @@ private:
int getNumDisplayMonitors() const noexcept;
const Rectangle<int> getDisplayMonitorCoordinates (int index, bool clippedToWorkArea) const noexcept;
static void getCurrentMonitorPositions (Array <Rectangle<int> >& monitorCoords, const bool clipToWorkArea);
static void getCurrentMonitorPositions (Array <Rectangle<int> >&, 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();


+ 3
- 3
modules/juce_gui_basics/components/juce_ModalComponentManager.h View File

@@ -139,9 +139,9 @@ private:
friend class OwnedArray <ModalItem>;
OwnedArray <ModalItem> 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);
};


+ 11
- 0
modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp View File

@@ -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;


+ 11
- 9
modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.h View File

@@ -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;


+ 3
- 0
modules/juce_gui_basics/filebrowser/juce_FileBrowserListener.h View File

@@ -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;
};


+ 3
- 4
modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.cpp View File

@@ -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)


+ 5
- 3
modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.h View File

@@ -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;


+ 19
- 48
modules/juce_gui_basics/keyboard/juce_TextEditorKeyMapper.h View File

@@ -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();


Loading…
Cancel
Save