mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-02-08 04:20:09 +00:00
BLOCKS: Remove dependency on juce_gui_basics
This commit is contained in:
parent
b2e2346745
commit
5189b4bbd9
4 changed files with 39 additions and 16 deletions
|
|
@ -130,10 +130,13 @@ public:
|
|||
/** Returns the length of one logical device unit as physical millimeters. */
|
||||
virtual float getMillimetersPerUnit() const = 0;
|
||||
|
||||
/** A simple struct representing the area of a block. */
|
||||
struct BlockArea { int x, y, width, height; };
|
||||
|
||||
/** Returns the area that this block covers within the layout of the group as a whole.
|
||||
The coordinates are in logical block units, and are relative to the origin, which is the master block's top-left corner.
|
||||
*/
|
||||
virtual Rectangle<int> getBlockAreaWithinLayout() const = 0;
|
||||
virtual BlockArea getBlockAreaWithinLayout() const = 0;
|
||||
|
||||
/** Returns the rotation of this block relative to the master block in 90 degree steps clockwise. */
|
||||
virtual int getRotation() const = 0;
|
||||
|
|
|
|||
|
|
@ -124,12 +124,12 @@ public:
|
|||
Block::UID getConnectedMasterUID() const override { return masterUID; }
|
||||
int getRotation() const override { return rotation; }
|
||||
|
||||
Rectangle<int> getBlockAreaWithinLayout() const override
|
||||
BlockArea getBlockAreaWithinLayout() const override
|
||||
{
|
||||
if (rotation % 2 == 0)
|
||||
return { position.getX(), position.getY(), modelData.widthUnits, modelData.heightUnits };
|
||||
return { position.first, position.second, modelData.widthUnits, modelData.heightUnits };
|
||||
|
||||
return { position.getX(), position.getY(), modelData.heightUnits, modelData.widthUnits };
|
||||
return { position.first, position.second, modelData.heightUnits, modelData.widthUnits };
|
||||
}
|
||||
|
||||
TouchSurface* getTouchSurface() const override { return touchSurface.get(); }
|
||||
|
|
@ -584,7 +584,7 @@ private:
|
|||
bool isMaster = false;
|
||||
Block::UID masterUID = {};
|
||||
|
||||
Point<int> position;
|
||||
std::pair<int, int> position;
|
||||
int rotation = 0;
|
||||
friend Detector;
|
||||
|
||||
|
|
|
|||
|
|
@ -573,26 +573,26 @@ private:
|
|||
+ getRotationForEdge (myPort.edge)
|
||||
- getRotationForEdge (theirPort.edge)) % 4;
|
||||
|
||||
Point<int> delta;
|
||||
std::pair<int, int> delta;
|
||||
const auto theirBounds = neighbour->getBlockAreaWithinLayout();
|
||||
|
||||
switch ((block->getRotation() + getRotationForEdge (myPort.edge)) % 4)
|
||||
{
|
||||
case 0: // over me
|
||||
delta = { myOffset - (theirBounds.getWidth() - (theirOffset + 1)), -theirBounds.getHeight() };
|
||||
delta = { myOffset - (theirBounds.width - (theirOffset + 1)), -theirBounds.height };
|
||||
break;
|
||||
case 1: // right of me
|
||||
delta = { myBounds.getWidth(), myOffset - (theirBounds.getHeight() - (theirOffset + 1)) };
|
||||
delta = { myBounds.width, myOffset - (theirBounds.height - (theirOffset + 1)) };
|
||||
break;
|
||||
case 2: // under me
|
||||
delta = { (myBounds.getWidth() - (myOffset + 1)) - theirOffset, myBounds.getHeight() };
|
||||
delta = { (myBounds.width - (myOffset + 1)) - theirOffset, myBounds.height };
|
||||
break;
|
||||
case 3: // left of me
|
||||
delta = { -theirBounds.getWidth(), (myBounds.getHeight() - (myOffset + 1)) - theirOffset };
|
||||
delta = { -theirBounds.width, (myBounds.height - (myOffset + 1)) - theirOffset };
|
||||
break;
|
||||
}
|
||||
|
||||
neighbour->position = myBounds.getPosition() + delta;
|
||||
neighbour->position = { myBounds.x + delta.first, myBounds.y + delta.second };
|
||||
}
|
||||
|
||||
layoutNeighbours (neighbourPtr, topology, masterUid, visited);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue