Cleanup ResizeHandle code
Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
parent
e226cbe101
commit
fed5823bc7
1 changed files with 7 additions and 32 deletions
|
|
@ -39,6 +39,7 @@ public:
|
||||||
explicit ResizeHandle(TopLevelWidget* const tlw)
|
explicit ResizeHandle(TopLevelWidget* const tlw)
|
||||||
: TopLevelWidget(tlw->getWindow()),
|
: TopLevelWidget(tlw->getWindow()),
|
||||||
handleSize(16),
|
handleSize(16),
|
||||||
|
hasCursor(false),
|
||||||
isResizing(false)
|
isResizing(false)
|
||||||
{
|
{
|
||||||
resetArea();
|
resetArea();
|
||||||
|
|
@ -120,7 +121,6 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Rectangle<uint> area;
|
Rectangle<uint> area;
|
||||||
Line<double> l1, l2, l3;
|
|
||||||
uint handleSize;
|
uint handleSize;
|
||||||
|
|
||||||
// event handling state
|
// event handling state
|
||||||
|
|
@ -130,48 +130,23 @@ private:
|
||||||
|
|
||||||
void recheckCursor(const Point<double>& pos)
|
void recheckCursor(const Point<double>& pos)
|
||||||
{
|
{
|
||||||
const bool shouldSetCursor = area.contains(pos);
|
const bool shouldHaveCursor = area.contains(pos);
|
||||||
|
|
||||||
if (shouldSetCursor == hasCursor)
|
if (shouldHaveCursor == hasCursor)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
hasCursor = shouldSetCursor;
|
hasCursor = shouldHaveCursor;
|
||||||
setCursor(shouldSetCursor ? kMouseCursorDiagonal : kMouseCursorArrow);
|
setCursor(shouldHaveCursor ? kMouseCursorDiagonal : kMouseCursorArrow);
|
||||||
}
|
}
|
||||||
|
|
||||||
void resetArea()
|
void resetArea()
|
||||||
{
|
{
|
||||||
const double scaleFactor = getScaleFactor();
|
const double scaleFactor = getScaleFactor();
|
||||||
const uint margin = 0.0 * scaleFactor;
|
|
||||||
const uint size = handleSize * scaleFactor;
|
const uint size = handleSize * scaleFactor;
|
||||||
|
|
||||||
area = Rectangle<uint>(getWidth() - size - margin,
|
area = Rectangle<uint>(getWidth() - size,
|
||||||
getHeight() - size - margin,
|
getHeight() - size,
|
||||||
size, size);
|
size, size);
|
||||||
|
|
||||||
recreateLines(area.getX(), area.getY(), size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void recreateLines(const uint x, const uint y, const uint size)
|
|
||||||
{
|
|
||||||
uint linesize = size;
|
|
||||||
uint offset = 0;
|
|
||||||
|
|
||||||
// 1st line, full diagonal size
|
|
||||||
l1.setStartPos(x + size, y);
|
|
||||||
l1.setEndPos(x, y + size);
|
|
||||||
|
|
||||||
// 2nd line, bit more to the right and down, cropped
|
|
||||||
offset += size / 3;
|
|
||||||
linesize -= size / 3;
|
|
||||||
l2.setStartPos(x + linesize + offset, y + offset);
|
|
||||||
l2.setEndPos(x + offset, y + linesize + offset);
|
|
||||||
|
|
||||||
// 3rd line, even more right and down
|
|
||||||
offset += size / 3;
|
|
||||||
linesize -= size / 3;
|
|
||||||
l3.setStartPos(x + linesize + offset, y + offset);
|
|
||||||
l3.setEndPos(x + offset, y + linesize + offset);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ResizeHandle)
|
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ResizeHandle)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue