From 5189b4bbd983fe58854cc2078ceea8aaabc97c55 Mon Sep 17 00:00:00 2001 From: ed Date: Tue, 22 Jan 2019 17:19:46 +0000 Subject: [PATCH] BLOCKS: Remove dependency on juce_gui_basics --- BREAKING-CHANGES.txt | 30 +++++++++++++++---- .../juce_blocks_basics/blocks/juce_Block.h | 5 +++- .../internal/juce_BlockImplementation.cpp | 8 ++--- .../topology/internal/juce_Detector.cpp | 12 ++++---- 4 files changed, 39 insertions(+), 16 deletions(-) diff --git a/BREAKING-CHANGES.txt b/BREAKING-CHANGES.txt index 98d6f5bc83..3f221f17e6 100644 --- a/BREAKING-CHANGES.txt +++ b/BREAKING-CHANGES.txt @@ -6,13 +6,34 @@ Develop Change ----- -Allow renaming and deletion of open file handles on Windows using the +The return type of Block::getBlockAreaWithinLayout() has been changed from +Rectangle to a simpler BlockArea struct. + +Possible Issues +--------------- +Classes that derive from Block and implement this pure virtual method will no +longer compile due to a change in the function signature. + +Workaround +---------- +Update the method to return a BlockArea struct and update code that calls +getBlockAreaWithinLayout to handle a BlockArea instead of a Rectangle. + +Rationale +--------- +The juce_blocks_basics is ISC licensed and therefore cannot depend on the +GPL/Commercial licensed juce_gui_basics module that contains Rectangle. + + +Change +----- +Renaming and deletion of open file handles on Windows is now possible using the FILE_SHARE_DELETE flag. Possible Issues --------------- -Previous code that relied on open files not being able to be renamed or -deleted on Windows may fail. +Previous code that relied on open files not being able to be renamed or deleted +on Windows may fail. Workaround ---------- @@ -20,8 +41,7 @@ No workaround. Rationale --------- -This unifies the behaviour across OSes as POSIX systems already allow -this. +This unifies the behaviour across OSes as POSIX systems already allow this. Change diff --git a/modules/juce_blocks_basics/blocks/juce_Block.h b/modules/juce_blocks_basics/blocks/juce_Block.h index 042ee63d4f..48ec1127da 100644 --- a/modules/juce_blocks_basics/blocks/juce_Block.h +++ b/modules/juce_blocks_basics/blocks/juce_Block.h @@ -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 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; diff --git a/modules/juce_blocks_basics/topology/internal/juce_BlockImplementation.cpp b/modules/juce_blocks_basics/topology/internal/juce_BlockImplementation.cpp index 48ac8916a1..6ccacaa24c 100644 --- a/modules/juce_blocks_basics/topology/internal/juce_BlockImplementation.cpp +++ b/modules/juce_blocks_basics/topology/internal/juce_BlockImplementation.cpp @@ -124,12 +124,12 @@ public: Block::UID getConnectedMasterUID() const override { return masterUID; } int getRotation() const override { return rotation; } - Rectangle 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 position; + std::pair position; int rotation = 0; friend Detector; diff --git a/modules/juce_blocks_basics/topology/internal/juce_Detector.cpp b/modules/juce_blocks_basics/topology/internal/juce_Detector.cpp index 1187ce32a0..1b0cd03b30 100644 --- a/modules/juce_blocks_basics/topology/internal/juce_Detector.cpp +++ b/modules/juce_blocks_basics/topology/internal/juce_Detector.cpp @@ -573,26 +573,26 @@ private: + getRotationForEdge (myPort.edge) - getRotationForEdge (theirPort.edge)) % 4; - Point delta; + std::pair 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);