Add remaining files
[juce-lv2.git] / juce / source / src / gui / components / layout / juce_StretchableLayoutResizerBar.cpp
blob0bf20434529ecda9984872ead0f52d29ba7a2b9f
1 /*
2 ==============================================================================
4 This file is part of the JUCE library - "Jules' Utility Class Extensions"
5 Copyright 2004-11 by Raw Material Software Ltd.
7 ------------------------------------------------------------------------------
9 JUCE can be redistributed and/or modified under the terms of the GNU General
10 Public License (Version 2), as published by the Free Software Foundation.
11 A copy of the license is included in the JUCE distribution, or can be found
12 online at www.gnu.org/licenses.
14 JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 ------------------------------------------------------------------------------
20 To release a closed-source product which uses JUCE, commercial licenses are
21 available: visit www.rawmaterialsoftware.com/juce for more information.
23 ==============================================================================
26 #include "../../../core/juce_StandardHeader.h"
28 BEGIN_JUCE_NAMESPACE
30 #include "juce_StretchableLayoutResizerBar.h"
31 #include "../lookandfeel/juce_LookAndFeel.h"
34 //==============================================================================
35 StretchableLayoutResizerBar::StretchableLayoutResizerBar (StretchableLayoutManager* layout_,
36 const int itemIndex_,
37 const bool isVertical_)
38 : layout (layout_),
39 itemIndex (itemIndex_),
40 isVertical (isVertical_)
42 setRepaintsOnMouseActivity (true);
43 setMouseCursor (MouseCursor (isVertical_ ? MouseCursor::LeftRightResizeCursor
44 : MouseCursor::UpDownResizeCursor));
47 StretchableLayoutResizerBar::~StretchableLayoutResizerBar()
51 //==============================================================================
52 void StretchableLayoutResizerBar::paint (Graphics& g)
54 getLookAndFeel().drawStretchableLayoutResizerBar (g,
55 getWidth(), getHeight(),
56 isVertical,
57 isMouseOver(),
58 isMouseButtonDown());
61 void StretchableLayoutResizerBar::mouseDown (const MouseEvent&)
63 mouseDownPos = layout->getItemCurrentPosition (itemIndex);
66 void StretchableLayoutResizerBar::mouseDrag (const MouseEvent& e)
68 const int desiredPos = mouseDownPos + (isVertical ? e.getDistanceFromDragStartX()
69 : e.getDistanceFromDragStartY());
72 if (layout->getItemCurrentPosition (itemIndex) != desiredPos)
74 layout->setItemPosition (itemIndex, desiredPos);
75 hasBeenMoved();
79 void StretchableLayoutResizerBar::hasBeenMoved()
81 if (getParentComponent() != nullptr)
82 getParentComponent()->resized();
85 END_JUCE_NAMESPACE