Browse Source

Added a method ResizableWindow::setDraggable()

tags/2021-05-28
jules 10 years ago
parent
commit
a73e8d6b80
2 changed files with 20 additions and 6 deletions
  1. +9
    -1
      modules/juce_gui_basics/windows/juce_ResizableWindow.cpp
  2. +11
    -5
      modules/juce_gui_basics/windows/juce_ResizableWindow.h

+ 9
- 1
modules/juce_gui_basics/windows/juce_ResizableWindow.cpp View File

@@ -27,6 +27,7 @@ ResizableWindow::ResizableWindow (const String& name, bool shouldAddToDesktop)
ownsContentComponent (false),
resizeToFitContent (false),
fullscreen (false),
canDrag (true),
dragStarted (false),
constrainer (nullptr)
#if JUCE_DEBUG
@@ -41,6 +42,8 @@ ResizableWindow::ResizableWindow (const String& name, Colour bkgnd, bool shouldA
ownsContentComponent (false),
resizeToFitContent (false),
fullscreen (false),
canDrag (true),
dragStarted (false),
constrainer (nullptr)
#if JUCE_DEBUG
, hasBeenResized (false)
@@ -314,6 +317,11 @@ void ResizableWindow::setResizeLimits (const int newMinimumWidth,
setBoundsConstrained (getBounds());
}
void ResizableWindow::setDraggable (bool shouldBeDraggable) noexcept
{
canDrag = shouldBeDraggable;
}
void ResizableWindow::setConstrainer (ComponentBoundsConstrainer* newConstrainer)
{
if (constrainer != newConstrainer)
@@ -571,7 +579,7 @@ bool ResizableWindow::restoreWindowStateFromString (const String& s)
//==============================================================================
void ResizableWindow::mouseDown (const MouseEvent& e)
{
if (! isFullScreen())
if (canDrag && ! isFullScreen())
{
dragStarted = true;
dragger.startDraggingComponent (this, e);


+ 11
- 5
modules/juce_gui_basics/windows/juce_ResizableWindow.h View File

@@ -140,6 +140,12 @@ public:
int newMaximumWidth,
int newMaximumHeight) noexcept;
/** Can be used to enable or disable user-dragging of the window. */
void setDraggable (bool shouldBeDraggable) noexcept;
/** Returns true if the window can be dragged around by the user. */
bool isDraggable() const noexcept { return canDrag; }
/** Returns the bounds constrainer object that this window is using.
You can access this to change its properties.
*/
@@ -370,20 +376,20 @@ protected:
void addAndMakeVisible (Component*, int zOrder = -1);
#endif
ScopedPointer <ResizableCornerComponent> resizableCorner;
ScopedPointer <ResizableBorderComponent> resizableBorder;
ScopedPointer<ResizableCornerComponent> resizableCorner;
ScopedPointer<ResizableBorderComponent> resizableBorder;
private:
//==============================================================================
Component::SafePointer<Component> contentComponent;
bool ownsContentComponent, resizeToFitContent, fullscreen, dragStarted;
bool ownsContentComponent, resizeToFitContent, fullscreen, canDrag, dragStarted;
ComponentDragger dragger;
Rectangle<int> lastNonFullScreenPos;
ComponentBoundsConstrainer defaultConstrainer;
ComponentBoundsConstrainer* constrainer;
#if JUCE_DEBUG
#if JUCE_DEBUG
bool hasBeenResized;
#endif
#endif
void initialise (bool addToDesktop);
void updateLastPosIfNotFullScreen();


Loading…
Cancel
Save