mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Added a method ResizableWindow::setDraggable()
This commit is contained in:
parent
1952ed195e
commit
a73e8d6b80
2 changed files with 20 additions and 6 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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…
Add table
Add a link
Reference in a new issue