From fcbca25c24e446f084658039453734f2d952841e Mon Sep 17 00:00:00 2001 From: tpoole Date: Mon, 21 Aug 2017 09:05:04 +0100 Subject: [PATCH 001/129] Doxygen: Remove groups from LittleFoot functions --- doxygen/Doxyfile | 2 +- .../juce_LittleFootFunctions.dox | 238 +----------------- 2 files changed, 10 insertions(+), 230 deletions(-) diff --git a/doxygen/Doxyfile b/doxygen/Doxyfile index 5fe7bd005a..a8fa280df6 100644 --- a/doxygen/Doxyfile +++ b/doxygen/Doxyfile @@ -397,7 +397,7 @@ SUBGROUPING = YES # SEPARATE_MEMBER_PAGES. # The default value is: NO. -INLINE_GROUPED_CLASSES = YES +INLINE_GROUPED_CLASSES = NO # When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions # with only public data fields or simple typedef fields will be shown inline in diff --git a/modules/juce_blocks_basics/juce_LittleFootFunctions.dox b/modules/juce_blocks_basics/juce_LittleFootFunctions.dox index 9ebdb286eb..9933e3aa63 100644 --- a/modules/juce_blocks_basics/juce_LittleFootFunctions.dox +++ b/modules/juce_blocks_basics/juce_LittleFootFunctions.dox @@ -1,32 +1,7 @@ -/** @defgroup LittleFootFunctions LittleFoot Functions - Functions available in the LittleFoot language - @{ - - @defgroup LittleFootFunctions-Graphics Graphics functions - @defgroup LittleFootFunctions-MIDI MIDI functions - @defgroup LittleFootFunctions-Callbacks Callbacks from the OS - @defgroup LittleFootFunctions-Maths Math functions - @defgroup LittleFootFunctions-Memory Memory Access functions - @defgroup LittleFootFunctions-Debug Debugging functions - @defgroup LittleFootFunctions-Configs Configuration functions - @defgroup LittleFootFunctions-Messaging Messaging functions - @defgroup LittleFootFunctions-Clustering Cluster functions - @defgroup LittleFootFunctions-Topology Topology functions - @defgroup LittleFootFunctions-Touch Touch functions - @defgroup LittleFootFunctions-Lightpad Lightpad specific functions - @defgroup LittleFootFunctions-ControlBlock Control Block specific functions - @defgroup LittleFootFunctions-Seaboard Seaboard specific functions - @defgroup LittleFootFunctions-Power Power functions - @defgroup LittleFootFunctions-Utility Utility functions - @defgroup LittleFootFunctions-Internal Internal functions (not for general usage) -*/ - /** Reads and returns the value of a single byte from the heap. @param byteIndex the index (in bytes) of the byte to read @returns the value of the byte - - @ingroup LittleFootFunctions-Memory */ int getHeapByte (int byteIndex); @@ -34,8 +9,6 @@ int getHeapByte (int byteIndex); @param byteIndex the index (in bytes) of the start of the 4 bytes to read @returns the value of the 4 bytes as an integer - - @ingroup LittleFootFunctions-Memory */ int getHeapInt (int byteIndex); @@ -44,8 +17,6 @@ int getHeapInt (int byteIndex); @param startBitIndex the index (in bits) of the start of the sequence of bits to read @param numBits how many bits to read @returns the value of the sequence of bits as an integer - - @ingroup LittleFootFunctions-Memory */ int getHeapBits (int startBitIndex, int numBits); @@ -53,8 +24,6 @@ int getHeapBits (int startBitIndex, int numBits); @param byteIndex the index (in bytes) of the byte to set @param newValue the new value to set this byte to - - @ingroup LittleFootFunctions-Memory */ void setHeapByte (int byteIndex, int newValue); @@ -62,8 +31,6 @@ void setHeapByte (int byteIndex, int newValue); @param byteIndex the index (in bytes) of the start of the 4 bytes to set @param newValue the new value to set the 4 bytes to - - @ingroup LittleFootFunctions-Memory */ void setHeapInt (int byteIndex, int newValue); @@ -72,8 +39,6 @@ void setHeapInt (int byteIndex, int newValue); @param a The first parameter @param b The second parameter @retval The minimum of a and b - - @ingroup LittleFootFunctions-Maths */ int min (int a, int b); @@ -82,8 +47,6 @@ int min (int a, int b); @param a The first parameter @param b The second parameter @retval The minimum of a and b - - @ingroup LittleFootFunctions-Maths */ float min (float a, float b); @@ -92,8 +55,6 @@ float min (float a, float b); @param a The first parameter @param b The second parameter @retval The maximum of a and b - - @ingroup LittleFootFunctions-Maths */ int max (int a, int b); @@ -102,8 +63,6 @@ int max (int a, int b); @param a The first parameter @param b The second parameter @retval The maximum of a and b - - @ingroup LittleFootFunctions-Maths */ float max (float a, float b); @@ -114,8 +73,6 @@ float max (float a, float b); @param valueToConstrain the value to try to return @returns the closest value to valueToConstrain which lies between lowerLimit and upperLimit (inclusive) - - @ingroup LittleFootFunctions-Maths */ int clamp (int lowerLimit, int upperLimit, int valueToConstrain); @@ -126,8 +83,6 @@ int clamp (int lowerLimit, int upperLimit, int valueToConstrain); @param valueToConstrain the value to try to return @returns the closest value to valueToConstrain which lies between lowerLimit and upperLimit (inclusive) - - @ingroup LittleFootFunctions-Maths */ float clamp (float lowerLimit, float upperLimit, float valueToConstrain); @@ -135,8 +90,6 @@ float clamp (float lowerLimit, float upperLimit, float valueToConstrain); @param arg The argument to compute the absolute value of @retval either -arg if arg is negative or arg if arg is positive - - @ingroup LittleFootFunctions-Maths */ int abs (int arg); @@ -144,8 +97,6 @@ int abs (int arg); @param arg The argument to compute the absolute value of @retval either -arg if arg is negative or arg if arg is positive - - @ingroup LittleFootFunctions-Maths */ float abs (float arg); @@ -157,8 +108,6 @@ float abs (float arg); @param destMin the minumum value of the destination range @param destMax the maximum value of the destination range @returns the original value mapped to the destination range - - @ingroup LittleFootFunctions-Maths */ float map (float value, float sourceMin, float sourceMax, float destMin, float destMax); @@ -168,8 +117,6 @@ float map (float value, float sourceMin, float sourceMax, float destMin, float d @param sourceMin the minimum value of the source range @param sourceMax the maximum value of the source range @returns the original value mapped to the range 0 - 1.0 - - @ingroup LittleFootFunctions-Maths */ float map (float value, float sourceMin, float sourceMax); @@ -177,24 +124,18 @@ float map (float value, float sourceMin, float sourceMax); The divisor must be greater than zero. @returns the result of the modulo operation - - @ingroup LittleFootFunctions-Maths */ int mod (int dividend, int divisor); /** Returns a random floating-point number. @returns a random value in the range 0 (inclusive) to 1.0 (exclusive) - - @ingroup LittleFootFunctions-Maths */ float getRandomFloat(); /** Returns a random integer, limited to a given range. @returns a random integer between 0 (inclusive) and maxValue (exclusive). - - @ingroup LittleFootFunctions-Maths */ int getRandomInt (int maxValue); @@ -202,48 +143,34 @@ int getRandomInt (int maxValue); @returns a monotonically increasing value which is unaffected by changes to the system clock. It should be accurate to within a few millisecseconds. - - @ingroup LittleFootFunctions-Maths */ int getMillisecondCounter(); /** Returns the length of time spent in the current function call in milliseconds. @returns the length of time spent in the current function call in milliseconds. - - @ingroup LittleFootFunctions-Maths */ int getTimeInCurrentFunctionCall(); /** Logs an integer value to the console. @param data The 32 bit signed integer to log to the topology as an integer - - @ingroup LittleFootFunctions-Debug */ void log (int data); /** Logs a hexadecimal value to the console. @param data The 32 bit signed integer to log to the topology as a hexidecimal int - - @ingroup LittleFootFunctions-Debug */ void logHex (int data); -/** Sends a 1-byte short midi message. - @ingroup LittleFootFunctions-MIDI -*/ +/** Sends a 1-byte short midi message. */ void sendMIDI (int byte0); -/** Sends a 2-byte short midi message. - @ingroup LittleFootFunctions-MIDI -*/ +/** Sends a 2-byte short midi message. */ void sendMIDI (int byte0, int byte1); -/** Sends a 3-byte short midi message. - @ingroup LittleFootFunctions-MIDI -*/ +/** Sends a 3-byte short midi message. */ void sendMIDI (int byte0, int byte1, int byte2); /** Sends a key-down message. @@ -251,8 +178,6 @@ void sendMIDI (int byte0, int byte1, int byte2); @param channel the midi channel, in the range 0 to 15 @param noteNumber the key number, in the range 0 to 127 @param velocity the velocity, in the range 0 to 127 - - @ingroup LittleFootFunctions-MIDI */ void sendNoteOn (int channel, int noteNumber, int velocity); @@ -261,8 +186,6 @@ void sendNoteOn (int channel, int noteNumber, int velocity); @param channel the midi channel, in the range 0 to 15 @param noteNumber the key number, in the range 0 to 127 @param velocity the velocity, in the range 0 to 127 - - @ingroup LittleFootFunctions-MIDI */ void sendNoteOff (int channel, int noteNumber, int velocity); @@ -271,8 +194,6 @@ void sendNoteOff (int channel, int noteNumber, int velocity); @param channel the midi channel, in the range 0 to 15 @param noteNumber the key number, in the range 0 to 127 @param level the amount of aftertouch, in the range 0 to 127 - - @ingroup LittleFootFunctions-MIDI */ void sendAftertouch (int channel, int noteNumber, int level); @@ -281,8 +202,6 @@ void sendAftertouch (int channel, int noteNumber, int level); @param channel the midi channel, in the range 0 to 15 @param controller the type of controller @param value the controller value - - @ingroup LittleFootFunctions-MIDI */ void sendCC (int channel, int controller, int value); @@ -290,8 +209,6 @@ void sendCC (int channel, int controller, int value); @param channel the midi channel, in the range 0 to 15 @param position the wheel position, in the range 0 to 16383 - - @ingroup LittleFootFunctions-MIDI */ void sendPitchBend (int channel, int position); @@ -299,8 +216,6 @@ void sendPitchBend (int channel, int position); @param channel the midi channel, in the range 0 to 15 @param pressure the pressure, in the range 0 to 127 - - @ingroup LittleFootFunctions-MIDI */ void sendChannelPressure (int channel, int pressure); @@ -309,8 +224,6 @@ void sendChannelPressure (int channel, int pressure); @param useMPE @param lowChannel @param highChannel - - @ingroup LittleFootFunctions-MIDI */ void setChannelRange (bool useMPE, int lowChannel, int highChannel); @@ -318,8 +231,6 @@ void setChannelRange (bool useMPE, int lowChannel, int highChannel); @param noteNumber the note number to assign the channel to @returns the MIDI channel that has been assigned - - @ingroup LittleFootFunctions-MIDI */ int assignChannel (int noteNumber); @@ -327,45 +238,32 @@ int assignChannel (int noteNumber); @param noteNumber the note number to deassign @param channel the MIDI channel - - @ingroup LittleFootFunctions-MIDI */ void deassignChannel (int noteNumber, int channel); /** Returns the channel that is being used for control messages. @returns the channel that is being used for control messages. (If MPE is enabled then this will be the first channel.) - - @ingroup LittleFootFunctions-MIDI */ int getControlChannel(); -/** Sets whether duplicate notes should be filtered out when MPE is enabled. - - @ingroup LittleFootFunctions-MIDI -*/ +/** Sets whether duplicate notes should be filtered out when MPE is enabled. */ void useMPEDuplicateFilter (bool active); /** Use this method to draw the display. The block will call this approximately 25 times per second. - - @ingroup LittleFootFunctions-Callbacks */ void repaint(); /** Called when a button is pushed. @param index the index of the button that was pushed - - @ingroup LittleFootFunctions-Callbacks */ void handleButtonDown (int index); /** Called when a button is released. @param index the index of the button that was released - - @ingroup LittleFootFunctions-Callbacks */ void handleButtonUp (int index); @@ -373,8 +271,6 @@ void handleButtonUp (int index); @param buttonIndex the index of the button - @ingroup LittleFootFunctions-Callbacks - @note Requires >= 0.2.5 firmware @note Only valid with a control block */ @@ -384,8 +280,6 @@ void onControlPress (int buttonIndex); @param buttonIndex the index of the button - @ingroup LittleFootFunctions-Callbacks - @note Requires >= 0.2.5 firmware @note Only valid with a control block */ @@ -398,8 +292,6 @@ void onControlRelease (int buttonIndex); @param y the Y position of this touch on the device, in block units starting from 0 (top) @param z the current pressure of this touch, in the range 0.0 (no pressure) to 1.0 (very hard) @param vz the rate at which pressure is currently changing, measured in units/second - - @ingroup LittleFootFunctions-Touch */ void touchStart (int index, float x, float y, float z, float vz); @@ -410,8 +302,6 @@ void touchStart (int index, float x, float y, float z, float vz); @param y the Y position of this touch on the device, in block units starting from 0 (top) @param z the current pressure of this touch, in the range 0.0 (no pressure) to 1.0 (very hard) @param vz the rate at which pressure is currently changing, measured in units/second - - @ingroup LittleFootFunctions-Touch */ void touchMove (int index, float x, float y, float z, float vz); @@ -422,27 +312,18 @@ void touchMove (int index, float x, float y, float z, float vz); @param y the Y position of this touch on the device, in block units starting from 0 (top) @param z the current pressure of this touch, in the range 0.0 (no pressure) to 1.0 (very hard) @param vz the rate at which pressure is currently changing, measured in units/second - - @ingroup LittleFootFunctions-Touch */ void touchEnd (int index, float x, float y, float z, float vz); -/** Called when a program is loaded onto the block and is about to start. Do any setup here. - - @ingroup LittleFootFunctions-Callbacks -*/ +/** Called when a program is loaded onto the block and is about to start. Do any setup here. */ void initialise(); -/** Called when a block receives a MIDI message. - - @ingroup LittleFootFunctions-MIDI -*/ +/** Called when a block receives a MIDI message. */ void handleMIDI (int byte0, int byte1, int byte2); /** Called when a block receives a message. @see sendMessageToBlock - @ingroup LittleFootFunctions-Messaging */ void handleMessage (int param1, int param2, int param3); @@ -453,8 +334,6 @@ void handleMessage (int param1, int param2, int param3); @param red The red in range 0 - 255 inclusive @param green The green in range 0 - 255 inclusive @param blue The blue in range 0 - 255 inclusive - - @ingroup LittleFootFunctions-Graphics */ int makeARGB (int alpha, int red, int green, int blue); @@ -463,8 +342,6 @@ int makeARGB (int alpha, int red, int green, int blue); @param baseColour the colour to blend on to @param overlaidColour The colour to blend in to the baseColour @returns The blended colour - - @ingroup LittleFootFunctions-Graphics */ int blendARGB (int baseColour, int overlaidColour); @@ -472,23 +349,16 @@ int blendARGB (int baseColour, int overlaidColour); A control block will light up its top LEDs indicating battery level and a lightpad block will draw the battery level on the display. - @ingroup LittleFootFunctions-Graphics - @note Requires >= 0.2.5 firmware */ void displayBatteryLevel(); -/** Clears the display and sets all the LEDs to black. - - @ingroup LittleFootFunctions-Graphics -*/ +/** Clears the display and sets all the LEDs to black. */ void clearDisplay(); /** Clears the display and sets all the LEDs to a specified colour. @param rgb the colour to use (0xff...) - - @ingroup LittleFootFunctions-Graphics */ void clearDisplay (int rgb); @@ -497,8 +367,6 @@ void clearDisplay (int rgb); @param rgb the colour to use (0xff...) @param x the x coordinate of the pixel to fill @param y the y coordinate of the pixel to fill - - @ingroup LittleFootFunctions-Graphics */ void fillPixel (int rgb, int x, int y); @@ -507,8 +375,6 @@ void fillPixel (int rgb, int x, int y); @param argb the colour to use @param x the x coordinate of the pixel to blend @param y the y coordinate of the pixel to blend - - @ingroup LittleFootFunctions-Graphics */ void blendPixel (int argb, int x, int y); @@ -519,8 +385,6 @@ void blendPixel (int argb, int x, int y); @param y the y coordinate of the rectangle to draw @param width the width of the rectangle to draw @param height the height of the rectangle to draw - - @ingroup LittleFootFunctions-Graphics */ void fillRect (int rgb, int x, int y, int width, int height); @@ -531,8 +395,6 @@ void fillRect (int rgb, int x, int y, int width, int height); @param y the y coordinate of the rectangle to blend @param width the width of the rectangle to blend @param height the height of the rectangle to blend - - @ingroup LittleFootFunctions-Graphics */ void blendRect (int argb, int x, int y, int width, int height); @@ -546,8 +408,6 @@ void blendRect (int argb, int x, int y, int width, int height); @param y the y coordinate of the rectangle @param width the width of the rectangle @param height the height of the rectangle - - @ingroup LittleFootFunctions-Graphics */ void blendGradientRect (int colourNW, int colourNE, int colourSE, int colourSW, int x, int y, int width, int height); @@ -559,8 +419,6 @@ void blendGradientRect (int colourNW, int colourNE, int colourSE, int colourSW, @param radius the radius of the circle in block units @param fill if true then the circle will be filled, if false the circle will be an outline - @ingroup LittleFootFunctions-Graphics - @note Requires >= 0.2.5 firmware */ void blendCircle (int argb, float xCentre, float yCentre, float radius, bool fill); @@ -571,8 +429,6 @@ void blendCircle (int argb, float xCentre, float yCentre, float radius, bool fil @param colour the colour to use @param x the x coordinate to use @param y the y coordinate to use - - @ingroup LittleFootFunctions-Graphics */ void drawNumber (int value, int colour, int x, int y); @@ -580,8 +436,6 @@ void drawNumber (int value, int colour, int x, int y); @returns The firmware version of the form 0xMJMIRV (where MJ = Major, MI = Minor, RV = Revision) - @ingroup LittleFootFunctions-Utility - @note Requires >= 0.2.5 firmware */ int getFirmwareVersion(); @@ -590,8 +444,6 @@ int getFirmwareVersion(); @returns the battery level of this block, between 0 and 1.0. - @ingroup LittleFootFunctions-Power - @note Requires >= 0.2.5 firmware */ float getBatteryLevel(); @@ -600,24 +452,18 @@ float getBatteryLevel(); @returns true if this block's battery is charging - @ingroup LittleFootFunctions-Power - @note Requires >= 0.2.5 firmware */ bool isBatteryCharging(); /** Sets whether status overlays should be displayed on this block. - @ingroup LittleFootFunctions-Utility - @note Requires >= 0.2.5 firmware */ void setStatusOverlayActive (bool active); /** Sets whether power saving mode should be enabled on this block. - @ingroup LittleFootFunctions-Power - @note Requires >= 0.2.5 firmware */ void setPowerSavingEnabled (bool enabled); @@ -626,8 +472,6 @@ void setPowerSavingEnabled (bool enabled); @returns an enum indicating the type of block @see Block::Type - @ingroup LittleFootFunctions-Clustering - @note Requires >= 0.2.5 firmware */ int getBlockTypeForID (int blockID); @@ -639,8 +483,6 @@ int getBlockTypeForID (int blockID); @param param1 the first chunk of data to send @param param2 the second chunk of data to send @param param3 the third chunk of data to send - - @ingroup LittleFootFunctions-Messaging */ void sendMessageToBlock (int blockID, int param1, int param2, int param3); @@ -650,8 +492,6 @@ void sendMessageToBlock (int blockID, int param1, int param2, int param3); @param param1 the first chunk of data to send @param param2 the second chunk of data to send @param param3 the third chunk of data to send - - @ingroup LittleFootFunctions-Messaging */ void sendMessageToHost (int param1, int param2, int param3); @@ -661,27 +501,19 @@ void sendMessageToHost (int param1, int param2, int param3); @param touchX the x position of the touch in block units @param touchY the y position of the touch in block units @param touchZ the pressure value of the touch - - @ingroup LittleFootFunctions-Lightpad */ void addPressurePoint (int argb, float touchX, float touchY, float touchZ); -/** Draws the pressure map on the display. - @ingroup LittleFootFunctions-Lightpad -*/ +/** Draws the pressure map on the display. */ void drawPressureMap(); -/** Fades the pressure map on the display. - @ingroup LittleFootFunctions-Lightpad -*/ +/** Fades the pressure map on the display. */ void fadePressureMap(); /** Links a another block to this control block. @param blockID the ID of the block to link - @ingroup LittleFootFunctions-ControlBlock - @note Requires >= 0.2.5 firmware @note Only valid with a control block */ @@ -689,8 +521,6 @@ void linkBlockIDtoController (int blockID); /** Repaints the control block display. - @ingroup LittleFootFunctions-ControlBlock - @note Requires >= 0.2.5 firmware @note Only valid with a control block */ @@ -708,8 +538,6 @@ void repaintControl(); @param onColourToUse the colour to use when this button is on @param offColourToUse the colour to use when this button is off - @ingroup LittleFootFunctions-ControlBlock - @note Requires >= 0.2.5 firmware @note Only valid with a control block */ @@ -719,8 +547,6 @@ void initControl (int buttonIndex, int modeToUse, int outputType, int val, int m /** Control type for use with initControl @see initControl - - @ingroup LittleFootFunctions-ControlBlock */ enum ControlType { @@ -732,8 +558,6 @@ enum ControlType /** Control mode for use with initControl @see initControl - - @ingroup LittleFootFunctions-ControlBlock */ enum ControlMode { @@ -750,15 +574,12 @@ enum ControlMode @param touchIndex the index of the touch event - @ingroup LittleFootFunctions-Seaboard - @note Requires >= 0.2.5 firmware @note Only valid on a Seaboard */ void handleTouchAsSeaboard (int touchIndex); /** Returns the number of blocks in the current topology. - @ingroup LittleFootFunctions-Topology @note Requires >= 0.2.5 firmware */ @@ -769,8 +590,6 @@ int getNumBlocksInTopology(); @param index The index of the block to find in the topology @returns int The id of the block - @ingroup LittleFootFunctions-Topology - @note Requires >= 0.2.5 firmware */ int getBlockIDForIndex (int index); @@ -778,8 +597,6 @@ int getBlockIDForIndex (int index); /** Returns true if this block is directly connected to the host, as opposed to only being connected to a different block via a connection port. - @ingroup LittleFootFunctions-Topology - @note Requires >= 0.2.5 firmware */ bool isMasterBlock(); @@ -787,14 +604,11 @@ bool isMasterBlock(); /** Returns true if this block is connected to the host computer, this can be directly or through connections to other blocks. - @ingroup LittleFootFunctions-Topology - @note Requires >= 0.2.5 firmware */ bool isConnectedToHost(); /** Returns the ID of a block connected to a specified port on this block. - @ingroup LittleFootFunctions-Topology @note Requires >= 0.2.5 firmware */ @@ -806,42 +620,35 @@ int getBlockIDOnPort (int port); @returns the port number that is connected to the master block. Returns 0xFF if there is no port connected to master. - @ingroup LittleFootFunctions-Topology - @note Requires >= 0.2.5 firmware */ int getPortToMaster(); /** Returns the horizontal distance between this block and the master block in block units. - @ingroup LittleFootFunctions-Clustering @note Requires >= 0.2.5 firmware */ int getHorizontalDistFromMaster(); /** Returns the vertical distance between this block and the master block in block units. - @ingroup LittleFootFunctions-Clustering @note Requires >= 0.2.5 firmware */ int getVerticalDistFromMaster(); /** Returns the angle of this block relative to the master block in degrees. - @ingroup LittleFootFunctions-Clustering @note Requires >= 0.2.5 firmware */ int getAngleFromMaster(); /** Sets whether this block should auto-rotate when its angle relative to the master block changes. - @ingroup LittleFootFunctions-Clustering @note Requires >= 0.2.5 firmware */ void setAutoRotate (bool enabled); /** Returns the index of this block in the current cluster. - @ingroup LittleFootFunctions-Clustering @note Requires >= 0.2.5 firmware */ @@ -851,8 +658,6 @@ int getClusterIndex(); @returns the width of the cluster (note that a single block will return 1 here) - @ingroup LittleFootFunctions-Clustering - @note Requires >= 0.2.5 firmware */ int getClusterWidth(); @@ -861,8 +666,6 @@ int getClusterWidth(); @returns the height of the cluster (note that a single block will return 1 here) - @ingroup LittleFootFunctions-Clustering - @note Requires >= 0.2.5 firmware */ int getClusterHeight(); @@ -871,8 +674,6 @@ int getClusterHeight(); @returns int The cluster x position. (0, 0) is considered to be the top left block - @ingroup LittleFootFunctions-Clustering - @note Requires >= 0.2.5 firmware */ int getClusterXpos(); @@ -881,8 +682,6 @@ int getClusterXpos(); @returns int The cluster x position. (0, 0) is considered to be the top left block - @ingroup LittleFootFunctions-Clustering - @note Requires >= 0.2.5 firmware */ int getClusterYpos(); @@ -891,8 +690,6 @@ int getClusterYpos(); @returns the number of blocks in the current cluster. - @ingroup LittleFootFunctions-Clustering - @note Requires >= 0.2.5 firmware */ int getNumBlocksInCurrentCluster(); @@ -901,14 +698,11 @@ int getNumBlocksInCurrentCluster(); @param index the cluster index of the block to get the ID of - @ingroup LittleFootFunctions-Clustering - @note Requires >= 0.2.5 firmware */ int getBlockIdForBlockInCluster (int index); /** Returns true if the master block is in the current cluster. - @ingroup LittleFootFunctions-Clustering @note Requires >= 0.2.5 firmware */ @@ -918,8 +712,6 @@ bool isMasterInCurrentCluster(); @param item the config item to get (see ConfigItemId enum in juce_BlocksProtocolDefinitions.h) - @ingroup LittleFootFunctions-Configs - @note Requires >= 0.2.5 firmware */ int getLocalConfig (int item); @@ -929,8 +721,6 @@ int getLocalConfig (int item); @param item the config item to set the value of (see ConfigItemId enum in juce_BlocksProtocolDefinitions.h) @param value the value to set the config to - @ingroup LittleFootFunctions-Configs - @note Requires >= 0.2.5 firmware */ void setLocalConfig (int item, int value); @@ -940,8 +730,6 @@ void setLocalConfig (int item, int value); @param longAddress the address of the remote block @param item the config item (see ConfigItemId enum in juce_BlocksProtocolDefinitions.h) - @ingroup LittleFootFunctions-Configs - @note Requires >= 0.2.5 firmware */ void requestRemoteConfig (int longAddress, int item); @@ -952,8 +740,6 @@ void requestRemoteConfig (int longAddress, int item); @param item the config item (see ConfigItemId enum in juce_BlocksProtocolDefinitions.h) @param value the value to set the config to - @ingroup LittleFootFunctions-Configs - @note Requires >= 0.2.5 firmware */ void setRemoteConfig (int longAddress, int item, int value); @@ -964,8 +750,6 @@ void setRemoteConfig (int longAddress, int item, int value); @param min the minimum value this config item should use @param max the maximum value this config item should use - @ingroup LittleFootFunctions-Configs - @note Requires >= 0.2.5 firmware */ void setLocalConfigItemRange (int item, int min, int max); @@ -976,10 +760,6 @@ void setLocalConfigItemRange (int item, int min, int max); @param isActive sets whether the config should be active or not @param saveToFlash if true then this config item will be saved to the flash memory of the block - @ingroup LittleFootFunctions-Configs - @note Requires >= 0.2.5 firmware */ void setLocalConfigActiveState (int item, bool isActive, bool saveToFlash); - -/** @} */ From ac75714aba8c9d74ccfc133e9c20de47e25388f6 Mon Sep 17 00:00:00 2001 From: tpoole Date: Mon, 21 Aug 2017 09:52:31 +0100 Subject: [PATCH 002/129] Doxygen: Add top-level LittleFoot functions group --- modules/juce_blocks_basics/juce_LittleFootFunctions.dox | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/juce_blocks_basics/juce_LittleFootFunctions.dox b/modules/juce_blocks_basics/juce_LittleFootFunctions.dox index 9933e3aa63..bc61a2a737 100644 --- a/modules/juce_blocks_basics/juce_LittleFootFunctions.dox +++ b/modules/juce_blocks_basics/juce_LittleFootFunctions.dox @@ -1,3 +1,8 @@ +/** @defgroup LittleFootFunctions LittleFoot Functions + Functions available in the LittleFoot language + @{ +*/ + /** Reads and returns the value of a single byte from the heap. @param byteIndex the index (in bytes) of the byte to read @@ -763,3 +768,5 @@ void setLocalConfigItemRange (int item, int min, int max); @note Requires >= 0.2.5 firmware */ void setLocalConfigActiveState (int item, bool isActive, bool saveToFlash); + +/** @} */ From 90bbda1f195b4cf940f54f7f41986e0d5d68c9ec Mon Sep 17 00:00:00 2001 From: tpoole Date: Wed, 23 Aug 2017 14:19:27 +0100 Subject: [PATCH 003/129] DSP: Added template specialisations of the Matrix class --- modules/juce_dsp/maths/juce_Matrix.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/juce_dsp/maths/juce_Matrix.cpp b/modules/juce_dsp/maths/juce_Matrix.cpp index 27d2d1436e..19fa3a57a2 100644 --- a/modules/juce_dsp/maths/juce_Matrix.cpp +++ b/modules/juce_dsp/maths/juce_Matrix.cpp @@ -277,7 +277,7 @@ String Matrix::toString() const StringArray entries; int sizeMax = 0; - auto* p = data.getRawDataPointer(); + auto* p = data.begin(); for (size_t i = 0; i < rows; ++i) { @@ -306,3 +306,6 @@ String Matrix::toString() const return result.toString(); } + +template class Matrix; +template class Matrix; From a2a0a2cae6753b33c74327b20f6121a315d06721 Mon Sep 17 00:00:00 2001 From: hogliux Date: Mon, 28 Aug 2017 12:31:59 +0100 Subject: [PATCH 004/129] Fixed compiler errors when compiling with GNU libstdc++ --- examples/Demo/Source/Demos/GridDemo.cpp | 4 ++++ .../codecs/juce_CoreAudioFormat.cpp | 5 +++-- modules/juce_core/text/juce_CharacterFunctions.h | 15 ++++++++++++++- modules/juce_gui_basics/juce_gui_basics.h | 7 +++++-- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/examples/Demo/Source/Demos/GridDemo.cpp b/examples/Demo/Source/Demos/GridDemo.cpp index 56fe5a19fa..caaf6eed27 100644 --- a/examples/Demo/Source/Demos/GridDemo.cpp +++ b/examples/Demo/Source/Demos/GridDemo.cpp @@ -26,6 +26,8 @@ #include "../JuceDemoHeader.h" +// these classes are C++11-only +#if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS struct GridDemo : public Component { @@ -116,3 +118,5 @@ struct GridDemo : public Component // This static object will register this demo type in a global list of demos.. static JuceDemoType demo ("10 Components: GridDemo"); + +#endif // JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS diff --git a/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.cpp index 4808fd85fc..4d28dee8bb 100644 --- a/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.cpp @@ -697,7 +697,7 @@ private: //============================================================================== const Array& getAllKnownLayoutTags() const { - static Array knownTags ({ + static CoreAudioChannelLayoutTag tags[] = { DEFINE_CHANNEL_LAYOUT_TAG_ENTRY (kAudioChannelLayoutTag_Mono, AudioChannelSet::mono()), DEFINE_CHANNEL_LAYOUT_TAG_ENTRY (kAudioChannelLayoutTag_Stereo, AudioChannelSet::stereo()), DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_StereoHeadphones), @@ -821,7 +821,8 @@ private: DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_DTS_8_1_A), DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_DTS_8_1_B), DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_DTS_6_1_D) - }); + }; + static Array knownTags (tags, sizeof (tags) / sizeof (CoreAudioChannelLayoutTag)); return knownTags; } diff --git a/modules/juce_core/text/juce_CharacterFunctions.h b/modules/juce_core/text/juce_CharacterFunctions.h index e4b23378d1..6cdfca9c03 100644 --- a/modules/juce_core/text/juce_CharacterFunctions.h +++ b/modules/juce_core/text/juce_CharacterFunctions.h @@ -60,6 +60,19 @@ #define T(stringLiteral) JUCE_T(stringLiteral) #endif +//============================================================================== +/** GNU libstdc++ does not have std::make_unsigned */ +namespace internal +{ + template struct make_unsigned { typedef Type type; }; + template <> struct make_unsigned { typedef unsigned char type; }; + template <> struct make_unsigned { typedef unsigned char type; }; + template <> struct make_unsigned { typedef unsigned short type; }; + template <> struct make_unsigned { typedef unsigned int type; }; + template <> struct make_unsigned { typedef unsigned long type; }; + template <> struct make_unsigned { typedef unsigned long long type; }; +}; + //============================================================================== /** A collection of functions for manipulating characters and character strings. @@ -243,7 +256,7 @@ public: template static IntType getIntValue (const CharPointerType text) noexcept { - typedef typename std::make_unsigned::type UIntType; + typedef typename internal::make_unsigned::type UIntType; UIntType v = 0; auto s = text.findEndOfWhitespace(); diff --git a/modules/juce_gui_basics/juce_gui_basics.h b/modules/juce_gui_basics/juce_gui_basics.h index 2bab3e408f..4405ff0c88 100644 --- a/modules/juce_gui_basics/juce_gui_basics.h +++ b/modules/juce_gui_basics/juce_gui_basics.h @@ -156,8 +156,11 @@ class BubbleComponent; class KeyPressMappingSet; class ApplicationCommandManagerListener; class DrawableButton; -class FlexBox; -class Grid; + +#if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS + class FlexBox; + class Grid; +#endif #include "mouse/juce_MouseCursor.h" #include "mouse/juce_MouseListener.h" From 6d1fa807f97e5f5922f359cd4a9fad2128746a5e Mon Sep 17 00:00:00 2001 From: tpoole Date: Tue, 29 Aug 2017 09:06:01 +0100 Subject: [PATCH 005/129] Fixed some compiler errors when logging debug ALSA output --- modules/juce_audio_devices/native/juce_linux_ALSA.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/juce_audio_devices/native/juce_linux_ALSA.cpp b/modules/juce_audio_devices/native/juce_linux_ALSA.cpp index 0912f4e462..36b98bc7f9 100644 --- a/modules/juce_audio_devices/native/juce_linux_ALSA.cpp +++ b/modules/juce_audio_devices/native/juce_linux_ALSA.cpp @@ -155,7 +155,7 @@ public: isInput (forInput), isInterleaved (true) { - JUCE_ALSA_LOG ("snd_pcm_open (" << deviceID.toUTF8().getAddress() << ", forInput=" << forInput << ")"); + JUCE_ALSA_LOG ("snd_pcm_open (" << deviceID.toUTF8().getAddress() << ", forInput=" << (int) forInput << ")"); int err = snd_pcm_open (&handle, deviceID.toUTF8(), forInput ? SND_PCM_STREAM_CAPTURE : SND_PCM_STREAM_PLAYBACK, @@ -418,8 +418,8 @@ private: bool isFloat, bool isLittleEndian, bool useOnlyLower24Bits, int numInterleavedChannels) { - JUCE_ALSA_LOG ("format: bitDepth=" << bitDepth << ", isFloat=" << isFloat - << ", isLittleEndian=" << isLittleEndian << ", numChannels=" << numInterleavedChannels); + JUCE_ALSA_LOG ("format: bitDepth=" << bitDepth << ", isFloat=" << (int) isFloat + << ", isLittleEndian=" << (int) isLittleEndian << ", numChannels=" << numInterleavedChannels); if (isFloat) return ConverterHelper ::createConverter (forInput, isLittleEndian, numInterleavedChannels); if (bitDepth == 16) return ConverterHelper ::createConverter (forInput, isLittleEndian, numInterleavedChannels); @@ -1037,7 +1037,7 @@ private: if ((isInput || isOutput) && rates.size() > 0) { JUCE_ALSA_LOG ("testDevice: '" << id.toUTF8().getAddress() << "' -> isInput: " - << isInput << ", isOutput: " << isOutput); + << (int) isInput << ", isOutput: " << (int) isOutput); if (isInput) { @@ -1128,7 +1128,8 @@ private: } JUCE_ALSA_LOG ("Soundcard ID: " << id << ", name: '" << name - << ", isInput:" << isInput << ", isOutput:" << isOutput << "\n"); + << ", isInput:" << (int) isInput + << ", isOutput:" << (int) isOutput << "\n"); if (isInput) { From 450de0d3a6b434ace6386161e8a58128d9775bbc Mon Sep 17 00:00:00 2001 From: tpoole Date: Tue, 29 Aug 2017 09:27:08 +0100 Subject: [PATCH 006/129] Added a uint8 operator<< to the String class --- modules/juce_core/text/juce_String.cpp | 3 ++- modules/juce_core/text/juce_String.h | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/juce_core/text/juce_String.cpp b/modules/juce_core/text/juce_String.cpp index f1598f983d..311117b012 100644 --- a/modules/juce_core/text/juce_String.cpp +++ b/modules/juce_core/text/juce_String.cpp @@ -858,8 +858,9 @@ JUCE_API String& JUCE_CALLTYPE operator<< (String& s1, const wchar_t* const s2) JUCE_API String& JUCE_CALLTYPE operator<< (String& s1, const String& s2) { return s1 += s2; } JUCE_API String& JUCE_CALLTYPE operator<< (String& s1, StringRef s2) { return s1 += s2; } -JUCE_API String& JUCE_CALLTYPE operator<< (String& s1, const int number) { return s1 += number; } +JUCE_API String& JUCE_CALLTYPE operator<< (String& s1, uint8 number) { return s1 += (int) number; } JUCE_API String& JUCE_CALLTYPE operator<< (String& s1, const short number) { return s1 += (int) number; } +JUCE_API String& JUCE_CALLTYPE operator<< (String& s1, const int number) { return s1 += number; } JUCE_API String& JUCE_CALLTYPE operator<< (String& s1, const unsigned short number) { return s1 += (uint64) number; } JUCE_API String& JUCE_CALLTYPE operator<< (String& s1, const long number) { return s1 += String (number); } JUCE_API String& JUCE_CALLTYPE operator<< (String& s1, const unsigned long number) { return s1 += String (number); } diff --git a/modules/juce_core/text/juce_String.h b/modules/juce_core/text/juce_String.h index 885256b322..446b69996a 100644 --- a/modules/juce_core/text/juce_String.h +++ b/modules/juce_core/text/juce_String.h @@ -1327,6 +1327,8 @@ JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, const String& string /** Appends a string to the end of the first one. */ JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, StringRef string2); +/** Appends a decimal number to the end of a string. */ +JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, uint8 number); /** Appends a decimal number to the end of a string. */ JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, short number); /** Appends a decimal number to the end of a string. */ From d5249492aeba9292ac4ea48958ee28683d34d427 Mon Sep 17 00:00:00 2001 From: hogliux Date: Tue, 29 Aug 2017 09:33:39 +0100 Subject: [PATCH 007/129] Android: Fixed File::getSpecialLocation (userDocumentsDirectory) to return correct directory on newer Android versions --- modules/juce_core/native/java/JuceAppActivity.java | 11 +++++++++-- modules/juce_core/native/juce_android_JNIHelpers.h | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/modules/juce_core/native/java/JuceAppActivity.java b/modules/juce_core/native/java/JuceAppActivity.java index 53c3ff0644..42de8c7a8c 100644 --- a/modules/juce_core/native/java/JuceAppActivity.java +++ b/modules/juce_core/native/java/JuceAppActivity.java @@ -1226,7 +1226,14 @@ public class JuceAppActivity extends Activity return Environment.getExternalStoragePublicDirectory (type).getAbsolutePath(); } - public static final String getDocumentsFolder() { return Environment.getDataDirectory().getAbsolutePath(); } + public static final String getDocumentsFolder() + { + if (getAndroidSDKVersion() >= android.os.Build.VERSION_CODES.KITKAT) + return getFileLocation (Environment.DIRECTORY_DOCUMENTS); + + return Environment.getDataDirectory().getAbsolutePath(); + } + public static final String getPicturesFolder() { return getFileLocation (Environment.DIRECTORY_PICTURES); } public static final String getMusicFolder() { return getFileLocation (Environment.DIRECTORY_MUSIC); } public static final String getMoviesFolder() { return getFileLocation (Environment.DIRECTORY_MOVIES); } @@ -1321,7 +1328,7 @@ public class JuceAppActivity extends Activity return null; } - public final int getAndroidSDKVersion() + public static final int getAndroidSDKVersion() { return android.os.Build.VERSION.SDK_INT; } diff --git a/modules/juce_core/native/juce_android_JNIHelpers.h b/modules/juce_core/native/juce_android_JNIHelpers.h index a0e17e347e..1b5b100ea8 100644 --- a/modules/juce_core/native/juce_android_JNIHelpers.h +++ b/modules/juce_core/native/juce_android_JNIHelpers.h @@ -305,7 +305,7 @@ extern AndroidSystem android; METHOD (getScreenSaver, "getScreenSaver", "()Z") \ METHOD (getAndroidMidiDeviceManager, "getAndroidMidiDeviceManager", "()L" JUCE_ANDROID_ACTIVITY_CLASSPATH "$MidiDeviceManager;") \ METHOD (getAndroidBluetoothManager, "getAndroidBluetoothManager", "()L" JUCE_ANDROID_ACTIVITY_CLASSPATH "$BluetoothManager;") \ - METHOD (getAndroidSDKVersion, "getAndroidSDKVersion", "()I") \ + STATICMETHOD (getAndroidSDKVersion, "getAndroidSDKVersion", "()I") \ METHOD (audioManagerGetProperty, "audioManagerGetProperty", "(Ljava/lang/String;)Ljava/lang/String;") \ METHOD (hasSystemFeature, "hasSystemFeature", "(Ljava/lang/String;)Z" ) \ METHOD (requestRuntimePermission, "requestRuntimePermission", "(IJ)V" ) \ From b83bf4e7cecf8ac6a5ae792975e290fd0a4fd679 Mon Sep 17 00:00:00 2001 From: hogliux Date: Tue, 29 Aug 2017 09:44:45 +0100 Subject: [PATCH 008/129] Windows: Ensure that memory mapped files behave the same on all targets by allowing other code to open the memory mapped file with write priveleges even if the map was created with read priveleges only --- modules/juce_core/native/juce_win32_Files.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/juce_core/native/juce_win32_Files.cpp b/modules/juce_core/native/juce_win32_Files.cpp index 5185d12087..6ecaf91c7e 100644 --- a/modules/juce_core/native/juce_win32_Files.cpp +++ b/modules/juce_core/native/juce_win32_Files.cpp @@ -360,7 +360,7 @@ void MemoryMappedFile::openInternal (const File& file, AccessMode mode, bool exc } HANDLE h = CreateFile (file.getFullPathName().toWideCharPointer(), accessMode, - exclusive ? 0 : (FILE_SHARE_READ | (mode == readWrite ? FILE_SHARE_WRITE : 0)), 0, + exclusive ? 0 : FILE_SHARE_WRITE, 0, createType, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, 0); if (h != INVALID_HANDLE_VALUE) From 8a239ea5c39ce2a9653844bf15875deb76240a32 Mon Sep 17 00:00:00 2001 From: hogliux Date: Tue, 29 Aug 2017 10:14:32 +0100 Subject: [PATCH 009/129] Linux: Increased maximum number of reported ALSA channels --- modules/juce_audio_devices/native/juce_linux_ALSA.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/juce_audio_devices/native/juce_linux_ALSA.cpp b/modules/juce_audio_devices/native/juce_linux_ALSA.cpp index 36b98bc7f9..b3eb21dd7b 100644 --- a/modules/juce_audio_devices/native/juce_linux_ALSA.cpp +++ b/modules/juce_audio_devices/native/juce_linux_ALSA.cpp @@ -75,7 +75,7 @@ static void getDeviceNumChannels (snd_pcm_t* handle, unsigned int* minChans, uns JUCE_ALSA_LOG ("getDeviceNumChannels: " << (int) *minChans << " " << (int) *maxChans); // some virtual devices (dmix for example) report 10000 channels , we have to clamp these values - *maxChans = jmin (*maxChans, 32u); + *maxChans = jmin (*maxChans, 256u); *minChans = jmin (*minChans, *maxChans); } else From 64597c287386017f3b14988c0ca2f31504ce583d Mon Sep 17 00:00:00 2001 From: hogliux Date: Tue, 29 Aug 2017 10:27:54 +0100 Subject: [PATCH 010/129] Android: Fixed a potential deadlock in Sockets --- modules/juce_core/network/juce_Socket.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/juce_core/network/juce_Socket.cpp b/modules/juce_core/network/juce_Socket.cpp index 19723b69b4..64288abcea 100644 --- a/modules/juce_core/network/juce_Socket.cpp +++ b/modules/juce_core/network/juce_Socket.cpp @@ -130,7 +130,7 @@ namespace SocketHelpers // a chance to process before close is called. On Mac OS X shutdown // does not unblock a select call, so using a lock here will dead-lock // both threads. - #if JUCE_LINUX + #if JUCE_LINUX || JUCE_ANDROID CriticalSection::ScopedLockType lock (readLock); ::close (h); #else From 35facc36561f03ed12abcb5cd1013075c5c599fc Mon Sep 17 00:00:00 2001 From: hogliux Date: Tue, 29 Aug 2017 11:39:26 +0100 Subject: [PATCH 011/129] Fixed a potential use-after-free in AudioBuffer's move semantics --- modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h b/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h index 04dc758135..7702b6e70d 100644 --- a/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h +++ b/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h @@ -184,7 +184,7 @@ public: : numChannels (other.numChannels), size (other.size), allocatedBytes (other.allocatedBytes), - channels (other.channels), + channels (numChannels < (int) numElementsInArray (preallocatedChannelSpace) ? preallocatedChannelSpace : other.channels), allocatedData (static_cast&&> (other.allocatedData)), isClear (other.isClear) { @@ -200,7 +200,7 @@ public: numChannels = other.numChannels; size = other.size; allocatedBytes = other.allocatedBytes; - channels = other.channels; + channels = numChannels < (int) numElementsInArray (preallocatedChannelSpace) ? preallocatedChannelSpace : other.channels; allocatedData = static_cast&&> (other.allocatedData); isClear = other.isClear; memcpy (preallocatedChannelSpace, other.preallocatedChannelSpace, sizeof (preallocatedChannelSpace)); From 9b687968dba7496f80bc50de374665ad5c41faf4 Mon Sep 17 00:00:00 2001 From: tpoole Date: Tue, 29 Aug 2017 14:47:04 +0100 Subject: [PATCH 012/129] Fixed some g++ compiler warnings --- .../buffers/juce_AudioDataConverters.cpp | 4 +- .../buffers/juce_AudioSampleBuffer.h | 2 +- .../buffers/juce_FloatVectorOperations.cpp | 4 +- .../midi/juce_MidiBuffer.cpp | 2 +- .../audio_io/juce_AudioDeviceManager.cpp | 2 +- .../native/juce_linux_Midi.cpp | 2 +- .../sources/juce_AudioTransportSource.cpp | 10 +- .../juce_audio_formats/codecs/flac/compat.h | 334 +++++++++--------- .../codecs/juce_WavAudioFormat.cpp | 2 +- .../juce_audio_plugin_client_Standalone.cpp | 2 +- .../format_types/juce_VSTPluginFormat.cpp | 79 ----- .../juce_core/misc/juce_StdFunctionCompat.cpp | 4 +- .../juce_core/text/juce_CharacterFunctions.h | 6 +- .../juce_dsp/native/juce_avx_SIMDNativeOps.h | 8 +- .../juce_gui_basics/layout/juce_FlexBox.cpp | 4 +- .../misc/juce_JUCESplashScreen.cpp | 2 +- .../geometry/juce_Draggable3DOrientation.h | 4 +- modules/juce_osc/osc/juce_OSCTimeTag.cpp | 3 - .../in_app_purchases/juce_InAppPurchases.cpp | 4 +- 19 files changed, 198 insertions(+), 280 deletions(-) diff --git a/modules/juce_audio_basics/buffers/juce_AudioDataConverters.cpp b/modules/juce_audio_basics/buffers/juce_AudioDataConverters.cpp index de705a8d36..e46de33503 100644 --- a/modules/juce_audio_basics/buffers/juce_AudioDataConverters.cpp +++ b/modules/juce_audio_basics/buffers/juce_AudioDataConverters.cpp @@ -309,7 +309,7 @@ void AudioDataConverters::convertInt24BEToFloat (const void* const source, float void AudioDataConverters::convertInt32LEToFloat (const void* const source, float* const dest, int numSamples, const int srcBytesPerSample) { - const float scale = 1.0f / 0x7fffffff; + const auto scale = 1.0f / (float) 0x7fffffff; const char* intData = static_cast (source); if (source != (void*) dest || srcBytesPerSample >= 4) @@ -334,7 +334,7 @@ void AudioDataConverters::convertInt32LEToFloat (const void* const source, float void AudioDataConverters::convertInt32BEToFloat (const void* const source, float* const dest, int numSamples, const int srcBytesPerSample) { - const float scale = 1.0f / 0x7fffffff; + const auto scale = 1.0f / (float) 0x7fffffff; const char* intData = static_cast (source); if (source != (void*) dest || srcBytesPerSample >= 4) diff --git a/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h b/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h index 7702b6e70d..dc78d7b2ec 100644 --- a/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h +++ b/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h @@ -629,7 +629,7 @@ public: jassert (isPositiveAndBelow (channel, numChannels)); jassert (startSample >= 0 && numSamples >= 0 && startSample + numSamples <= size); - const auto increment = (endGain - startGain) / numSamples; + const auto increment = (endGain - startGain) / (float) numSamples; auto* d = channels[channel] + startSample; while (--numSamples >= 0) diff --git a/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp b/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp index cbf6fb2554..5ec378ab49 100644 --- a/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp +++ b/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp @@ -874,7 +874,7 @@ void JUCE_CALLTYPE FloatVectorOperations::convertFixedToFloat (float* dest, cons vmulq_n_f32 (vcvtq_f32_s32 (vld1q_s32 (src)), multiplier), JUCE_LOAD_NONE, JUCE_INCREMENT_SRC_DEST, ) #else - JUCE_PERFORM_VEC_OP_SRC_DEST (dest[i] = src[i] * multiplier, + JUCE_PERFORM_VEC_OP_SRC_DEST (dest[i] = (float) src[i] * multiplier, Mode::mul (mult, _mm_cvtepi32_ps (_mm_loadu_si128 ((const __m128i*) src))), JUCE_LOAD_NONE, JUCE_INCREMENT_SRC_DEST, const Mode::ParallelType mult = Mode::load1 (multiplier);) @@ -1158,7 +1158,7 @@ public: static void convertFixed (float* d, const int* s, ValueType multiplier, int num) { while (--num >= 0) - *d++ = *s++ * multiplier; + *d++ = (float) *s++ * multiplier; } static bool areAllValuesEqual (const ValueType* d, int num, ValueType target) diff --git a/modules/juce_audio_basics/midi/juce_MidiBuffer.cpp b/modules/juce_audio_basics/midi/juce_MidiBuffer.cpp index cc71ff0bc8..8795756c70 100644 --- a/modules/juce_audio_basics/midi/juce_MidiBuffer.cpp +++ b/modules/juce_audio_basics/midi/juce_MidiBuffer.cpp @@ -34,7 +34,7 @@ namespace MidiBufferHelpers inline uint16 getEventTotalSize (const void* const d) noexcept { - return getEventDataSize (d) + sizeof (int32) + sizeof (uint16); + return (uint16) (getEventDataSize (d) + sizeof (int32) + sizeof (uint16)); } static int findActualEventLength (const uint8* const data, const int maxBytes) noexcept diff --git a/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp b/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp index 32108d48d2..a6e74c570f 100644 --- a/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp +++ b/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp @@ -929,7 +929,7 @@ void AudioDeviceManager::LevelMeter::updateLevel (const float* const* channelDat for (int i = 0; i < numChannels; ++i) s += std::abs (channelData[i][j]); - s /= numChannels; + s /= (float) numChannels; const double decayFactor = 0.99992; diff --git a/modules/juce_audio_devices/native/juce_linux_Midi.cpp b/modules/juce_audio_devices/native/juce_linux_Midi.cpp index 74bbe4131b..260fcc95d0 100644 --- a/modules/juce_audio_devices/native/juce_linux_Midi.cpp +++ b/modules/juce_audio_devices/native/juce_linux_Midi.cpp @@ -137,7 +137,7 @@ public: numBytes -= numSent; data += numSent; - snd_seq_ev_set_source (&event, portId); + snd_seq_ev_set_source (&event, (unsigned char) portId); snd_seq_ev_set_subs (&event); snd_seq_ev_set_direct (&event); diff --git a/modules/juce_audio_devices/sources/juce_AudioTransportSource.cpp b/modules/juce_audio_devices/sources/juce_AudioTransportSource.cpp index 31610633b0..7d59f13c76 100644 --- a/modules/juce_audio_devices/sources/juce_AudioTransportSource.cpp +++ b/modules/juce_audio_devices/sources/juce_AudioTransportSource.cpp @@ -159,7 +159,7 @@ void AudioTransportSource::setPosition (double newPosition) double AudioTransportSource::getCurrentPosition() const { if (sampleRate > 0.0) - return getNextReadPosition() / sampleRate; + return (double) getNextReadPosition() / sampleRate; return 0.0; } @@ -167,7 +167,7 @@ double AudioTransportSource::getCurrentPosition() const double AudioTransportSource::getLengthInSeconds() const { if (sampleRate > 0.0) - return getTotalLength() / sampleRate; + return (double) getTotalLength() / sampleRate; return 0.0; } @@ -177,7 +177,7 @@ void AudioTransportSource::setNextReadPosition (int64 newPosition) if (positionableSource != nullptr) { if (sampleRate > 0 && sourceSampleRate > 0) - newPosition = (int64) (newPosition * sourceSampleRate / sampleRate); + newPosition = (int64) ((double) newPosition * sourceSampleRate / sampleRate); positionableSource->setNextReadPosition (newPosition); @@ -193,7 +193,7 @@ int64 AudioTransportSource::getNextReadPosition() const if (positionableSource != nullptr) { const double ratio = (sampleRate > 0 && sourceSampleRate > 0) ? sampleRate / sourceSampleRate : 1.0; - return (int64) (positionableSource->getNextReadPosition() * ratio); + return (int64) ((double) positionableSource->getNextReadPosition() * ratio); } return 0; @@ -206,7 +206,7 @@ int64 AudioTransportSource::getTotalLength() const if (positionableSource != nullptr) { const double ratio = (sampleRate > 0 && sourceSampleRate > 0) ? sampleRate / sourceSampleRate : 1.0; - return (int64) (positionableSource->getTotalLength() * ratio); + return (int64) ((double) positionableSource->getTotalLength() * ratio); } return 0; diff --git a/modules/juce_audio_formats/codecs/flac/compat.h b/modules/juce_audio_formats/codecs/flac/compat.h index 543f49e83a..6c26491411 100644 --- a/modules/juce_audio_formats/codecs/flac/compat.h +++ b/modules/juce_audio_formats/codecs/flac/compat.h @@ -1,167 +1,167 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2012-2014 Xiph.org Foundation - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * - Neither the name of the Xiph.org Foundation nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* This is the prefered location of all CPP hackery to make $random_compiler - * work like something approaching a C99 (or maybe more accurately GNU99) - * compiler. - * - * It is assumed that this header will be included after "config.h". - */ - -#ifndef FLAC__SHARE__COMPAT_H -#define FLAC__SHARE__COMPAT_H - -#if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__ -#define FLAC__off_t __int64 /* use this instead of off_t to fix the 2 GB limit */ -#if !defined __MINGW32__ -#define fseeko _fseeki64 -#define ftello _ftelli64 -#else /* MinGW */ -#if !defined(HAVE_FSEEKO) -#define fseeko fseeko64 -#define ftello ftello64 -#endif -#endif -#else -#define FLAC__off_t off_t -#endif - -#if defined(_MSC_VER) -#define strtoll _strtoi64 -#define strtoull _strtoui64 -#endif - -#if defined(_MSC_VER) -#define inline __inline -#endif - -#if defined __INTEL_COMPILER || (defined _MSC_VER && defined _WIN64) -/* MSVS generates VERY slow 32-bit code with __restrict */ -#define flac_restrict __restrict -#elif defined __GNUC__ -#define flac_restrict __restrict__ -#else -#define flac_restrict -#endif - -#define FLAC__U64L(x) x##ULL - -#if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__ -#define FLAC__STRCASECMP stricmp -#define FLAC__STRNCASECMP strnicmp -#else -#define FLAC__STRCASECMP strcasecmp -#define FLAC__STRNCASECMP strncasecmp -#endif - -#if defined _MSC_VER -# if _MSC_VER >= 1600 -/* Visual Studio 2010 has decent C99 support */ -# define PRIu64 "llu" -# define PRId64 "lld" -# define PRIx64 "llx" -# else -# ifndef UINT32_MAX -# define UINT32_MAX _UI32_MAX -# endif - typedef unsigned __int64 uint64_t; - typedef unsigned __int32 uint32_t; - typedef unsigned __int16 uint16_t; - typedef unsigned __int8 uint8_t; - typedef __int64 int64_t; - typedef __int32 int32_t; - typedef __int16 int16_t; - typedef __int8 int8_t; -# define PRIu64 "I64u" -# define PRId64 "I64d" -# define PRIx64 "I64x" -# endif -#endif /* defined _MSC_VER */ - -#ifdef _WIN32 -/* All char* strings are in UTF-8 format. Added to support Unicode files on Windows */ -#include "win_utf8_io.h" - -#define flac_printf printf_utf8 -#define flac_fprintf fprintf_utf8 -#define flac_vfprintf vfprintf_utf8 -#define flac_fopen fopen_utf8 -#define flac_chmod chmod_utf8 -#define flac_utime utime_utf8 -#define flac_unlink unlink_utf8 -#define flac_rename rename_utf8 -#define flac_stat _stat64_utf8 - -#else - -#define flac_printf printf -#define flac_fprintf fprintf -#define flac_vfprintf vfprintf -#define flac_fopen fopen -#define flac_chmod chmod -#define flac_utime utime -#define flac_unlink unlink -#define flac_rename rename -#define flac_stat stat - -#endif - -#ifdef _WIN32 -#define flac_stat_s __stat64 /* stat struct */ -#define flac_fstat _fstat64 -#else -#define flac_stat_s stat /* stat struct */ -#define flac_fstat fstat -#endif - -#ifndef M_LN2 -#define M_LN2 0.69314718055994530942 -#endif -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif - -/* FLAC needs to compile and work correctly on systems with a normal ISO C99 - * snprintf as well as Microsoft Visual Studio which has an non-standards - * conformant snprint_s function. - * - * This function wraps the MS version to behave more like the the ISO version. - */ -#ifdef __cplusplus -extern "C" { -#endif -int flac_snprintf(char *str, size_t size, const char *fmt, ...); -int flac_vsnprintf(char *str, size_t size, const char *fmt, va_list va); -#ifdef __cplusplus -}; -#endif - -#endif /* FLAC__SHARE__COMPAT_H */ +/* libFLAC - Free Lossless Audio Codec library + * Copyright (C) 2012-2014 Xiph.org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* This is the prefered location of all CPP hackery to make $random_compiler + * work like something approaching a C99 (or maybe more accurately GNU99) + * compiler. + * + * It is assumed that this header will be included after "config.h". + */ + +#ifndef FLAC__SHARE__COMPAT_H +#define FLAC__SHARE__COMPAT_H + +#if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__ +#define FLAC__off_t __int64 /* use this instead of off_t to fix the 2 GB limit */ +#if !defined __MINGW32__ +#define fseeko _fseeki64 +#define ftello _ftelli64 +#else /* MinGW */ +#if !defined(HAVE_FSEEKO) +#define fseeko fseeko64 +#define ftello ftello64 +#endif +#endif +#else +#define FLAC__off_t off_t +#endif + +#if defined(_MSC_VER) +#define strtoll _strtoi64 +#define strtoull _strtoui64 +#endif + +#if defined(_MSC_VER) +#define inline __inline +#endif + +#if defined __INTEL_COMPILER || (defined _MSC_VER && defined _WIN64) +/* MSVS generates VERY slow 32-bit code with __restrict */ +#define flac_restrict __restrict +#elif defined __GNUC__ +#define flac_restrict __restrict__ +#else +#define flac_restrict +#endif + +#define FLAC__U64L(x) x##ULL + +#if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__ +#define FLAC__STRCASECMP stricmp +#define FLAC__STRNCASECMP strnicmp +#else +#define FLAC__STRCASECMP strcasecmp +#define FLAC__STRNCASECMP strncasecmp +#endif + +#if defined _MSC_VER +# if _MSC_VER >= 1600 +/* Visual Studio 2010 has decent C99 support */ +# define PRIu64 "llu" +# define PRId64 "lld" +# define PRIx64 "llx" +# else +# ifndef UINT32_MAX +# define UINT32_MAX _UI32_MAX +# endif + typedef unsigned __int64 uint64_t; + typedef unsigned __int32 uint32_t; + typedef unsigned __int16 uint16_t; + typedef unsigned __int8 uint8_t; + typedef __int64 int64_t; + typedef __int32 int32_t; + typedef __int16 int16_t; + typedef __int8 int8_t; +# define PRIu64 "I64u" +# define PRId64 "I64d" +# define PRIx64 "I64x" +# endif +#endif /* defined _MSC_VER */ + +#ifdef _WIN32 +/* All char* strings are in UTF-8 format. Added to support Unicode files on Windows */ +#include "win_utf8_io.h" + +#define flac_printf printf_utf8 +#define flac_fprintf fprintf_utf8 +#define flac_vfprintf vfprintf_utf8 +#define flac_fopen fopen_utf8 +#define flac_chmod chmod_utf8 +#define flac_utime utime_utf8 +#define flac_unlink unlink_utf8 +#define flac_rename rename_utf8 +#define flac_stat _stat64_utf8 + +#else + +#define flac_printf printf +#define flac_fprintf fprintf +#define flac_vfprintf vfprintf +#define flac_fopen fopen +#define flac_chmod chmod +#define flac_utime utime +#define flac_unlink unlink +#define flac_rename rename +#define flac_stat stat + +#endif + +#ifdef _WIN32 +#define flac_stat_s __stat64 /* stat struct */ +#define flac_fstat _fstat64 +#else +#define flac_stat_s stat /* stat struct */ +#define flac_fstat fstat +#endif + +#ifndef M_LN2 +#define M_LN2 0.69314718055994530942 +#endif +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +/* FLAC needs to compile and work correctly on systems with a normal ISO C99 + * snprintf as well as Microsoft Visual Studio which has an non-standards + * conformant snprint_s function. + * + * This function wraps the MS version to behave more like the the ISO version. + */ +#ifdef __cplusplus +extern "C" { +#endif +int flac_snprintf(char *str, size_t size, const char *fmt, ...); +int flac_vsnprintf(char *str, size_t size, const char *fmt, va_list va); +#ifdef __cplusplus +} +#endif + +#endif /* FLAC__SHARE__COMPAT_H */ diff --git a/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp index 9021d68142..d54bdc6f78 100644 --- a/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp @@ -892,7 +892,7 @@ namespace WavFileHelpers return xml.getMemoryBlock(); } - }; + } //============================================================================== struct ExtensibleWavSubFormat diff --git a/modules/juce_audio_plugin_client/juce_audio_plugin_client_Standalone.cpp b/modules/juce_audio_plugin_client/juce_audio_plugin_client_Standalone.cpp index 614cdbe52c..e5bf500d87 100644 --- a/modules/juce_audio_plugin_client/juce_audio_plugin_client_Standalone.cpp +++ b/modules/juce_audio_plugin_client/juce_audio_plugin_client_Standalone.cpp @@ -38,7 +38,7 @@ #endif #else - JUCE_CREATE_APPLICATION_DEFINE(StandaloneFilterApp); + JUCE_CREATE_APPLICATION_DEFINE(StandaloneFilterApp) #endif JUCE_MAIN_FUNCTION_DEFINITION diff --git a/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp b/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp index 11e311d684..0b1dcb5e41 100644 --- a/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp +++ b/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp @@ -228,38 +228,8 @@ static pointer_sized_int VSTINTERFACECALL audioMaster (VstEffectInterface*, int3 namespace { - static bool xErrorTriggered = false; - - static int temporaryErrorHandler (::Display*, XErrorEvent*) - { - xErrorTriggered = true; - return 0; - } - typedef void (*EventProcPtr) (XEvent* ev); - static EventProcPtr getPropertyFromXWindow (Window handle, Atom atom) - { - XErrorHandler oldErrorHandler = XSetErrorHandler (temporaryErrorHandler); - xErrorTriggered = false; - - int userSize; - unsigned long bytes, userCount; - unsigned char* data; - Atom userType; - - { - ScopedXDisplay xDisplay; - - XGetWindowProperty (xDisplay.display, handle, atom, 0, 1, false, AnyPropertyType, - &userType, &userSize, &userCount, &bytes, &data); - } - - XSetErrorHandler (oldErrorHandler); - - return (userCount == 1 && ! xErrorTriggered) ? *reinterpret_cast (data) : nullptr; - } - Window getChildWindow (Window windowToCheck) { Window rootWindow, parentWindow; @@ -276,55 +246,6 @@ namespace return 0; } - - static void translateJuceToXButtonModifiers (const MouseEvent& e, XEvent& ev) noexcept - { - if (e.mods.isLeftButtonDown()) - { - ev.xbutton.button = Button1; - ev.xbutton.state |= Button1Mask; - } - else if (e.mods.isRightButtonDown()) - { - ev.xbutton.button = Button3; - ev.xbutton.state |= Button3Mask; - } - else if (e.mods.isMiddleButtonDown()) - { - ev.xbutton.button = Button2; - ev.xbutton.state |= Button2Mask; - } - } - - static void translateJuceToXMotionModifiers (const MouseEvent& e, XEvent& ev) noexcept - { - if (e.mods.isLeftButtonDown()) ev.xmotion.state |= Button1Mask; - else if (e.mods.isRightButtonDown()) ev.xmotion.state |= Button3Mask; - else if (e.mods.isMiddleButtonDown()) ev.xmotion.state |= Button2Mask; - } - - static void translateJuceToXCrossingModifiers (const MouseEvent& e, XEvent& ev) noexcept - { - if (e.mods.isLeftButtonDown()) ev.xcrossing.state |= Button1Mask; - else if (e.mods.isRightButtonDown()) ev.xcrossing.state |= Button3Mask; - else if (e.mods.isMiddleButtonDown()) ev.xcrossing.state |= Button2Mask; - } - - static void translateJuceToXMouseWheelModifiers (const MouseEvent& e, const float increment, XEvent& ev) noexcept - { - ignoreUnused (e); - - if (increment < 0) - { - ev.xbutton.button = Button5; - ev.xbutton.state |= Button5Mask; - } - else if (increment > 0) - { - ev.xbutton.button = Button4; - ev.xbutton.state |= Button4Mask; - } - } } #endif diff --git a/modules/juce_core/misc/juce_StdFunctionCompat.cpp b/modules/juce_core/misc/juce_StdFunctionCompat.cpp index cf548ef609..ec56e2255e 100644 --- a/modules/juce_core/misc/juce_StdFunctionCompat.cpp +++ b/modules/juce_core/misc/juce_StdFunctionCompat.cpp @@ -32,8 +32,8 @@ namespace FunctionTestsHelpers { - void incrementArgument (int& x) { x++; }; - double multiply (double x, double a) noexcept { return a * x; }; + void incrementArgument (int& x) { x++; } + double multiply (double x, double a) noexcept { return a * x; } struct BigData { diff --git a/modules/juce_core/text/juce_CharacterFunctions.h b/modules/juce_core/text/juce_CharacterFunctions.h index 6cdfca9c03..bfdf54d15b 100644 --- a/modules/juce_core/text/juce_CharacterFunctions.h +++ b/modules/juce_core/text/juce_CharacterFunctions.h @@ -71,7 +71,7 @@ namespace internal template <> struct make_unsigned { typedef unsigned int type; }; template <> struct make_unsigned { typedef unsigned long type; }; template <> struct make_unsigned { typedef unsigned long long type; }; -}; +} //============================================================================== /** @@ -181,7 +181,7 @@ public: || ((numSigFigs == 0 && (! decimalPointFound)) && digit == 0)) continue; - *currentCharacter++ = '0' + (char) digit; + *currentCharacter++ = (char) ('0' + (char) digit); numSigFigs++; } else if ((! decimalPointFound) && *text == '.') @@ -219,7 +219,7 @@ public: if (digit != 0 || exponentMagnitude != 0) { - *currentCharacter++ = '0' + (char) digit; + *currentCharacter++ = (char) ('0' + (char) digit); exponentMagnitude = (exponentMagnitude * 10) + digit; } } diff --git a/modules/juce_dsp/native/juce_avx_SIMDNativeOps.h b/modules/juce_dsp/native/juce_avx_SIMDNativeOps.h index cdeda72596..c3f6506e95 100644 --- a/modules/juce_dsp/native/juce_avx_SIMDNativeOps.h +++ b/modules/juce_dsp/native/juce_avx_SIMDNativeOps.h @@ -198,7 +198,7 @@ struct SIMDNativeOps const int8_t* lo_ptr = reinterpret_cast (&lo); const int8_t* hi_ptr = reinterpret_cast (&hi); - return lo_ptr[0] + hi_ptr[0] + lo_ptr[16] + hi_ptr[16]; + return (int8_t) (lo_ptr[0] + hi_ptr[0] + lo_ptr[16] + hi_ptr[16]); } static forcedinline __m256i JUCE_VECTOR_CALLTYPE mul (__m256i a, __m256i b) @@ -257,7 +257,7 @@ struct SIMDNativeOps const uint8_t* lo_ptr = reinterpret_cast (&lo); const uint8_t* hi_ptr = reinterpret_cast (&hi); - return lo_ptr[0] + hi_ptr[0] + lo_ptr[16] + hi_ptr[16]; + return (uint8_t) (lo_ptr[0] + hi_ptr[0] + lo_ptr[16] + hi_ptr[16]); } static forcedinline __m256i JUCE_VECTOR_CALLTYPE mul (__m256i a, __m256i b) @@ -308,7 +308,7 @@ struct SIMDNativeOps tmp = _mm256_hadd_epi16 (tmp, tmp); tmp = _mm256_hadd_epi16 (tmp, tmp); int16_t* ptr = reinterpret_cast (&tmp); - return ptr[0] + ptr[8]; + return (int16_t) (ptr[0] + ptr[8]); } }; @@ -351,7 +351,7 @@ struct SIMDNativeOps tmp = _mm256_hadd_epi16 (tmp, tmp); tmp = _mm256_hadd_epi16 (tmp, tmp); uint16_t* ptr = reinterpret_cast (&tmp); - return ptr[0] + ptr[8]; + return (uint16_t) (ptr[0] + ptr[8]); } }; diff --git a/modules/juce_gui_basics/layout/juce_FlexBox.cpp b/modules/juce_gui_basics/layout/juce_FlexBox.cpp index bdaaea8060..fb042d3727 100644 --- a/modules/juce_gui_basics/layout/juce_FlexBox.cpp +++ b/modules/juce_gui_basics/layout/juce_FlexBox.cpp @@ -844,8 +844,8 @@ FlexItem FlexItem::withWidth (float newWidth) const noexcept { auto fi = FlexItem FlexItem::withMinWidth (float newMinWidth) const noexcept { auto fi = *this; fi.minWidth = newMinWidth; return fi; } FlexItem FlexItem::withMaxWidth (float newMaxWidth) const noexcept { auto fi = *this; fi.maxWidth = newMaxWidth; return fi; } -FlexItem FlexItem::withMinHeight (float newMinHeight) const noexcept { auto fi = *this; fi.minHeight = newMinHeight; return fi; }; -FlexItem FlexItem::withMaxHeight (float newMaxHeight) const noexcept { auto fi = *this; fi.maxHeight = newMaxHeight; return fi; }; +FlexItem FlexItem::withMinHeight (float newMinHeight) const noexcept { auto fi = *this; fi.minHeight = newMinHeight; return fi; } +FlexItem FlexItem::withMaxHeight (float newMaxHeight) const noexcept { auto fi = *this; fi.maxHeight = newMaxHeight; return fi; } FlexItem FlexItem::withHeight (float newHeight) const noexcept { auto fi = *this; fi.height = newHeight; return fi; } FlexItem FlexItem::withMargin (Margin m) const noexcept { auto fi = *this; fi.margin = m; return fi; } diff --git a/modules/juce_gui_basics/misc/juce_JUCESplashScreen.cpp b/modules/juce_gui_basics/misc/juce_JUCESplashScreen.cpp index 103266104a..387c481283 100644 --- a/modules/juce_gui_basics/misc/juce_JUCESplashScreen.cpp +++ b/modules/juce_gui_basics/misc/juce_JUCESplashScreen.cpp @@ -77,7 +77,7 @@ struct ReportingThreadContainer : public ChangeListener, juce_DeclareSingleton_SingleThreaded_Minimal (ReportingThreadContainer) }; -juce_ImplementSingleton_SingleThreaded (ReportingThreadContainer); +juce_ImplementSingleton_SingleThreaded (ReportingThreadContainer) //============================================================================== struct ReportingThread : public Thread, diff --git a/modules/juce_opengl/geometry/juce_Draggable3DOrientation.h b/modules/juce_opengl/geometry/juce_Draggable3DOrientation.h index cbc9093def..125f65f429 100644 --- a/modules/juce_opengl/geometry/juce_Draggable3DOrientation.h +++ b/modules/juce_opengl/geometry/juce_Draggable3DOrientation.h @@ -128,8 +128,8 @@ private: // calling any of the mouse input methods! jassert (scale > 0); - return Point ((mousePos.x - area.getCentreX()) / scale, - (area.getCentreY() - mousePos.y) / scale); + return Point ((mousePos.x - (float) area.getCentreX()) / (float) scale, + ((float) area.getCentreY() - mousePos.y) / (float) scale); } VectorType projectOnSphere (const Point pos) const noexcept diff --git a/modules/juce_osc/osc/juce_OSCTimeTag.cpp b/modules/juce_osc/osc/juce_OSCTimeTag.cpp index 35021a2ec8..cfc7c95203 100644 --- a/modules/juce_osc/osc/juce_OSCTimeTag.cpp +++ b/modules/juce_osc/osc/juce_OSCTimeTag.cpp @@ -42,9 +42,6 @@ OSCTimeTag::OSCTimeTag (Time time) noexcept { const uint64 milliseconds = (uint64) time.toMilliseconds() + millisecondsBetweenOscAndJuceEpochs; - // something went seriously wrong if the line above didn't render the time nonnegative! - jassert (milliseconds >= 0); - uint64 seconds = milliseconds / 1000; uint32 fractionalPart = uint32 (4294967.296 * (milliseconds % 1000)); diff --git a/modules/juce_product_unlocking/in_app_purchases/juce_InAppPurchases.cpp b/modules/juce_product_unlocking/in_app_purchases/juce_InAppPurchases.cpp index 341ba1a0ad..39a8cb17f8 100644 --- a/modules/juce_product_unlocking/in_app_purchases/juce_InAppPurchases.cpp +++ b/modules/juce_product_unlocking/in_app_purchases/juce_InAppPurchases.cpp @@ -48,7 +48,7 @@ void InAppPurchases::getProductsInformation (const StringArray& productIdentifie #else Array products; for (auto productId : productIdentifiers) - products.add (Product {productId}); + products.add (Product { productId, {}, {}, {}, {} }); listeners.call (&Listener::productsInfoReturned, products); #endif @@ -63,7 +63,7 @@ void InAppPurchases::purchaseProduct (const String& productIdentifier, pimpl->purchaseProduct (productIdentifier, isSubscription, upgradeProductIdentifiers, creditForUnusedSubscription); #else - Listener::PurchaseInfo purchaseInfo { Purchase {"", productIdentifier}, {} }; + Listener::PurchaseInfo purchaseInfo { Purchase { "", productIdentifier, {}, {}, {} }, {} }; listeners.call (&Listener::productPurchaseFinished, purchaseInfo, false, "In-app purchases unavailable"); ignoreUnused (isSubscription, upgradeProductIdentifiers, creditForUnusedSubscription); From f0ada66b0f022b397e525ea0ff7e7f1301cfc40b Mon Sep 17 00:00:00 2001 From: Lukasz Kozakiewicz Date: Tue, 29 Aug 2017 15:02:05 +0100 Subject: [PATCH 013/129] Android: ensure that temp directory exists before returning a path to it. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes “no such file or directory” error when calling open() for a file for which parent directory does not exist. --- modules/juce_core/native/juce_android_Files.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/juce_core/native/juce_android_Files.cpp b/modules/juce_core/native/juce_android_Files.cpp index 2b8f7ea998..41f8ec5f66 100644 --- a/modules/juce_core/native/juce_android_Files.cpp +++ b/modules/juce_core/native/juce_android_Files.cpp @@ -105,7 +105,11 @@ File File::getSpecialLocation (const SpecialLocationType type) return File ("/system/app"); case tempDirectory: - return File (android.appDataDir).getChildFile (".temp"); + { + File tmp = File (android.appDataDir).getChildFile (".temp"); + tmp.createDirectory(); + return File (tmp.getFullPathName()); + } case invokedExecutableFile: case currentExecutableFile: From 768163f75c79e5af0f00728483084b5996e6c7be Mon Sep 17 00:00:00 2001 From: hogliux Date: Tue, 29 Aug 2017 17:54:41 +0100 Subject: [PATCH 014/129] Added support for more F-keys --- .../keyboard/juce_KeyPress.cpp | 5 +++- .../juce_gui_basics/keyboard/juce_KeyPress.h | 19 +++++++++++++ .../native/juce_android_Windowing.cpp | 19 +++++++++++++ .../native/juce_ios_UIViewComponentPeer.mm | 19 +++++++++++++ .../native/juce_linux_X11_Windowing.cpp | 22 ++++++++++++++- .../native/juce_mac_NSViewComponentPeer.mm | 21 ++++++++++++++ .../native/juce_win32_Windowing.cpp | 28 +++++++++++++++++++ 7 files changed, 131 insertions(+), 2 deletions(-) diff --git a/modules/juce_gui_basics/keyboard/juce_KeyPress.cpp b/modules/juce_gui_basics/keyboard/juce_KeyPress.cpp index 8f407972ba..502a6a47f8 100644 --- a/modules/juce_gui_basics/keyboard/juce_KeyPress.cpp +++ b/modules/juce_gui_basics/keyboard/juce_KeyPress.cpp @@ -269,7 +269,10 @@ String KeyPress::getTextDescription() const if (keyCode == KeyPressHelpers::translations[i].code) return desc + KeyPressHelpers::translations[i].name; - if (keyCode >= F1Key && keyCode <= F16Key) desc << 'F' << (1 + keyCode - F1Key); + // not all F keys have consecutive key codes on all platforms + if (keyCode >= F1Key && keyCode <= F16Key) desc << 'F' << (1 + keyCode - F1Key); + else if (keyCode >= F17Key && keyCode <= F24Key) desc << 'F' << (17 + keyCode - F17Key); + else if (keyCode >= F25Key && keyCode <= F35Key) desc << 'F' << (25 + keyCode - F25Key); else if (keyCode >= numberPad0 && keyCode <= numberPad9) desc << KeyPressHelpers::numberPadPrefix() << (keyCode - numberPad0); else if (keyCode >= 33 && keyCode < 176) desc += CharacterFunctions::toUpperCase ((juce_wchar) keyCode); else if (keyCode == numberPadAdd) desc << KeyPressHelpers::numberPadPrefix() << '+'; diff --git a/modules/juce_gui_basics/keyboard/juce_KeyPress.h b/modules/juce_gui_basics/keyboard/juce_KeyPress.h index 420a869fb2..7e4c20bb5e 100644 --- a/modules/juce_gui_basics/keyboard/juce_KeyPress.h +++ b/modules/juce_gui_basics/keyboard/juce_KeyPress.h @@ -216,6 +216,25 @@ public: static const int F14Key; /**< key-code for the F14 key */ static const int F15Key; /**< key-code for the F15 key */ static const int F16Key; /**< key-code for the F16 key */ + static const int F17Key; /**< key-code for the F17 key */ + static const int F18Key; /**< key-code for the F18 key */ + static const int F19Key; /**< key-code for the F19 key */ + static const int F20Key; /**< key-code for the F20 key */ + static const int F21Key; /**< key-code for the F21 key */ + static const int F22Key; /**< key-code for the F22 key */ + static const int F23Key; /**< key-code for the F23 key */ + static const int F24Key; /**< key-code for the F24 key */ + static const int F25Key; /**< key-code for the F25 key */ + static const int F26Key; /**< key-code for the F26 key */ + static const int F27Key; /**< key-code for the F27 key */ + static const int F28Key; /**< key-code for the F28 key */ + static const int F29Key; /**< key-code for the F29 key */ + static const int F30Key; /**< key-code for the F30 key */ + static const int F31Key; /**< key-code for the F31 key */ + static const int F32Key; /**< key-code for the F32 key */ + static const int F33Key; /**< key-code for the F33 key */ + static const int F34Key; /**< key-code for the F34 key */ + static const int F35Key; /**< key-code for the F35 key */ static const int numberPad0; /**< key-code for the 0 on the numeric keypad. */ static const int numberPad1; /**< key-code for the 1 on the numeric keypad. */ diff --git a/modules/juce_gui_basics/native/juce_android_Windowing.cpp b/modules/juce_gui_basics/native/juce_android_Windowing.cpp index f6970feacb..f15090bf8f 100644 --- a/modules/juce_gui_basics/native/juce_android_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_android_Windowing.cpp @@ -1023,6 +1023,25 @@ const int KeyPress::F13Key = extendedKeyModifier + 23; const int KeyPress::F14Key = extendedKeyModifier + 24; const int KeyPress::F15Key = extendedKeyModifier + 25; const int KeyPress::F16Key = extendedKeyModifier + 26; +const int KeyPress::F17Key = extendedKeyModifier + 50; +const int KeyPress::F18Key = extendedKeyModifier + 51; +const int KeyPress::F19Key = extendedKeyModifier + 52; +const int KeyPress::F20Key = extendedKeyModifier + 53; +const int KeyPress::F21Key = extendedKeyModifier + 54; +const int KeyPress::F22Key = extendedKeyModifier + 55; +const int KeyPress::F23Key = extendedKeyModifier + 56; +const int KeyPress::F24Key = extendedKeyModifier + 57; +const int KeyPress::F25Key = extendedKeyModifier + 58; +const int KeyPress::F26Key = extendedKeyModifier + 59; +const int KeyPress::F27Key = extendedKeyModifier + 60; +const int KeyPress::F28Key = extendedKeyModifier + 61; +const int KeyPress::F29Key = extendedKeyModifier + 62; +const int KeyPress::F30Key = extendedKeyModifier + 63; +const int KeyPress::F31Key = extendedKeyModifier + 64; +const int KeyPress::F32Key = extendedKeyModifier + 65; +const int KeyPress::F33Key = extendedKeyModifier + 66; +const int KeyPress::F34Key = extendedKeyModifier + 67; +const int KeyPress::F35Key = extendedKeyModifier + 68; const int KeyPress::numberPad0 = extendedKeyModifier + 27; const int KeyPress::numberPad1 = extendedKeyModifier + 28; const int KeyPress::numberPad2 = extendedKeyModifier + 29; diff --git a/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm b/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm index e9cb4a22dd..e61f2621bb 100644 --- a/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm +++ b/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm @@ -1127,6 +1127,25 @@ const int KeyPress::F13Key = 0x200d; const int KeyPress::F14Key = 0x200e; const int KeyPress::F15Key = 0x200f; const int KeyPress::F16Key = 0x2010; +const int KeyPress::F17Key = 0x2011; +const int KeyPress::F18Key = 0x2012; +const int KeyPress::F19Key = 0x2013; +const int KeyPress::F20Key = 0x2014; +const int KeyPress::F21Key = 0x2015; +const int KeyPress::F22Key = 0x2016; +const int KeyPress::F23Key = 0x2017; +const int KeyPress::F24Key = 0x2018; +const int KeyPress::F25Key = 0x2019; +const int KeyPress::F26Key = 0x201a; +const int KeyPress::F27Key = 0x201b; +const int KeyPress::F28Key = 0x201c; +const int KeyPress::F29Key = 0x201d; +const int KeyPress::F30Key = 0x201e; +const int KeyPress::F31Key = 0x201f; +const int KeyPress::F32Key = 0x2020; +const int KeyPress::F33Key = 0x2021; +const int KeyPress::F34Key = 0x2022; +const int KeyPress::F35Key = 0x2023; const int KeyPress::numberPad0 = 0x30020; const int KeyPress::numberPad1 = 0x30021; const int KeyPress::numberPad2 = 0x30022; diff --git a/modules/juce_gui_basics/native/juce_linux_X11_Windowing.cpp b/modules/juce_gui_basics/native/juce_linux_X11_Windowing.cpp index 1ed776fcf6..9d5ca6e53b 100644 --- a/modules/juce_gui_basics/native/juce_linux_X11_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_linux_X11_Windowing.cpp @@ -135,6 +135,26 @@ const int KeyPress::F13Key = (XK_F13 & 0xff) | Keys::extendedKe const int KeyPress::F14Key = (XK_F14 & 0xff) | Keys::extendedKeyModifier; const int KeyPress::F15Key = (XK_F15 & 0xff) | Keys::extendedKeyModifier; const int KeyPress::F16Key = (XK_F16 & 0xff) | Keys::extendedKeyModifier; +const int KeyPress::F17Key = (XK_F17 & 0xff) | Keys::extendedKeyModifier; +const int KeyPress::F18Key = (XK_F18 & 0xff) | Keys::extendedKeyModifier; +const int KeyPress::F19Key = (XK_F19 & 0xff) | Keys::extendedKeyModifier; +const int KeyPress::F20Key = (XK_F20 & 0xff) | Keys::extendedKeyModifier; +const int KeyPress::F21Key = (XK_F21 & 0xff) | Keys::extendedKeyModifier; +const int KeyPress::F22Key = (XK_F22 & 0xff) | Keys::extendedKeyModifier; +const int KeyPress::F23Key = (XK_F23 & 0xff) | Keys::extendedKeyModifier; +const int KeyPress::F24Key = (XK_F24 & 0xff) | Keys::extendedKeyModifier; +const int KeyPress::F25Key = (XK_F25 & 0xff) | Keys::extendedKeyModifier; +const int KeyPress::F26Key = (XK_F26 & 0xff) | Keys::extendedKeyModifier; +const int KeyPress::F27Key = (XK_F27 & 0xff) | Keys::extendedKeyModifier; +const int KeyPress::F28Key = (XK_F28 & 0xff) | Keys::extendedKeyModifier; +const int KeyPress::F29Key = (XK_F29 & 0xff) | Keys::extendedKeyModifier; +const int KeyPress::F30Key = (XK_F30 & 0xff) | Keys::extendedKeyModifier; +const int KeyPress::F31Key = (XK_F31 & 0xff) | Keys::extendedKeyModifier; +const int KeyPress::F32Key = (XK_F32 & 0xff) | Keys::extendedKeyModifier; +const int KeyPress::F33Key = (XK_F33 & 0xff) | Keys::extendedKeyModifier; +const int KeyPress::F34Key = (XK_F34 & 0xff) | Keys::extendedKeyModifier; +const int KeyPress::F35Key = (XK_F35 & 0xff) | Keys::extendedKeyModifier; + const int KeyPress::numberPad0 = (XK_KP_0 & 0xff) | Keys::extendedKeyModifier; const int KeyPress::numberPad1 = (XK_KP_1 & 0xff) | Keys::extendedKeyModifier; const int KeyPress::numberPad2 = (XK_KP_2 & 0xff) | Keys::extendedKeyModifier; @@ -2125,7 +2145,7 @@ public: break; default: - if (sym >= XK_F1 && sym <= XK_F16) + if (sym >= XK_F1 && sym <= XK_F35) { keyPressed = true; keyCode = (sym & 0xff) | Keys::extendedKeyModifier; diff --git a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm index 492bea9b1a..3b0244b5ca 100644 --- a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm +++ b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm @@ -2150,6 +2150,27 @@ const int KeyPress::F13Key = NSF13FunctionKey; const int KeyPress::F14Key = NSF14FunctionKey; const int KeyPress::F15Key = NSF15FunctionKey; const int KeyPress::F16Key = NSF16FunctionKey; +const int KeyPress::F17Key = NSF17FunctionKey; +const int KeyPress::F18Key = NSF18FunctionKey; +const int KeyPress::F19Key = NSF19FunctionKey; +const int KeyPress::F20Key = NSF20FunctionKey; +const int KeyPress::F21Key = NSF21FunctionKey; +const int KeyPress::F22Key = NSF22FunctionKey; +const int KeyPress::F23Key = NSF23FunctionKey; +const int KeyPress::F24Key = NSF24FunctionKey; +const int KeyPress::F25Key = NSF25FunctionKey; +const int KeyPress::F26Key = NSF26FunctionKey; +const int KeyPress::F27Key = NSF27FunctionKey; +const int KeyPress::F28Key = NSF28FunctionKey; +const int KeyPress::F29Key = NSF29FunctionKey; +const int KeyPress::F30Key = NSF30FunctionKey; +const int KeyPress::F31Key = NSF31FunctionKey; +const int KeyPress::F32Key = NSF32FunctionKey; +const int KeyPress::F33Key = NSF33FunctionKey; +const int KeyPress::F34Key = NSF34FunctionKey; +const int KeyPress::F35Key = NSF35FunctionKey; + + const int KeyPress::numberPad0 = 0x30020; const int KeyPress::numberPad1 = 0x30021; const int KeyPress::numberPad2 = 0x30022; diff --git a/modules/juce_gui_basics/native/juce_win32_Windowing.cpp b/modules/juce_gui_basics/native/juce_win32_Windowing.cpp index 884faea93e..80216af862 100644 --- a/modules/juce_gui_basics/native/juce_win32_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_win32_Windowing.cpp @@ -429,6 +429,26 @@ const int KeyPress::F13Key = VK_F13 | extendedKeyMod const int KeyPress::F14Key = VK_F14 | extendedKeyModifier; const int KeyPress::F15Key = VK_F15 | extendedKeyModifier; const int KeyPress::F16Key = VK_F16 | extendedKeyModifier; +const int KeyPress::F17Key = VK_F17 | extendedKeyModifier; +const int KeyPress::F18Key = VK_F18 | extendedKeyModifier; +const int KeyPress::F19Key = VK_F19 | extendedKeyModifier; +const int KeyPress::F20Key = VK_F20 | extendedKeyModifier; +const int KeyPress::F21Key = VK_F21 | extendedKeyModifier; +const int KeyPress::F22Key = VK_F22 | extendedKeyModifier; +const int KeyPress::F23Key = VK_F23 | extendedKeyModifier; +const int KeyPress::F24Key = VK_F24 | extendedKeyModifier; +const int KeyPress::F25Key = 0x31000; // Windows doesn't support F-keys 25 or higher +const int KeyPress::F26Key = 0x31001; +const int KeyPress::F27Key = 0x31002; +const int KeyPress::F28Key = 0x31003; +const int KeyPress::F29Key = 0x31004; +const int KeyPress::F30Key = 0x31005; +const int KeyPress::F31Key = 0x31006; +const int KeyPress::F32Key = 0x31007; +const int KeyPress::F33Key = 0x31008; +const int KeyPress::F34Key = 0x31009; +const int KeyPress::F35Key = 0x3100a; + const int KeyPress::numberPad0 = VK_NUMPAD0 | extendedKeyModifier; const int KeyPress::numberPad1 = VK_NUMPAD1 | extendedKeyModifier; const int KeyPress::numberPad2 = VK_NUMPAD2 | extendedKeyModifier; @@ -2584,6 +2604,14 @@ private: case VK_F14: case VK_F15: case VK_F16: + case VK_F17: + case VK_F18: + case VK_F19: + case VK_F20: + case VK_F21: + case VK_F22: + case VK_F23: + case VK_F24: used = handleKeyUpOrDown (true); used = handleKeyPress (extendedKeyModifier | (int) key, 0) || used; break; From ff6d01bc254bbaf359b474f53da9a1534b19b90e Mon Sep 17 00:00:00 2001 From: tpoole Date: Wed, 30 Aug 2017 09:55:56 +0100 Subject: [PATCH 015/129] Added a function to the InterprocessConnectionServer class to get the bound port number --- modules/juce_core/network/juce_Socket.h | 3 ++- .../interprocess/juce_InterprocessConnectionServer.cpp | 5 +++++ .../interprocess/juce_InterprocessConnectionServer.h | 10 +++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/modules/juce_core/network/juce_Socket.h b/modules/juce_core/network/juce_Socket.h index 66d259fdbe..8c586f9f38 100644 --- a/modules/juce_core/network/juce_Socket.h +++ b/modules/juce_core/network/juce_Socket.h @@ -74,7 +74,8 @@ public: This is useful if you need to know to which port the OS has actually bound your socket when calling the constructor or bindToPort with zero as the - localPortNumber argument. Returns -1 if the function fails. */ + localPortNumber argument. Returns -1 if the function fails. + */ int getBoundPort() const noexcept; /** Tries to connect the socket to hostname:port. diff --git a/modules/juce_events/interprocess/juce_InterprocessConnectionServer.cpp b/modules/juce_events/interprocess/juce_InterprocessConnectionServer.cpp index d972d9794b..196d90978e 100644 --- a/modules/juce_events/interprocess/juce_InterprocessConnectionServer.cpp +++ b/modules/juce_events/interprocess/juce_InterprocessConnectionServer.cpp @@ -58,6 +58,11 @@ void InterprocessConnectionServer::stop() socket = nullptr; } +int InterprocessConnectionServer::getBoundPort() const noexcept +{ + return (socket == nullptr) ? -1 : socket->getBoundPort(); +} + void InterprocessConnectionServer::run() { while ((! threadShouldExit()) && socket != nullptr) diff --git a/modules/juce_events/interprocess/juce_InterprocessConnectionServer.h b/modules/juce_events/interprocess/juce_InterprocessConnectionServer.h index 8afd71ae34..f731a379a2 100644 --- a/modules/juce_events/interprocess/juce_InterprocessConnectionServer.h +++ b/modules/juce_events/interprocess/juce_InterprocessConnectionServer.h @@ -71,6 +71,15 @@ public: */ void stop(); + /** Returns the local port number to which this server is currently bound. + + This is useful if you need to know to which port the OS has actually bound your + socket when calling beginWaitingForSocket with a port number of zero. + + Returns -1 if the function fails. + */ + int getBoundPort() const noexcept; + protected: /** Creates a suitable connection object for a client process that wants to connect to this one. @@ -83,7 +92,6 @@ protected: */ virtual InterprocessConnection* createConnectionObject() = 0; - private: //============================================================================== ScopedPointer socket; From b78ce1f059fb6941c95e7726d5398714348307c4 Mon Sep 17 00:00:00 2001 From: hogliux Date: Wed, 30 Aug 2017 10:47:51 +0100 Subject: [PATCH 016/129] Fixed an assertion when quitting the standalone plug-in target when the audio settings window is open --- .../Standalone/juce_StandaloneFilterApp.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterApp.cpp b/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterApp.cpp index 7b8934b4c8..a4c9a1e6b8 100644 --- a/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterApp.cpp +++ b/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterApp.cpp @@ -116,7 +116,16 @@ public: //============================================================================== void systemRequestedQuit() override { - quit(); + if (ModalComponentManager::getInstance()->cancelAllModalComponents()) + { + Timer::callAfterDelay (100, []() + { + if (auto app = JUCEApplicationBase::getInstance()) + app->systemRequestedQuit(); + }); + } + else + quit(); } protected: From 91e0385d262ae347293de3f78f6f0fa0546b125e Mon Sep 17 00:00:00 2001 From: hogliux Date: Wed, 30 Aug 2017 11:38:34 +0100 Subject: [PATCH 017/129] Linux ALSA: Fixed a crash when playing/recording audio on a device that only supports interleaved audio --- .../native/juce_linux_ALSA.cpp | 36 ++++++++++++------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/modules/juce_audio_devices/native/juce_linux_ALSA.cpp b/modules/juce_audio_devices/native/juce_linux_ALSA.cpp index b3eb21dd7b..84432055a6 100644 --- a/modules/juce_audio_devices/native/juce_linux_ALSA.cpp +++ b/modules/juce_audio_devices/native/juce_linux_ALSA.cpp @@ -241,7 +241,8 @@ public: (type & isFloatBit) != 0, (type & isLittleEndianBit) != 0, (type & onlyUseLower24Bits) != 0, - numChannels); + numChannels, + isInterleaved); break; } } @@ -393,44 +394,55 @@ private: template struct ConverterHelper { - static AudioData::Converter* createConverter (const bool forInput, const bool isLittleEndian, const int numInterleavedChannels) + static AudioData::Converter* createConverter (const bool forInput, const bool isLittleEndian, const int numInterleavedChannels, bool interleaved) + { + if (interleaved) + return create (forInput, isLittleEndian, numInterleavedChannels); + + return create (forInput, isLittleEndian, numInterleavedChannels); + } + + private: + template + static AudioData::Converter* create (const bool forInput, const bool isLittleEndian, const int numInterleavedChannels) { if (forInput) { typedef AudioData::Pointer DestType; if (isLittleEndian) - return new AudioData::ConverterInstance , DestType> (numInterleavedChannels, 1); + return new AudioData::ConverterInstance , DestType> (numInterleavedChannels, 1); - return new AudioData::ConverterInstance , DestType> (numInterleavedChannels, 1); + return new AudioData::ConverterInstance , DestType> (numInterleavedChannels, 1); } typedef AudioData::Pointer SourceType; if (isLittleEndian) - return new AudioData::ConverterInstance > (1, numInterleavedChannels); + return new AudioData::ConverterInstance > (1, numInterleavedChannels); - return new AudioData::ConverterInstance > (1, numInterleavedChannels); + return new AudioData::ConverterInstance > (1, numInterleavedChannels); } }; static AudioData::Converter* createConverter (bool forInput, int bitDepth, bool isFloat, bool isLittleEndian, bool useOnlyLower24Bits, - int numInterleavedChannels) + int numInterleavedChannels, + bool interleaved) { JUCE_ALSA_LOG ("format: bitDepth=" << bitDepth << ", isFloat=" << (int) isFloat << ", isLittleEndian=" << (int) isLittleEndian << ", numChannels=" << numInterleavedChannels); - if (isFloat) return ConverterHelper ::createConverter (forInput, isLittleEndian, numInterleavedChannels); - if (bitDepth == 16) return ConverterHelper ::createConverter (forInput, isLittleEndian, numInterleavedChannels); - if (bitDepth == 24) return ConverterHelper ::createConverter (forInput, isLittleEndian, numInterleavedChannels); + if (isFloat) return ConverterHelper ::createConverter (forInput, isLittleEndian, numInterleavedChannels, interleaved); + if (bitDepth == 16) return ConverterHelper ::createConverter (forInput, isLittleEndian, numInterleavedChannels, interleaved); + if (bitDepth == 24) return ConverterHelper ::createConverter (forInput, isLittleEndian, numInterleavedChannels, interleaved); jassert (bitDepth == 32); if (useOnlyLower24Bits) - return ConverterHelper ::createConverter (forInput, isLittleEndian, numInterleavedChannels); + return ConverterHelper ::createConverter (forInput, isLittleEndian, numInterleavedChannels, interleaved); - return ConverterHelper ::createConverter (forInput, isLittleEndian, numInterleavedChannels); + return ConverterHelper ::createConverter (forInput, isLittleEndian, numInterleavedChannels, interleaved); } //============================================================================== From 858b206553dcccc9c78cb8c337f404ad3888ab54 Mon Sep 17 00:00:00 2001 From: hogliux Date: Wed, 30 Aug 2017 11:42:00 +0100 Subject: [PATCH 018/129] Revert recent commit - Windows: Ensure that memory mapped files behave the same on all targets by allowing other code to open the memory mapped file with write priveleges even if the map was created with read priveleges only --- modules/juce_core/native/juce_win32_Files.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/juce_core/native/juce_win32_Files.cpp b/modules/juce_core/native/juce_win32_Files.cpp index 6ecaf91c7e..5185d12087 100644 --- a/modules/juce_core/native/juce_win32_Files.cpp +++ b/modules/juce_core/native/juce_win32_Files.cpp @@ -360,7 +360,7 @@ void MemoryMappedFile::openInternal (const File& file, AccessMode mode, bool exc } HANDLE h = CreateFile (file.getFullPathName().toWideCharPointer(), accessMode, - exclusive ? 0 : FILE_SHARE_WRITE, 0, + exclusive ? 0 : (FILE_SHARE_READ | (mode == readWrite ? FILE_SHARE_WRITE : 0)), 0, createType, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, 0); if (h != INVALID_HANDLE_VALUE) From 66da02d233cb92ce9d40e2dab95864ca24336692 Mon Sep 17 00:00:00 2001 From: hogliux Date: Wed, 30 Aug 2017 14:59:26 +0100 Subject: [PATCH 019/129] Fixed an issue where ComboBox popup menus would flicker if a second combobox menu was opened --- modules/juce_gui_basics/widgets/juce_ComboBox.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/juce_gui_basics/widgets/juce_ComboBox.cpp b/modules/juce_gui_basics/widgets/juce_ComboBox.cpp index 95702233a4..a601c86b0e 100644 --- a/modules/juce_gui_basics/widgets/juce_ComboBox.cpp +++ b/modules/juce_gui_basics/widgets/juce_ComboBox.cpp @@ -505,7 +505,14 @@ void ComboBox::showPopupIfNotActive() if (! menuActive) { menuActive = true; - showPopup(); + + SafePointer safePointer (this); + + // as this method was triggered by a mouse event, the same mouse event may have + // exited the modal state of other popups currently on the screen. By calling + // showPopup asynchronously, we are giving the other popups a chance to properly + // close themselves + MessageManager::callAsync([safePointer] () mutable { if (safePointer != nullptr) safePointer->showPopup(); }); } } From 53aa5b9849e9c9509cb97222d37b5aabaa957672 Mon Sep 17 00:00:00 2001 From: tpoole Date: Wed, 30 Aug 2017 13:22:59 +0100 Subject: [PATCH 020/129] Removed some duplicated code from the demo plug-in --- .../Source/PluginProcessor.cpp | 128 +----------------- 1 file changed, 1 insertion(+), 127 deletions(-) diff --git a/examples/audio plugin demo/Source/PluginProcessor.cpp b/examples/audio plugin demo/Source/PluginProcessor.cpp index f8c06d9de8..6e791763ea 100644 --- a/examples/audio plugin demo/Source/PluginProcessor.cpp +++ b/examples/audio plugin demo/Source/PluginProcessor.cpp @@ -26,137 +26,11 @@ #include "PluginProcessor.h" #include "PluginEditor.h" +#include "SinewaveSynth.h" AudioProcessor* JUCE_CALLTYPE createPluginFilter(); -//============================================================================== -/** A demo synth sound that's just a basic sine wave.. */ -class SineWaveSound : public SynthesiserSound -{ -public: - SineWaveSound() {} - - bool appliesToNote (int /*midiNoteNumber*/) override { return true; } - bool appliesToChannel (int /*midiChannel*/) override { return true; } -}; - -//============================================================================== -/** A simple demo synth voice that just plays a sine wave.. */ -class SineWaveVoice : public SynthesiserVoice -{ -public: - SineWaveVoice() - { - } - - bool canPlaySound (SynthesiserSound* sound) override - { - return dynamic_cast (sound) != nullptr; - } - - void startNote (int midiNoteNumber, float velocity, - SynthesiserSound* /*sound*/, - int /*currentPitchWheelPosition*/) override - { - currentAngle = 0.0; - level = velocity * 0.15; - tailOff = 0.0; - - double cyclesPerSecond = MidiMessage::getMidiNoteInHertz (midiNoteNumber); - double cyclesPerSample = cyclesPerSecond / getSampleRate(); - - angleDelta = cyclesPerSample * 2.0 * double_Pi; - } - - void stopNote (float /*velocity*/, bool allowTailOff) override - { - if (allowTailOff) - { - // start a tail-off by setting this flag. The render callback will pick up on - // this and do a fade out, calling clearCurrentNote() when it's finished. - - if (tailOff == 0.0) // we only need to begin a tail-off if it's not already doing so - the - // stopNote method could be called more than once. - tailOff = 1.0; - } - else - { - // we're being told to stop playing immediately, so reset everything.. - - clearCurrentNote(); - angleDelta = 0.0; - } - } - - void pitchWheelMoved (int /*newValue*/) override - { - // can't be bothered implementing this for the demo! - } - - void controllerMoved (int /*controllerNumber*/, int /*newValue*/) override - { - // not interested in controllers in this case. - } - - void renderNextBlock (AudioBuffer& outputBuffer, int startSample, int numSamples) override - { - processBlock (outputBuffer, startSample, numSamples); - } - - void renderNextBlock (AudioBuffer& outputBuffer, int startSample, int numSamples) override - { - processBlock (outputBuffer, startSample, numSamples); - } - -private: - template - void processBlock (AudioBuffer& outputBuffer, int startSample, int numSamples) - { - if (angleDelta != 0.0) - { - if (tailOff > 0) - { - while (--numSamples >= 0) - { - auto currentSample = static_cast (std::sin (currentAngle) * level * tailOff); - - for (int i = outputBuffer.getNumChannels(); --i >= 0;) - outputBuffer.addSample (i, startSample, currentSample); - - currentAngle += angleDelta; - ++startSample; - - tailOff *= 0.99; - - if (tailOff <= 0.005) - { - clearCurrentNote(); - - angleDelta = 0.0; - break; - } - } - } - else - { - while (--numSamples >= 0) - { - auto currentSample = static_cast (std::sin (currentAngle) * level); - - for (int i = outputBuffer.getNumChannels(); --i >= 0;) - outputBuffer.addSample (i, startSample, currentSample); - - currentAngle += angleDelta; - ++startSample; - } - } - } - } - - double currentAngle = 0, angleDelta = 0, level = 0, tailOff = 0; -}; - //============================================================================== JuceDemoPluginAudioProcessor::JuceDemoPluginAudioProcessor() : AudioProcessor (getBusesProperties()) From 9b30c2401a96c6aa785cb9f4a612a358ad78a264 Mon Sep 17 00:00:00 2001 From: tpoole Date: Wed, 30 Aug 2017 15:08:13 +0100 Subject: [PATCH 021/129] Added plug-in host type detection for Cubase 8.5 and 9 --- .../utility/juce_PluginHostType.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/modules/juce_audio_plugin_client/utility/juce_PluginHostType.h b/modules/juce_audio_plugin_client/utility/juce_PluginHostType.h index b4963cd702..1308232036 100644 --- a/modules/juce_audio_plugin_client/utility/juce_PluginHostType.h +++ b/modules/juce_audio_plugin_client/utility/juce_PluginHostType.h @@ -65,6 +65,8 @@ public: SteinbergCubase6, SteinbergCubase7, SteinbergCubase8, + SteinbergCubase8_5, + SteinbergCubase9, SteinbergCubaseGeneric, SteinbergNuendo3, SteinbergNuendo4, @@ -91,7 +93,7 @@ public: bool isAdobeAudition() const noexcept { return type == AdobeAudition; } bool isArdour() const noexcept { return type == Ardour; } bool isBitwigStudio() const noexcept { return type == BitwigStudio; } - bool isCubase() const noexcept { return type == SteinbergCubase4 || type == SteinbergCubase5 || type == SteinbergCubase5Bridged || type == SteinbergCubase6 || type == SteinbergCubase7 || type == SteinbergCubase8 || type == SteinbergCubaseGeneric; } + bool isCubase() const noexcept { return type == SteinbergCubase4 || type == SteinbergCubase5 || type == SteinbergCubase5Bridged || type == SteinbergCubase6 || type == SteinbergCubase7 || type == SteinbergCubase8 || type == SteinbergCubase8_5 || type == SteinbergCubase9 || type == SteinbergCubaseGeneric; } bool isCubase7orLater() const noexcept { return isCubase() && ! (type == SteinbergCubase4 || type == SteinbergCubase5 || type == SteinbergCubase6); } bool isCubaseBridged() const noexcept { return type == SteinbergCubase5Bridged; } bool isDaVinciResolve() const noexcept { return type == DaVinciResolve; } @@ -151,6 +153,8 @@ public: case SteinbergCubase6: return "Steinberg Cubase 6"; case SteinbergCubase7: return "Steinberg Cubase 7"; case SteinbergCubase8: return "Steinberg Cubase 8"; + case SteinbergCubase8_5: return "Steinberg Cubase 8.5"; + case SteinbergCubase9: return "Steinberg Cubase 9"; case SteinbergCubaseGeneric: return "Steinberg Cubase"; case SteinbergNuendo3: return "Steinberg Nuendo 3"; case SteinbergNuendo4: return "Steinberg Nuendo 4"; @@ -229,7 +233,9 @@ private: if (hostFilename.containsIgnoreCase ("Cubase 5")) return SteinbergCubase5; if (hostFilename.containsIgnoreCase ("Cubase 6")) return SteinbergCubase6; if (hostFilename.containsIgnoreCase ("Cubase 7")) return SteinbergCubase7; - if (hostFilename.containsIgnoreCase ("Cubase 8")) return SteinbergCubase8; + if (hostPath.containsIgnoreCase ("Cubase 8.app")) return SteinbergCubase8; + if (hostPath.containsIgnoreCase ("Cubase 8.5.app")) return SteinbergCubase8_5; + if (hostPath.containsIgnoreCase ("Cubase 9.app")) return SteinbergCubase9; if (hostFilename.containsIgnoreCase ("Cubase")) return SteinbergCubaseGeneric; if (hostPath.containsIgnoreCase ("Wavelab 7")) return SteinbergWavelab7; if (hostPath.containsIgnoreCase ("Wavelab 8")) return SteinbergWavelab8; @@ -265,7 +271,11 @@ private: if (hostFilename.containsIgnoreCase ("Cubase5")) return SteinbergCubase5; if (hostFilename.containsIgnoreCase ("Cubase6")) return SteinbergCubase6; if (hostFilename.containsIgnoreCase ("Cubase7")) return SteinbergCubase7; - if (hostFilename.containsIgnoreCase ("Cubase8")) return SteinbergCubase8; + if (hostFilename.containsIgnoreCase ("Cubase8.exe")) return SteinbergCubase8; + if (hostFilename.containsIgnoreCase ("Cubase8.5.exe")) return SteinbergCubase8_5; + // Cubase 9 scans plug-ins with a separate executable "vst2xscanner" + if (hostFilename.containsIgnoreCase ("Cubase9.exe") + || hostPath.containsIgnoreCase ("Cubase 9")) return SteinbergCubase9; if (hostFilename.containsIgnoreCase ("Cubase")) return SteinbergCubaseGeneric; if (hostFilename.containsIgnoreCase ("VSTBridgeApp")) return SteinbergCubase5Bridged; if (hostPath.containsIgnoreCase ("Wavelab 5")) return SteinbergWavelab5; From d105d9418aec0a652b4c0c979b796e11839641bf Mon Sep 17 00:00:00 2001 From: hogliux Date: Wed, 30 Aug 2017 15:53:04 +0100 Subject: [PATCH 022/129] Added a minimum velocity property to the ContinuousWithMomentum animated position behaviour and increased the minimum velocity of the viewport to avoid some jitter when the viewport animation is close to stand still --- .../layout/juce_AnimatedPositionBehaviours.h | 11 +++++++++-- modules/juce_gui_basics/layout/juce_Viewport.cpp | 4 ++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/modules/juce_gui_basics/layout/juce_AnimatedPositionBehaviours.h b/modules/juce_gui_basics/layout/juce_AnimatedPositionBehaviours.h index e29bc73ccd..481e2be7ee 100644 --- a/modules/juce_gui_basics/layout/juce_AnimatedPositionBehaviours.h +++ b/modules/juce_gui_basics/layout/juce_AnimatedPositionBehaviours.h @@ -56,6 +56,13 @@ namespace AnimatedPositionBehaviours damping = 1.0 - newFriction; } + /** Sets the minimum velocity of the movement. Any velocity that's slower than + this will stop the animation. The default is 0.05. */ + void setMinimumVelocity (double newMinimumVelocityToUse) noexcept + { + minimumVelocity = newMinimumVelocityToUse; + } + /** Called by the AnimatedPosition class. This tells us the position and velocity at which the user is about to release the object. The velocity is measured in units/second. @@ -72,7 +79,7 @@ namespace AnimatedPositionBehaviours { velocity *= damping; - if (std::abs (velocity) < 0.05) + if (std::abs (velocity) < minimumVelocity) velocity = 0; return oldPos + velocity * elapsedSeconds; @@ -87,7 +94,7 @@ namespace AnimatedPositionBehaviours } private: - double velocity = 0, damping = 0.92; + double velocity = 0, damping = 0.92, minimumVelocity = 0.05; }; //============================================================================== diff --git a/modules/juce_gui_basics/layout/juce_Viewport.cpp b/modules/juce_gui_basics/layout/juce_Viewport.cpp index eae3b6bb52..aaebbb3249 100644 --- a/modules/juce_gui_basics/layout/juce_Viewport.cpp +++ b/modules/juce_gui_basics/layout/juce_Viewport.cpp @@ -191,6 +191,8 @@ struct Viewport::DragToScrollListener : private MouseListener, viewport.contentHolder.addMouseListener (this, true); offsetX.addListener (this); offsetY.addListener (this); + offsetX.behaviour.setMinimumVelocity (60); + offsetY.behaviour.setMinimumVelocity (60); } ~DragToScrollListener() @@ -209,6 +211,8 @@ struct Viewport::DragToScrollListener : private MouseListener, if (doesMouseEventComponentBlockViewportDrag (e.eventComponent)) isViewportDragBlocked = true; + offsetX.setPosition (offsetX.getPosition()); + offsetY.setPosition (offsetY.getPosition()); ++numTouches; } From 43ccf26b91b8b82f3bbe5a0158cf8fa95fd5de17 Mon Sep 17 00:00:00 2001 From: tpoole Date: Wed, 30 Aug 2017 16:01:36 +0100 Subject: [PATCH 023/129] Removed a duplicate line when detecting the plug-in host type --- modules/juce_audio_plugin_client/utility/juce_PluginHostType.h | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/juce_audio_plugin_client/utility/juce_PluginHostType.h b/modules/juce_audio_plugin_client/utility/juce_PluginHostType.h index 1308232036..97379a0768 100644 --- a/modules/juce_audio_plugin_client/utility/juce_PluginHostType.h +++ b/modules/juce_audio_plugin_client/utility/juce_PluginHostType.h @@ -265,7 +265,6 @@ private: if (hostFilename.startsWithIgnoreCase ("Waveform")) return TracktionWaveform; if (hostPath.containsIgnoreCase ("Tracktion 3")) return Tracktion3; if (hostFilename.containsIgnoreCase ("Tracktion")) return TracktionGeneric; - if (hostFilename.containsIgnoreCase ("Tracktion")) return TracktionGeneric; if (hostFilename.containsIgnoreCase ("reaper")) return Reaper; if (hostFilename.containsIgnoreCase ("Cubase4")) return SteinbergCubase4; if (hostFilename.containsIgnoreCase ("Cubase5")) return SteinbergCubase5; From da30211b1994ab10ecde72ecd2b72b770787365f Mon Sep 17 00:00:00 2001 From: hogliux Date: Wed, 30 Aug 2017 16:22:12 +0100 Subject: [PATCH 024/129] Fixed an issue where sliders would draw incorrectly in LookAndFeel4 if the slider's value text box was placed above the slider --- modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.cpp b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.cpp index 29facbd2ba..ebd9057307 100644 --- a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.cpp +++ b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.cpp @@ -943,7 +943,7 @@ void LookAndFeel_V4::drawLinearSlider (Graphics& g, int x, int y, int width, int const auto trackWidth = jmin (6.0f, slider.isHorizontal() ? height * 0.25f : width * 0.25f); const Point startPoint (slider.isHorizontal() ? x : width * 0.5f, - slider.isHorizontal() ? height * 0.5f : height + y); + slider.isHorizontal() ? y + height * 0.5f : height + y); const Point endPoint (slider.isHorizontal() ? width + x : startPoint.x, slider.isHorizontal() ? startPoint.y : y); From 29b5c98c538c1e6bd79ed2116b3916740e0e8f07 Mon Sep 17 00:00:00 2001 From: hogliux Date: Wed, 30 Aug 2017 16:52:03 +0100 Subject: [PATCH 025/129] Android: Fixed a compiler error when targeting Android SDK versions < 19 --- modules/juce_core/native/java/JuceAppActivity.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/juce_core/native/java/JuceAppActivity.java b/modules/juce_core/native/java/JuceAppActivity.java index 42de8c7a8c..061c979972 100644 --- a/modules/juce_core/native/java/JuceAppActivity.java +++ b/modules/juce_core/native/java/JuceAppActivity.java @@ -1228,8 +1228,8 @@ public class JuceAppActivity extends Activity public static final String getDocumentsFolder() { - if (getAndroidSDKVersion() >= android.os.Build.VERSION_CODES.KITKAT) - return getFileLocation (Environment.DIRECTORY_DOCUMENTS); + if (getAndroidSDKVersion() >= 19) + return getFileLocation ("Documents"); return Environment.getDataDirectory().getAbsolutePath(); } From 7316128918ffeeaad78cbd41872d7199da674d9b Mon Sep 17 00:00:00 2001 From: tpoole Date: Wed, 30 Aug 2017 17:43:52 +0100 Subject: [PATCH 026/129] Fixed some bugs in the sliders demo --- examples/Demo/Source/Demos/WidgetsDemo.cpp | 72 ++++++++++++++-------- 1 file changed, 47 insertions(+), 25 deletions(-) diff --git a/examples/Demo/Source/Demos/WidgetsDemo.cpp b/examples/Demo/Source/Demos/WidgetsDemo.cpp index 7e9b64088f..cb31f9f79a 100644 --- a/examples/Demo/Source/Demos/WidgetsDemo.cpp +++ b/examples/Demo/Source/Demos/WidgetsDemo.cpp @@ -105,10 +105,13 @@ struct SlidersPage : public Component : hintLabel ("hint", "Try right-clicking on a slider for an options menu. \n\n" "Also, holding down CTRL while dragging will turn on a slider's velocity-sensitive mode") { + Rectangle layoutArea { 20, 20, 580, 430 }; + auto sliderArea = layoutArea.removeFromTop (320); + Slider* s = createSlider (false); s->setSliderStyle (Slider::LinearVertical); s->setTextBoxStyle (Slider::TextBoxBelow, false, 100, 20); - s->setBounds (10, 25, 70, 200); + s->setBounds (sliderArea.removeFromLeft (70)); s->setDoubleClickReturnValue (true, 50.0); // double-clicking this slider will set it to 50.0 s->setTextValueSuffix (" units"); @@ -117,68 +120,85 @@ struct SlidersPage : public Component s->setVelocityBasedMode (true); s->setSkewFactor (0.5); s->setTextBoxStyle (Slider::TextBoxAbove, true, 100, 20); - s->setBounds (85, 25, 70, 200); + s->setBounds (sliderArea.removeFromLeft (70)); s->setTextValueSuffix (" rels"); + sliderArea.removeFromLeft (20); + auto horizonalSliderArea = sliderArea.removeFromLeft (180); + s = createSlider (true); s->setSliderStyle (Slider::LinearHorizontal); s->setTextBoxStyle (Slider::TextBoxLeft, false, 80, 20); - s->setBounds (180, 35, 150, 20); + s->setBounds (horizonalSliderArea.removeFromTop (20)); s = createSlider (false); s->setSliderStyle (Slider::LinearHorizontal); s->setTextBoxStyle (Slider::NoTextBox, false, 0, 0); - s->setBounds (180, 65, 150, 20); + horizonalSliderArea.removeFromTop (20); + s->setBounds (horizonalSliderArea.removeFromTop (20)); s->setPopupDisplayEnabled (true, false, this); s->setTextValueSuffix (" nuns required to change a lightbulb"); + s = createSlider (false); + s->setSliderStyle (Slider::LinearHorizontal); + s->setTextBoxStyle (Slider::TextEntryBoxPosition::TextBoxAbove, false, 70, 20); + horizonalSliderArea.removeFromTop (20); + s->setBounds (horizonalSliderArea.removeFromTop (50)); + s->setPopupDisplayEnabled (true, false, this); + s = createSlider (false); s->setSliderStyle (Slider::IncDecButtons); s->setTextBoxStyle (Slider::TextBoxLeft, false, 50, 20); - s->setBounds (180, 105, 100, 20); + horizonalSliderArea.removeFromTop (20); + s->setBounds (horizonalSliderArea.removeFromTop (20)); s->setIncDecButtonsMode (Slider::incDecButtonsDraggable_Vertical); s = createSlider (false); s->setSliderStyle (Slider::Rotary); s->setRotaryParameters (float_Pi * 1.2f, float_Pi * 2.8f, false); s->setTextBoxStyle (Slider::TextBoxRight, false, 70, 20); - s->setBounds (190, 145, 120, 40); + horizonalSliderArea.removeFromTop (15); + s->setBounds (horizonalSliderArea.removeFromTop (70)); s->setTextValueSuffix (" mm"); s = createSlider (false); s->setSliderStyle (Slider::LinearBar); - s->setBounds (180, 195, 100, 30); + horizonalSliderArea.removeFromTop (10); + s->setBounds (horizonalSliderArea.removeFromTop (30)); s->setTextValueSuffix (" gallons"); + sliderArea.removeFromLeft (20); + auto twoValueSliderArea = sliderArea.removeFromLeft (180); + s = createSlider (false); s->setSliderStyle (Slider::TwoValueHorizontal); - s->setBounds (360, 20, 160, 40); + s->setBounds (twoValueSliderArea.removeFromTop (40)); s = createSlider (false); - s->setSliderStyle (Slider::TwoValueVertical); - s->setBounds (360, 110, 40, 160); + s->setSliderStyle (Slider::ThreeValueHorizontal); + s->setPopupDisplayEnabled (true, false, this); + twoValueSliderArea.removeFromTop (10); + s->setBounds (twoValueSliderArea.removeFromTop (40)); s = createSlider (false); - s->setSliderStyle (Slider::ThreeValueHorizontal); - s->setBounds (360, 70, 160, 40); + s->setSliderStyle (Slider::TwoValueVertical); + twoValueSliderArea.removeFromLeft (30); + s->setBounds (twoValueSliderArea.removeFromLeft (40)); s = createSlider (false); s->setSliderStyle (Slider::ThreeValueVertical); - s->setBounds (440, 110, 40, 160); + s->setPopupDisplayEnabled (true, false, this); + twoValueSliderArea.removeFromLeft (30); + s->setBounds (twoValueSliderArea.removeFromLeft (40)); s = createSlider (false); s->setSliderStyle (Slider::LinearBarVertical); s->setTextBoxStyle (Slider::NoTextBox, false, 0, 0); - s->setBounds (540, 35, 20, 230); + sliderArea.removeFromLeft (20); + s->setBounds (sliderArea.removeFromLeft (20)); s->setPopupDisplayEnabled (true, true, this); s->setTextValueSuffix (" mickles in a muckle"); - for (int i = 7; i <= 10; ++i) - { - sliders.getUnchecked(i)->setTextBoxStyle (Slider::NoTextBox, false, 0, 0); - sliders.getUnchecked(i)->setPopupDisplayEnabled (true, false, this); - } - /* Here, we'll create a Value object, and tell a bunch of our sliders to use it as their value source. By telling them all to share the same Value, they'll stay in sync with each other. @@ -188,7 +208,7 @@ struct SlidersPage : public Component */ Value sharedValue; sharedValue = Random::getSystemRandom().nextDouble() * 100; - for (int i = 0; i < 7; ++i) + for (int i = 0; i < 8; ++i) sliders.getUnchecked(i)->getValueObject().referTo (sharedValue); // ..and now we'll do the same for all our min/max slider values.. @@ -196,13 +216,15 @@ struct SlidersPage : public Component sharedValueMin = Random::getSystemRandom().nextDouble() * 40.0; sharedValueMax = Random::getSystemRandom().nextDouble() * 40.0 + 60.0; - for (int i = 7; i <= 10; ++i) + for (int i = 8; i <= 11; ++i) { - sliders.getUnchecked(i)->getMaxValueObject().referTo (sharedValueMax); - sliders.getUnchecked(i)->getMinValueObject().referTo (sharedValueMin); + auto* selectedSlider = sliders.getUnchecked(i); + selectedSlider->setTextBoxStyle (Slider::NoTextBox, false, 0, 0); + selectedSlider->getMaxValueObject().referTo (sharedValueMax); + selectedSlider->getMinValueObject().referTo (sharedValueMin); } - hintLabel.setBounds (20, 245, 350, 150); + hintLabel.setBounds (layoutArea); addAndMakeVisible (hintLabel); } From 8e7b29b3eef20669ce8426f4e7c214f5cd42adc5 Mon Sep 17 00:00:00 2001 From: Lukasz Kozakiewicz Date: Wed, 30 Aug 2017 18:03:57 +0100 Subject: [PATCH 027/129] Android: fix HTTP redirect. --- .../native/java/JuceAppActivity.java | 253 +++++++++++------- .../juce_core/native/juce_android_Network.cpp | 4 +- 2 files changed, 163 insertions(+), 94 deletions(-) diff --git a/modules/juce_core/native/java/JuceAppActivity.java b/modules/juce_core/native/java/JuceAppActivity.java index 061c979972..26b3d2ba08 100644 --- a/modules/juce_core/native/java/JuceAppActivity.java +++ b/modules/juce_core/native/java/JuceAppActivity.java @@ -899,13 +899,74 @@ public class JuceAppActivity extends Activity //============================================================================== public static class HTTPStream { - public HTTPStream (HttpURLConnection connection_, - int[] statusCode_, - StringBuffer responseHeaders_) + public HTTPStream (String address, boolean isPostToUse, byte[] postDataToUse, + String headersToUse, int timeOutMsToUse, + int[] statusCodeToUse, StringBuffer responseHeadersToUse, + int numRedirectsToFollowToUse, String httpRequestCmdToUse) throws IOException { - connection = connection_; - statusCode = statusCode_; - responseHeaders = responseHeaders_; + isPost = isPostToUse; + postData = postDataToUse; + headers = headersToUse; + timeOutMs = timeOutMsToUse; + statusCode = statusCodeToUse; + responseHeaders = responseHeadersToUse; + numRedirectsToFollow = numRedirectsToFollowToUse; + httpRequestCmd = httpRequestCmdToUse; + + connection = createConnection (address, isPost, postData, headers, timeOutMs, httpRequestCmd); + } + + private final HttpURLConnection createConnection (String address, boolean isPost, byte[] postData, + String headers, int timeOutMs, String httpRequestCmdToUse) throws IOException + { + HttpURLConnection newConnection = (HttpURLConnection) (new URL(address).openConnection()); + + try + { + newConnection.setInstanceFollowRedirects (false); + newConnection.setConnectTimeout (timeOutMs); + newConnection.setReadTimeout (timeOutMs); + + // headers - if not empty, this string is appended onto the headers that are used for the request. It must therefore be a valid set of HTML header directives, separated by newlines. + // So convert headers string to an array, with an element for each line + String headerLines[] = headers.split("\\n"); + + // Set request headers + for (int i = 0; i < headerLines.length; ++i) + { + int pos = headerLines[i].indexOf (":"); + + if (pos > 0 && pos < headerLines[i].length()) + { + String field = headerLines[i].substring (0, pos); + String value = headerLines[i].substring (pos + 1); + + if (value.length() > 0) + newConnection.setRequestProperty (field, value); + } + } + + newConnection.setRequestMethod (httpRequestCmd); + + if (isPost) + { + newConnection.setDoOutput (true); + + if (postData != null) + { + OutputStream out = newConnection.getOutputStream(); + out.write(postData); + out.flush(); + } + } + + return newConnection; + } + catch (Throwable e) + { + newConnection.disconnect(); + throw new IOException ("Connection error"); + } } private final InputStream getCancellableStream (final boolean isInput) throws ExecutionException @@ -928,19 +989,12 @@ public class JuceAppActivity extends Activity try { - if (connection.getConnectTimeout() > 0) - return streamFuture.get (connection.getConnectTimeout(), TimeUnit.MILLISECONDS); - else - return streamFuture.get(); + return streamFuture.get(); } catch (InterruptedException e) { return null; } - catch (TimeoutException e) - { - return null; - } catch (CancellationException e) { return null; @@ -948,6 +1002,89 @@ public class JuceAppActivity extends Activity } public final boolean connect() + { + boolean result = false; + int numFollowedRedirects = 0; + + while (true) + { + result = doConnect(); + + if (! result) + return false; + + if (++numFollowedRedirects > numRedirectsToFollow) + break; + + int status = statusCode[0]; + + if (status == 301 || status == 302 || status == 303 || status == 307) + { + // Assumes only one occurrence of "Location" + int pos1 = responseHeaders.indexOf ("Location:") + 10; + int pos2 = responseHeaders.indexOf ("\n", pos1); + + if (pos2 > pos1) + { + String currentLocation = connection.getURL().toString(); + String newLocation = responseHeaders.substring (pos1, pos2); + + try + { + // Handle newLocation whether it's absolute or relative + URL baseUrl = new URL (currentLocation); + URL newUrl = new URL (baseUrl, newLocation); + String transformedNewLocation = newUrl.toString(); + + if (transformedNewLocation != currentLocation) + { + // Clear responseHeaders before next iteration + responseHeaders.delete (0, responseHeaders.length()); + + synchronized (createStreamLock) + { + if (hasBeenCancelled.get()) + return false; + + connection.disconnect(); + + try + { + connection = createConnection (transformedNewLocation, isPost, + postData, headers, timeOutMs, + httpRequestCmd); + } + catch (Throwable e) + { + return false; + } + } + } + else + { + break; + } + } + catch (Throwable e) + { + return false; + } + } + else + { + break; + } + } + else + { + break; + } + } + + return result; + } + + private final boolean doConnect() { synchronized (createStreamLock) { @@ -1094,9 +1231,15 @@ public class JuceAppActivity extends Activity public final boolean isExhausted() { return false; } public final boolean setPosition (long newPos) { return false; } + private boolean isPost; + private byte[] postData; + private String headers; + private int timeOutMs; + String httpRequestCmd; private HttpURLConnection connection; private int[] statusCode; private StringBuffer responseHeaders; + private int numRedirectsToFollow; private InputStream inputStream; private long position; private final ReentrantLock createStreamLock = new ReentrantLock(); @@ -1118,89 +1261,15 @@ public class JuceAppActivity extends Activity else if (timeOutMs == 0) timeOutMs = 30000; - // headers - if not empty, this string is appended onto the headers that are used for the request. It must therefore be a valid set of HTML header directives, separated by newlines. - // So convert headers string to an array, with an element for each line - String headerLines[] = headers.split("\\n"); - for (;;) { try { - HttpURLConnection connection = (HttpURLConnection) (new URL(address).openConnection()); - - if (connection != null) - { - try - { - connection.setInstanceFollowRedirects (false); - connection.setConnectTimeout (timeOutMs); - connection.setReadTimeout (timeOutMs); - - // Set request headers - for (int i = 0; i < headerLines.length; ++i) - { - int pos = headerLines[i].indexOf (":"); - - if (pos > 0 && pos < headerLines[i].length()) - { - String field = headerLines[i].substring (0, pos); - String value = headerLines[i].substring (pos + 1); - - if (value.length() > 0) - connection.setRequestProperty (field, value); - } - } + HTTPStream httpStream = new HTTPStream (address, isPost, postData, headers, + timeOutMs, statusCode, responseHeaders, + numRedirectsToFollow, httpRequestCmd); - connection.setRequestMethod (httpRequestCmd); - if (isPost) - { - connection.setDoOutput (true); - - if (postData != null) - { - OutputStream out = connection.getOutputStream(); - out.write(postData); - out.flush(); - } - } - - HTTPStream httpStream = new HTTPStream (connection, statusCode, responseHeaders); - - // Process redirect & continue as necessary - int status = statusCode[0]; - - if (--numRedirectsToFollow >= 0 - && (status == 301 || status == 302 || status == 303 || status == 307)) - { - // Assumes only one occurrence of "Location" - int pos1 = responseHeaders.indexOf ("Location:") + 10; - int pos2 = responseHeaders.indexOf ("\n", pos1); - - if (pos2 > pos1) - { - String newLocation = responseHeaders.substring(pos1, pos2); - // Handle newLocation whether it's absolute or relative - URL baseUrl = new URL (address); - URL newUrl = new URL (baseUrl, newLocation); - String transformedNewLocation = newUrl.toString(); - - if (transformedNewLocation != address) - { - address = transformedNewLocation; - // Clear responseHeaders before next iteration - responseHeaders.delete (0, responseHeaders.length()); - continue; - } - } - } - - return httpStream; - } - catch (Throwable e) - { - connection.disconnect(); - } - } + return httpStream; } catch (Throwable e) {} diff --git a/modules/juce_core/native/juce_android_Network.cpp b/modules/juce_core/native/juce_android_Network.cpp index 55e33f8b2f..4189766e4d 100644 --- a/modules/juce_core/native/juce_android_Network.cpp +++ b/modules/juce_core/native/juce_android_Network.cpp @@ -132,8 +132,8 @@ public: javaString (httpRequest).get())); } - if (stream != 0) - stream.callBooleanMethod (HTTPStream.connect); + if (stream != 0 && ! stream.callBooleanMethod (HTTPStream.connect)) + stream.clear(); jint* const statusCodeElements = env->GetIntArrayElements (statusCodeArray, 0); statusCode = statusCodeElements[0]; From 7cbb792f7157b0ad4a196de18659e6296b723e0d Mon Sep 17 00:00:00 2001 From: hogliux Date: Wed, 30 Aug 2017 18:07:59 +0100 Subject: [PATCH 028/129] Fixed an issue where sliders would draw incorrectly in LookAndFeel4 if the slider's value text box was placed left to the slider --- modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.cpp b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.cpp index ebd9057307..304a321f50 100644 --- a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.cpp +++ b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.cpp @@ -942,7 +942,7 @@ void LookAndFeel_V4::drawLinearSlider (Graphics& g, int x, int y, int width, int const auto trackWidth = jmin (6.0f, slider.isHorizontal() ? height * 0.25f : width * 0.25f); - const Point startPoint (slider.isHorizontal() ? x : width * 0.5f, + const Point startPoint (slider.isHorizontal() ? x : x + width * 0.5f, slider.isHorizontal() ? y + height * 0.5f : height + y); const Point endPoint (slider.isHorizontal() ? width + x : startPoint.x, From c8c692e2b70dbb70d7ca4bd96d04558c607243b6 Mon Sep 17 00:00:00 2001 From: Lukasz Kozakiewicz Date: Thu, 31 Aug 2017 10:28:24 +0100 Subject: [PATCH 029/129] Android: fix web input stream reporting always total length of -1. --- .../juce_core/native/java/JuceAppActivity.java | 15 ++++++++++++--- modules/juce_core/network/juce_URL.cpp | 3 +++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/modules/juce_core/native/java/JuceAppActivity.java b/modules/juce_core/native/java/JuceAppActivity.java index 26b3d2ba08..6e8a898d99 100644 --- a/modules/juce_core/native/java/JuceAppActivity.java +++ b/modules/juce_core/native/java/JuceAppActivity.java @@ -910,6 +910,7 @@ public class JuceAppActivity extends Activity timeOutMs = timeOutMsToUse; statusCode = statusCodeToUse; responseHeaders = responseHeadersToUse; + totalLength = -1; numRedirectsToFollow = numRedirectsToFollowToUse; httpRequestCmd = httpRequestCmdToUse; @@ -1122,9 +1123,16 @@ public class JuceAppActivity extends Activity {} for (java.util.Map.Entry> entry : connection.getHeaderFields().entrySet()) + { if (entry.getKey() != null && entry.getValue() != null) - responseHeaders.append (entry.getKey() + ": " - + android.text.TextUtils.join (",", entry.getValue()) + "\n"); + { + responseHeaders.append(entry.getKey() + ": " + + android.text.TextUtils.join(",", entry.getValue()) + "\n"); + + if (entry.getKey().compareTo ("Content-Length") == 0) + totalLength = Integer.decode (entry.getValue().get (0)); + } + } return true; } @@ -1227,7 +1235,7 @@ public class JuceAppActivity extends Activity } public final long getPosition() { return position; } - public final long getTotalLength() { return -1; } + public final long getTotalLength() { return totalLength; } public final boolean isExhausted() { return false; } public final boolean setPosition (long newPos) { return false; } @@ -1239,6 +1247,7 @@ public class JuceAppActivity extends Activity private HttpURLConnection connection; private int[] statusCode; private StringBuffer responseHeaders; + private int totalLength; private int numRedirectsToFollow; private InputStream inputStream; private long position; diff --git a/modules/juce_core/network/juce_URL.cpp b/modules/juce_core/network/juce_URL.cpp index 60c791a3a9..4264cace89 100644 --- a/modules/juce_core/network/juce_URL.cpp +++ b/modules/juce_core/network/juce_URL.cpp @@ -73,6 +73,9 @@ struct FallbackDownloadTask : public URL::DownloadTask, } downloaded += actual; + + if (downloaded == contentLength) + break; } fileStream->flush(); From a7b9da40a2294ea374bb3b746acfa1abea80895f Mon Sep 17 00:00:00 2001 From: hogliux Date: Thu, 31 Aug 2017 10:57:44 +0100 Subject: [PATCH 030/129] Fixed a crash when animators delete top-level components during a screen rotate animation --- .../juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm b/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm index e61f2621bb..113eacc859 100644 --- a/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm +++ b/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm @@ -312,8 +312,9 @@ private: static void sendScreenBoundsUpdate (JuceUIViewController* c) { JuceUIView* juceView = (JuceUIView*) [c view]; - jassert (juceView != nil && juceView->owner != nullptr); - juceView->owner->updateTransformAndScreenBounds(); + + if (juceView != nil && juceView->owner != nullptr) + juceView->owner->updateTransformAndScreenBounds(); } static bool isKioskModeView (JuceUIViewController* c) From 37c243bb491e31e84fa13ccbecbab5b6c51ebb28 Mon Sep 17 00:00:00 2001 From: ed Date: Thu, 31 Aug 2017 12:04:07 +0100 Subject: [PATCH 031/129] Fixed a bug in plug-ins on Mac where mouse exit events weren't being sent when the mouse cursor left the plug-in window --- .../utility/juce_FakeMouseMoveGenerator.h | 32 ++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/modules/juce_audio_plugin_client/utility/juce_FakeMouseMoveGenerator.h b/modules/juce_audio_plugin_client/utility/juce_FakeMouseMoveGenerator.h index c9559cc725..d78d3bd10d 100644 --- a/modules/juce_audio_plugin_client/utility/juce_FakeMouseMoveGenerator.h +++ b/modules/juce_audio_plugin_client/utility/juce_FakeMouseMoveGenerator.h @@ -41,24 +41,48 @@ public: void timerCallback() override { // Workaround for windows not getting mouse-moves... - const Point screenPos (Desktop::getInstance().getMainMouseSource().getScreenPosition()); + auto screenPos = Desktop::getInstance().getMainMouseSource().getScreenPosition(); if (screenPos != lastScreenPos) { lastScreenPos = screenPos; - const ModifierKeys mods (ModifierKeys::getCurrentModifiers()); + auto mods = ModifierKeys::getCurrentModifiers(); if (! mods.isAnyMouseButtonDown()) - if (Component* const comp = Desktop::getInstance().findComponentAt (screenPos.roundToInt())) - if (ComponentPeer* const peer = comp->getPeer()) + { + if (auto* comp = Desktop::getInstance().findComponentAt (screenPos.roundToInt())) + { + safeOldComponent = comp; + + if (auto* peer = comp->getPeer()) + { if (! peer->isFocused()) + { peer->handleMouseEvent (MouseInputSource::InputSourceType::mouse, peer->globalToLocal (screenPos), mods, MouseInputSource::invalidPressure, MouseInputSource::invalidOrientation, Time::currentTimeMillis()); + } + } + } + else + { + if (safeOldComponent != nullptr) + { + if (auto* peer = safeOldComponent->getPeer()) + { + peer->handleMouseEvent (MouseInputSource::InputSourceType::mouse, { -1.0f, -1.0f }, mods, + MouseInputSource::invalidPressure, MouseInputSource::invalidOrientation, Time::currentTimeMillis()); + } + } + + safeOldComponent = nullptr; + } + } } } private: Point lastScreenPos; + WeakReference safeOldComponent; }; #else From 16f2c13ea7775dac2dae0b9e3706d49b402dbcfd Mon Sep 17 00:00:00 2001 From: tpoole Date: Thu, 31 Aug 2017 14:17:43 +0100 Subject: [PATCH 032/129] Added the ability to use non-automatable parameters with the AudioProcessorValueTreeState class --- .../processors/juce_AudioProcessor.h | 2 +- .../processors/juce_AudioProcessorParameter.h | 7 +++--- .../juce_AudioProcessorValueTreeState.cpp | 16 +++++++----- .../juce_AudioProcessorValueTreeState.h | 25 +++++++++++-------- 4 files changed, 29 insertions(+), 21 deletions(-) diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessor.h b/modules/juce_audio_processors/processors/juce_AudioProcessor.h index 66fb89d9fe..e9e13618c1 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessor.h +++ b/modules/juce_audio_processors/processors/juce_AudioProcessor.h @@ -1119,7 +1119,7 @@ public: NOTE! This method will eventually be deprecated! It's recommended that you use AudioProcessorParameter::isMetaParameter() instead. - */ + */ virtual AudioProcessorParameter::Category getParameterCategory (int parameterIndex) const; /** Sends a signal to the host to tell it that the user is about to start changing this diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessorParameter.h b/modules/juce_audio_processors/processors/juce_AudioProcessorParameter.h index 3abccb795a..4d4be65814 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessorParameter.h +++ b/modules/juce_audio_processors/processors/juce_AudioProcessorParameter.h @@ -152,9 +152,10 @@ public: outputGain = (1 << 16) | 1, /** The following categories tell the host that this parameter is a meter level value - and therefore read-only. Most hosts will display these type of parameters as - a meter in the generic view of your plug-in. Pro-Tools will also show the meter - in the mixer view. */ + and therefore read-only. Most hosts will display these type of parameters as + a meter in the generic view of your plug-in. Pro-Tools will also show the meter + in the mixer view. + */ inputMeter = (2 << 16) | 0, outputMeter = (2 << 16) | 1, compressorLimiterGainReductionMeter = (2 << 16) | 2, diff --git a/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.cpp b/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.cpp index 4c7fb00547..d5540cac7d 100644 --- a/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.cpp +++ b/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.cpp @@ -33,12 +33,14 @@ struct AudioProcessorValueTreeState::Parameter : public AudioProcessorParamete NormalisableRange r, float defaultVal, std::function valueToText, std::function textToValue, - bool meta) + bool meta, + bool automatable) : AudioProcessorParameterWithID (parameterID, paramName, labelText), owner (s), valueToTextFunction (valueToText), textToValueFunction (textToValue), range (r), value (defaultVal), defaultValue (defaultVal), listenersNeedCalling (true), - isMeta (meta) + isMetaParam (meta), + isAutomatableParam (automatable) { state.addListener (this); needsUpdate.set (1); @@ -146,7 +148,8 @@ struct AudioProcessorValueTreeState::Parameter : public AudioProcessorParamete return nullptr; } - bool isMetaParameter() const override { return isMeta; } + bool isMetaParameter() const override { return isMetaParam; } + bool isAutomatable() const override { return isAutomatableParam; } AudioProcessorValueTreeState& owner; ValueTree state; @@ -157,7 +160,7 @@ struct AudioProcessorValueTreeState::Parameter : public AudioProcessorParamete float value, defaultValue; Atomic needsUpdate; bool listenersNeedCalling; - bool isMeta; + const bool isMetaParam, isAutomatableParam; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Parameter) }; @@ -181,7 +184,8 @@ AudioProcessorParameterWithID* AudioProcessorValueTreeState::createAndAddParamet const String& labelText, NormalisableRange r, float defaultVal, std::function valueToTextFunction, std::function textToValueFunction, - bool isMetaParameter) + bool isMetaParameter, + bool isAutomatableParameter) { // All parameters must be created before giving this manager a ValueTree state! jassert (! state.isValid()); @@ -191,7 +195,7 @@ AudioProcessorParameterWithID* AudioProcessorValueTreeState::createAndAddParamet Parameter* p = new Parameter (*this, paramID, paramName, labelText, r, defaultVal, valueToTextFunction, textToValueFunction, - isMetaParameter); + isMetaParameter, isAutomatableParameter); processor.addParameter (p); return p; } diff --git a/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.h b/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.h index b3a129fef3..aa276b470d 100644 --- a/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.h +++ b/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.h @@ -66,16 +66,18 @@ public: Calling this will create and add a special type of AudioProcessorParameter to the AudioProcessor to which this state is attached. - @param parameterID A unique string ID for the new parameter - @param parameterName The name that the parameter will return from AudioProcessorParameter::getName() - @param labelText The label that the parameter will return from AudioProcessorParameter::getLabel() - @param valueRange A mapping that will be used to determine the value range which this parameter uses - @param defaultValue A default value for the parameter (in non-normalised units) - @param valueToTextFunction A function that will convert a non-normalised value to a string for the - AudioProcessorParameter::getText() method. This can be nullptr to use the - default implementation - @param textToValueFunction The inverse of valueToTextFunction - @param isMetaParameter Set this value to true if this should be a meta parameter + @param parameterID A unique string ID for the new parameter + @param parameterName The name that the parameter will return from AudioProcessorParameter::getName() + @param labelText The label that the parameter will return from AudioProcessorParameter::getLabel() + @param valueRange A mapping that will be used to determine the value range which this parameter uses + @param defaultValue A default value for the parameter (in non-normalised units) + @param valueToTextFunction A function that will convert a non-normalised value to a string for the + AudioProcessorParameter::getText() method. This can be nullptr to use the + default implementation + @param textToValueFunction The inverse of valueToTextFunction + @param isMetaParameter Set this value to true if this should be a meta parameter + @param isAutomatableParameter Set this value to false if this parameter should not be automatable + @returns the parameter object that was created */ AudioProcessorParameterWithID* createAndAddParameter (const String& parameterID, @@ -85,7 +87,8 @@ public: float defaultValue, std::function valueToTextFunction, std::function textToValueFunction, - bool isMetaParameter = false); + bool isMetaParameter = false, + bool isAutomatableParameter = true); /** Returns a parameter by its ID string. */ AudioProcessorParameterWithID* getParameter (StringRef parameterID) const noexcept; From dec870f5ebef9f44a760a36d10ff7daa33a40f9f Mon Sep 17 00:00:00 2001 From: ed Date: Fri, 1 Sep 2017 11:06:01 +0100 Subject: [PATCH 033/129] Projucer: Fixed a few live-build errors on Windows --- modules/juce_core/native/juce_win32_Files.cpp | 2 +- modules/juce_core/text/juce_CharacterFunctions.h | 2 +- modules/juce_gui_basics/native/juce_win32_FileChooser.cpp | 6 +++--- modules/juce_gui_basics/native/juce_win32_Windowing.cpp | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/juce_core/native/juce_win32_Files.cpp b/modules/juce_core/native/juce_win32_Files.cpp index 5185d12087..07641d558f 100644 --- a/modules/juce_core/native/juce_win32_Files.cpp +++ b/modules/juce_core/native/juce_win32_Files.cpp @@ -682,7 +682,7 @@ File File::getLinkedTarget() const CloseHandle (h); const StringRef prefix ("\\\\?\\"); - const String path (buffer); + const String path (buffer.get()); // It turns out that GetFinalPathNameByHandleW prepends \\?\ to the path. // This is not a bug, it's feature. See MSDN for more information. diff --git a/modules/juce_core/text/juce_CharacterFunctions.h b/modules/juce_core/text/juce_CharacterFunctions.h index bfdf54d15b..759080b283 100644 --- a/modules/juce_core/text/juce_CharacterFunctions.h +++ b/modules/juce_core/text/juce_CharacterFunctions.h @@ -231,7 +231,7 @@ public: *currentCharacter++ = '0'; } - #if JUCE_MSVC + #if JUCE_WINDOWS static _locale_t locale = _create_locale (LC_ALL, "C"); return _strtod_l (&buffer[0], nullptr, locale); #else diff --git a/modules/juce_gui_basics/native/juce_win32_FileChooser.cpp b/modules/juce_gui_basics/native/juce_win32_FileChooser.cpp index 728a4c6d36..ae2de01ea8 100644 --- a/modules/juce_gui_basics/native/juce_win32_FileChooser.cpp +++ b/modules/juce_gui_basics/native/juce_win32_FileChooser.cpp @@ -202,7 +202,7 @@ void FileChooser::showPlatformDialog (Array& results, const String& title_ if (info.returnedString.isNotEmpty()) { - results.add (File (String (files)).getSiblingFile (info.returnedString)); + results.add (File (String (files.get())).getSiblingFile (info.returnedString)); return; } } @@ -287,12 +287,12 @@ void FileChooser::showPlatformDialog (Array& results, const String& title_ while (*filename != 0) { - results.add (File (String (files)).getChildFile (String (filename))); + results.add (File (String (files.get())).getChildFile (String (filename))); filename += wcslen (filename) + 1; } } else if (files[0] != 0) { - results.add (File (String (files))); + results.add (File (String (files.get()))); } } diff --git a/modules/juce_gui_basics/native/juce_win32_Windowing.cpp b/modules/juce_gui_basics/native/juce_win32_Windowing.cpp index 80216af862..12602fa149 100644 --- a/modules/juce_gui_basics/native/juce_win32_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_win32_Windowing.cpp @@ -3449,7 +3449,7 @@ private: HeapBlock buffer; buffer.calloc (stringSizeBytes / sizeof (TCHAR) + 1); ImmGetCompositionString (hImc, type, buffer, (DWORD) stringSizeBytes); - return String (buffer); + return String (buffer.get()); } return {}; From 86f9c11d15d74baa6b268c1c45f99eb9639e01e3 Mon Sep 17 00:00:00 2001 From: hogliux Date: Fri, 1 Sep 2017 11:09:44 +0100 Subject: [PATCH 034/129] Added new FrameRateType fps23976 to AudioPlayHead --- BREAKING-CHANGES.txt | 21 +++++++++++++++++++ .../audio_play_head/juce_AudioPlayHead.h | 17 ++++++++------- .../AAX/juce_AAX_Wrapper.cpp | 2 +- .../AU/juce_AU_Wrapper.mm | 1 + .../AU/juce_AUv3_Wrapper.mm | 1 + .../RTAS/juce_RTAS_Wrapper.cpp | 2 +- .../VST/juce_VST_Wrapper.cpp | 2 +- .../VST3/juce_VST3_Wrapper.cpp | 9 +++++++- .../format_types/juce_VST3PluginFormat.cpp | 1 + .../format_types/juce_VSTPluginFormat.cpp | 1 + 10 files changed, 45 insertions(+), 12 deletions(-) diff --git a/BREAKING-CHANGES.txt b/BREAKING-CHANGES.txt index 54bfe9846e..20235c65ba 100644 --- a/BREAKING-CHANGES.txt +++ b/BREAKING-CHANGES.txt @@ -4,6 +4,27 @@ JUCE breaking changes Develop Branch ============= +Change +------ +A new FrameRateType fps23976 has been added to AudioPlayHead + +Possible Issues +--------------- +Previously JUCE would report the FrameRateType fps24 for both 24 and +23.976 fps. If your code uses switch statements (or similar) to handle +all possible frame rate types, then this change may cause it to fall +through. + +Workaround +---------- +Add fps23976 to your switch statement and handle it appropriately. + +Rationale +--------- +JUCE should be able to handle all popular frame rate codes but was +missing support for 23.976. + + Change ------ The String (bool) constructor and operator<< (String&, bool) have been diff --git a/modules/juce_audio_basics/audio_play_head/juce_AudioPlayHead.h b/modules/juce_audio_basics/audio_play_head/juce_AudioPlayHead.h index b8c3b0f520..2f4859996d 100644 --- a/modules/juce_audio_basics/audio_play_head/juce_AudioPlayHead.h +++ b/modules/juce_audio_basics/audio_play_head/juce_AudioPlayHead.h @@ -46,14 +46,15 @@ public: /** Frame rate types. */ enum FrameRateType { - fps24 = 0, - fps25 = 1, - fps2997 = 2, - fps30 = 3, - fps2997drop = 4, - fps30drop = 5, - fps60 = 6, - fps60drop = 7, + fps23976 = 0, + fps24 = 1, + fps25 = 2, + fps2997 = 3, + fps30 = 4, + fps2997drop = 5, + fps30drop = 6, + fps60 = 7, + fps60drop = 8, fpsUnknown = 99 }; diff --git a/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp b/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp index 6f390c9f5d..eaecdd6a7d 100644 --- a/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp @@ -900,7 +900,7 @@ namespace AAXClasses case AAX_eFrameRate_2997DropFrame: info.frameRate = AudioPlayHead::fps2997drop; framesPerSec = 30.0 * 1000.0 / 1001.0; break; case AAX_eFrameRate_30NonDrop: info.frameRate = AudioPlayHead::fps30; framesPerSec = 30.0; break; case AAX_eFrameRate_30DropFrame: info.frameRate = AudioPlayHead::fps30drop; framesPerSec = 30.0; break; - case AAX_eFrameRate_23976: info.frameRate = AudioPlayHead::fps24; framesPerSec = 24.0 * 1000.0 / 1001.0; break; + case AAX_eFrameRate_23976: info.frameRate = AudioPlayHead::fps23976; framesPerSec = 24.0 * 1000.0 / 1001.0; break; default: break; } diff --git a/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm b/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm index f3d9a0e8e9..e3ee1d7d1f 100644 --- a/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm +++ b/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm @@ -932,6 +932,7 @@ public: switch (lastTimeStamp.mSMPTETime.mType) { + case kSMPTETimeType2398: info.frameRate = AudioPlayHead::fps23976; break; case kSMPTETimeType24: info.frameRate = AudioPlayHead::fps24; break; case kSMPTETimeType25: info.frameRate = AudioPlayHead::fps25; break; case kSMPTETimeType30Drop: info.frameRate = AudioPlayHead::fps30drop; break; diff --git a/modules/juce_audio_plugin_client/AU/juce_AUv3_Wrapper.mm b/modules/juce_audio_plugin_client/AU/juce_AUv3_Wrapper.mm index 56afdb4c0f..63e6a59676 100644 --- a/modules/juce_audio_plugin_client/AU/juce_AUv3_Wrapper.mm +++ b/modules/juce_audio_plugin_client/AU/juce_AUv3_Wrapper.mm @@ -884,6 +884,7 @@ public: switch (lastTimeStamp.mSMPTETime.mType) { + case kSMPTETimeType2398: info.frameRate = AudioPlayHead::fps23976; break; case kSMPTETimeType24: info.frameRate = AudioPlayHead::fps24; break; case kSMPTETimeType25: info.frameRate = AudioPlayHead::fps25; break; case kSMPTETimeType2997: info.frameRate = AudioPlayHead::fps2997; break; diff --git a/modules/juce_audio_plugin_client/RTAS/juce_RTAS_Wrapper.cpp b/modules/juce_audio_plugin_client/RTAS/juce_RTAS_Wrapper.cpp index 5be7565929..f97ec634c3 100644 --- a/modules/juce_audio_plugin_client/RTAS/juce_RTAS_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/RTAS/juce_RTAS_Wrapper.cpp @@ -764,7 +764,7 @@ public: case ficFrameRate_2997DropFrame: info.frameRate = AudioPlayHead::fps2997drop; framesPerSec = 30.0 * 1000.0 / 1001.0; break; case ficFrameRate_30NonDrop: info.frameRate = AudioPlayHead::fps30; framesPerSec = 30.0; break; case ficFrameRate_30DropFrame: info.frameRate = AudioPlayHead::fps30drop; framesPerSec = 30.0; break; - case ficFrameRate_23976: info.frameRate = AudioPlayHead::fps24; framesPerSec = 24.0 * 1000.0 / 1001.0; break; + case ficFrameRate_23976: info.frameRate = AudioPlayHead::fps23976; framesPerSec = 24.0 * 1000.0 / 1001.0; break; default: info.frameRate = AudioPlayHead::fpsUnknown; break; } diff --git a/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp b/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp index ebbf421457..e57d0f5776 100644 --- a/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp @@ -656,6 +656,7 @@ public: switch (ti->smpteRate) { + case vstSmpteRateFps239: rate = AudioPlayHead::fps23976; fps = 24.0 * 1000.0 / 1001.0; break; case vstSmpteRateFps24: rate = AudioPlayHead::fps24; fps = 24.0; break; case vstSmpteRateFps25: rate = AudioPlayHead::fps25; fps = 25.0; break; case vstSmpteRateFps2997: rate = AudioPlayHead::fps2997; fps = 30.0 * 1000.0 / 1001.0; break; @@ -666,7 +667,6 @@ public: case vstSmpteRate16mmFilm: case vstSmpteRate35mmFilm: fps = 24.0; break; - case vstSmpteRateFps239: fps = 24.0 * 1000.0 / 1001.0; break; case vstSmpteRateFps249: fps = 25.0 * 1000.0 / 1001.0; break; case vstSmpteRateFps599: fps = 60.0 * 1000.0 / 1001.0; break; case vstSmpteRateFps60: fps = 60; break; diff --git a/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp b/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp index f68244ca0e..3ef3e755cc 100644 --- a/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp @@ -1669,7 +1669,14 @@ public: { switch (processContext.frameRate.framesPerSecond) { - case 24: info.frameRate = AudioPlayHead::fps24; break; + case 24: + { + if ((processContext.frameRate.flags & Vst::FrameRate::kPullDownRate) != 0) + info.frameRate = AudioPlayHead::fps23976; + else + info.frameRate = AudioPlayHead::fps24; + } + break; case 25: info.frameRate = AudioPlayHead::fps25; break; case 29: info.frameRate = AudioPlayHead::fps30drop; break; diff --git a/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp b/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp index cd3d9811f0..938c6b736c 100644 --- a/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp +++ b/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp @@ -207,6 +207,7 @@ static void toProcessContext (Vst::ProcessContext& context, AudioPlayHead* playH switch (position.frameRate) { + case AudioPlayHead::fps23976: fr.framesPerSecond = 24; fr.flags = FrameRate::kPullDownRate; break; case AudioPlayHead::fps24: fr.framesPerSecond = 24; fr.flags = 0; break; case AudioPlayHead::fps25: fr.framesPerSecond = 25; fr.flags = 0; break; case AudioPlayHead::fps2997: fr.framesPerSecond = 30; fr.flags = FrameRate::kPullDownRate; break; diff --git a/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp b/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp index 0b1dcb5e41..8f394e8140 100644 --- a/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp +++ b/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp @@ -1703,6 +1703,7 @@ private: case AudioPlayHead::fps30: setHostTimeFrameRate (vstSmpteRateFps30, 30.0, position.timeInSeconds); break; case AudioPlayHead::fps60: setHostTimeFrameRate (vstSmpteRateFps60, 60.0, position.timeInSeconds); break; + case AudioPlayHead::fps23976: setHostTimeFrameRateDrop (vstSmpteRateFps239, 24.0, position.timeInSeconds); break; case AudioPlayHead::fps2997: setHostTimeFrameRateDrop (vstSmpteRateFps2997, 30.0, position.timeInSeconds); break; case AudioPlayHead::fps2997drop: setHostTimeFrameRateDrop (vstSmpteRateFps2997drop, 30.0, position.timeInSeconds); break; case AudioPlayHead::fps30drop: setHostTimeFrameRateDrop (vstSmpteRateFps30drop, 30.0, position.timeInSeconds); break; From 7d98da98ea4ea811ca5b0bc4ca315b95d9bfc0d1 Mon Sep 17 00:00:00 2001 From: hogliux Date: Fri, 1 Sep 2017 15:06:32 +0100 Subject: [PATCH 035/129] Added FakeMouseMoveGenerator to AAX plug-ins so that the recent plug-in mouse exit fix also works for AAX plug-ins --- modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp b/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp index eaecdd6a7d..897b573075 100644 --- a/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp @@ -32,6 +32,7 @@ #include "../utility/juce_IncludeSystemHeaders.h" #include "../utility/juce_IncludeModuleHeaders.h" #include "../utility/juce_WindowsHooks.h" +#include "../utility/juce_FakeMouseMoveGenerator.h" #ifdef __clang__ #pragma clang diagnostic push @@ -469,6 +470,8 @@ namespace AAXClasses setBounds (pluginEditor->getLocalBounds()); pluginEditor->addMouseListener (this, true); } + + ignoreUnused (fakeMouseGenerator); } ~ContentWrapperComponent() @@ -526,6 +529,7 @@ namespace AAXClasses #if JUCE_WINDOWS WindowsHooks hooks; #endif + FakeMouseMoveGenerator fakeMouseGenerator; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ContentWrapperComponent) }; From 8106722da7b192d5cb06814bd94b461f49055c91 Mon Sep 17 00:00:00 2001 From: ed Date: Fri, 1 Sep 2017 16:02:03 +0100 Subject: [PATCH 036/129] BLOCKS: Added some extra LittleFoot definitions and a new local config for gamma correction --- .../blocks/juce_BlockConfigManager.h | 5 ++++- .../protocol/juce_BlocksProtocolDefinitions.h | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/modules/juce_blocks_basics/blocks/juce_BlockConfigManager.h b/modules/juce_blocks_basics/blocks/juce_BlockConfigManager.h index ad1d70b585..4369372c8d 100644 --- a/modules/juce_blocks_basics/blocks/juce_BlockConfigManager.h +++ b/modules/juce_blocks_basics/blocks/juce_BlockConfigManager.h @@ -49,7 +49,7 @@ struct BlockConfigManager options }; - static constexpr uint32 numConfigItems = 59; + static constexpr uint32 numConfigItems = 60; struct ConfigDescription { @@ -115,6 +115,9 @@ struct BlockConfigManager "Lowest", "Disabled", "Hardest" }, "Play mode" }, + + { gammaCorrection, 0, 0, 1, false, "Gamma Correction", ConfigType::boolean, {}, {} }, + // These can be defined for unique usage for a given Littlefoot script { user0, 0, 0, 127, false, {}, ConfigType::integer, {}, {} }, { user1, 0, 0, 127, false, {}, ConfigType::integer, {}, {} }, diff --git a/modules/juce_blocks_basics/protocol/juce_BlocksProtocolDefinitions.h b/modules/juce_blocks_basics/protocol/juce_BlocksProtocolDefinitions.h index 6a7934f8b6..c989a2f4b0 100644 --- a/modules/juce_blocks_basics/protocol/juce_BlocksProtocolDefinitions.h +++ b/modules/juce_blocks_basics/protocol/juce_BlocksProtocolDefinitions.h @@ -222,6 +222,8 @@ enum ConfigItemId xTrackingMode = 30, yTrackingMode = 31, zTrackingMode = 32, + // Graphics + gammaCorrection = 33, // User user0 = 64, user1 = 65, @@ -447,12 +449,22 @@ static constexpr const char* ledProgramLittleFootFunctions[] = "setClusteringActive/vb", "makeARGB/iiiii", "blendARGB/iii", + "setDepthShadingActive/viiiib", + "setBlendType/vi", "fillPixel/viii", "blendPixel/viii", + "drawLine/viiiii", + "blendLine/viiiii", "fillRect/viiiii", "blendRect/viiiii", "blendGradientRect/viiiiiiii", + "fillQuad/vifffffffff", + "blendQuad/viffffffff", "blendCircle/vifffb", + "drawLine3D/viiiiiii", + "blendLine3D/viiiiiii", + "fillQuad3D/viffffffffffff", + "blendQuad3D/viffffffffffff", "addPressurePoint/vifff", "drawPressureMap/v", "fadePressureMap/v", @@ -489,5 +501,7 @@ static constexpr const char* ledProgramLittleFootFunctions[] = "onControlPress/vi", "onControlRelease/vi", "initControl/viiiiiiiii", + "setLED/viii", + "blendLed/viii", nullptr }; From 6b53daa4485ff5dcbefac5ac6ab8bd4a125cfd58 Mon Sep 17 00:00:00 2001 From: ed Date: Fri, 1 Sep 2017 16:31:33 +0100 Subject: [PATCH 037/129] BLOCKS: Removed a couple of old LittleFoot methods --- .../protocol/juce_BlocksProtocolDefinitions.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/juce_blocks_basics/protocol/juce_BlocksProtocolDefinitions.h b/modules/juce_blocks_basics/protocol/juce_BlocksProtocolDefinitions.h index c989a2f4b0..519889d873 100644 --- a/modules/juce_blocks_basics/protocol/juce_BlocksProtocolDefinitions.h +++ b/modules/juce_blocks_basics/protocol/juce_BlocksProtocolDefinitions.h @@ -501,7 +501,5 @@ static constexpr const char* ledProgramLittleFootFunctions[] = "onControlPress/vi", "onControlRelease/vi", "initControl/viiiiiiiii", - "setLED/viii", - "blendLed/viii", nullptr }; From 87c22acd97d5d992e2c409f6dee3d14e530b8053 Mon Sep 17 00:00:00 2001 From: tpoole Date: Mon, 4 Sep 2017 08:38:21 +0100 Subject: [PATCH 038/129] Projucer: Fixed a bug in the plug-in template code --- .../Source/BinaryData/jucer_AudioPluginFilterTemplate.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extras/Projucer/Source/BinaryData/jucer_AudioPluginFilterTemplate.cpp b/extras/Projucer/Source/BinaryData/jucer_AudioPluginFilterTemplate.cpp index d84df3f16d..64b036e975 100644 --- a/extras/Projucer/Source/BinaryData/jucer_AudioPluginFilterTemplate.cpp +++ b/extras/Projucer/Source/BinaryData/jucer_AudioPluginFilterTemplate.cpp @@ -54,9 +54,9 @@ bool FILTERCLASSNAME::producesMidi() const #endif } -bool FILTERCLASSNAME::isMidiEffect () const +bool FILTERCLASSNAME::isMidiEffect() const { - #ifdef JucePlugin_IsMidiEffect + #if JucePlugin_IsMidiEffect return true; #else return false; From 65ba03254505d30a1e6a76f2966796c852cdd3ef Mon Sep 17 00:00:00 2001 From: jules Date: Tue, 5 Sep 2017 09:02:15 +0100 Subject: [PATCH 039/129] Tweaked the wording of some comments in AudioPlayHead --- .../audio_play_head/juce_AudioPlayHead.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/juce_audio_basics/audio_play_head/juce_AudioPlayHead.h b/modules/juce_audio_basics/audio_play_head/juce_AudioPlayHead.h index 2f4859996d..45f916238b 100644 --- a/modules/juce_audio_basics/audio_play_head/juce_AudioPlayHead.h +++ b/modules/juce_audio_basics/audio_play_head/juce_AudioPlayHead.h @@ -71,12 +71,12 @@ public: /** Time signature denominator, e.g. the 4 of a 3/4 time sig */ int timeSigDenominator; - /** The current play position, in samples from the start of the edit. */ + /** The current play position, in samples from the start of the timeline. */ int64 timeInSamples; - /** The current play position, in seconds from the start of the edit. */ + /** The current play position, in seconds from the start of the timeline. */ double timeInSeconds; - /** For timecode, the position of the start of the edit, in seconds from 00:00:00:00. */ + /** For timecode, the position of the start of the timeline, in seconds from 00:00:00:00. */ double editOriginTime; /** The current play position, in pulses-per-quarter-note. */ @@ -84,7 +84,7 @@ public: /** The position of the start of the last bar, in pulses-per-quarter-note. - This is the time from the start of the edit to the start of the current + This is the time from the start of the timeline to the start of the current bar, in ppq units. Note - this value may be unavailable on some hosts, e.g. Pro-Tools. If From f65500ec7b02d8f2979c28fe8500ea2bb0fb5a48 Mon Sep 17 00:00:00 2001 From: Lukasz Kozakiewicz Date: Mon, 4 Sep 2017 17:36:36 +0200 Subject: [PATCH 040/129] InAppPurchases: fix linker error on iOS when product unlocking module is included by IAP capability is turned off. --- .../Source/Project Saving/jucer_ProjectExport_Android.h | 3 +++ .../Source/Project Saving/jucer_ProjectExport_XCode.h | 3 +++ modules/juce_gui_basics/native/juce_android_Windowing.cpp | 4 ++-- modules/juce_product_unlocking/juce_product_unlocking.cpp | 3 +++ modules/juce_product_unlocking/juce_product_unlocking.h | 2 ++ 5 files changed, 13 insertions(+), 2 deletions(-) diff --git a/extras/Projucer/Source/Project Saving/jucer_ProjectExport_Android.h b/extras/Projucer/Source/Project Saving/jucer_ProjectExport_Android.h index 81f6d1b069..ba8c6e7513 100644 --- a/extras/Projucer/Source/Project Saving/jucer_ProjectExport_Android.h +++ b/extras/Projucer/Source/Project Saving/jucer_ProjectExport_Android.h @@ -1236,6 +1236,9 @@ private: defines.set ("JUCE_ANDROID_ACTIVITY_CLASSNAME", getJNIActivityClassName().replaceCharacter ('/', '_')); defines.set ("JUCE_ANDROID_ACTIVITY_CLASSPATH", "\"" + getJNIActivityClassName() + "\""); + if (androidInAppBillingPermission.get()) + defines.set ("JUCE_IN_APP_PURCHASES", "1"); + if (supportsGLv3()) defines.set ("JUCE_ANDROID_GL_ES_VERSION_3_0", "1"); diff --git a/extras/Projucer/Source/Project Saving/jucer_ProjectExport_XCode.h b/extras/Projucer/Source/Project Saving/jucer_ProjectExport_XCode.h index f376e70eb6..3d18e12c8f 100644 --- a/extras/Projucer/Source/Project Saving/jucer_ProjectExport_XCode.h +++ b/extras/Projucer/Source/Project Saving/jucer_ProjectExport_XCode.h @@ -1040,6 +1040,9 @@ public: s.add ("SEPARATE_STRIP = YES"); } + if (owner.iOS && owner.isInAppPurchasesEnabled()) + defines.set ("JUCE_IN_APP_PURCHASES", "1"); + defines = mergePreprocessorDefs (defines, owner.getAllPreprocessorDefs (config, type)); StringArray defsList; diff --git a/modules/juce_gui_basics/native/juce_android_Windowing.cpp b/modules/juce_gui_basics/native/juce_android_Windowing.cpp index f15090bf8f..ba5ac8a7f4 100644 --- a/modules/juce_gui_basics/native/juce_android_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_android_Windowing.cpp @@ -32,7 +32,7 @@ namespace juce { //============================================================================== -#if JUCE_MODULE_AVAILABLE_juce_product_unlocking +#if JUCE_IN_APP_PURCHASES && JUCE_MODULE_AVAILABLE_juce_product_unlocking extern void juce_inAppPurchaseCompleted (void*); #endif @@ -92,7 +92,7 @@ JUCE_JNI_CALLBACK (JUCE_ANDROID_ACTIVITY_CLASSNAME, appActivityResult, void, (JN { setEnv (env); - #if JUCE_MODULE_AVAILABLE_juce_product_unlocking + #if JUCE_IN_APP_PURCHASES && JUCE_MODULE_AVAILABLE_juce_product_unlocking if (requestCode == 1001) juce_inAppPurchaseCompleted (intentData); #else diff --git a/modules/juce_product_unlocking/juce_product_unlocking.cpp b/modules/juce_product_unlocking/juce_product_unlocking.cpp index aa15069954..4e78809c61 100644 --- a/modules/juce_product_unlocking/juce_product_unlocking.cpp +++ b/modules/juce_product_unlocking/juce_product_unlocking.cpp @@ -50,6 +50,7 @@ namespace juce { + #if JUCE_IN_APP_PURCHASES #if JUCE_ANDROID #include "native/juce_android_InAppPurchases.cpp" #elif JUCE_IOS @@ -57,6 +58,8 @@ namespace juce #endif #include "in_app_purchases/juce_InAppPurchases.cpp" + #endif + #include "marketplace/juce_OnlineUnlockStatus.cpp" #if JUCE_MODULE_AVAILABLE_juce_data_structures diff --git a/modules/juce_product_unlocking/juce_product_unlocking.h b/modules/juce_product_unlocking/juce_product_unlocking.h index e715afbf16..85884e2df0 100644 --- a/modules/juce_product_unlocking/juce_product_unlocking.h +++ b/modules/juce_product_unlocking/juce_product_unlocking.h @@ -79,7 +79,9 @@ namespace juce { + #if JUCE_IN_APP_PURCHASES #include "in_app_purchases/juce_InAppPurchases.h" + #endif #if JUCE_MODULE_AVAILABLE_juce_data_structures #include "marketplace/juce_OnlineUnlockStatus.h" From baa59076685697431b32877a45a080f656691060 Mon Sep 17 00:00:00 2001 From: jules Date: Tue, 5 Sep 2017 10:03:45 +0100 Subject: [PATCH 041/129] Added some setter methods to SynthesiserVoice --- .../synthesisers/juce_Synthesiser.cpp | 16 ++++++++-------- .../synthesisers/juce_Synthesiser.h | 18 ++++++++++++------ 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/modules/juce_audio_basics/synthesisers/juce_Synthesiser.cpp b/modules/juce_audio_basics/synthesisers/juce_Synthesiser.cpp index 4df64603e0..fa12e84033 100644 --- a/modules/juce_audio_basics/synthesisers/juce_Synthesiser.cpp +++ b/modules/juce_audio_basics/synthesisers/juce_Synthesiser.cpp @@ -305,8 +305,8 @@ void Synthesiser::startVoice (SynthesiserVoice* const voice, voice->noteOnTime = ++lastNoteOnCounter; voice->currentlyPlayingSound = sound; voice->setKeyDown (true); - voice->sostenutoPedalDown = false; - voice->sustainPedalDown = sustainPedalsDown[midiChannel]; + voice->setSostenutoPedalDown (false); + voice->setSustainPedalDown (sustainPedalsDown[midiChannel]); voice->startNote (midiNoteNumber, velocity, sound, lastPitchWheelValues [midiChannel - 1]); @@ -340,11 +340,11 @@ void Synthesiser::noteOff (const int midiChannel, if (sound->appliesToNote (midiNoteNumber) && sound->appliesToChannel (midiChannel)) { - jassert (! voice->keyIsDown || voice->sustainPedalDown == sustainPedalsDown [midiChannel]); + jassert (! voice->keyIsDown || voice->isSustainPedalDown() == sustainPedalsDown [midiChannel]); voice->setKeyDown (false); - if (! (voice->sustainPedalDown || voice->sostenutoPedalDown)) + if (! (voice->isSustainPedalDown() || voice->isSostenutoPedalDown())) stopVoice (voice, velocity, allowTailOff); } } @@ -421,7 +421,7 @@ void Synthesiser::handleSustainPedal (int midiChannel, bool isDown) for (auto* voice : voices) if (voice->isPlayingChannel (midiChannel) && voice->isKeyDown()) - voice->sustainPedalDown = true; + voice->setSustainPedalDown (true); } else { @@ -429,7 +429,7 @@ void Synthesiser::handleSustainPedal (int midiChannel, bool isDown) { if (voice->isPlayingChannel (midiChannel)) { - voice->sustainPedalDown = false; + voice->setSustainPedalDown (false); if (! (voice->isKeyDown() || voice->isSostenutoPedalDown())) stopVoice (voice, 1.0f, true); @@ -450,8 +450,8 @@ void Synthesiser::handleSostenutoPedal (int midiChannel, bool isDown) if (voice->isPlayingChannel (midiChannel)) { if (isDown) - voice->sostenutoPedalDown = true; - else if (voice->sostenutoPedalDown) + voice->setSostenutoPedalDown (true); + else if (voice->isSostenutoPedalDown()) stopVoice (voice, 1.0f, true); } } diff --git a/modules/juce_audio_basics/synthesisers/juce_Synthesiser.h b/modules/juce_audio_basics/synthesisers/juce_Synthesiser.h index cad5ac393f..1089960628 100644 --- a/modules/juce_audio_basics/synthesisers/juce_Synthesiser.h +++ b/modules/juce_audio_basics/synthesisers/juce_Synthesiser.h @@ -224,9 +224,15 @@ public: /** Returns true if the sustain pedal is currently active for this voice. */ bool isSustainPedalDown() const noexcept { return sustainPedalDown; } + /** Modifies the sustain pedal flag. */ + void setSustainPedalDown (bool isNowDown) noexcept { sustainPedalDown = isNowDown; } + /** Returns true if the sostenuto pedal is currently active for this voice. */ bool isSostenutoPedalDown() const noexcept { return sostenutoPedalDown; } + /** Modifies the sostenuto pedal flag. */ + void setSostenutoPedalDown (bool isNowDown) noexcept { sostenutoPedalDown = isNowDown; } + /** Returns true if a voice is sounding in its release phase **/ bool isPlayingButReleased() const noexcept { @@ -514,15 +520,15 @@ public: with timestamps outside the specified region will be ignored. */ inline void renderNextBlock (AudioBuffer& outputAudio, - const MidiBuffer& inputMidi, - int startSample, - int numSamples) + const MidiBuffer& inputMidi, + int startSample, + int numSamples) { processNextBlock (outputAudio, inputMidi, startSample, numSamples); } inline void renderNextBlock (AudioBuffer& outputAudio, - const MidiBuffer& inputMidi, - int startSample, - int numSamples) + const MidiBuffer& inputMidi, + int startSample, + int numSamples) { processNextBlock (outputAudio, inputMidi, startSample, numSamples); } /** Returns the current target sample rate at which rendering is being done. From e30178418c2fa37d1ab9278d6b909735ee633560 Mon Sep 17 00:00:00 2001 From: jules Date: Tue, 5 Sep 2017 12:47:15 +0100 Subject: [PATCH 042/129] Modernised some code in TableListBox --- .../widgets/juce_TableHeaderComponent.cpp | 247 ++++++++---------- .../widgets/juce_TableHeaderComponent.h | 9 +- .../widgets/juce_TableListBox.cpp | 89 +++---- .../widgets/juce_TableListBox.h | 6 +- 4 files changed, 155 insertions(+), 196 deletions(-) diff --git a/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp b/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp index 444e7d50c6..3e8a635bcb 100644 --- a/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp +++ b/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp @@ -27,8 +27,7 @@ class TableHeaderComponent::DragOverlayComp : public Component { public: - DragOverlayComp (const Image& image_) - : image (image_) + DragOverlayComp (const Image& i) : image (i) { image.duplicateIfShared(); image.multiplyAllAlphas (0.8f); @@ -40,7 +39,6 @@ public: g.drawImageAt (image, 0, 0); } -private: Image image; JUCE_DECLARE_NON_COPYABLE (DragOverlayComp) @@ -49,15 +47,6 @@ private: //============================================================================== TableHeaderComponent::TableHeaderComponent() - : columnsChanged (false), - columnsResized (false), - sortChanged (false), - menuActive (true), - stretchToFit (false), - columnIdBeingResized (0), - columnIdBeingDragged (0), - columnIdUnderMouse (0), - lastDeliberateWidth (0) { } @@ -67,12 +56,12 @@ TableHeaderComponent::~TableHeaderComponent() } //============================================================================== -void TableHeaderComponent::setPopupMenuActive (const bool hasMenu) +void TableHeaderComponent::setPopupMenuActive (bool hasMenu) { menuActive = hasMenu; } -bool TableHeaderComponent::isPopupMenuActive() const { return menuActive; } +bool TableHeaderComponent::isPopupMenuActive() const { return menuActive; } //============================================================================== @@ -82,8 +71,8 @@ int TableHeaderComponent::getNumColumns (const bool onlyCountVisibleColumns) con { int num = 0; - for (int i = columns.size(); --i >= 0;) - if (columns.getUnchecked(i)->isVisible()) + for (auto* c : columns) + if (c->isVisible()) ++num; return num; @@ -113,26 +102,24 @@ void TableHeaderComponent::setColumnName (const int columnId, const String& newN } void TableHeaderComponent::addColumn (const String& columnName, - const int columnId, - const int width, - const int minimumWidth, - const int maximumWidth, - const int propertyFlags, - const int insertIndex) -{ - // can't have a duplicate or null ID! + int columnId, + int width, + int minimumWidth, + int maximumWidth, + int propertyFlags, + int insertIndex) +{ + // can't have a duplicate or zero ID! jassert (columnId != 0 && getIndexOfColumnId (columnId, false) < 0); jassert (width > 0); - ColumnInfo* const ci = new ColumnInfo(); + auto ci = new ColumnInfo(); ci->name = columnName; ci->id = columnId; ci->width = width; ci->lastDeliberateWidth = width; ci->minimumWidth = minimumWidth; - ci->maximumWidth = maximumWidth; - if (ci->maximumWidth < 0) - ci->maximumWidth = std::numeric_limits::max(); + ci->maximumWidth = maximumWidth >= 0 ? maximumWidth : std::numeric_limits::max(); jassert (ci->maximumWidth >= ci->minimumWidth); ci->propertyFlags = propertyFlags; @@ -142,7 +129,7 @@ void TableHeaderComponent::addColumn (const String& columnName, void TableHeaderComponent::removeColumn (const int columnIdToRemove) { - const int index = getIndexOfColumnId (columnIdToRemove, false); + auto index = getIndexOfColumnId (columnIdToRemove, false); if (index >= 0) { @@ -163,7 +150,7 @@ void TableHeaderComponent::removeAllColumns() void TableHeaderComponent::moveColumn (const int columnId, int newIndex) { - const int currentIndex = getIndexOfColumnId (columnId, false); + auto currentIndex = getIndexOfColumnId (columnId, false); newIndex = visibleIndexToTotalIndex (newIndex); if (columns [currentIndex] != 0 && currentIndex != newIndex) @@ -175,7 +162,7 @@ void TableHeaderComponent::moveColumn (const int columnId, int newIndex) int TableHeaderComponent::getColumnWidth (const int columnId) const { - if (const ColumnInfo* const ci = getInfoForId (columnId)) + if (auto* ci = getInfoForId (columnId)) return ci->width; return 0; @@ -183,33 +170,34 @@ int TableHeaderComponent::getColumnWidth (const int columnId) const void TableHeaderComponent::setColumnWidth (const int columnId, const int newWidth) { - ColumnInfo* const ci = getInfoForId (columnId); - - if (ci != nullptr && ci->width != newWidth) + if (auto* ci = getInfoForId (columnId)) { - const int numColumns = getNumColumns (true); - - ci->lastDeliberateWidth = ci->width - = jlimit (ci->minimumWidth, ci->maximumWidth, newWidth); - - if (stretchToFit) + if (ci->width != newWidth) { - const int index = getIndexOfColumnId (columnId, true) + 1; + auto numColumns = getNumColumns (true); + + ci->lastDeliberateWidth = ci->width + = jlimit (ci->minimumWidth, ci->maximumWidth, newWidth); - if (isPositiveAndBelow (index, numColumns)) + if (stretchToFit) { - const int x = getColumnPosition (index).getX(); + auto index = getIndexOfColumnId (columnId, true) + 1; - if (lastDeliberateWidth == 0) - lastDeliberateWidth = getTotalWidth(); + if (isPositiveAndBelow (index, numColumns)) + { + auto x = getColumnPosition (index).getX(); + + if (lastDeliberateWidth == 0) + lastDeliberateWidth = getTotalWidth(); - resizeColumnsToFit (visibleIndexToTotalIndex (index), lastDeliberateWidth - x); + resizeColumnsToFit (visibleIndexToTotalIndex (index), lastDeliberateWidth - x); + } } - } - repaint(); - columnsResized = true; - triggerAsyncUpdate(); + repaint(); + columnsResized = true; + triggerAsyncUpdate(); + } } } @@ -218,11 +206,11 @@ int TableHeaderComponent::getIndexOfColumnId (const int columnId, const bool onl { int n = 0; - for (int i = 0; i < columns.size(); ++i) + for (auto* c : columns) { - if ((! onlyCountVisibleColumns) || columns.getUnchecked(i)->isVisible()) + if ((! onlyCountVisibleColumns) || c->isVisible()) { - if (columns.getUnchecked(i)->id == columnId) + if (c->id == columnId) return n; ++n; @@ -237,7 +225,7 @@ int TableHeaderComponent::getColumnIdOfIndex (int index, const bool onlyCountVis if (onlyCountVisibleColumns) index = visibleIndexToTotalIndex (index); - if (const ColumnInfo* const ci = columns [index]) + if (auto* ci = columns [index]) return ci->id; return 0; @@ -247,13 +235,13 @@ Rectangle TableHeaderComponent::getColumnPosition (const int index) const { int x = 0, width = 0, n = 0; - for (int i = 0; i < columns.size(); ++i) + for (auto* c : columns) { x += width; - if (columns.getUnchecked(i)->isVisible()) + if (c->isVisible()) { - width = columns.getUnchecked(i)->width; + width = c->width; if (n++ == index) break; @@ -264,7 +252,7 @@ Rectangle TableHeaderComponent::getColumnPosition (const int index) const } } - return Rectangle (x, 0, width, getHeight()); + return { x, 0, width, getHeight() }; } int TableHeaderComponent::getColumnIdAtX (const int xToFind) const @@ -273,10 +261,8 @@ int TableHeaderComponent::getColumnIdAtX (const int xToFind) const { int x = 0; - for (int i = 0; i < columns.size(); ++i) + for (auto* ci : columns) { - const ColumnInfo* const ci = columns.getUnchecked(i); - if (ci->isVisible()) { x += ci->width; @@ -294,9 +280,9 @@ int TableHeaderComponent::getTotalWidth() const { int w = 0; - for (int i = columns.size(); --i >= 0;) - if (columns.getUnchecked(i)->isVisible()) - w += columns.getUnchecked(i)->width; + for (auto* c : columns) + if (c->isVisible()) + w += c->width; return w; } @@ -326,27 +312,27 @@ void TableHeaderComponent::resizeAllColumnsToFit (int targetTotalWidth) void TableHeaderComponent::resizeColumnsToFit (int firstColumnIndex, int targetTotalWidth) { targetTotalWidth = jmax (targetTotalWidth, 0); - StretchableObjectResizer sor; + for (int i = firstColumnIndex; i < columns.size(); ++i) { - ColumnInfo* const ci = columns.getUnchecked(i); + auto* ci = columns.getUnchecked(i); if (ci->isVisible()) sor.addItem (ci->lastDeliberateWidth, ci->minimumWidth, ci->maximumWidth); } sor.resizeToFit (targetTotalWidth); - int visIndex = 0; + for (int i = firstColumnIndex; i < columns.size(); ++i) { - ColumnInfo* const ci = columns.getUnchecked(i); + auto* ci = columns.getUnchecked(i); if (ci->isVisible()) { - const int newWidth = jlimit (ci->minimumWidth, ci->maximumWidth, - (int) std::floor (sor.getItemSize (visIndex++))); + auto newWidth = jlimit (ci->minimumWidth, ci->maximumWidth, + (int) std::floor (sor.getItemSize (visIndex++))); if (newWidth != ci->width) { @@ -361,7 +347,7 @@ void TableHeaderComponent::resizeColumnsToFit (int firstColumnIndex, int targetT void TableHeaderComponent::setColumnVisible (const int columnId, const bool shouldBeVisible) { - if (ColumnInfo* const ci = getInfoForId (columnId)) + if (auto* ci = getInfoForId (columnId)) { if (shouldBeVisible != ci->isVisible()) { @@ -378,8 +364,10 @@ void TableHeaderComponent::setColumnVisible (const int columnId, const bool shou bool TableHeaderComponent::isColumnVisible (const int columnId) const { - const ColumnInfo* const ci = getInfoForId (columnId); - return ci != nullptr && ci->isVisible(); + if (auto* ci = getInfoForId (columnId)) + return ci->isVisible(); + + return false; } //============================================================================== @@ -387,10 +375,10 @@ void TableHeaderComponent::setSortColumnId (const int columnId, const bool sortF { if (getSortColumnId() != columnId || isSortedForwards() != sortForwards) { - for (int i = columns.size(); --i >= 0;) - columns.getUnchecked(i)->propertyFlags &= ~(sortedForwards | sortedBackwards); + for (auto* c : columns) + c->propertyFlags &= ~(sortedForwards | sortedBackwards); - if (ColumnInfo* const ci = getInfoForId (columnId)) + if (auto* ci = getInfoForId (columnId)) ci->propertyFlags |= (sortForwards ? sortedForwards : sortedBackwards); reSortTable(); @@ -399,18 +387,18 @@ void TableHeaderComponent::setSortColumnId (const int columnId, const bool sortF int TableHeaderComponent::getSortColumnId() const { - for (int i = columns.size(); --i >= 0;) - if ((columns.getUnchecked(i)->propertyFlags & (sortedForwards | sortedBackwards)) != 0) - return columns.getUnchecked(i)->id; + for (auto* c : columns) + if ((c->propertyFlags & (sortedForwards | sortedBackwards)) != 0) + return c->id; return 0; } bool TableHeaderComponent::isSortedForwards() const { - for (int i = columns.size(); --i >= 0;) - if ((columns.getUnchecked(i)->propertyFlags & (sortedForwards | sortedBackwards)) != 0) - return (columns.getUnchecked(i)->propertyFlags & sortedForwards) != 0; + for (auto* c : columns) + if ((c->propertyFlags & (sortedForwards | sortedBackwards)) != 0) + return (c->propertyFlags & sortedForwards) != 0; return true; } @@ -432,17 +420,15 @@ String TableHeaderComponent::toString() const doc.setAttribute ("sortedCol", getSortColumnId()); doc.setAttribute ("sortForwards", isSortedForwards()); - for (int i = 0; i < columns.size(); ++i) + for (auto* ci : columns) { - const ColumnInfo* const ci = columns.getUnchecked (i); - - XmlElement* const e = doc.createNewChildElement ("COLUMN"); + auto* e = doc.createNewChildElement ("COLUMN"); e->setAttribute ("id", ci->id); e->setAttribute ("visible", ci->isVisible()); e->setAttribute ("width", ci->width); } - return doc.createDocument ("", true, false); + return doc.createDocument ({}, true, false); } void TableHeaderComponent::restoreFromString (const String& storedVersion) @@ -454,9 +440,9 @@ void TableHeaderComponent::restoreFromString (const String& storedVersion) { forEachXmlChildElement (*storedXml, col) { - const int tabId = col->getIntAttribute ("id"); + auto tabId = col->getIntAttribute ("id"); - if (ColumnInfo* const ci = getInfoForId (tabId)) + if (auto* ci = getInfoForId (tabId)) { columns.move (columns.indexOf (ci), index); ci->width = col->getIntAttribute ("width"); @@ -488,22 +474,18 @@ void TableHeaderComponent::removeListener (Listener* const listenerToRemove) //============================================================================== void TableHeaderComponent::columnClicked (int columnId, const ModifierKeys& mods) { - if (const ColumnInfo* const ci = getInfoForId (columnId)) + if (auto* ci = getInfoForId (columnId)) if ((ci->propertyFlags & sortable) != 0 && ! mods.isPopupMenu()) setSortColumnId (columnId, (ci->propertyFlags & sortedForwards) == 0); } void TableHeaderComponent::addMenuItems (PopupMenu& menu, const int /*columnIdClicked*/) { - for (int i = 0; i < columns.size(); ++i) - { - const ColumnInfo* const ci = columns.getUnchecked(i); - + for (auto* ci : columns) if ((ci->propertyFlags & appearsOnColumnMenu) != 0) menu.addItem (ci->id, ci->name, (ci->propertyFlags & (sortedForwards | sortedBackwards)) == 0, isColumnVisible (ci->id)); - } } void TableHeaderComponent::reactToMenuItem (const int menuReturnId, const int /*columnIdClicked*/) @@ -521,10 +503,9 @@ void TableHeaderComponent::paint (Graphics& g) const Rectangle clip (g.getClipBounds()); int x = 0; - for (int i = 0; i < columns.size(); ++i) - { - const ColumnInfo* const ci = columns.getUnchecked(i); + for (auto* ci : columns) + { if (ci->isVisible()) { if (x + ci->width > clip.getX() @@ -551,24 +532,9 @@ void TableHeaderComponent::paint (Graphics& g) } } -void TableHeaderComponent::resized() -{ -} - -void TableHeaderComponent::mouseMove (const MouseEvent& e) -{ - updateColumnUnderMouse (e); -} - -void TableHeaderComponent::mouseEnter (const MouseEvent& e) -{ - updateColumnUnderMouse (e); -} - -void TableHeaderComponent::mouseExit (const MouseEvent&) -{ - setColumnUnderMouse (0); -} +void TableHeaderComponent::mouseMove (const MouseEvent& e) { updateColumnUnderMouse (e); } +void TableHeaderComponent::mouseEnter (const MouseEvent& e) { updateColumnUnderMouse (e); } +void TableHeaderComponent::mouseExit (const MouseEvent&) { setColumnUnderMouse (0); } void TableHeaderComponent::mouseDown (const MouseEvent& e) { @@ -601,9 +567,10 @@ void TableHeaderComponent::mouseDrag (const MouseEvent& e) if (columnIdBeingResized != 0) { - const ColumnInfo* const ci = getInfoForId (columnIdBeingResized); - jassert (ci != nullptr); - initialColumnWidth = ci->width; + if (auto* ci = getInfoForId (columnIdBeingResized)) + initialColumnWidth = ci->width; + else + jassertfalse; } else { @@ -613,20 +580,21 @@ void TableHeaderComponent::mouseDrag (const MouseEvent& e) if (columnIdBeingResized != 0) { - if (const ColumnInfo* const ci = getInfoForId (columnIdBeingResized)) + if (auto* ci = getInfoForId (columnIdBeingResized)) { - int w = jlimit (ci->minimumWidth, ci->maximumWidth, - initialColumnWidth + e.getDistanceFromDragStartX()); + auto w = jlimit (ci->minimumWidth, ci->maximumWidth, + initialColumnWidth + e.getDistanceFromDragStartX()); if (stretchToFit) { // prevent us dragging a column too far right if we're in stretch-to-fit mode int minWidthOnRight = 0; + for (int i = getIndexOfColumnId (columnIdBeingResized, false) + 1; i < columns.size(); ++i) if (columns.getUnchecked (i)->isVisible()) minWidthOnRight += columns.getUnchecked (i)->minimumWidth; - const Rectangle currentPos (getColumnPosition (getIndexOfColumnId (columnIdBeingResized, true))); + auto currentPos = getColumnPosition (getIndexOfColumnId (columnIdBeingResized, true)); w = jmax (ci->minimumWidth, jmin (w, lastDeliberateWidth - minWidthOnRight - currentPos.getX())); } @@ -656,15 +624,15 @@ void TableHeaderComponent::mouseDrag (const MouseEvent& e) { // if the previous column isn't draggable, we can't move our column // past it, because that'd change the undraggable column's position.. - const ColumnInfo* const previous = columns.getUnchecked (newIndex - 1); + auto* previous = columns.getUnchecked (newIndex - 1); if ((previous->propertyFlags & draggable) != 0) { - const int leftOfPrevious = getColumnPosition (newIndex - 1).getX(); - const int rightOfCurrent = getColumnPosition (newIndex).getRight(); + auto leftOfPrevious = getColumnPosition (newIndex - 1).getX(); + auto rightOfCurrent = getColumnPosition (newIndex).getRight(); - if (abs (dragOverlayComp->getX() - leftOfPrevious) - < abs (dragOverlayComp->getRight() - rightOfCurrent)) + if (std::abs (dragOverlayComp->getX() - leftOfPrevious) + < std::abs (dragOverlayComp->getRight() - rightOfCurrent)) { --newIndex; } @@ -675,15 +643,15 @@ void TableHeaderComponent::mouseDrag (const MouseEvent& e) { // if the next column isn't draggable, we can't move our column // past it, because that'd change the undraggable column's position.. - const ColumnInfo* const nextCol = columns.getUnchecked (newIndex + 1); + auto* nextCol = columns.getUnchecked (newIndex + 1); if ((nextCol->propertyFlags & draggable) != 0) { - const int leftOfCurrent = getColumnPosition (newIndex).getX(); - const int rightOfNext = getColumnPosition (newIndex + 1).getRight(); + auto leftOfCurrent = getColumnPosition (newIndex).getX(); + auto rightOfNext = getColumnPosition (newIndex + 1).getRight(); - if (abs (dragOverlayComp->getX() - leftOfCurrent) - > abs (dragOverlayComp->getRight() - rightOfNext)) + if (std::abs (dragOverlayComp->getX() - leftOfCurrent) + > std::abs (dragOverlayComp->getRight() - rightOfNext)) { ++newIndex; } @@ -710,7 +678,7 @@ void TableHeaderComponent::beginDrag (const MouseEvent& e) { columnIdBeingDragged = getColumnIdAtX (e.getMouseDownX()); - const ColumnInfo* const ci = getInfoForId (columnIdBeingDragged); + auto* ci = getInfoForId (columnIdBeingDragged); if (ci == nullptr || (ci->propertyFlags & draggable) == 0) { @@ -720,9 +688,8 @@ void TableHeaderComponent::beginDrag (const MouseEvent& e) { draggingColumnOriginalIndex = getIndexOfColumnId (columnIdBeingDragged, true); - const Rectangle columnRect (getColumnPosition (draggingColumnOriginalIndex)); - - const int temp = columnIdBeingDragged; + auto columnRect = getColumnPosition (draggingColumnOriginalIndex); + auto temp = columnIdBeingDragged; columnIdBeingDragged = 0; addAndMakeVisible (dragOverlayComp = new DragOverlayComp (createComponentSnapshot (columnRect, false))); @@ -872,13 +839,11 @@ int TableHeaderComponent::getResizeDraggerAt (const int mouseX) const const int draggableDistance = 3; int x = 0; - for (int i = 0; i < columns.size(); ++i) + for (auto* ci : columns) { - const ColumnInfo* const ci = columns.getUnchecked(i); - if (ci->isVisible()) { - if (abs (mouseX - (x + ci->width)) <= draggableDistance + if (std::abs (mouseX - (x + ci->width)) <= draggableDistance && (ci->propertyFlags & resizable) != 0) return ci->id; diff --git a/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.h b/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.h index 4efedbdf82..51ad376a0f 100644 --- a/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.h +++ b/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.h @@ -402,8 +402,6 @@ public: /** @internal */ void paint (Graphics&) override; /** @internal */ - void resized() override; - /** @internal */ void mouseMove (const MouseEvent&) override; /** @internal */ void mouseEnter (const MouseEvent&) override; @@ -436,9 +434,10 @@ private: ScopedPointer dragOverlayComp; class DragOverlayComp; - bool columnsChanged, columnsResized, sortChanged, menuActive, stretchToFit; - int columnIdBeingResized, columnIdBeingDragged, initialColumnWidth; - int columnIdUnderMouse, draggingColumnOffset, draggingColumnOriginalIndex, lastDeliberateWidth; + bool columnsChanged = false, columnsResized = false, sortChanged = false; + bool menuActive = true, stretchToFit = false; + int columnIdBeingResized = 0, columnIdBeingDragged = 0, initialColumnWidth = 0; + int columnIdUnderMouse = 0, draggingColumnOffset = 0, draggingColumnOriginalIndex = 0, lastDeliberateWidth = 0; ColumnInfo* getInfoForId (int columnId) const; int visibleIndexToTotalIndex (int visibleIndex) const; diff --git a/modules/juce_gui_basics/widgets/juce_TableListBox.cpp b/modules/juce_gui_basics/widgets/juce_TableListBox.cpp index b9b4b9f2a8..220d50e917 100644 --- a/modules/juce_gui_basics/widgets/juce_TableListBox.cpp +++ b/modules/juce_gui_basics/widgets/juce_TableListBox.cpp @@ -28,25 +28,23 @@ class TableListBox::RowComp : public Component, public TooltipClient { public: - RowComp (TableListBox& tlb) noexcept : owner (tlb), row (-1), isSelected (false) - { - } + RowComp (TableListBox& tlb) noexcept : owner (tlb) {} void paint (Graphics& g) override { - if (TableListBoxModel* const tableModel = owner.getModel()) + if (auto* tableModel = owner.getModel()) { tableModel->paintRowBackground (g, row, getWidth(), getHeight(), isSelected); - const TableHeaderComponent& headerComp = owner.getHeader(); - const int numColumns = headerComp.getNumColumns (true); - const Rectangle clipBounds (g.getClipBounds()); + auto& headerComp = owner.getHeader(); + auto numColumns = headerComp.getNumColumns (true); + auto clipBounds = g.getClipBounds(); for (int i = 0; i < numColumns; ++i) { if (columnComponents[i] == nullptr) { - const Rectangle columnRect (headerComp.getColumnPosition(i).withHeight (getHeight())); + auto columnRect = headerComp.getColumnPosition(i).withHeight (getHeight()); if (columnRect.getX() >= clipBounds.getRight()) break; @@ -67,7 +65,7 @@ public: } } - void update (const int newRow, const bool isNowSelected) + void update (int newRow, bool isNowSelected) { jassert (newRow >= 0); @@ -78,19 +76,19 @@ public: repaint(); } - TableListBoxModel* const tableModel = owner.getModel(); + auto* tableModel = owner.getModel(); if (tableModel != nullptr && row < owner.getNumRows()) { const Identifier columnProperty ("_tableColumnId"); - const int numColumns = owner.getHeader().getNumColumns (true); + auto numColumns = owner.getHeader().getNumColumns (true); for (int i = 0; i < numColumns; ++i) { - const int columnId = owner.getHeader().getColumnIdOfIndex (i, true); - Component* comp = columnComponents[i]; + auto columnId = owner.getHeader().getColumnIdOfIndex (i, true); + auto* comp = columnComponents[i]; - if (comp != nullptr && columnId != (int) comp->getProperties() [columnProperty]) + if (comp != nullptr && columnId != static_cast (comp->getProperties() [columnProperty])) { columnComponents.set (i, nullptr); comp = nullptr; @@ -122,9 +120,9 @@ public: resizeCustomComp (i); } - void resizeCustomComp (const int index) + void resizeCustomComp (int index) { - if (Component* const c = columnComponents.getUnchecked (index)) + if (auto* c = columnComponents.getUnchecked (index)) c->setBounds (owner.getHeader().getColumnPosition (index) .withY (0).withHeight (getHeight())); } @@ -140,10 +138,10 @@ public: { owner.selectRowsBasedOnModifierKeys (row, e.mods, false); - const int columnId = owner.getHeader().getColumnIdAtX (e.x); + auto columnId = owner.getHeader().getColumnIdAtX (e.x); if (columnId != 0) - if (TableListBoxModel* m = owner.getModel()) + if (auto* m = owner.getModel()) m->cellClicked (row, columnId, e); } else @@ -169,7 +167,7 @@ public: if (rowsToDrag.size() > 0) { - const var dragDescription (owner.getModel()->getDragSourceDescription (rowsToDrag)); + auto dragDescription = owner.getModel()->getDragSourceDescription (rowsToDrag); if (! (dragDescription.isVoid() || (dragDescription.isString() && dragDescription.toString().isEmpty()))) { @@ -186,7 +184,7 @@ public: { owner.selectRowsBasedOnModifierKeys (row, e.mods, true); - const int columnId = owner.getHeader().getColumnIdAtX (e.x); + auto columnId = owner.getHeader().getColumnIdAtX (e.x); if (columnId != 0) if (TableListBoxModel* m = owner.getModel()) @@ -196,16 +194,16 @@ public: void mouseDoubleClick (const MouseEvent& e) override { - const int columnId = owner.getHeader().getColumnIdAtX (e.x); + auto columnId = owner.getHeader().getColumnIdAtX (e.x); if (columnId != 0) - if (TableListBoxModel* m = owner.getModel()) + if (auto* m = owner.getModel()) m->cellDoubleClicked (row, columnId, e); } String getTooltip() override { - const int columnId = owner.getHeader().getColumnIdAtX (getMouseXYRelative().getX()); + auto columnId = owner.getHeader().getColumnIdAtX (getMouseXYRelative().getX()); if (columnId != 0) if (auto* m = owner.getModel()) @@ -214,7 +212,7 @@ public: return {}; } - Component* findChildComponentForColumn (const int columnId) const + Component* findChildComponentForColumn (int columnId) const { return columnComponents [owner.getHeader().getIndexOfColumnId (columnId, true)]; } @@ -222,8 +220,8 @@ public: private: TableListBox& owner; OwnedArray columnComponents; - int row; - bool isSelected, isDragging, selectRowOnMouseUp; + int row = -1; + bool isSelected = false, isDragging = false, selectRowOnMouseUp = false; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (RowComp) }; @@ -267,10 +265,7 @@ private: //============================================================================== TableListBox::TableListBox (const String& name, TableListBoxModel* const m) - : ListBox (name, nullptr), - header (nullptr), - model (m), - autoSizeOptionsShown (true) + : ListBox (name, nullptr), model (m) { ListBox::model = this; @@ -281,7 +276,7 @@ TableListBox::~TableListBox() { } -void TableListBox::setModel (TableListBoxModel* const newModel) +void TableListBox::setModel (TableListBoxModel* newModel) { if (model != newModel) { @@ -295,6 +290,7 @@ void TableListBox::setHeader (TableHeaderComponent* newHeader) jassert (newHeader != nullptr); // you need to supply a real header for a table! Rectangle newBounds (100, 28); + if (header != nullptr) newBounds = header->getBounds(); @@ -311,15 +307,15 @@ int TableListBox::getHeaderHeight() const noexcept return header->getHeight(); } -void TableListBox::setHeaderHeight (const int newHeight) +void TableListBox::setHeaderHeight (int newHeight) { header->setSize (header->getWidth(), newHeight); resized(); } -void TableListBox::autoSizeColumn (const int columnId) +void TableListBox::autoSizeColumn (int columnId) { - const int width = model != nullptr ? model->getColumnAutoSizeWidth (columnId) : 0; + auto width = model != nullptr ? model->getColumnAutoSizeWidth (columnId) : 0; if (width > 0) header->setColumnWidth (columnId, width); @@ -331,15 +327,14 @@ void TableListBox::autoSizeAllColumns() autoSizeColumn (header->getColumnIdOfIndex (i, true)); } -void TableListBox::setAutoSizeMenuOptionShown (const bool shouldBeShown) noexcept +void TableListBox::setAutoSizeMenuOptionShown (bool shouldBeShown) noexcept { autoSizeOptionsShown = shouldBeShown; } -Rectangle TableListBox::getCellPosition (const int columnId, const int rowNumber, - const bool relativeToComponentTopLeft) const +Rectangle TableListBox::getCellPosition (int columnId, int rowNumber, bool relativeToComponentTopLeft) const { - Rectangle headerCell (header->getColumnPosition (header->getIndexOfColumnId (columnId, true))); + auto headerCell = header->getColumnPosition (header->getIndexOfColumnId (columnId, true)); if (relativeToComponentTopLeft) headerCell.translate (header->getX(), 0); @@ -351,20 +346,20 @@ Rectangle TableListBox::getCellPosition (const int columnId, const int rowN Component* TableListBox::getCellComponent (int columnId, int rowNumber) const { - if (RowComp* const rowComp = dynamic_cast (getComponentForRowNumber (rowNumber))) + if (auto* rowComp = dynamic_cast (getComponentForRowNumber (rowNumber))) return rowComp->findChildComponentForColumn (columnId); return nullptr; } -void TableListBox::scrollToEnsureColumnIsOnscreen (const int columnId) +void TableListBox::scrollToEnsureColumnIsOnscreen (int columnId) { - if (ScrollBar* const scrollbar = getHorizontalScrollBar()) + if (auto* scrollbar = getHorizontalScrollBar()) { - const Rectangle pos (header->getColumnPosition (header->getIndexOfColumnId (columnId, true))); + auto pos = header->getColumnPosition (header->getIndexOfColumnId (columnId, true)); - double x = scrollbar->getCurrentRangeStart(); - const double w = scrollbar->getCurrentRangeSize(); + auto x = scrollbar->getCurrentRangeStart(); + auto w = scrollbar->getCurrentRangeSize(); if (pos.getX() < x) x = pos.getX(); @@ -461,10 +456,10 @@ void TableListBox::resized() void TableListBox::updateColumnComponents() const { - const int firstRow = getRowContainingPosition (0, 0); + auto firstRow = getRowContainingPosition (0, 0); for (int i = firstRow + getNumRowsOnScreen() + 2; --i >= firstRow;) - if (RowComp* const rowComp = dynamic_cast (getComponentForRowNumber (i))) + if (auto* rowComp = dynamic_cast (getComponentForRowNumber (i))) rowComp->resized(); } @@ -472,7 +467,7 @@ void TableListBox::updateColumnComponents() const void TableListBoxModel::cellClicked (int, int, const MouseEvent&) {} void TableListBoxModel::cellDoubleClicked (int, int, const MouseEvent&) {} void TableListBoxModel::backgroundClicked (const MouseEvent&) {} -void TableListBoxModel::sortOrderChanged (int, const bool) {} +void TableListBoxModel::sortOrderChanged (int, bool) {} int TableListBoxModel::getColumnAutoSizeWidth (int) { return 0; } void TableListBoxModel::selectedRowsChanged (int) {} void TableListBoxModel::deleteKeyPressed (int) {} diff --git a/modules/juce_gui_basics/widgets/juce_TableListBox.h b/modules/juce_gui_basics/widgets/juce_TableListBox.h index 8454e959c6..7b36e0707b 100644 --- a/modules/juce_gui_basics/widgets/juce_TableListBox.h +++ b/modules/juce_gui_basics/widgets/juce_TableListBox.h @@ -336,10 +336,10 @@ private: class Header; class RowComp; - TableHeaderComponent* header; + TableHeaderComponent* header = nullptr; TableListBoxModel* model; - int columnIdNowBeingDragged; - bool autoSizeOptionsShown; + int columnIdNowBeingDragged = 0; + bool autoSizeOptionsShown = true; void updateColumnComponents() const; From 9ac2fae46919fe6ba121d5dac89e8e6060eed111 Mon Sep 17 00:00:00 2001 From: jules Date: Tue, 5 Sep 2017 14:13:11 +0100 Subject: [PATCH 043/129] Made TooltipWindow::getTipFor() a public virtual method --- .../windows/juce_TooltipWindow.cpp | 47 +++++++++---------- .../windows/juce_TooltipWindow.h | 15 +++--- 2 files changed, 30 insertions(+), 32 deletions(-) diff --git a/modules/juce_gui_basics/windows/juce_TooltipWindow.cpp b/modules/juce_gui_basics/windows/juce_TooltipWindow.cpp index abf71124af..565ad0acca 100644 --- a/modules/juce_gui_basics/windows/juce_TooltipWindow.cpp +++ b/modules/juce_gui_basics/windows/juce_TooltipWindow.cpp @@ -24,22 +24,18 @@ ============================================================================== */ -TooltipWindow::TooltipWindow (Component* const parentComp, const int delayMs) +TooltipWindow::TooltipWindow (Component* parentComp, int delayMs) : Component ("tooltip"), - lastComponentUnderMouse (nullptr), - millisecondsBeforeTipAppears (delayMs), - mouseClicks (0), mouseWheelMoves (0), - lastCompChangeTime (0), lastHideTime (0), - reentrant (false) + millisecondsBeforeTipAppears (delayMs) { - if (Desktop::getInstance().getMainMouseSource().canHover()) - startTimer (123); - setAlwaysOnTop (true); setOpaque (true); if (parentComp != nullptr) parentComp->addChildComponent (this); + + if (Desktop::getInstance().getMainMouseSource().canHover()) + startTimer (123); } TooltipWindow::~TooltipWindow() @@ -102,14 +98,13 @@ void TooltipWindow::displayTip (Point screenPos, const String& tip) } } -String TooltipWindow::getTipFor (Component* const c) +String TooltipWindow::getTipFor (Component& c) { - if (c != nullptr - && Process::isForegroundProcess() + if (Process::isForegroundProcess() && ! ModifierKeys::getCurrentModifiers().isAnyMouseButtonDown()) { - if (TooltipClient* const ttc = dynamic_cast (c)) - if (! c->isCurrentlyBlockedByAnotherModalComponent()) + if (auto* ttc = dynamic_cast (&c)) + if (! c.isCurrentlyBlockedByAnotherModalComponent()) return ttc->getTooltip(); } @@ -128,24 +123,24 @@ void TooltipWindow::hideTip() void TooltipWindow::timerCallback() { - Desktop& desktop = Desktop::getInstance(); - const MouseInputSource mouseSource (desktop.getMainMouseSource()); - const unsigned int now = Time::getApproximateMillisecondCounter(); + auto& desktop = Desktop::getInstance(); + auto mouseSource = desktop.getMainMouseSource(); + auto now = Time::getApproximateMillisecondCounter(); - Component* const newComp = ! mouseSource.isTouch() ? mouseSource.getComponentUnderMouse() : nullptr; - const String newTip (getTipFor (newComp)); - const bool tipChanged = (newTip != lastTipUnderMouse || newComp != lastComponentUnderMouse); + auto* newComp = mouseSource.isTouch() ? nullptr : mouseSource.getComponentUnderMouse(); + auto newTip = newComp != nullptr ? getTipFor (*newComp) : String(); + bool tipChanged = (newTip != lastTipUnderMouse || newComp != lastComponentUnderMouse); lastComponentUnderMouse = newComp; lastTipUnderMouse = newTip; - const int clickCount = desktop.getMouseButtonClickCounter(); - const int wheelCount = desktop.getMouseWheelMoveCounter(); - const bool mouseWasClicked = (clickCount > mouseClicks || wheelCount > mouseWheelMoves); + auto clickCount = desktop.getMouseButtonClickCounter(); + auto wheelCount = desktop.getMouseWheelMoveCounter(); + bool mouseWasClicked = (clickCount > mouseClicks || wheelCount > mouseWheelMoves); mouseClicks = clickCount; mouseWheelMoves = wheelCount; - const Point mousePos (mouseSource.getScreenPosition()); - const bool mouseMovedQuickly = mousePos.getDistanceFrom (lastMousePos) > 12; + auto mousePos = mouseSource.getScreenPosition(); + bool mouseMovedQuickly = mousePos.getDistanceFrom (lastMousePos) > 12; lastMousePos = mousePos; if (tipChanged || mouseWasClicked || mouseMovedQuickly) @@ -174,7 +169,7 @@ void TooltipWindow::timerCallback() // appear after a timeout.. if (newTip.isNotEmpty() && newTip != tipShowing - && now > lastCompChangeTime + (unsigned int) millisecondsBeforeTipAppears) + && now > lastCompChangeTime + (uint32) millisecondsBeforeTipAppears) { displayTip (mousePos.roundToInt(), newTip); } diff --git a/modules/juce_gui_basics/windows/juce_TooltipWindow.h b/modules/juce_gui_basics/windows/juce_TooltipWindow.h index 42d60a33f0..b4a6656b5f 100644 --- a/modules/juce_gui_basics/windows/juce_TooltipWindow.h +++ b/modules/juce_gui_basics/windows/juce_TooltipWindow.h @@ -85,6 +85,11 @@ public: /** Can be called to manually hide the tip if it's showing. */ void hideTip(); + /** Asks a component for its tooltip. + This can be overridden if you need custom lookup behaviour or to modify the strings. + */ + virtual String getTipFor (Component&); + //============================================================================== /** A set of colour IDs to use to change the colour of various aspects of the tooltip. @@ -121,19 +126,17 @@ public: private: //============================================================================== Point lastMousePos; - Component* lastComponentUnderMouse; + Component* lastComponentUnderMouse = nullptr; String tipShowing, lastTipUnderMouse; int millisecondsBeforeTipAppears; - int mouseClicks, mouseWheelMoves; - unsigned int lastCompChangeTime, lastHideTime; - bool reentrant; + int mouseClicks = 0, mouseWheelMoves = 0; + unsigned int lastCompChangeTime = 0, lastHideTime = 0; + bool reentrant = false; void paint (Graphics&) override; void mouseEnter (const MouseEvent&) override; void timerCallback() override; void updatePosition (const String&, Point, Rectangle); - static String getTipFor (Component*); - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TooltipWindow) }; From 80f76bfe0a042a10d796cc540f253ff3b3910503 Mon Sep 17 00:00:00 2001 From: jules Date: Tue, 5 Sep 2017 14:20:19 +0100 Subject: [PATCH 044/129] Added a std::hash function for juce::String to make it more compatible with std containers --- modules/juce_core/text/juce_String.h | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/modules/juce_core/text/juce_String.h b/modules/juce_core/text/juce_String.h index 446b69996a..9fb0784bcd 100644 --- a/modules/juce_core/text/juce_String.h +++ b/modules/juce_core/text/juce_String.h @@ -1358,11 +1358,11 @@ JUCE_API bool JUCE_CALLTYPE operator== (const String& string1, const char* strin /** Case-sensitive comparison of two strings. */ JUCE_API bool JUCE_CALLTYPE operator== (const String& string1, const wchar_t* string2) noexcept; /** Case-sensitive comparison of two strings. */ -JUCE_API bool JUCE_CALLTYPE operator== (const String& string1, const CharPointer_UTF8 string2) noexcept; +JUCE_API bool JUCE_CALLTYPE operator== (const String& string1, CharPointer_UTF8 string2) noexcept; /** Case-sensitive comparison of two strings. */ -JUCE_API bool JUCE_CALLTYPE operator== (const String& string1, const CharPointer_UTF16 string2) noexcept; +JUCE_API bool JUCE_CALLTYPE operator== (const String& string1, CharPointer_UTF16 string2) noexcept; /** Case-sensitive comparison of two strings. */ -JUCE_API bool JUCE_CALLTYPE operator== (const String& string1, const CharPointer_UTF32 string2) noexcept; +JUCE_API bool JUCE_CALLTYPE operator== (const String& string1, CharPointer_UTF32 string2) noexcept; /** Case-sensitive comparison of two strings. */ JUCE_API bool JUCE_CALLTYPE operator!= (const String& string1, const String& string2) noexcept; @@ -1371,11 +1371,11 @@ JUCE_API bool JUCE_CALLTYPE operator!= (const String& string1, const char* strin /** Case-sensitive comparison of two strings. */ JUCE_API bool JUCE_CALLTYPE operator!= (const String& string1, const wchar_t* string2) noexcept; /** Case-sensitive comparison of two strings. */ -JUCE_API bool JUCE_CALLTYPE operator!= (const String& string1, const CharPointer_UTF8 string2) noexcept; +JUCE_API bool JUCE_CALLTYPE operator!= (const String& string1, CharPointer_UTF8 string2) noexcept; /** Case-sensitive comparison of two strings. */ -JUCE_API bool JUCE_CALLTYPE operator!= (const String& string1, const CharPointer_UTF16 string2) noexcept; +JUCE_API bool JUCE_CALLTYPE operator!= (const String& string1, CharPointer_UTF16 string2) noexcept; /** Case-sensitive comparison of two strings. */ -JUCE_API bool JUCE_CALLTYPE operator!= (const String& string1, const CharPointer_UTF32 string2) noexcept; +JUCE_API bool JUCE_CALLTYPE operator!= (const String& string1, CharPointer_UTF32 string2) noexcept; /** Case-sensitive comparison of two strings. */ JUCE_API bool JUCE_CALLTYPE operator> (const String& string1, const String& string2) noexcept; @@ -1410,3 +1410,17 @@ JUCE_API OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const Str /** Writes a string to an OutputStream as UTF8. */ JUCE_API OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, StringRef stringToWrite); + + +} // namespace juce + +namespace std +{ + template <> struct hash + { + size_t operator() (const juce::String& s) const noexcept { return s.hash(); } + }; +} + +namespace juce { + From 95e02b1b2692058321e02a56f41c426441e575b6 Mon Sep 17 00:00:00 2001 From: jules Date: Tue, 5 Sep 2017 14:56:22 +0100 Subject: [PATCH 045/129] A bit of minor tidying up in TableHeaderComponent --- .../widgets/juce_TableHeaderComponent.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp b/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp index 3e8a635bcb..296888af0e 100644 --- a/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp +++ b/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp @@ -727,9 +727,9 @@ void TableHeaderComponent::mouseUp (const MouseEvent& e) { mouseDrag (e); - for (int i = columns.size(); --i >= 0;) - if (columns.getUnchecked (i)->isVisible()) - columns.getUnchecked (i)->lastDeliberateWidth = columns.getUnchecked (i)->width; + for (auto* c : columns) + if (c->isVisible()) + c->lastDeliberateWidth = c->width; columnIdBeingResized = 0; repaint(); @@ -758,11 +758,11 @@ bool TableHeaderComponent::ColumnInfo::isVisible() const return (propertyFlags & TableHeaderComponent::visible) != 0; } -TableHeaderComponent::ColumnInfo* TableHeaderComponent::getInfoForId (const int id) const +TableHeaderComponent::ColumnInfo* TableHeaderComponent::getInfoForId (int id) const { - for (int i = columns.size(); --i >= 0;) - if (columns.getUnchecked(i)->id == id) - return columns.getUnchecked(i); + for (auto* c : columns) + if (c->id == id) + return c; return nullptr; } From 32fe9e81ce28af19ac923deb0723d1956ac9aa2a Mon Sep 17 00:00:00 2001 From: jules Date: Tue, 5 Sep 2017 15:05:56 +0100 Subject: [PATCH 046/129] Removed the need for the window to be focused for the slider's hover popup to work --- modules/juce_gui_basics/widgets/juce_Slider.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/juce_gui_basics/widgets/juce_Slider.cpp b/modules/juce_gui_basics/widgets/juce_Slider.cpp index 5981b4a0b1..3ed9282792 100644 --- a/modules/juce_gui_basics/widgets/juce_Slider.cpp +++ b/modules/juce_gui_basics/widgets/juce_Slider.cpp @@ -953,7 +953,7 @@ public: && style != TwoValueHorizontal && style != TwoValueVertical) { - if (owner.isMouseOver (true) && owner.getTopLevelComponent()->hasKeyboardFocus (true)) + if (owner.isMouseOver (true)) { if (popupDisplay == nullptr) showPopupDisplay(); From 637367959c1bfcd9a03e092a135f88ae91e0131f Mon Sep 17 00:00:00 2001 From: jules Date: Tue, 5 Sep 2017 15:06:25 +0100 Subject: [PATCH 047/129] Whitespace --- .../juce_audio_formats/codecs/flac/compat.h | 334 +++++++++--------- modules/juce_core/text/juce_String.h | 1 - 2 files changed, 167 insertions(+), 168 deletions(-) diff --git a/modules/juce_audio_formats/codecs/flac/compat.h b/modules/juce_audio_formats/codecs/flac/compat.h index 6c26491411..f97b1939e6 100644 --- a/modules/juce_audio_formats/codecs/flac/compat.h +++ b/modules/juce_audio_formats/codecs/flac/compat.h @@ -1,167 +1,167 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2012-2014 Xiph.org Foundation - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * - Neither the name of the Xiph.org Foundation nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* This is the prefered location of all CPP hackery to make $random_compiler - * work like something approaching a C99 (or maybe more accurately GNU99) - * compiler. - * - * It is assumed that this header will be included after "config.h". - */ - -#ifndef FLAC__SHARE__COMPAT_H -#define FLAC__SHARE__COMPAT_H - -#if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__ -#define FLAC__off_t __int64 /* use this instead of off_t to fix the 2 GB limit */ -#if !defined __MINGW32__ -#define fseeko _fseeki64 -#define ftello _ftelli64 -#else /* MinGW */ -#if !defined(HAVE_FSEEKO) -#define fseeko fseeko64 -#define ftello ftello64 -#endif -#endif -#else -#define FLAC__off_t off_t -#endif - -#if defined(_MSC_VER) -#define strtoll _strtoi64 -#define strtoull _strtoui64 -#endif - -#if defined(_MSC_VER) -#define inline __inline -#endif - -#if defined __INTEL_COMPILER || (defined _MSC_VER && defined _WIN64) -/* MSVS generates VERY slow 32-bit code with __restrict */ -#define flac_restrict __restrict -#elif defined __GNUC__ -#define flac_restrict __restrict__ -#else -#define flac_restrict -#endif - -#define FLAC__U64L(x) x##ULL - -#if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__ -#define FLAC__STRCASECMP stricmp -#define FLAC__STRNCASECMP strnicmp -#else -#define FLAC__STRCASECMP strcasecmp -#define FLAC__STRNCASECMP strncasecmp -#endif - -#if defined _MSC_VER -# if _MSC_VER >= 1600 -/* Visual Studio 2010 has decent C99 support */ -# define PRIu64 "llu" -# define PRId64 "lld" -# define PRIx64 "llx" -# else -# ifndef UINT32_MAX -# define UINT32_MAX _UI32_MAX -# endif - typedef unsigned __int64 uint64_t; - typedef unsigned __int32 uint32_t; - typedef unsigned __int16 uint16_t; - typedef unsigned __int8 uint8_t; - typedef __int64 int64_t; - typedef __int32 int32_t; - typedef __int16 int16_t; - typedef __int8 int8_t; -# define PRIu64 "I64u" -# define PRId64 "I64d" -# define PRIx64 "I64x" -# endif -#endif /* defined _MSC_VER */ - -#ifdef _WIN32 -/* All char* strings are in UTF-8 format. Added to support Unicode files on Windows */ -#include "win_utf8_io.h" - -#define flac_printf printf_utf8 -#define flac_fprintf fprintf_utf8 -#define flac_vfprintf vfprintf_utf8 -#define flac_fopen fopen_utf8 -#define flac_chmod chmod_utf8 -#define flac_utime utime_utf8 -#define flac_unlink unlink_utf8 -#define flac_rename rename_utf8 -#define flac_stat _stat64_utf8 - -#else - -#define flac_printf printf -#define flac_fprintf fprintf -#define flac_vfprintf vfprintf -#define flac_fopen fopen -#define flac_chmod chmod -#define flac_utime utime -#define flac_unlink unlink -#define flac_rename rename -#define flac_stat stat - -#endif - -#ifdef _WIN32 -#define flac_stat_s __stat64 /* stat struct */ -#define flac_fstat _fstat64 -#else -#define flac_stat_s stat /* stat struct */ -#define flac_fstat fstat -#endif - -#ifndef M_LN2 -#define M_LN2 0.69314718055994530942 -#endif -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif - -/* FLAC needs to compile and work correctly on systems with a normal ISO C99 - * snprintf as well as Microsoft Visual Studio which has an non-standards - * conformant snprint_s function. - * - * This function wraps the MS version to behave more like the the ISO version. - */ -#ifdef __cplusplus -extern "C" { -#endif -int flac_snprintf(char *str, size_t size, const char *fmt, ...); -int flac_vsnprintf(char *str, size_t size, const char *fmt, va_list va); -#ifdef __cplusplus -} -#endif - -#endif /* FLAC__SHARE__COMPAT_H */ +/* libFLAC - Free Lossless Audio Codec library + * Copyright (C) 2012-2014 Xiph.org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* This is the prefered location of all CPP hackery to make $random_compiler + * work like something approaching a C99 (or maybe more accurately GNU99) + * compiler. + * + * It is assumed that this header will be included after "config.h". + */ + +#ifndef FLAC__SHARE__COMPAT_H +#define FLAC__SHARE__COMPAT_H + +#if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__ +#define FLAC__off_t __int64 /* use this instead of off_t to fix the 2 GB limit */ +#if !defined __MINGW32__ +#define fseeko _fseeki64 +#define ftello _ftelli64 +#else /* MinGW */ +#if !defined(HAVE_FSEEKO) +#define fseeko fseeko64 +#define ftello ftello64 +#endif +#endif +#else +#define FLAC__off_t off_t +#endif + +#if defined(_MSC_VER) +#define strtoll _strtoi64 +#define strtoull _strtoui64 +#endif + +#if defined(_MSC_VER) +#define inline __inline +#endif + +#if defined __INTEL_COMPILER || (defined _MSC_VER && defined _WIN64) +/* MSVS generates VERY slow 32-bit code with __restrict */ +#define flac_restrict __restrict +#elif defined __GNUC__ +#define flac_restrict __restrict__ +#else +#define flac_restrict +#endif + +#define FLAC__U64L(x) x##ULL + +#if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__ +#define FLAC__STRCASECMP stricmp +#define FLAC__STRNCASECMP strnicmp +#else +#define FLAC__STRCASECMP strcasecmp +#define FLAC__STRNCASECMP strncasecmp +#endif + +#if defined _MSC_VER +# if _MSC_VER >= 1600 +/* Visual Studio 2010 has decent C99 support */ +# define PRIu64 "llu" +# define PRId64 "lld" +# define PRIx64 "llx" +# else +# ifndef UINT32_MAX +# define UINT32_MAX _UI32_MAX +# endif + typedef unsigned __int64 uint64_t; + typedef unsigned __int32 uint32_t; + typedef unsigned __int16 uint16_t; + typedef unsigned __int8 uint8_t; + typedef __int64 int64_t; + typedef __int32 int32_t; + typedef __int16 int16_t; + typedef __int8 int8_t; +# define PRIu64 "I64u" +# define PRId64 "I64d" +# define PRIx64 "I64x" +# endif +#endif /* defined _MSC_VER */ + +#ifdef _WIN32 +/* All char* strings are in UTF-8 format. Added to support Unicode files on Windows */ +#include "win_utf8_io.h" + +#define flac_printf printf_utf8 +#define flac_fprintf fprintf_utf8 +#define flac_vfprintf vfprintf_utf8 +#define flac_fopen fopen_utf8 +#define flac_chmod chmod_utf8 +#define flac_utime utime_utf8 +#define flac_unlink unlink_utf8 +#define flac_rename rename_utf8 +#define flac_stat _stat64_utf8 + +#else + +#define flac_printf printf +#define flac_fprintf fprintf +#define flac_vfprintf vfprintf +#define flac_fopen fopen +#define flac_chmod chmod +#define flac_utime utime +#define flac_unlink unlink +#define flac_rename rename +#define flac_stat stat + +#endif + +#ifdef _WIN32 +#define flac_stat_s __stat64 /* stat struct */ +#define flac_fstat _fstat64 +#else +#define flac_stat_s stat /* stat struct */ +#define flac_fstat fstat +#endif + +#ifndef M_LN2 +#define M_LN2 0.69314718055994530942 +#endif +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +/* FLAC needs to compile and work correctly on systems with a normal ISO C99 + * snprintf as well as Microsoft Visual Studio which has an non-standards + * conformant snprint_s function. + * + * This function wraps the MS version to behave more like the the ISO version. + */ +#ifdef __cplusplus +extern "C" { +#endif +int flac_snprintf(char *str, size_t size, const char *fmt, ...); +int flac_vsnprintf(char *str, size_t size, const char *fmt, va_list va); +#ifdef __cplusplus +} +#endif + +#endif /* FLAC__SHARE__COMPAT_H */ diff --git a/modules/juce_core/text/juce_String.h b/modules/juce_core/text/juce_String.h index 9fb0784bcd..aba06e723f 100644 --- a/modules/juce_core/text/juce_String.h +++ b/modules/juce_core/text/juce_String.h @@ -1423,4 +1423,3 @@ namespace std } namespace juce { - From 7c6f3d40b6e9fec3d822aa2d4011e13e62662642 Mon Sep 17 00:00:00 2001 From: jules Date: Tue, 5 Sep 2017 16:06:57 +0100 Subject: [PATCH 048/129] Tidied up some method calls involving HeapBlock --- examples/AUv3Synth/Source/AUv3SynthProcessor.cpp | 15 ++++++--------- .../buffers/juce_AudioSampleBuffer.h | 8 ++++---- .../buffers/juce_FloatVectorOperations.cpp | 6 +++--- .../native/juce_android_Midi.cpp | 4 ++-- .../native/juce_android_OpenSL.cpp | 8 ++++---- .../native/juce_mac_CoreAudio.cpp | 4 ++-- .../codecs/juce_CoreAudioFormat.cpp | 4 ++-- .../codecs/juce_FlacAudioFormat.cpp | 4 ++-- .../format/juce_AudioFormatReader.cpp | 4 ++-- .../format_types/juce_AU_Shared.h | 6 +++--- .../format_types/juce_AudioUnitPluginFormat.mm | 16 ++++++++-------- .../format_types/juce_VSTCommon.h | 4 ++-- .../format_types/juce_VSTPluginFormat.cpp | 10 +++++----- modules/juce_core/containers/juce_Array.h | 12 ++++++------ modules/juce_core/containers/juce_OwnedArray.h | 12 ++++++------ .../containers/juce_ReferenceCountedArray.h | 12 ++++++------ modules/juce_core/native/juce_mac_Files.mm | 2 +- modules/juce_core/native/juce_mac_Strings.mm | 6 +++--- modules/juce_core/native/juce_mac_SystemStats.mm | 2 +- modules/juce_core/network/juce_URL.cpp | 4 ++-- modules/juce_core/text/juce_String.cpp | 4 ++-- .../juce_graphics/geometry/juce_PathIterator.cpp | 2 +- .../juce_graphics/native/juce_RenderingHelpers.h | 4 ++-- modules/juce_opengl/opengl/juce_OpenGLImage.cpp | 2 +- 24 files changed, 76 insertions(+), 79 deletions(-) diff --git a/examples/AUv3Synth/Source/AUv3SynthProcessor.cpp b/examples/AUv3Synth/Source/AUv3SynthProcessor.cpp index 348bf98d8c..72a9ba6ac2 100644 --- a/examples/AUv3Synth/Source/AUv3SynthProcessor.cpp +++ b/examples/AUv3Synth/Source/AUv3SynthProcessor.cpp @@ -96,19 +96,16 @@ public: const String getName() const override { return "AUv3 Synth"; } int getNumPrograms() override { return 4; } int getCurrentProgram() override { return currentProgram; } - void setCurrentProgram (int index) override { currentProgram = index; } + void setCurrentProgram (int index) override { currentProgram = index; } + const String getProgramName (int index) override { switch (index) { - case 0: - return "Piano"; - case 1: - return "Singing"; - case 2: - return "Pinched Balloon"; - case 3: - return "Gazeebo"; + case 0: return "Piano"; + case 1: return "Singing"; + case 2: return "Pinched Balloon"; + case 3: return "Gazeebo"; } return ""; diff --git a/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h b/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h index dc78d7b2ec..ed945e0896 100644 --- a/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h +++ b/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h @@ -332,7 +332,7 @@ public: auto numSamplesToCopy = (size_t) jmin (newNumSamples, size); - auto newChannels = reinterpret_cast (newData.getData()); + auto newChannels = reinterpret_cast (newData.get()); auto newChan = reinterpret_cast (newData + channelListSize); for (int j = 0; j < newNumChannels; ++j) @@ -364,7 +364,7 @@ public: { allocatedBytes = newTotalBytes; allocatedData.allocate (newTotalBytes, clearExtraSpace || isClear); - channels = reinterpret_cast (allocatedData.getData()); + channels = reinterpret_cast (allocatedData.get()); } auto* chan = reinterpret_cast (allocatedData + channelListSize); @@ -1051,7 +1051,7 @@ private: auto channelListSize = sizeof (Type*) * (size_t) (numChannels + 1); allocatedBytes = (size_t) numChannels * (size_t) size * sizeof (Type) + channelListSize + 32; allocatedData.malloc (allocatedBytes); - channels = reinterpret_cast (allocatedData.getData()); + channels = reinterpret_cast (allocatedData.get()); auto* chan = (Type*) (allocatedData + channelListSize); for (int i = 0; i < numChannels; ++i) @@ -1076,7 +1076,7 @@ private: else { allocatedData.malloc ((size_t) numChannels + 1, sizeof (Type*)); - channels = reinterpret_cast (allocatedData.getData()); + channels = reinterpret_cast (allocatedData.get()); } for (int i = 0; i < numChannels; ++i) diff --git a/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp b/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp index 5ec378ab49..7813c81abc 100644 --- a/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp +++ b/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp @@ -1068,9 +1068,9 @@ public: #else // These tests deliberately operate on misaligned memory and will be flagged up by // checks for undefined behavior! - ValueType* const data1 = addBytesToPointer (buffer1.getData(), random.nextInt (16)); - ValueType* const data2 = addBytesToPointer (buffer2.getData(), random.nextInt (16)); - int* const int1 = addBytesToPointer (buffer3.getData(), random.nextInt (16)); + ValueType* const data1 = addBytesToPointer (buffer1.get(), random.nextInt (16)); + ValueType* const data2 = addBytesToPointer (buffer2.get(), random.nextInt (16)); + int* const int1 = addBytesToPointer (buffer3.get(), random.nextInt (16)); #endif fillRandomly (random, data1, num); diff --git a/modules/juce_audio_devices/native/juce_android_Midi.cpp b/modules/juce_audio_devices/native/juce_android_Midi.cpp index c968982cb3..3bcd3ea053 100644 --- a/modules/juce_audio_devices/native/juce_android_Midi.cpp +++ b/modules/juce_audio_devices/native/juce_android_Midi.cpp @@ -89,9 +89,9 @@ public: jbyte* data = getEnv()->GetByteArrayElements (byteArray, nullptr); HeapBlock buffer (static_cast (len)); - std::memcpy (buffer.getData(), data + offset, static_cast (len)); + std::memcpy (buffer.get(), data + offset, static_cast (len)); - midiConcatenator.pushMidiData (buffer.getData(), + midiConcatenator.pushMidiData (buffer.get(), len, static_cast (timestamp) * 1.0e-9, juceMidiInput, *callback); diff --git a/modules/juce_audio_devices/native/juce_android_OpenSL.cpp b/modules/juce_audio_devices/native/juce_android_OpenSL.cpp index d1dd6be331..400d0f54f8 100644 --- a/modules/juce_audio_devices/native/juce_android_OpenSL.cpp +++ b/modules/juce_audio_devices/native/juce_android_OpenSL.cpp @@ -308,7 +308,7 @@ public: nextBlock.set (0); numBlocksOut.set (0); - zeromem (nativeBuffer.getData(), static_cast (owner.bufferSize * numChannels * owner.numBuffers) * sizeof (T)); + zeromem (nativeBuffer.get(), static_cast (owner.bufferSize * numChannels * owner.numBuffers) * sizeof (T)); scratchBuffer.clear(); (*queue)->Clear (queue); } @@ -321,7 +321,7 @@ public: bool isBufferAvailable() const { return (numBlocksOut.get() < owner.numBuffers); } T* getNextBuffer() { nextBlock.set((nextBlock.get() + 1) % owner.numBuffers); return getCurrentBuffer(); } - T* getCurrentBuffer() { return nativeBuffer.getData() + (static_cast (nextBlock.get()) * getBufferSizeInSamples()); } + T* getCurrentBuffer() { return nativeBuffer.get() + (static_cast (nextBlock.get()) * getBufferSizeInSamples()); } size_t getBufferSizeInSamples() const { return static_cast (owner.bufferSize * numChannels); } void finished (SLAndroidSimpleBufferQueueItf) @@ -1203,11 +1203,11 @@ public: pthread_t startThread (void* (*entry) (void*), void* userPtr) { - memset (buffer.getData(), 0, static_cast (sizeof (int16) * static_cast (bufferSize * numBuffers))); + memset (buffer.get(), 0, static_cast (sizeof (int16) * static_cast (bufferSize * numBuffers))); for (int i = 0; i < numBuffers; ++i) { - int16* dst = buffer.getData() + (bufferSize * i); + int16* dst = buffer.get() + (bufferSize * i); (*queue)->Enqueue (queue, dst, static_cast (static_cast (bufferSize) * sizeof (int16))); } diff --git a/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp b/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp index 80758de9f3..0cb091a7e6 100644 --- a/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp +++ b/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp @@ -228,7 +228,7 @@ public: for (int i = 0; i < numStreams; ++i) { - const ::AudioBuffer& b = bufList->mBuffers[i]; + auto& b = bufList->mBuffers[i]; for (unsigned int j = 0; j < b.mNumberChannels; ++j) { @@ -733,7 +733,7 @@ public: } } - callback->audioDeviceIOCallback (const_cast (tempInputBuffers.getData()), + callback->audioDeviceIOCallback (const_cast (tempInputBuffers.get()), numInputChans, tempOutputBuffers, numOutputChans, diff --git a/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.cpp index 4d28dee8bb..1b310579e4 100644 --- a/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.cpp @@ -389,11 +389,11 @@ public: caLayout.malloc (1, static_cast (sizeOfLayout)); status = AudioFileGetProperty (audioFileID, kAudioFilePropertyChannelLayout, - &sizeOfLayout, caLayout.getData()); + &sizeOfLayout, caLayout.get()); if (status == noErr) { - auto fileLayout = CoreAudioLayouts::fromCoreAudio (*caLayout.getData()); + auto fileLayout = CoreAudioLayouts::fromCoreAudio (*caLayout.get()); if (fileLayout.size() == static_cast (numChannels)) { diff --git a/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp index 0c6b267595..d8b97fc2f0 100644 --- a/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp @@ -449,14 +449,14 @@ public: if (samplesToWrite[i] == nullptr) break; - int* const destData = temp.getData() + i * (size_t) numSamples; + int* const destData = temp.get() + i * (size_t) numSamples; channels[i] = destData; for (int j = 0; j < numSamples; ++j) destData[j] = (samplesToWrite[i][j] >> bitsToShift); } - samplesToWrite = const_cast (channels.getData()); + samplesToWrite = const_cast (channels.get()); } return FLAC__stream_encoder_process (encoder, (const FLAC__int32**) samplesToWrite, (unsigned) numSamples) != 0; diff --git a/modules/juce_audio_formats/format/juce_AudioFormatReader.cpp b/modules/juce_audio_formats/format/juce_AudioFormatReader.cpp index ccd002a0f3..d0521d2df5 100644 --- a/modules/juce_audio_formats/format/juce_AudioFormatReader.cpp +++ b/modules/juce_audio_formats/format/juce_AudioFormatReader.cpp @@ -262,8 +262,8 @@ int64 AudioFormatReader::searchForLevel (int64 startSample, HeapBlock tempSpace (bufferSize * 2 + 64); int* tempBuffer[3]; - tempBuffer[0] = tempSpace.getData(); - tempBuffer[1] = tempSpace.getData() + bufferSize; + tempBuffer[0] = tempSpace.get(); + tempBuffer[1] = tempSpace.get() + bufferSize; tempBuffer[2] = 0; int consecutive = 0; diff --git a/modules/juce_audio_processors/format_types/juce_AU_Shared.h b/modules/juce_audio_processors/format_types/juce_AU_Shared.h index 71768e3b47..5b5e5fcf65 100644 --- a/modules/juce_audio_processors/format_types/juce_AU_Shared.h +++ b/modules/juce_audio_processors/format_types/juce_AU_Shared.h @@ -84,12 +84,12 @@ struct AudioUnitHelpers layoutMapPtrStorage.calloc (static_cast (numBuses)); layoutMapStorage.calloc (static_cast (isInput ? totalInChannels : totalOutChannels)); - layoutMap = layoutMapPtrStorage. getData(); + layoutMap = layoutMapPtrStorage. get(); int ch = 0; for (int busIdx = 0; busIdx < numBuses; ++busIdx) { - layoutMap[busIdx] = layoutMapStorage.getData() + ch; + layoutMap[busIdx] = layoutMapStorage.get() + ch; ch += processor.getChannelCountOfBus (isInput, busIdx); } } @@ -138,7 +138,7 @@ struct AudioUnitHelpers { pushIdx = 0; popIdx = 0; - zeromem (channels.getData(), sizeof(float*) * static_cast (scratch.getNumChannels())); + zeromem (channels.get(), sizeof(float*) * static_cast (scratch.getNumChannels())); } //============================================================================== diff --git a/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm b/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm index ed05018b44..fb3ae77b7f 100644 --- a/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm +++ b/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm @@ -581,7 +581,7 @@ public: dataSize = expectedSize; err = AudioUnitGetProperty (audioUnit, kAudioUnitProperty_AudioChannelLayout, scope, - static_cast (i), layoutBuffer.getData(), &dataSize); + static_cast (i), layoutBuffer.get(), &dataSize); if (err != noErr || dataSize < expectedSize) return false; @@ -834,7 +834,7 @@ public: AudioUnitRenderActionFlags flags = 0; if (AUBuffer* buf = outputBufferList[i]) - AudioUnitRender (audioUnit, &flags, &timeStamp, static_cast (i), (UInt32) numSamples, buf->bufferList.getData()); + AudioUnitRender (audioUnit, &flags, &timeStamp, static_cast (i), (UInt32) numSamples, buf->bufferList.get()); } timeStamp.mSampleTime += numSamples; @@ -1232,14 +1232,14 @@ private: AUBuffer (size_t numBuffers) { bufferList.calloc (1, (sizeof (AudioBufferList) - sizeof (::AudioBuffer)) + (sizeof (::AudioBuffer) * numBuffers)); - AudioBufferList& buffer = *bufferList.getData(); + AudioBufferList& buffer = *bufferList.get(); buffer.mNumberBuffers = static_cast (numBuffers); } operator AudioBufferList&() { - return *bufferList.getData(); + return *bufferList.get(); } HeapBlock bufferList; @@ -1721,7 +1721,7 @@ private: propertySize = static_cast (sizeof (AudioChannelLayoutTag) * numElements); if (AudioUnitGetProperty (audioUnit, kAudioUnitProperty_SupportedChannelLayoutTags, scope, - static_cast (busIdx), layoutTags.getData(), &propertySize) == noErr) + static_cast (busIdx), layoutTags.get(), &propertySize) == noErr) { for (int j = 0; j < static_cast (numElements); ++j) { @@ -1757,15 +1757,15 @@ private: channelInfos.malloc (static_cast (numChannelInfos)); propertySize = static_cast (sizeof (AUChannelInfo) * static_cast (numChannelInfos)); - if (AudioUnitGetProperty (audioUnit, kAudioUnitProperty_SupportedNumChannels, kAudioUnitScope_Global, 0, channelInfos.getData(), &propertySize) != noErr) + if (AudioUnitGetProperty (audioUnit, kAudioUnitProperty_SupportedNumChannels, kAudioUnitScope_Global, 0, channelInfos.get(), &propertySize) != noErr) numChannelInfos = 0; } else { numChannelInfos = 1; channelInfos.malloc (static_cast (numChannelInfos)); - channelInfos.getData()->inChannels = -1; - channelInfos.getData()->outChannels = -1; + channelInfos.get()->inChannels = -1; + channelInfos.get()->outChannels = -1; } } } diff --git a/modules/juce_audio_processors/format_types/juce_VSTCommon.h b/modules/juce_audio_processors/format_types/juce_VSTCommon.h index bda9ec84af..cbd5446d1b 100644 --- a/modules/juce_audio_processors/format_types/juce_VSTCommon.h +++ b/modules/juce_audio_processors/format_types/juce_VSTCommon.h @@ -171,7 +171,7 @@ struct SpeakerMappings : private AudioChannelSet // (inheritance only to give e return *this; } - const VstSpeakerConfiguration& get() const { return *storage.getData(); } + const VstSpeakerConfiguration& get() const { return *storage.get(); } private: JUCE_LEAK_DETECTOR (VstSpeakerConfigurationHolder) @@ -184,7 +184,7 @@ struct SpeakerMappings : private AudioChannelSet // (inheritance only to give e + sizeof (VstIndividualSpeakerInfo) * static_cast (jmax (8, numChannels) - 8); storage.malloc (1, arrangementSize); - return storage.getData(); + return storage.get(); } void clear() diff --git a/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp b/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp index 8f394e8140..ea64a20085 100644 --- a/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp +++ b/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp @@ -1547,8 +1547,8 @@ private: HeapBlock inArrBlock (1, true), outArrBlock (1, true); - auto* inArr = inArrBlock.getData(); - auto* outArr = outArrBlock.getData(); + auto* inArr = inArrBlock.get(); + auto* outArr = outArrBlock.get(); if (! getSpeakerArrangementWrapper (effect, inArr, outArr)) inArr = outArr = nullptr; @@ -1611,8 +1611,8 @@ private: { HeapBlock inArrBlock (1, true), outArrBlock (1, true); - auto* inArr = inArrBlock.getData(); - auto* outArr = outArrBlock.getData(); + auto* inArr = inArrBlock.get(); + auto* outArr = outArrBlock.get(); if (getSpeakerArrangementWrapper (effect, inArr, outArr)) return true; @@ -1746,7 +1746,7 @@ private: // always ensure that the buffer is at least as large as the maximum number of channels auto maxChannels = jmax (vstEffect->numInputChannels, vstEffect->numOutputChannels); - auto channels = channelBuffer.getData(); + auto channels = channelBuffer.get(); if (numChannels < maxChannels) { diff --git a/modules/juce_core/containers/juce_Array.h b/modules/juce_core/containers/juce_Array.h index 4e66a70eaa..11465ed4ee 100644 --- a/modules/juce_core/containers/juce_Array.h +++ b/modules/juce_core/containers/juce_Array.h @@ -358,12 +358,12 @@ public: int indexOf (ParameterType elementToLookFor) const { const ScopedLockType lock (getLock()); - const ElementType* e = data.elements.getData(); + const ElementType* e = data.elements.get(); const ElementType* const end_ = e + numUsed; for (; e != end_; ++e) if (elementToLookFor == *e) - return static_cast (e - data.elements.getData()); + return static_cast (e - data.elements.get()); return -1; } @@ -376,7 +376,7 @@ public: bool contains (ParameterType elementToLookFor) const { const ScopedLockType lock (getLock()); - const ElementType* e = data.elements.getData(); + const ElementType* e = data.elements.get(); const ElementType* const end_ = e + numUsed; for (; e != end_; ++e) @@ -719,8 +719,8 @@ public: void resize (const int targetNumItems) { jassert (targetNumItems >= 0); + auto numToAdd = targetNumItems - numUsed; - const int numToAdd = targetNumItems - numUsed; if (numToAdd > 0) insertMultiple (numUsed, ElementType(), numToAdd); else if (numToAdd < 0) @@ -743,7 +743,7 @@ public: int addSorted (ElementComparator& comparator, ParameterType newElement) { const ScopedLockType lock (getLock()); - const int index = findInsertIndexInSortedArray (comparator, data.elements.getData(), newElement, 0, numUsed); + auto index = findInsertIndexInSortedArray (comparator, data.elements.get(), newElement, 0, numUsed); insert (index, newElement); return index; } @@ -1197,7 +1197,7 @@ public: const ScopedLockType lock (getLock()); ignoreUnused (comparator); // if you pass in an object with a static compareElements() method, this // avoids getting warning messages about the parameter being unused - sortArray (comparator, data.elements.getData(), 0, size() - 1, retainOrderOfEquivalentItems); + sortArray (comparator, data.elements.get(), 0, size() - 1, retainOrderOfEquivalentItems); } //============================================================================== diff --git a/modules/juce_core/containers/juce_OwnedArray.h b/modules/juce_core/containers/juce_OwnedArray.h index 4bb502814c..4edc190683 100644 --- a/modules/juce_core/containers/juce_OwnedArray.h +++ b/modules/juce_core/containers/juce_OwnedArray.h @@ -233,12 +233,12 @@ public: int indexOf (const ObjectClass* objectToLookFor) const noexcept { const ScopedLockType lock (getLock()); - ObjectClass* const* e = data.elements.getData(); + ObjectClass* const* e = data.elements.get(); ObjectClass* const* const end_ = e + numUsed; for (; e != end_; ++e) if (objectToLookFor == *e) - return static_cast (e - data.elements.getData()); + return static_cast (e - data.elements.get()); return -1; } @@ -251,7 +251,7 @@ public: bool contains (const ObjectClass* objectToLookFor) const noexcept { const ScopedLockType lock (getLock()); - ObjectClass* const* e = data.elements.getData(); + ObjectClass* const* e = data.elements.get(); ObjectClass* const* const end_ = e + numUsed; for (; e != end_; ++e) @@ -526,7 +526,7 @@ public: ignoreUnused (comparator); // if you pass in an object with a static compareElements() method, this // avoids getting warning messages about the parameter being unused const ScopedLockType lock (getLock()); - const int index = findInsertIndexInSortedArray (comparator, data.elements.getData(), newObject, 0, numUsed); + const int index = findInsertIndexInSortedArray (comparator, data.elements.get(), newObject, 0, numUsed); insert (index, newObject); return index; } @@ -648,7 +648,7 @@ public: void removeObject (const ObjectClass* objectToRemove, bool deleteObject = true) { const ScopedLockType lock (getLock()); - ObjectClass** const e = data.elements.getData(); + ObjectClass** const e = data.elements.get(); for (int i = 0; i < numUsed; ++i) { @@ -858,7 +858,7 @@ public: // avoids getting warning messages about the parameter being unused const ScopedLockType lock (getLock()); - sortArray (comparator, data.elements.getData(), 0, size() - 1, retainOrderOfEquivalentItems); + sortArray (comparator, data.elements.get(), 0, size() - 1, retainOrderOfEquivalentItems); } //============================================================================== diff --git a/modules/juce_core/containers/juce_ReferenceCountedArray.h b/modules/juce_core/containers/juce_ReferenceCountedArray.h index 64eb2d5312..7c10c9c690 100644 --- a/modules/juce_core/containers/juce_ReferenceCountedArray.h +++ b/modules/juce_core/containers/juce_ReferenceCountedArray.h @@ -274,13 +274,13 @@ public: int indexOf (const ObjectClass* const objectToLookFor) const noexcept { const ScopedLockType lock (getLock()); - ObjectClass** e = data.elements.getData(); + ObjectClass** e = data.elements.get(); ObjectClass** const endPointer = e + numUsed; while (e != endPointer) { if (objectToLookFor == *e) - return static_cast (e - data.elements.getData()); + return static_cast (e - data.elements.get()); ++e; } @@ -296,7 +296,7 @@ public: bool contains (const ObjectClass* const objectToLookFor) const noexcept { const ScopedLockType lock (getLock()); - ObjectClass** e = data.elements.getData(); + ObjectClass** e = data.elements.get(); ObjectClass** const endPointer = e + numUsed; while (e != endPointer) @@ -483,7 +483,7 @@ public: int addSorted (ElementComparator& comparator, ObjectClass* newObject) noexcept { const ScopedLockType lock (getLock()); - const int index = findInsertIndexInSortedArray (comparator, data.elements.getData(), newObject, 0, numUsed); + const int index = findInsertIndexInSortedArray (comparator, data.elements.get(), newObject, 0, numUsed); insert (index, newObject); return index; } @@ -498,7 +498,7 @@ public: ObjectClass* newObject) noexcept { const ScopedLockType lock (getLock()); - const int index = findInsertIndexInSortedArray (comparator, data.elements.getData(), newObject, 0, numUsed); + const int index = findInsertIndexInSortedArray (comparator, data.elements.get(), newObject, 0, numUsed); if (index > 0 && comparator.compareElements (newObject, data.elements [index - 1]) == 0) set (index - 1, newObject); // replace an existing object that matches @@ -843,7 +843,7 @@ public: // avoids getting warning messages about the parameter being unused const ScopedLockType lock (getLock()); - sortArray (comparator, data.elements.getData(), 0, size() - 1, retainOrderOfEquivalentItems); + sortArray (comparator, data.elements.get(), 0, size() - 1, retainOrderOfEquivalentItems); } //============================================================================== diff --git a/modules/juce_core/native/juce_mac_Files.mm b/modules/juce_core/native/juce_mac_Files.mm index 78cab85051..a88b4d444f 100644 --- a/modules/juce_core/native/juce_mac_Files.mm +++ b/modules/juce_core/native/juce_mac_Files.mm @@ -237,7 +237,7 @@ File File::getSpecialLocation (const SpecialLocationType type) HeapBlock buffer; buffer.calloc (size + 8); - _NSGetExecutablePath (buffer.getData(), &size); + _NSGetExecutablePath (buffer.get(), &size); return File (String::fromUTF8 (buffer, (int) size)); } diff --git a/modules/juce_core/native/juce_mac_Strings.mm b/modules/juce_core/native/juce_mac_Strings.mm index 62f9d8717b..e8996ba5e0 100644 --- a/modules/juce_core/native/juce_mac_Strings.mm +++ b/modules/juce_core/native/juce_mac_Strings.mm @@ -32,8 +32,8 @@ String String::fromCFString (CFStringRef cfString) HeapBlock utf8 ((size_t) bytesNeeded + 1); CFStringGetBytes (cfString, range, kCFStringEncodingUTF8, 0, false, utf8, bytesNeeded + 1, nullptr); - return String (CharPointer_UTF8 ((const CharPointer_UTF8::CharType*) utf8.getData()), - CharPointer_UTF8 ((const CharPointer_UTF8::CharType*) utf8.getData() + bytesNeeded)); + return String (CharPointer_UTF8 ((const CharPointer_UTF8::CharType*) utf8.get()), + CharPointer_UTF8 ((const CharPointer_UTF8::CharType*) utf8.get() + bytesNeeded)); } CFStringRef String::toCFString() const @@ -89,7 +89,7 @@ String String::convertToPrecomposedUnicode() const bytesNeeded, &bytesRead, &outputBufferSize, tempOut) == noErr) { - result = String (CharPointer_UTF16 ((CharPointer_UTF16::CharType*) tempOut.getData())); + result = String (CharPointer_UTF16 ((CharPointer_UTF16::CharType*) tempOut.get())); } DisposeUnicodeToTextInfo (&conversionInfo); diff --git a/modules/juce_core/native/juce_mac_SystemStats.mm b/modules/juce_core/native/juce_mac_SystemStats.mm index db81b1991b..a3f97d208f 100644 --- a/modules/juce_core/native/juce_mac_SystemStats.mm +++ b/modules/juce_core/native/juce_mac_SystemStats.mm @@ -144,7 +144,7 @@ String SystemStats::getDeviceDescription() { HeapBlock model (size); if (sysctlbyname ("hw.model", model, &size, nullptr, 0) >= 0) - return model.getData(); + return model.get(); } return {}; #endif diff --git a/modules/juce_core/network/juce_URL.cpp b/modules/juce_core/network/juce_URL.cpp index 4264cace89..9505dd89b6 100644 --- a/modules/juce_core/network/juce_URL.cpp +++ b/modules/juce_core/network/juce_URL.cpp @@ -61,12 +61,12 @@ struct FallbackDownloadTask : public URL::DownloadTask, const int max = jmin ((int) bufferSize, contentLength < 0 ? std::numeric_limits::max() : static_cast (contentLength - downloaded)); - const int actual = stream->read (buffer.getData(), max); + const int actual = stream->read (buffer.get(), max); if (actual < 0 || threadShouldExit() || stream->isError()) break; - if (! fileStream->write (buffer.getData(), static_cast (actual))) + if (! fileStream->write (buffer.get(), static_cast (actual))) { error = true; break; diff --git a/modules/juce_core/text/juce_String.cpp b/modules/juce_core/text/juce_String.cpp index 311117b012..5f2ac413de 100644 --- a/modules/juce_core/text/juce_String.cpp +++ b/modules/juce_core/text/juce_String.cpp @@ -1868,7 +1868,7 @@ String String::formattedRaw (const char* pf, ...) #if JUCE_ANDROID HeapBlock temp (bufferSize); - int num = (int) vsnprintf (temp.getData(), bufferSize - 1, pf, args); + int num = (int) vsnprintf (temp.get(), bufferSize - 1, pf, args); if (num >= static_cast (bufferSize)) num = -1; #else @@ -1880,7 +1880,7 @@ String String::formattedRaw (const char* pf, ...) #else vswprintf #endif - (temp.getData(), bufferSize - 1, wideCharVersion.toWideCharPointer(), args); + (temp.get(), bufferSize - 1, wideCharVersion.toWideCharPointer(), args); #endif va_end (args); diff --git a/modules/juce_graphics/geometry/juce_PathIterator.cpp b/modules/juce_graphics/geometry/juce_PathIterator.cpp index f3fbe128ab..d56cd436a1 100644 --- a/modules/juce_graphics/geometry/juce_PathIterator.cpp +++ b/modules/juce_graphics/geometry/juce_PathIterator.cpp @@ -51,7 +51,7 @@ PathFlatteningIterator::~PathFlatteningIterator() bool PathFlatteningIterator::isLastInSubpath() const noexcept { - return stackPos == stackBase.getData() + return stackPos == stackBase.get() && (index >= path.numElements || isMarker (points[index], Path::moveMarker)); } diff --git a/modules/juce_graphics/native/juce_RenderingHelpers.h b/modules/juce_graphics/native/juce_RenderingHelpers.h index 5cbb679e38..67b9b561c0 100644 --- a/modules/juce_graphics/native/juce_RenderingHelpers.h +++ b/modules/juce_graphics/native/juce_RenderingHelpers.h @@ -996,10 +996,10 @@ namespace EdgeTableFillers } y = y_; - generate (scratchBuffer.getData(), x, width); + generate (scratchBuffer.get(), x, width); et.clipLineToMask (x, y_, - reinterpret_cast (scratchBuffer.getData()) + SrcPixelType::indexA, + reinterpret_cast (scratchBuffer.get()) + SrcPixelType::indexA, sizeof (SrcPixelType), width); } diff --git a/modules/juce_opengl/opengl/juce_OpenGLImage.cpp b/modules/juce_opengl/opengl/juce_OpenGLImage.cpp index 027a90a6ad..36a1e1733b 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLImage.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLImage.cpp @@ -156,7 +156,7 @@ private: DataReleaser* r = new DataReleaser (frameBuffer, x, y, bitmapData.width, bitmapData.height); bitmapData.dataReleaser = r; - bitmapData.data = (uint8*) r->data.getData(); + bitmapData.data = (uint8*) r->data.get(); bitmapData.lineStride = (bitmapData.width * bitmapData.pixelStride + 3) & ~3; ReaderType::read (frameBuffer, bitmapData, x, y); From 1cc371cae94efe7f2ff3cb84df59496f73db814c Mon Sep 17 00:00:00 2001 From: jules Date: Tue, 5 Sep 2017 16:39:51 +0100 Subject: [PATCH 049/129] Fix for an AudioBuffer move operator bug --- .../buffers/juce_AudioSampleBuffer.h | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h b/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h index ed945e0896..6ef06a177f 100644 --- a/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h +++ b/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h @@ -184,11 +184,19 @@ public: : numChannels (other.numChannels), size (other.size), allocatedBytes (other.allocatedBytes), - channels (numChannels < (int) numElementsInArray (preallocatedChannelSpace) ? preallocatedChannelSpace : other.channels), allocatedData (static_cast&&> (other.allocatedData)), isClear (other.isClear) { - memcpy (preallocatedChannelSpace, other.preallocatedChannelSpace, sizeof (preallocatedChannelSpace)); + if (numChannels < (int) numElementsInArray (preallocatedChannelSpace)) + { + channels = preallocatedChannelSpace; + memcpy (preallocatedChannelSpace, other.channels, sizeof (preallocatedChannelSpace)); + } + else + { + channels = other.channels; + } + other.numChannels = 0; other.size = 0; other.allocatedBytes = 0; @@ -200,10 +208,19 @@ public: numChannels = other.numChannels; size = other.size; allocatedBytes = other.allocatedBytes; - channels = numChannels < (int) numElementsInArray (preallocatedChannelSpace) ? preallocatedChannelSpace : other.channels; allocatedData = static_cast&&> (other.allocatedData); isClear = other.isClear; - memcpy (preallocatedChannelSpace, other.preallocatedChannelSpace, sizeof (preallocatedChannelSpace)); + + if (numChannels < (int) numElementsInArray (preallocatedChannelSpace)) + { + channels = preallocatedChannelSpace; + memcpy (preallocatedChannelSpace, other.channels, sizeof (preallocatedChannelSpace)); + } + else + { + channels = other.channels; + } + other.numChannels = 0; other.size = 0; other.allocatedBytes = 0; From 0a7e9ff1196b9d371cd23e5083be51576b54e498 Mon Sep 17 00:00:00 2001 From: tpoole Date: Wed, 6 Sep 2017 08:38:50 +0100 Subject: [PATCH 050/129] Whitespace --- modules/juce_core/text/juce_String.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/juce_core/text/juce_String.h b/modules/juce_core/text/juce_String.h index aba06e723f..563b67f0ae 100644 --- a/modules/juce_core/text/juce_String.h +++ b/modules/juce_core/text/juce_String.h @@ -1416,7 +1416,7 @@ JUCE_API OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, StringRef namespace std { - template <> struct hash + template <> struct hash { size_t operator() (const juce::String& s) const noexcept { return s.hash(); } }; From 7a34790388b240cf6c7675880d47c41f00f71fcb Mon Sep 17 00:00:00 2001 From: hogliux Date: Wed, 6 Sep 2017 10:04:12 +0100 Subject: [PATCH 051/129] DSP: Made trimming of the convolution impulse response optional --- .../Source/PluginProcessor.cpp | 4 +- .../DSPDemo/JuceLibraryCode/BinaryData.cpp | 6 +- examples/DSPDemo/JuceLibraryCode/BinaryData.h | 2 +- .../DSPDemo/Source/Demos/ConvolutionDemo.cpp | 4 +- .../juce_dsp/frequency/juce_Convolution.cpp | 121 +++++++++++------- modules/juce_dsp/frequency/juce_Convolution.h | 9 +- 6 files changed, 91 insertions(+), 55 deletions(-) diff --git a/examples/DSP module plugin demo/Source/PluginProcessor.cpp b/examples/DSP module plugin demo/Source/PluginProcessor.cpp index 17ea3d6788..bd531c000c 100644 --- a/examples/DSP module plugin demo/Source/PluginProcessor.cpp +++ b/examples/DSP module plugin demo/Source/PluginProcessor.cpp @@ -240,9 +240,9 @@ void DspModulePluginDemoAudioProcessor::updateParameters() auto maxSize = static_cast (roundDoubleToInt (8192 * getSampleRate() / 44100)); if (type == 0) - convolution.loadImpulseResponse (BinaryData::Impulse1_wav, BinaryData::Impulse1_wavSize, false, maxSize); + convolution.loadImpulseResponse (BinaryData::Impulse1_wav, BinaryData::Impulse1_wavSize, false, true, maxSize); else - convolution.loadImpulseResponse (BinaryData::Impulse2_wav, BinaryData::Impulse2_wavSize, false, maxSize); + convolution.loadImpulseResponse (BinaryData::Impulse2_wav, BinaryData::Impulse2_wavSize, false, true, maxSize); } cabinetIsBypassed = ! cabinetSimParam->get(); diff --git a/examples/DSPDemo/JuceLibraryCode/BinaryData.cpp b/examples/DSPDemo/JuceLibraryCode/BinaryData.cpp index a8727331fc..83708c82d6 100644 --- a/examples/DSPDemo/JuceLibraryCode/BinaryData.cpp +++ b/examples/DSPDemo/JuceLibraryCode/BinaryData.cpp @@ -1565,11 +1565,11 @@ static const unsigned char temp_binary_data_3[] = " if (cabinetTypeParameter->getCurrentSelectedID() == 2)\r\n" " convolution.loadImpulseResponse (BinaryData::guitar_amp_wav,\r\n" " BinaryData::guitar_amp_wavSize,\r\n" -" false, maxSize);\r\n" +" false, true, maxSize);\r\n" " else\r\n" " convolution.loadImpulseResponse (BinaryData::cassette_recorder_wav,\r\n" " BinaryData::cassette_recorder_wavSize,\r\n" -" false, maxSize);\r\n" +" false, true, maxSize);\r\n" " }\r\n" " }\r\n" " }\r\n" @@ -2325,7 +2325,7 @@ const char* getNamedResource (const char* resourceNameUTF8, int& numBytes) throw case 0x409ff6ec: numBytes = 37902; return cassette_recorder_wav; case 0x69523d16: numBytes = 628; return EditorColourScheme_xml; case 0x700ccf3c: numBytes = 90246; return guitar_amp_wav; - case 0x5922ccdf: numBytes = 2999; return ConvolutionDemo_cpp; + case 0x5922ccdf: numBytes = 3011; return ConvolutionDemo_cpp; case 0x14aa0aae: numBytes = 2674; return FIRFilterDemo_cpp; case 0xab621a06: numBytes = 1809; return GainDemo_cpp; case 0x06a7a4b1: numBytes = 2819; return IIRFilterDemo_cpp; diff --git a/examples/DSPDemo/JuceLibraryCode/BinaryData.h b/examples/DSPDemo/JuceLibraryCode/BinaryData.h index 51444ccfed..fe5ad62cfd 100644 --- a/examples/DSPDemo/JuceLibraryCode/BinaryData.h +++ b/examples/DSPDemo/JuceLibraryCode/BinaryData.h @@ -18,7 +18,7 @@ namespace BinaryData const int guitar_amp_wavSize = 90246; extern const char* ConvolutionDemo_cpp; - const int ConvolutionDemo_cppSize = 2999; + const int ConvolutionDemo_cppSize = 3011; extern const char* FIRFilterDemo_cpp; const int FIRFilterDemo_cppSize = 2674; diff --git a/examples/DSPDemo/Source/Demos/ConvolutionDemo.cpp b/examples/DSPDemo/Source/Demos/ConvolutionDemo.cpp index 148b55194f..36aa11b4ad 100644 --- a/examples/DSPDemo/Source/Demos/ConvolutionDemo.cpp +++ b/examples/DSPDemo/Source/Demos/ConvolutionDemo.cpp @@ -65,11 +65,11 @@ struct ConvolutionDemo if (cabinetTypeParameter->getCurrentSelectedID() == 2) convolution.loadImpulseResponse (BinaryData::guitar_amp_wav, BinaryData::guitar_amp_wavSize, - false, maxSize); + false, true, maxSize); else convolution.loadImpulseResponse (BinaryData::cassette_recorder_wav, BinaryData::cassette_recorder_wavSize, - false, maxSize); + false, true, maxSize); } } } diff --git a/modules/juce_dsp/frequency/juce_Convolution.cpp b/modules/juce_dsp/frequency/juce_Convolution.cpp index ad07352a24..8dd3f21b2e 100644 --- a/modules/juce_dsp/frequency/juce_Convolution.cpp +++ b/modules/juce_dsp/frequency/juce_Convolution.cpp @@ -54,6 +54,7 @@ struct ConvolutionEngine double sampleRate = 0; bool wantsStereo; + bool wantsTrimming; size_t impulseResponseSize; size_t maximumBufferSize = 0; }; @@ -335,6 +336,7 @@ public: changeSource, changeImpulseResponseSize, changeStereo, + changeTrimming, numChangeRequestTypes }; @@ -588,6 +590,17 @@ public: } break; + case ChangeRequest::changeTrimming: + { + bool newWantsTrimming = requestParameters[n]; + + if (currentInfo.wantsTrimming != newWantsTrimming) + changeLevel = jmax(1, changeLevel); + + currentInfo.wantsTrimming = newWantsTrimming; + } + break; + default: jassertfalse; break; @@ -732,6 +745,7 @@ private: void processImpulseResponse() { + if (currentInfo.sourceType == SourceType::sourceBinaryData) { copyAudioStreamInAudioBuffer (new MemoryInputStream (currentInfo.sourceData, currentInfo.sourceDataSize, false)); @@ -743,7 +757,7 @@ private: else if (currentInfo.sourceType == SourceType::sourceAudioBuffer) { copyBufferFromTemporaryLocation(); - trimAndResampleImpulseResponse (temporaryBuffer.getNumChannels(), currentInfo.bufferSampleRate); + trimAndResampleImpulseResponse (temporaryBuffer.getNumChannels(), currentInfo.bufferSampleRate, currentInfo.wantsTrimming); } if (isThreadRunning() && threadShouldExit()) @@ -751,19 +765,19 @@ private: if (currentInfo.wantsStereo) { - normalizeImpulseResponse (currentInfo.buffer->getWritePointer(0), currentInfo.buffer->getNumSamples()); - normalizeImpulseResponse (currentInfo.buffer->getWritePointer(1), currentInfo.buffer->getNumSamples()); + normalizeImpulseResponse (currentInfo.buffer->getWritePointer(0), currentInfo.buffer->getNumSamples(), 1.0); + normalizeImpulseResponse (currentInfo.buffer->getWritePointer(1), currentInfo.buffer->getNumSamples(), 1.0); } else { - normalizeImpulseResponse (currentInfo.buffer->getWritePointer (0), currentInfo.buffer->getNumSamples()); + normalizeImpulseResponse (currentInfo.buffer->getWritePointer (0), currentInfo.buffer->getNumSamples(), 1.0); } } /** Converts the data from an audio file into a stereo audio buffer of floats, and performs resampling if necessary. */ - void copyAudioStreamInAudioBuffer (InputStream* stream) + double copyAudioStreamInAudioBuffer (InputStream* stream) { AudioFormatManager manager; manager.registerBasicFormats(); @@ -778,54 +792,65 @@ private: impulseResponseOriginal.clear(); formatReader->read (&(impulseResponseOriginal), 0, impulseResponseOriginal.getNumSamples(), 0, true, numChannels > 1); - trimAndResampleImpulseResponse (numChannels, formatReader->sampleRate); + return trimAndResampleImpulseResponse (numChannels, formatReader->sampleRate, currentInfo.wantsTrimming); } + else + return 0.0; } - void trimAndResampleImpulseResponse (int numChannels, double bufferSampleRate) + double trimAndResampleImpulseResponse (int numChannels, double bufferSampleRate, bool mustTrim) { auto thresholdTrim = Decibels::decibelsToGain (-80.0f); - auto indexStart = impulseResponseOriginal.getNumSamples() - 1; - auto indexEnd = 0; + auto indexStart = 0; + auto indexEnd = impulseResponseOriginal.getNumSamples() - 1; - for (auto channel = 0; channel < numChannels; ++channel) + if (mustTrim) { - auto localIndexStart = 0; - auto localIndexEnd = impulseResponseOriginal.getNumSamples() - 1; + indexStart = impulseResponseOriginal.getNumSamples() - 1; + indexEnd = 0; + + for (auto channel = 0; channel < numChannels; ++channel) + { + auto localIndexStart = 0; + auto localIndexEnd = impulseResponseOriginal.getNumSamples() - 1; - auto* channelData = impulseResponseOriginal.getReadPointer (channel); + auto* channelData = impulseResponseOriginal.getReadPointer (channel); - while (localIndexStart < impulseResponseOriginal.getNumSamples() - 1 - && channelData[localIndexStart] <= thresholdTrim - && channelData[localIndexStart] >= -thresholdTrim) - ++localIndexStart; + while (localIndexStart < impulseResponseOriginal.getNumSamples() - 1 + && channelData[localIndexStart] <= thresholdTrim + && channelData[localIndexStart] >= -thresholdTrim) + ++localIndexStart; - while (localIndexEnd >= 0 - && channelData[localIndexEnd] <= thresholdTrim - && channelData[localIndexEnd] >= -thresholdTrim) - --localIndexEnd; + while (localIndexEnd >= 0 + && channelData[localIndexEnd] <= thresholdTrim + && channelData[localIndexEnd] >= -thresholdTrim) + --localIndexEnd; - indexStart = jmin (indexStart, localIndexStart); - indexEnd = jmax (indexEnd, localIndexEnd); - } + indexStart = jmin (indexStart, localIndexStart); + indexEnd = jmax (indexEnd, localIndexEnd); + } - if (indexStart > 0) - { - for (auto channel = 0; channel < numChannels; ++channel) + if (indexStart > 0) { - auto* channelData = impulseResponseOriginal.getWritePointer (channel); + for (auto channel = 0; channel < numChannels; ++channel) + { + auto* channelData = impulseResponseOriginal.getWritePointer (channel); - for (auto i = 0; i < indexEnd - indexStart + 1; ++i) - channelData[i] = channelData[i + indexStart]; + for (auto i = 0; i < indexEnd - indexStart + 1; ++i) + channelData[i] = channelData[i + indexStart]; - for (auto i = indexEnd - indexStart + 1; i < impulseResponseOriginal.getNumSamples() - 1; ++i) - channelData[i] = 0.0f; + for (auto i = indexEnd - indexStart + 1; i < impulseResponseOriginal.getNumSamples() - 1; ++i) + channelData[i] = 0.0f; + } } } + double factorReading; + if (currentInfo.sampleRate == bufferSampleRate) { // No resampling + factorReading = 1.0; auto impulseSize = jmin (static_cast (currentInfo.impulseResponseSize), indexEnd - indexStart + 1); impulseResponse.setSize (2, impulseSize); @@ -837,7 +862,7 @@ private: else { // Resampling - auto factorReading = bufferSampleRate / currentInfo.sampleRate; + factorReading = bufferSampleRate / currentInfo.sampleRate; auto impulseSize = jmin (static_cast (currentInfo.impulseResponseSize), roundDoubleToInt ((indexEnd - indexStart + 1) / factorReading)); impulseResponse.setSize (2, impulseSize); @@ -860,16 +885,18 @@ private: // Filling the second channel with the first if necessary if (numChannels == 1) impulseResponse.copyFrom (1, 0, impulseResponse, 0, 0, impulseResponse.getNumSamples()); + + return factorReading; } - void normalizeImpulseResponse (float* samples, int numSamples) const + void normalizeImpulseResponse (float* samples, int numSamples, double factorResampling) const { auto magnitude = 0.0f; for (int i = 0; i < numSamples; ++i) magnitude += samples[i] * samples[i]; - auto magnitudeInv = 1.0f / (4.0f * std::sqrt (magnitude)); + auto magnitudeInv = 1.0f / (4.0f * std::sqrt (magnitude)) * 0.5f * static_cast (factorResampling); for (int i = 0; i < numSamples; ++i) samples[i] *= magnitudeInv; @@ -965,14 +992,15 @@ Convolution::~Convolution() { } -void Convolution::loadImpulseResponse (const void* sourceData, size_t sourceDataSize, bool wantsStereo, size_t size) +void Convolution::loadImpulseResponse (const void* sourceData, size_t sourceDataSize, bool wantsStereo, bool wantsTrimming, size_t size) { if (sourceData == nullptr) return; Pimpl::ChangeRequest types[] = { Pimpl::ChangeRequest::changeSource, Pimpl::ChangeRequest::changeImpulseResponseSize, - Pimpl::ChangeRequest::changeStereo }; + Pimpl::ChangeRequest::changeStereo, + Pimpl::ChangeRequest::changeTrimming }; Array sourceParameter; @@ -981,19 +1009,21 @@ void Convolution::loadImpulseResponse (const void* sourceData, size_t sourceData juce::var parameters[] = { juce::var (sourceParameter), juce::var (static_cast (size)), - juce::var (wantsStereo) }; + juce::var (wantsStereo), + juce::var (wantsTrimming) }; pimpl->addToFifo (types, parameters, 3); } -void Convolution::loadImpulseResponse (const File& fileImpulseResponse, bool wantsStereo, size_t size) +void Convolution::loadImpulseResponse (const File& fileImpulseResponse, bool wantsStereo, bool wantsTrimming, size_t size) { if (! fileImpulseResponse.existsAsFile()) return; Pimpl::ChangeRequest types[] = { Pimpl::ChangeRequest::changeSource, Pimpl::ChangeRequest::changeImpulseResponseSize, - Pimpl::ChangeRequest::changeStereo }; + Pimpl::ChangeRequest::changeStereo, + Pimpl::ChangeRequest::changeTrimming }; Array sourceParameter; @@ -1002,13 +1032,14 @@ void Convolution::loadImpulseResponse (const File& fileImpulseResponse, bool wan juce::var parameters[] = { juce::var (sourceParameter), juce::var (static_cast (size)), - juce::var (wantsStereo) }; + juce::var (wantsStereo), + juce::var (wantsTrimming) }; pimpl->addToFifo (types, parameters, 3); } void Convolution::copyAndLoadImpulseResponseFromBuffer (const AudioBuffer& buffer, - double bufferSampleRate, bool wantsStereo, size_t size) + double bufferSampleRate, bool wantsStereo, bool wantsTrimming, size_t size) { jassert (bufferSampleRate > 0); @@ -1019,7 +1050,8 @@ void Convolution::copyAndLoadImpulseResponseFromBuffer (const AudioBuffer Pimpl::ChangeRequest types[] = { Pimpl::ChangeRequest::changeSource, Pimpl::ChangeRequest::changeImpulseResponseSize, - Pimpl::ChangeRequest::changeStereo }; + Pimpl::ChangeRequest::changeStereo, + Pimpl::ChangeRequest::changeTrimming }; Array sourceParameter; sourceParameter.add (juce::var ((int) ConvolutionEngine::ProcessingInformation::SourceType::sourceAudioBuffer)); @@ -1027,7 +1059,8 @@ void Convolution::copyAndLoadImpulseResponseFromBuffer (const AudioBuffer juce::var parameters[] = { juce::var (sourceParameter), juce::var (static_cast (size)), - juce::var (wantsStereo) }; + juce::var (wantsStereo), + juce::var (wantsTrimming) }; pimpl->addToFifo (types, parameters, 3); } diff --git a/modules/juce_dsp/frequency/juce_Convolution.h b/modules/juce_dsp/frequency/juce_Convolution.h index 5525e99b7c..e440a41ab5 100644 --- a/modules/juce_dsp/frequency/juce_Convolution.h +++ b/modules/juce_dsp/frequency/juce_Convolution.h @@ -87,10 +87,11 @@ public: @param sourceData the block of data to use as the stream's source @param sourceDataSize the number of bytes in the source data block @param wantsStereo requests to load both stereo channels or only one mono channel + @param wantsTrimming requests to trim the start and the end of the impulse response @param size the expected size for the impulse response after loading */ void loadImpulseResponse (const void* sourceData, size_t sourceDataSize, - bool wantsStereo, size_t size); + bool wantsStereo, bool wantsTrimming, size_t size); /** This function loads an impulse response from an audio file on any drive. It can load any of the audio formats registered in JUCE, and performs some @@ -98,10 +99,11 @@ public: @param fileImpulseResponse the location of the audio file @param wantsStereo requests to load both stereo channels or only one mono channel + @param wantsTrimming requests to trim the start and the end of the impulse response @param size the expected size for the impulse response after loading */ void loadImpulseResponse (const File& fileImpulseResponse, - bool wantsStereo, size_t size); + bool wantsStereo, bool wantsTrimming, size_t size); /** This function loads an impulse response from an audio buffer, which is copied before doing anything else. Performs some resampling and @@ -110,10 +112,11 @@ public: @param buffer the AudioBuffer to use @param bufferSampleRate the sampleRate of the data in the AudioBuffer @param wantsStereo requests to load both stereo channels or only one mono channel + @param wantsTrimming requests to trim the start and the end of the impulse response @param size the expected size for the impulse response after loading */ void copyAndLoadImpulseResponseFromBuffer (const AudioBuffer& buffer, double bufferSampleRate, - bool wantsStereo, size_t size); + bool wantsStereo, bool wantsTrimming, size_t size); private: //============================================================================== From f1d62982063dbf69a2a4880fa266976e82d13134 Mon Sep 17 00:00:00 2001 From: hogliux Date: Wed, 6 Sep 2017 10:17:09 +0100 Subject: [PATCH 052/129] DSP: Fixed multiple issues with the DSP Oversampling class and updated DSP module plug-in demo code accordingly --- .../DSPModulePluginDemo_SharedCode.vcxproj | 6 + ...PModulePluginDemo_StandalonePlugin.vcxproj | 6 + .../DSPModulePluginDemo_VST.vcxproj | 6 + .../DSP module plugin demo.jucer | 4 +- .../Source/PluginEditor.cpp | 24 +- .../Source/PluginEditor.h | 4 +- .../Source/PluginProcessor.cpp | 44 +- .../Source/PluginProcessor.h | 4 + .../juce_dsp/processors/juce_Oversampling.cpp | 462 ++++++++++-------- .../juce_dsp/processors/juce_Oversampling.h | 17 +- 10 files changed, 345 insertions(+), 232 deletions(-) diff --git a/examples/DSP module plugin demo/Builds/VisualStudio2015/DSPModulePluginDemo_SharedCode.vcxproj b/examples/DSP module plugin demo/Builds/VisualStudio2015/DSPModulePluginDemo_SharedCode.vcxproj index c7b52988c6..f977707fd1 100644 --- a/examples/DSP module plugin demo/Builds/VisualStudio2015/DSPModulePluginDemo_SharedCode.vcxproj +++ b/examples/DSP module plugin demo/Builds/VisualStudio2015/DSPModulePluginDemo_SharedCode.vcxproj @@ -101,6 +101,9 @@ true $(IntDir)\DSPModulePluginDemo.bsc + + if "$(ProjectName)"=="$(SolutionName)_VST" copy /Y "$(TargetDir)\$(TargetName).dll" "c:\vstplugins\musical entropy\$(TargetName).dll" + @@ -143,6 +146,9 @@ true $(IntDir)\DSPModulePluginDemo.bsc + + if "$(ProjectName)"=="$(SolutionName)_VST" copy /Y "$(TargetDir)\$(TargetName).dll" "c:\vstplugins\musical entropy\$(TargetName).dll" + diff --git a/examples/DSP module plugin demo/Builds/VisualStudio2015/DSPModulePluginDemo_StandalonePlugin.vcxproj b/examples/DSP module plugin demo/Builds/VisualStudio2015/DSPModulePluginDemo_StandalonePlugin.vcxproj index 793416403c..96b3e8a143 100644 --- a/examples/DSP module plugin demo/Builds/VisualStudio2015/DSPModulePluginDemo_StandalonePlugin.vcxproj +++ b/examples/DSP module plugin demo/Builds/VisualStudio2015/DSPModulePluginDemo_StandalonePlugin.vcxproj @@ -104,6 +104,9 @@ true $(IntDir)\DSPModulePluginDemo.bsc + + if "$(ProjectName)"=="$(SolutionName)_VST" copy /Y "$(TargetDir)\$(TargetName).dll" "c:\vstplugins\musical entropy\$(TargetName).dll" + @@ -147,6 +150,9 @@ true $(IntDir)\DSPModulePluginDemo.bsc + + if "$(ProjectName)"=="$(SolutionName)_VST" copy /Y "$(TargetDir)\$(TargetName).dll" "c:\vstplugins\musical entropy\$(TargetName).dll" + diff --git a/examples/DSP module plugin demo/Builds/VisualStudio2015/DSPModulePluginDemo_VST.vcxproj b/examples/DSP module plugin demo/Builds/VisualStudio2015/DSPModulePluginDemo_VST.vcxproj index dfd834034f..374cb6fed4 100644 --- a/examples/DSP module plugin demo/Builds/VisualStudio2015/DSPModulePluginDemo_VST.vcxproj +++ b/examples/DSP module plugin demo/Builds/VisualStudio2015/DSPModulePluginDemo_VST.vcxproj @@ -104,6 +104,9 @@ true $(IntDir)\DSPModulePluginDemo.bsc + + if "$(ProjectName)"=="$(SolutionName)_VST" copy /Y "$(TargetDir)\$(TargetName).dll" "c:\vstplugins\musical entropy\$(TargetName).dll" + @@ -147,6 +150,9 @@ true $(IntDir)\DSPModulePluginDemo.bsc + + if "$(ProjectName)"=="$(SolutionName)_VST" copy /Y "$(TargetDir)\$(TargetName).dll" "c:\vstplugins\musical entropy\$(TargetName).dll" + diff --git a/examples/DSP module plugin demo/DSP module plugin demo.jucer b/examples/DSP module plugin demo/DSP module plugin demo.jucer index 67e37a1318..7ee8df1779 100644 --- a/examples/DSP module plugin demo/DSP module plugin demo.jucer +++ b/examples/DSP module plugin demo/DSP module plugin demo.jucer @@ -59,10 +59,10 @@ + warningsAreErrors="0" postbuildCommand="if "$(ProjectName)"=="$(SolutionName)_VST" copy /Y "$(TargetDir)\$(TargetName).dll" "c:\vstplugins\musical entropy\$(TargetName).dll""/> + useRuntimeLibDLL="0" postbuildCommand="if "$(ProjectName)"=="$(SolutionName)_VST" copy /Y "$(TargetDir)\$(TargetName).dll" "c:\vstplugins\musical entropy\$(TargetName).dll""/> diff --git a/examples/DSP module plugin demo/Source/PluginEditor.cpp b/examples/DSP module plugin demo/Source/PluginEditor.cpp index 982fe6cd93..6573a34e12 100644 --- a/examples/DSP module plugin demo/Source/PluginEditor.cpp +++ b/examples/DSP module plugin demo/Source/PluginEditor.cpp @@ -123,6 +123,10 @@ DspModulePluginDemoAudioProcessorEditor::DspModulePluginDemoAudioProcessorEditor cabinetSimButton.addListener (this); cabinetSimButton.setButtonText (processor.cabinetSimParam->name); + addAndMakeVisible (oversamplingButton); + oversamplingButton.addListener (this); + oversamplingButton.setButtonText (processor.oversamplingParam->name); + //============================================================================== setSize (600, 400); } @@ -172,9 +176,13 @@ void DspModulePluginDemoAudioProcessorEditor::resized() //============================================================================== auto buttonSlice = bounds.removeFromTop (30); - cabinetSimButton.setSize (200, bounds.getHeight()); + cabinetSimButton.setSize (200, buttonSlice.getHeight()); cabinetSimButton.setCentrePosition (buttonSlice.getCentre()); - bounds.removeFromTop (15); + bounds.removeFromTop(5); + + buttonSlice = bounds.removeFromTop (30); + oversamplingButton.setSize(200, buttonSlice.getHeight()); + oversamplingButton.setCentrePosition(buttonSlice.getCentre()); } //============================================================================== void DspModulePluginDemoAudioProcessorEditor::comboBoxChanged (ComboBox* box) @@ -198,3 +206,15 @@ void DspModulePluginDemoAudioProcessorEditor::comboBoxChanged (ComboBox* box) processor.cabinetTypeParam->operator= (index); } } + +void DspModulePluginDemoAudioProcessorEditor::buttonClicked (Button* button) +{ + if (button == &cabinetSimButton) + { + processor.cabinetSimParam->operator= (cabinetSimButton.getToggleState()); + } + else if (button == &oversamplingButton) + { + processor.oversamplingParam->operator= (oversamplingButton.getToggleState()); + } +} diff --git a/examples/DSP module plugin demo/Source/PluginEditor.h b/examples/DSP module plugin demo/Source/PluginEditor.h index d2a36b8bbd..ab43e1fbe9 100644 --- a/examples/DSP module plugin demo/Source/PluginEditor.h +++ b/examples/DSP module plugin demo/Source/PluginEditor.h @@ -86,7 +86,7 @@ public: private: //============================================================================== void comboBoxChanged (ComboBox*) override; - void buttonClicked (Button*) override { processor.cabinetSimParam->operator= (cabinetSimButton.getToggleState()); } + void buttonClicked (Button*) override; //============================================================================== DspModulePluginDemoAudioProcessor& processor; @@ -94,7 +94,7 @@ private: ScopedPointer inputVolumeSlider, outputVolumeSlider, lowPassFilterFreqSlider, highPassFilterFreqSlider; ComboBox stereoBox, slopeBox, waveshaperBox, cabinetTypeBox; - ToggleButton cabinetSimButton; + ToggleButton cabinetSimButton, oversamplingButton; Label inputVolumeLabel, outputVolumeLabel, lowPassFilterFreqLabel, highPassFilterFreqLabel, stereoLabel, slopeLabel, waveshaperLabel, diff --git a/examples/DSP module plugin demo/Source/PluginProcessor.cpp b/examples/DSP module plugin demo/Source/PluginProcessor.cpp index bd531c000c..8e9ac479ac 100644 --- a/examples/DSP module plugin demo/Source/PluginProcessor.cpp +++ b/examples/DSP module plugin demo/Source/PluginProcessor.cpp @@ -38,6 +38,9 @@ DspModulePluginDemoAudioProcessor::DspModulePluginDemoAudioProcessor() waveShapers { {std::tanh}, {dsp::FastMathApproximations::tanh} }, clipping { clip } { + // Oversampling 2 times with IIR filtering + oversampling = new dsp::Oversampling (2, 1, dsp::Oversampling::filterHalfBandPolyphaseIIR, false); + addParameter (inputVolumeParam = new AudioParameterFloat ("INPUT", "Input Volume", { 0.f, 60.f, 0.f, 1.0f }, 0.f, "dB")); addParameter (highPassFilterFreqParam = new AudioParameterFloat ("HPFREQ", "Pre Highpass Freq.", { 20.f, 20000.f, 0.f, 0.5f }, 20.f, "Hz")); addParameter (lowPassFilterFreqParam = new AudioParameterFloat ("LPFREQ", "Post Lowpass Freq.", { 20.f, 20000.f, 0.f, 0.5f }, 20000.f, "Hz")); @@ -50,12 +53,11 @@ DspModulePluginDemoAudioProcessor::DspModulePluginDemoAudioProcessor() "Cassette recorder cabinet" }, 0)); addParameter (cabinetSimParam = new AudioParameterBool ("CABSIM", "Cabinet Sim", false)); + addParameter (oversamplingParam = new AudioParameterBool ("OVERS", "Oversampling", false)); addParameter (outputVolumeParam = new AudioParameterFloat ("OUTPUT", "Output Volume", { -40.f, 40.f, 0.f, 1.0f }, 0.f, "dB")); cabinetType.set (0); - - } DspModulePluginDemoAudioProcessor::~DspModulePluginDemoAudioProcessor() @@ -82,8 +84,6 @@ void DspModulePluginDemoAudioProcessor::prepareToPlay (double sampleRate, int sa auto channels = static_cast (jmin (getMainBusNumInputChannels(), getMainBusNumOutputChannels())); dsp::ProcessSpec spec { sampleRate, static_cast (samplesPerBlock), channels }; - updateParameters(); - lowPassFilter.prepare (spec); highPassFilter.prepare (spec); @@ -92,6 +92,11 @@ void DspModulePluginDemoAudioProcessor::prepareToPlay (double sampleRate, int sa convolution.prepare (spec); cabinetType.set (-1); + + oversampling->initProcessing (static_cast (samplesPerBlock)); + + updateParameters(); + reset(); } void DspModulePluginDemoAudioProcessor::reset() @@ -99,6 +104,7 @@ void DspModulePluginDemoAudioProcessor::reset() lowPassFilter.reset(); highPassFilter.reset(); convolution.reset(); + oversampling->reset(); } void DspModulePluginDemoAudioProcessor::releaseResources() @@ -115,20 +121,34 @@ void DspModulePluginDemoAudioProcessor::process (dsp::ProcessContextReplacing oversampledBlock; + + setLatencySamples (audioCurrentlyOversampled ? roundFloatToInt (oversampling->getLatencyInSamples()) : 0); + + if (audioCurrentlyOversampled) + oversampledBlock = oversampling->processSamplesUp (context.getInputBlock()); + + dsp::ProcessContextReplacing waveshaperContext = audioCurrentlyOversampled ? dsp::ProcessContextReplacing (oversampledBlock) : context; + // Waveshaper processing, for distortion generation, thanks to the input gain // The fast tanh can be used instead of std::tanh to reduce the CPU load auto waveshaperIndex = waveshaperParam->getIndex(); if (isPositiveAndBelow (waveshaperIndex, (int) numWaveShapers) ) { - waveShapers[waveshaperIndex].process (context); + waveShapers[waveshaperIndex].process (waveshaperContext); if (waveshaperIndex == 1) - clipping.process(context); + clipping.process (waveshaperContext); - context.getOutputBlock() *= 0.7f; + waveshaperContext.getOutputBlock() *= 0.7f; } + // Downsampling + if (audioCurrentlyOversampled) + oversampling->processSamplesDown (context.getOutputBlock()); + // Post-lowpass filtering lowPassFilter.process (context); @@ -209,13 +229,20 @@ bool DspModulePluginDemoAudioProcessor::producesMidi() const //============================================================================== void DspModulePluginDemoAudioProcessor::updateParameters() { + auto newOversampling = oversamplingParam->get(); + if (newOversampling != audioCurrentlyOversampled) + { + audioCurrentlyOversampled = newOversampling; + oversampling->reset(); + } + + //============================================================================== auto inputdB = Decibels::decibelsToGain (inputVolumeParam->get()); auto outputdB = Decibels::decibelsToGain (outputVolumeParam->get()); if (inputVolume.getGainLinear() != inputdB) inputVolume.setGainLinear (inputdB); if (outputVolume.getGainLinear() != outputdB) outputVolume.setGainLinear (outputdB); - dsp::IIR::Coefficients::Ptr newHighPassCoeffs, newLowPassCoeffs; auto newSlopeType = slopeParam->getIndex(); if (newSlopeType == 0) @@ -246,6 +273,7 @@ void DspModulePluginDemoAudioProcessor::updateParameters() } cabinetIsBypassed = ! cabinetSimParam->get(); + } //============================================================================== diff --git a/examples/DSP module plugin demo/Source/PluginProcessor.h b/examples/DSP module plugin demo/Source/PluginProcessor.h index 2a8fd42ef0..4574cb33a7 100644 --- a/examples/DSP module plugin demo/Source/PluginProcessor.h +++ b/examples/DSP module plugin demo/Source/PluginProcessor.h @@ -88,6 +88,7 @@ public: AudioParameterChoice* cabinetTypeParam; AudioParameterBool* cabinetSimParam; + AudioParameterBool* oversamplingParam; private: //============================================================================== @@ -103,6 +104,9 @@ private: dsp::Gain inputVolume, outputVolume; + ScopedPointer> oversampling; + bool audioCurrentlyOversampled = false; + Atomic cabinetType; bool cabinetIsBypassed = false; diff --git a/modules/juce_dsp/processors/juce_Oversampling.cpp b/modules/juce_dsp/processors/juce_Oversampling.cpp index 5748ec272d..a6349966ac 100644 --- a/modules/juce_dsp/processors/juce_Oversampling.cpp +++ b/modules/juce_dsp/processors/juce_Oversampling.cpp @@ -34,7 +34,12 @@ class OversamplingEngine { public: //=============================================================================== - OversamplingEngine (size_t newFactor) { factor = newFactor; } + OversamplingEngine (size_t newNumChannels, size_t newFactor) + { + numChannels = newNumChannels; + factor = newFactor; + } + virtual ~OversamplingEngine() {} //=============================================================================== @@ -43,7 +48,7 @@ public: virtual void initProcessing (size_t maximumNumberOfSamplesBeforeOversampling) { - buffer.setSize (1, static_cast (maximumNumberOfSamplesBeforeOversampling * factor)); + buffer.setSize (static_cast (numChannels), static_cast (maximumNumberOfSamplesBeforeOversampling * factor), false, false, true); } virtual void reset() @@ -51,16 +56,19 @@ public: buffer.clear(); } - SampleType* getProcessedSamples() { return buffer.getWritePointer (0); } - size_t getNumProcessedSamples() { return static_cast (buffer.getNumSamples()); } + dsp::AudioBlock getProcessedSamples (size_t numSamples) + { + return dsp::AudioBlock (buffer).getSubBlock (0, numSamples); + } - virtual void processSamplesUp (SampleType *samples, size_t numSamples) = 0; - virtual void processSamplesDown (SampleType *samples, size_t numSamples) = 0; + virtual void processSamplesUp (dsp::AudioBlock &inputBlock) = 0; + virtual void processSamplesDown (dsp::AudioBlock &outputBlock) = 0; protected: //=============================================================================== AudioBuffer buffer; size_t factor; + size_t numChannels; }; @@ -73,7 +81,7 @@ class OversamplingDummy : public OversamplingEngine { public: //=============================================================================== - OversamplingDummy() : OversamplingEngine(1) {} + OversamplingDummy (size_t numChannels) : OversamplingEngine (numChannels, 1) {} ~OversamplingDummy() {} //=============================================================================== @@ -82,20 +90,22 @@ public: return 0.f; } - void processSamplesUp (SampleType *samples, size_t numSamples) override + void processSamplesUp (dsp::AudioBlock &inputBlock) override { - auto bufferSamples = this->buffer.getWritePointer (0); + jassert (inputBlock.getNumChannels() <= static_cast (OversamplingEngine::buffer.getNumChannels())); + jassert (inputBlock.getNumSamples() * OversamplingEngine::factor <= static_cast (OversamplingEngine::buffer.getNumSamples())); - for (size_t i = 0; i < numSamples; i++) - bufferSamples[i] = samples[i]; + for (size_t channel = 0; channel < inputBlock.getNumChannels(); channel++) + OversamplingEngine::buffer.copyFrom (static_cast (channel), 0, + inputBlock.getChannelPointer (channel), static_cast (inputBlock.getNumSamples())); } - void processSamplesDown (SampleType *samples, size_t numSamples) override + void processSamplesDown (dsp::AudioBlock &outputBlock) override { - auto bufferSamples = OversamplingEngine::buffer.getWritePointer (0); + jassert (outputBlock.getNumChannels() <= static_cast (OversamplingEngine::buffer.getNumChannels())); + jassert (outputBlock.getNumSamples() * OversamplingEngine::factor <= static_cast (OversamplingEngine::buffer.getNumSamples())); - for (size_t i = 0; i < numSamples; i++) - samples[i] = bufferSamples[i]; + outputBlock.copy (OversamplingEngine::getProcessedSamples (outputBlock.getNumSamples())); } private: @@ -104,8 +114,7 @@ private: }; //=============================================================================== -/** - Oversampling engine class performing 2 times oversampling using the Filter +/** Oversampling engine class performing 2 times oversampling using the Filter Design FIR Equiripple method. The resulting filter is linear phase, symmetric, and has every two samples but the middle one equal to zero, leading to specific processing optimizations. @@ -115,21 +124,26 @@ class Oversampling2TimesEquirippleFIR : public OversamplingEngine { public: //=============================================================================== - Oversampling2TimesEquirippleFIR (SampleType normalizedTransitionWidthUp, + Oversampling2TimesEquirippleFIR (size_t numChannels, + SampleType normalizedTransitionWidthUp, SampleType stopbandAttenuationdBUp, SampleType normalizedTransitionWidthDown, - SampleType stopbandAttenuationdBDown) : OversamplingEngine (2) + SampleType stopbandAttenuationdBDown) : OversamplingEngine (numChannels, 2) { coefficientsUp = *dsp::FilterDesign::designFIRLowpassHalfBandEquirippleMethod (normalizedTransitionWidthUp, stopbandAttenuationdBUp); coefficientsDown = *dsp::FilterDesign::designFIRLowpassHalfBandEquirippleMethod (normalizedTransitionWidthDown, stopbandAttenuationdBDown); - auto N = coefficientsDown.getFilterOrder() + 1; + auto N = coefficientsUp.getFilterOrder() + 1; + stateUp.setSize (static_cast (numChannels), static_cast (N)); + + N = coefficientsDown.getFilterOrder() + 1; auto Ndiv2 = N / 2; auto Ndiv4 = Ndiv2 / 2; - stateUp.setSize (1, static_cast (coefficientsUp.getFilterOrder() + 1)); - stateDown.setSize (1, static_cast (N)); - stateDown2.setSize (1, static_cast (Ndiv4)); + stateDown.setSize (static_cast (numChannels), static_cast (N)); + stateDown2.setSize (static_cast (numChannels), static_cast (Ndiv4 + 1)); + + position.resize (static_cast (numChannels)); } ~Oversampling2TimesEquirippleFIR() {} @@ -137,7 +151,7 @@ public: //=============================================================================== SampleType getLatencyInSamples() override { - return static_cast (coefficientsUp.getFilterOrder() + coefficientsDown.getFilterOrder()); + return static_cast (coefficientsUp.getFilterOrder() + coefficientsDown.getFilterOrder()) * 0.5f; } void reset() override @@ -148,83 +162,103 @@ public: stateDown.clear(); stateDown2.clear(); - position = 0; + position.fill (0); } - void processSamplesUp (SampleType *samples, size_t numSamples) override + void processSamplesUp (dsp::AudioBlock &inputBlock) override { + jassert (inputBlock.getNumChannels() <= static_cast (OversamplingEngine::buffer.getNumChannels())); + jassert (inputBlock.getNumSamples() * OversamplingEngine::factor <= static_cast (OversamplingEngine::buffer.getNumSamples())); + // Initialization - auto bufferSamples = OversamplingEngine::buffer.getWritePointer (0); auto fir = coefficientsUp.getRawCoefficients(); - auto buf = stateUp.getWritePointer (0); - auto N = coefficientsUp.getFilterOrder() + 1; auto Ndiv2 = N / 2; + auto numSamples = inputBlock.getNumSamples(); // Processing - for (size_t i = 0; i < numSamples; i++) + for (size_t channel = 0; channel < inputBlock.getNumChannels(); channel++) { - // Input - buf[N - 1] = 2 * samples[i]; + auto bufferSamples = OversamplingEngine::buffer.getWritePointer (static_cast (channel)); + auto buf = stateUp.getWritePointer (static_cast (channel)); + auto samples = inputBlock.getChannelPointer (channel); + + for (size_t i = 0; i < numSamples; i++) + { + // Input + buf[N - 1] = 2 * samples[i]; - // Convolution - auto out = static_cast (0.0); - for (size_t k = 0; k < Ndiv2; k += 2) - out += (buf[k] + buf[N - k - 1]) * fir[k]; + // Convolution + auto out = static_cast (0.0); + for (size_t k = 0; k < Ndiv2; k += 2) + out += (buf[k] + buf[N - k - 1]) * fir[k]; - // Outputs - bufferSamples[i << 1] = out; - bufferSamples[(i << 1) + 1] = buf[Ndiv2 + 1] * fir[Ndiv2]; + // Outputs + bufferSamples[i << 1] = out; + bufferSamples[(i << 1) + 1] = buf[Ndiv2 + 1] * fir[Ndiv2]; - // Shift data - for (size_t k = 0; k < N - 2; k+=2) - buf[k] = buf[k + 2]; + // Shift data + for (size_t k = 0; k < N - 2; k += 2) + buf[k] = buf[k + 2]; + } } } - void processSamplesDown (SampleType *samples, size_t numSamples) override + void processSamplesDown (dsp::AudioBlock &outputBlock) override { + jassert (outputBlock.getNumChannels() <= static_cast (OversamplingEngine::buffer.getNumChannels())); + jassert (outputBlock.getNumSamples() * OversamplingEngine::factor <= static_cast (OversamplingEngine::buffer.getNumSamples())); + // Initialization - auto bufferSamples = OversamplingEngine::buffer.getWritePointer (0); auto fir = coefficientsDown.getRawCoefficients(); - auto buf = stateDown.getWritePointer (0); - auto buf2 = stateDown2.getWritePointer (0); - auto N = coefficientsDown.getFilterOrder() + 1; auto Ndiv2 = N / 2; auto Ndiv4 = Ndiv2 / 2; + auto numSamples = outputBlock.getNumSamples(); // Processing - for (size_t i = 0; i < numSamples; i++) + for (size_t channel = 0; channel < outputBlock.getNumChannels(); channel++) { - // Input - buf[N - 1] = bufferSamples[2 * i]; + auto bufferSamples = OversamplingEngine::buffer.getWritePointer (static_cast (channel)); + auto buf = stateDown.getWritePointer (static_cast (channel)); + auto buf2 = stateDown2.getWritePointer (static_cast (channel)); + auto samples = outputBlock.getChannelPointer (channel); + auto pos = position.getUnchecked (static_cast (channel)); + + for (size_t i = 0; i < numSamples; i++) + { + // Input + buf[N - 1] = bufferSamples[i << 1]; - // Convolution - auto out = static_cast (0.0); - for (size_t k = 0; k < Ndiv2; k += 2) - out += (buf[k] + buf[N - k - 1]) * fir[k]; + // Convolution + auto out = static_cast (0.0); + for (size_t k = 0; k < Ndiv2; k += 2) + out += (buf[k] + buf[N - k - 1]) * fir[k]; - // Output - out += buf2[position] * fir[Ndiv2]; - buf2[position] = bufferSamples[2 * i + 1]; + // Output + out += buf2[pos] * fir[Ndiv2]; + buf2[pos] = bufferSamples[(i << 1) + 1]; - samples[i] = out; + samples[i] = out; - // Shift data - for (size_t k = 0; k < N - 2; k++) - buf[k] = buf[k + 2]; + // Shift data + for (size_t k = 0; k < N - 2; k++) + buf[k] = buf[k + 2]; + + // Circular buffer + pos = (pos == 0 ? Ndiv4 : pos - 1); + } - // Circular buffer - position = (position == 0 ? Ndiv4 - 1 : position - 1); + position.setUnchecked (static_cast (channel), pos); } + } private: //=============================================================================== dsp::FIR::Coefficients coefficientsUp, coefficientsDown; AudioBuffer stateUp, stateDown, stateDown2; - size_t position; + Array position; //=============================================================================== JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Oversampling2TimesEquirippleFIR) @@ -241,10 +275,11 @@ class Oversampling2TimesPolyphaseIIR : public OversamplingEngine { public: //=============================================================================== - Oversampling2TimesPolyphaseIIR (SampleType normalizedTransitionWidthUp, + Oversampling2TimesPolyphaseIIR (size_t numChannels, + SampleType normalizedTransitionWidthUp, SampleType stopbandAttenuationdBUp, SampleType normalizedTransitionWidthDown, - SampleType stopbandAttenuationdBDown) : OversamplingEngine (2) + SampleType stopbandAttenuationdBDown) : OversamplingEngine (2, numChannels) { auto structureUp = dsp::FilterDesign::designIIRLowpassHalfBandPolyphaseAllpassMethod (normalizedTransitionWidthUp, stopbandAttenuationdBUp); dsp::IIR::Coefficients coeffsUp = getCoefficients (structureUp); @@ -266,8 +301,9 @@ public: for (auto i = 1; i < structureDown.delayedPath.size(); i++) coefficientsDown.add (structureDown.delayedPath[i].coefficients[0]); - v1Up.resize (coefficientsUp.size()); - v1Down.resize (coefficientsDown.size()); + v1Up.setSize (static_cast (numChannels), coefficientsUp.size()); + v1Down.setSize (static_cast (numChannels), coefficientsDown.size()); + delayDown.resize (static_cast (numChannels)); } ~Oversampling2TimesPolyphaseIIR() {} @@ -282,95 +318,113 @@ public: { OversamplingEngine::reset(); - v1Up.fill (0); - v1Down.fill (0); - delayDown = 0; + v1Up.clear(); + v1Down.clear(); + delayDown.fill (0); } - void processSamplesUp (SampleType *samples, size_t numSamples) override + void processSamplesUp (dsp::AudioBlock &inputBlock) override { + jassert (inputBlock.getNumChannels() <= static_cast (OversamplingEngine::buffer.getNumChannels())); + jassert (inputBlock.getNumSamples() * OversamplingEngine::factor <= static_cast (OversamplingEngine::buffer.getNumSamples())); + // Initialization - auto bufferSamples = OversamplingEngine::buffer.getWritePointer (0); auto coeffs = coefficientsUp.getRawDataPointer(); - auto lv1 = v1Up.getRawDataPointer(); - auto numStages = coefficientsUp.size(); auto delayedStages = numStages / 2; auto directStages = numStages - delayedStages; + auto numSamples = inputBlock.getNumSamples(); // Processing - for (size_t i = 0; i < numSamples; i++) + for (size_t channel = 0; channel < inputBlock.getNumChannels(); channel++) { - // Direct path cascaded allpass filters - auto input = samples[i]; - for (auto n = 0; n < directStages; n++) - { - auto alpha = coeffs[n]; - auto output = alpha * input + lv1[n]; - lv1[n] = input - alpha * output; - input = output; - } + auto bufferSamples = OversamplingEngine::buffer.getWritePointer (static_cast (channel)); + auto lv1 = v1Up.getWritePointer (static_cast (channel)); + auto samples = inputBlock.getChannelPointer (channel); - // Output - bufferSamples[i << 1] = input; - - // Delayed path cascaded allpass filters - input = samples[i]; - for (auto n = directStages; n < numStages; n++) + for (size_t i = 0; i < numSamples; i++) { - auto alpha = coeffs[n]; - auto output = alpha * input + lv1[n]; - lv1[n] = input - alpha * output; - input = output; + // Direct path cascaded allpass filters + auto input = samples[i]; + for (auto n = 0; n < directStages; n++) + { + auto alpha = coeffs[n]; + auto output = alpha * input + lv1[n]; + lv1[n] = input - alpha * output; + input = output; + } + + // Output + bufferSamples[i << 1] = input; + + // Delayed path cascaded allpass filters + input = samples[i]; + for (auto n = directStages; n < numStages; n++) + { + auto alpha = coeffs[n]; + auto output = alpha * input + lv1[n]; + lv1[n] = input - alpha * output; + input = output; + } + + // Output + bufferSamples[(i << 1) + 1] = input; } - - // Output - bufferSamples[(i << 1) + 1] = input; } // Snap To Zero snapToZero (true); - } - void processSamplesDown (SampleType *samples, size_t numSamples) override + void processSamplesDown (dsp::AudioBlock &outputBlock) override { + jassert (outputBlock.getNumChannels() <= static_cast (OversamplingEngine::buffer.getNumChannels())); + jassert (outputBlock.getNumSamples() * OversamplingEngine::factor <= static_cast (OversamplingEngine::buffer.getNumSamples())); + // Initialization - auto bufferSamples = OversamplingEngine::buffer.getWritePointer (0); auto coeffs = coefficientsDown.getRawDataPointer(); - auto lv1 = v1Down.getRawDataPointer(); - auto numStages = coefficientsDown.size(); auto delayedStages = numStages / 2; auto directStages = numStages - delayedStages; + auto numSamples = outputBlock.getNumSamples(); // Processing - for (size_t i = 0; i < numSamples; i++) + for (size_t channel = 0; channel < outputBlock.getNumChannels(); channel++) { - // Direct path cascaded allpass filters - auto input = bufferSamples[i << 1]; - for (auto n = 0; n < directStages; n++) - { - auto alpha = coeffs[n]; - auto output = alpha * input + lv1[n]; - lv1[n] = input - alpha * output; - input = output; - } - auto directOut = input; + auto bufferSamples = OversamplingEngine::buffer.getWritePointer (static_cast (channel)); + auto lv1 = v1Down.getWritePointer (static_cast (channel)); + auto samples = outputBlock.getChannelPointer (channel); + auto delay = delayDown.getUnchecked (static_cast (channel)); - // Delayed path cascaded allpass filters - input = bufferSamples[(i << 1) + 1]; - for (auto n = directStages; n < numStages; n++) + for (size_t i = 0; i < numSamples; i++) { - auto alpha = coeffs[n]; - auto output = alpha * input + lv1[n]; - lv1[n] = input - alpha * output; - input = output; + // Direct path cascaded allpass filters + auto input = bufferSamples[i << 1]; + for (auto n = 0; n < directStages; n++) + { + auto alpha = coeffs[n]; + auto output = alpha * input + lv1[n]; + lv1[n] = input - alpha * output; + input = output; + } + auto directOut = input; + + // Delayed path cascaded allpass filters + input = bufferSamples[(i << 1) + 1]; + for (auto n = directStages; n < numStages; n++) + { + auto alpha = coeffs[n]; + auto output = alpha * input + lv1[n]; + lv1[n] = input - alpha * output; + input = output; + } + + // Output + samples[i] = (delay + directOut) * static_cast (0.5); + delay = input; } - // Output - samples[i] = (delayDown + directOut) * static_cast (0.5); - delayDown = input; + delayDown.setUnchecked (static_cast (channel), delay); } // Snap To Zero @@ -381,19 +435,25 @@ public: { if (snapUpProcessing) { - auto lv1 = v1Up.getRawDataPointer(); - auto numStages = coefficientsUp.size(); + for (auto channel = 0; channel < OversamplingEngine::buffer.getNumChannels(); channel++) + { + auto lv1 = v1Up.getWritePointer (channel); + auto numStages = coefficientsUp.size(); - for (auto n = 0; n < numStages; n++) - JUCE_SNAP_TO_ZERO (lv1[n]); + for (auto n = 0; n < numStages; n++) + JUCE_SNAP_TO_ZERO (lv1[n]); + } } else { - auto lv1 = v1Down.getRawDataPointer(); - auto numStages = coefficientsDown.size(); + for (auto channel = 0; channel < OversamplingEngine::buffer.getNumChannels(); channel++) + { + auto lv1 = v1Down.getWritePointer (channel); + auto numStages = coefficientsDown.size(); - for (auto n = 0; n < numStages; n++) - JUCE_SNAP_TO_ZERO (lv1[n]); + for (auto n = 0; n < numStages; n++) + JUCE_SNAP_TO_ZERO (lv1[n]); + } } } @@ -478,8 +538,8 @@ private: Array coefficientsUp, coefficientsDown; SampleType latency; - Array v1Up, v1Down; - SampleType delayDown; + AudioBuffer v1Up, v1Down; + Array delayDown; //=============================================================================== JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Oversampling2TimesPolyphaseIIR) @@ -492,43 +552,53 @@ Oversampling::Oversampling (size_t newNumChannels, size_t newFactor, { jassert (newFactor >= 0 && newFactor <= 4 && newNumChannels > 0); - factorOversampling = (size_t) 1 << newFactor; + factorOversampling = static_cast (1) << newFactor; isMaximumQuality = newMaxQuality; type = newType; numChannels = newNumChannels; if (newFactor == 0) { - for (size_t channel = 0; channel < numChannels; channel++) - engines.add (new OversamplingDummy()); - numStages = 1; + engines.add (new OversamplingDummy (numChannels)); } else if (type == FilterType::filterHalfBandPolyphaseIIR) { numStages = newFactor; - for (size_t channel = 0; channel < numChannels; channel++) - for (size_t n = 0; n < numStages; n++) - { - auto tw1 = (isMaximumQuality ? 0.10f : 0.12f); - auto tw2 = (isMaximumQuality ? 0.12f : 0.15f); + for (size_t n = 0; n < numStages; n++) + { + auto twUp = (isMaximumQuality ? 0.10f : 0.12f) * (n == 0 ? 0.5f : 1.f); + auto twDown = (isMaximumQuality ? 0.12f : 0.15f) * (n == 0 ? 0.5f : 1.f); - engines.add (new Oversampling2TimesPolyphaseIIR (tw1, -75.f + 10.f * n, tw2, -70.f + 10.f * n)); - } + auto gaindBStartUp = (isMaximumQuality ? -75.f : -65.f); + auto gaindBStartDown = (isMaximumQuality ? -70.f : -60.f); + auto gaindBFactorUp = (isMaximumQuality ? 10.f : 8.f); + auto gaindBFactorDown = (isMaximumQuality ? 10.f : 8.f); + + engines.add (new Oversampling2TimesPolyphaseIIR (numChannels, + twUp, gaindBStartUp + gaindBFactorUp * n, + twDown, gaindBStartDown + gaindBFactorDown * n)); + } } else if (type == FilterType::filterHalfBandFIREquiripple) { numStages = newFactor; - for (size_t channel = 0; channel < numChannels; channel++) - for (size_t n = 0; n < numStages; n++) - { - auto tw1 = (isMaximumQuality ? 0.10f : 0.12f); - auto tw2 = (isMaximumQuality ? 0.12f : 0.15f); + for (size_t n = 0; n < numStages; n++) + { + auto twUp = (isMaximumQuality ? 0.10f : 0.12f) * (n == 0 ? 0.5f : 1.f); + auto twDown = (isMaximumQuality ? 0.12f : 0.15f) * (n == 0 ? 0.5f : 1.f); - engines.add (new Oversampling2TimesEquirippleFIR (tw1, -90.f + 10.f * n, tw2, -70.f + 10.f * n)); - } + auto gaindBStartUp = (isMaximumQuality ? -90.f : -70.f); + auto gaindBStartDown = (isMaximumQuality ? -70.f : -60.f); + auto gaindBFactorUp = (isMaximumQuality ? 10.f : 8.f); + auto gaindBFactorDown = (isMaximumQuality ? 10.f : 8.f); + + engines.add (new Oversampling2TimesEquirippleFIR (numChannels, + twUp, gaindBStartUp + gaindBFactorUp * n, + twDown, gaindBStartDown + gaindBFactorDown * n)); + } } } @@ -550,7 +620,7 @@ SampleType Oversampling::getLatencyInSamples() noexcept auto& engine = *engines[static_cast (n)]; order *= engine.getFactor(); - latency += engine.getLatencyInSamples() / std::pow (static_cast (2), static_cast (order)); + latency += engine.getLatencyInSamples() / static_cast (order); } return latency; @@ -568,18 +638,14 @@ void Oversampling::initProcessing (size_t maximumNumberOfSamplesBefo { jassert (engines.size() > 0); - for (size_t channel = 0; channel < numChannels; channel++) - { - auto currentNumSamples = maximumNumberOfSamplesBeforeOversampling; - auto offset = numStages * channel; + auto currentNumSamples = maximumNumberOfSamplesBeforeOversampling; - for (size_t n = 0; n < numStages; n++) - { - auto& engine = *engines[static_cast (n + offset)]; + for (size_t n = 0; n < numStages; n++) + { + auto& engine = *engines[static_cast (n)]; - engine.initProcessing (currentNumSamples); - currentNumSamples *= engine.getFactor(); - } + engine.initProcessing (currentNumSamples); + currentNumSamples *= engine.getFactor(); } isReady = true; @@ -597,75 +663,49 @@ void Oversampling::reset() noexcept } template -typename dsp::AudioBlock Oversampling::getProcessedSamples() +typename dsp::AudioBlock Oversampling::processSamplesUp (const dsp::AudioBlock &inputBlock) noexcept { jassert (engines.size() > 0); - Array arrayChannels; - - for (size_t channel = 0; channel < numChannels; channel++) - arrayChannels.add (engines[static_cast (((channel + 1) * numStages) - 1)]->getProcessedSamples()); - - auto numSamples = engines[static_cast (numStages - 1)]->getNumProcessedSamples(); - auto block = dsp::AudioBlock (arrayChannels.getRawDataPointer(), numChannels, numSamples); - - return block; -} - -template -void Oversampling::processSamplesUp (dsp::AudioBlock &block) noexcept -{ - jassert (engines.size() > 0 && block.getNumChannels() <= numChannels); - if (! isReady) - return; - - for (size_t channel = 0; channel < jmin (numChannels, block.getNumChannels()); channel++) - { - SampleType* dataSamples = block.getChannelPointer (channel); - auto currentNumSamples = block.getNumSamples(); - auto offset = numStages * channel; + return dsp::AudioBlock(); - for (size_t n = 0; n < numStages; n++) - { - auto& engine = *engines[static_cast (n + offset)]; - engine.processSamplesUp (dataSamples, currentNumSamples); + dsp::AudioBlock audioBlock = inputBlock; - currentNumSamples *= engine.getFactor(); - dataSamples = engine.getProcessedSamples(); - } + for (size_t n = 0; n < numStages; n++) + { + auto& engine = *engines[static_cast (n)]; + engine.processSamplesUp (audioBlock); + audioBlock = engine.getProcessedSamples (audioBlock.getNumSamples() * engine.getFactor()); } + + return audioBlock; } template -void Oversampling::processSamplesDown (dsp::AudioBlock &block) noexcept +void Oversampling::processSamplesDown (dsp::AudioBlock &outputBlock) noexcept { - jassert (engines.size() > 0 && block.getNumChannels() <= numChannels); + jassert (engines.size() > 0); if (! isReady) return; - for (size_t channel = 0; channel < jmin (numChannels, block.getNumChannels()); channel++) - { - auto currentNumSamples = block.getNumSamples(); - auto offset = numStages * channel; - - for (size_t n = 0; n < numStages - 1; n++) - currentNumSamples *= engines[static_cast (n + offset)]->getFactor(); + auto currentNumSamples = outputBlock.getNumSamples(); - for (size_t n = numStages - 1; n > 0; n--) - { - auto& engine = *engines[static_cast (n + offset)]; + for (size_t n = 0; n < numStages - 1; n++) + currentNumSamples *= engines[static_cast (n)]->getFactor(); - auto dataSamples = engines[static_cast (n + offset - 1)]->getProcessedSamples(); - engine.processSamplesDown (dataSamples, currentNumSamples); + for (size_t n = numStages - 1; n > 0; n--) + { + auto& engine = *engines[static_cast (n)]; - currentNumSamples /= engine.getFactor(); - } + auto audioBlock = engines[static_cast (n - 1)]->getProcessedSamples (currentNumSamples); + engine.processSamplesDown (audioBlock); - engines[static_cast (offset)]->processSamplesDown (block.getChannelPointer (channel), currentNumSamples); + currentNumSamples /= engine.getFactor(); } + engines[static_cast (0)]->processSamplesDown (outputBlock); } template class Oversampling; diff --git a/modules/juce_dsp/processors/juce_Oversampling.h b/modules/juce_dsp/processors/juce_Oversampling.h index 0bcc7357a8..8b6da27c0c 100644 --- a/modules/juce_dsp/processors/juce_Oversampling.h +++ b/modules/juce_dsp/processors/juce_Oversampling.h @@ -87,6 +87,9 @@ public: in your main processor to compensate the additional latency involved with the oversampling, for example with a dry / wet functionality, and to report the latency to the DAW. + + Note : the latency might not be integer, so you might need to round its value + or to compensate it properly in your processing code. */ SampleType getLatencyInSamples() noexcept; @@ -102,21 +105,21 @@ public: /** Resets the processing pipeline, ready to oversample a new stream of data. */ void reset() noexcept; - /** Must be called to perform the upsampling, prior to any oversampled processing. */ - void processSamplesUp (dsp::AudioBlock &block) noexcept; + /** Must be called to perform the upsampling, prior to any oversampled processing. - /** Can be called to access to the oversampled input signal, to perform any non- - linear processing which needs the higher sample rate. Don't forget to set - the sample rate of that processing to N times the original sample rate. + Returns an AudioBlock referencing the oversampled input signal, which must be + used to perform the non-linear processing which needs the higher sample rate. + Don't forget to set the sample rate of that processing to N times the original + sample rate. */ - dsp::AudioBlock getProcessedSamples(); + dsp::AudioBlock processSamplesUp (const dsp::AudioBlock &inputBlock) noexcept; /** Must be called to perform the downsampling, after the upsampling and the non-linear processing. The output signal is probably delayed by the internal latency of the whole oversampling behaviour, so don't forget to take this into account. */ - void processSamplesDown (dsp::AudioBlock &block) noexcept; + void processSamplesDown (dsp::AudioBlock &outputBlock) noexcept; private: //=============================================================================== From cc6a417a1dfac5c37bf4626712b880f3b452987a Mon Sep 17 00:00:00 2001 From: hogliux Date: Wed, 6 Sep 2017 11:53:24 +0100 Subject: [PATCH 053/129] DSP: Removed left-over VS post-build commands from DSP module plugin demo sample --- .../VisualStudio2015/DSPModulePluginDemo_SharedCode.vcxproj | 6 ------ .../DSPModulePluginDemo_StandalonePlugin.vcxproj | 6 ------ .../Builds/VisualStudio2015/DSPModulePluginDemo_VST.vcxproj | 6 ------ .../DSP module plugin demo/DSP module plugin demo.jucer | 4 ++-- 4 files changed, 2 insertions(+), 20 deletions(-) diff --git a/examples/DSP module plugin demo/Builds/VisualStudio2015/DSPModulePluginDemo_SharedCode.vcxproj b/examples/DSP module plugin demo/Builds/VisualStudio2015/DSPModulePluginDemo_SharedCode.vcxproj index f977707fd1..c7b52988c6 100644 --- a/examples/DSP module plugin demo/Builds/VisualStudio2015/DSPModulePluginDemo_SharedCode.vcxproj +++ b/examples/DSP module plugin demo/Builds/VisualStudio2015/DSPModulePluginDemo_SharedCode.vcxproj @@ -101,9 +101,6 @@ true $(IntDir)\DSPModulePluginDemo.bsc - - if "$(ProjectName)"=="$(SolutionName)_VST" copy /Y "$(TargetDir)\$(TargetName).dll" "c:\vstplugins\musical entropy\$(TargetName).dll" - @@ -146,9 +143,6 @@ true $(IntDir)\DSPModulePluginDemo.bsc - - if "$(ProjectName)"=="$(SolutionName)_VST" copy /Y "$(TargetDir)\$(TargetName).dll" "c:\vstplugins\musical entropy\$(TargetName).dll" - diff --git a/examples/DSP module plugin demo/Builds/VisualStudio2015/DSPModulePluginDemo_StandalonePlugin.vcxproj b/examples/DSP module plugin demo/Builds/VisualStudio2015/DSPModulePluginDemo_StandalonePlugin.vcxproj index 96b3e8a143..793416403c 100644 --- a/examples/DSP module plugin demo/Builds/VisualStudio2015/DSPModulePluginDemo_StandalonePlugin.vcxproj +++ b/examples/DSP module plugin demo/Builds/VisualStudio2015/DSPModulePluginDemo_StandalonePlugin.vcxproj @@ -104,9 +104,6 @@ true $(IntDir)\DSPModulePluginDemo.bsc - - if "$(ProjectName)"=="$(SolutionName)_VST" copy /Y "$(TargetDir)\$(TargetName).dll" "c:\vstplugins\musical entropy\$(TargetName).dll" - @@ -150,9 +147,6 @@ true $(IntDir)\DSPModulePluginDemo.bsc - - if "$(ProjectName)"=="$(SolutionName)_VST" copy /Y "$(TargetDir)\$(TargetName).dll" "c:\vstplugins\musical entropy\$(TargetName).dll" - diff --git a/examples/DSP module plugin demo/Builds/VisualStudio2015/DSPModulePluginDemo_VST.vcxproj b/examples/DSP module plugin demo/Builds/VisualStudio2015/DSPModulePluginDemo_VST.vcxproj index 374cb6fed4..dfd834034f 100644 --- a/examples/DSP module plugin demo/Builds/VisualStudio2015/DSPModulePluginDemo_VST.vcxproj +++ b/examples/DSP module plugin demo/Builds/VisualStudio2015/DSPModulePluginDemo_VST.vcxproj @@ -104,9 +104,6 @@ true $(IntDir)\DSPModulePluginDemo.bsc - - if "$(ProjectName)"=="$(SolutionName)_VST" copy /Y "$(TargetDir)\$(TargetName).dll" "c:\vstplugins\musical entropy\$(TargetName).dll" - @@ -150,9 +147,6 @@ true $(IntDir)\DSPModulePluginDemo.bsc - - if "$(ProjectName)"=="$(SolutionName)_VST" copy /Y "$(TargetDir)\$(TargetName).dll" "c:\vstplugins\musical entropy\$(TargetName).dll" - diff --git a/examples/DSP module plugin demo/DSP module plugin demo.jucer b/examples/DSP module plugin demo/DSP module plugin demo.jucer index 7ee8df1779..67e37a1318 100644 --- a/examples/DSP module plugin demo/DSP module plugin demo.jucer +++ b/examples/DSP module plugin demo/DSP module plugin demo.jucer @@ -59,10 +59,10 @@ + warningsAreErrors="0" postbuildCommand=""/> + useRuntimeLibDLL="0" postbuildCommand=""/> From 3ba8c1f864a8d5612cf95b000379fca6575ee674 Mon Sep 17 00:00:00 2001 From: hogliux Date: Wed, 6 Sep 2017 12:48:21 +0100 Subject: [PATCH 054/129] iOS AUv3: Removed too strict API limitations to open URLs in AUv3s as iOS seems to allow this --- modules/juce_core/native/juce_mac_Files.mm | 3 --- 1 file changed, 3 deletions(-) diff --git a/modules/juce_core/native/juce_mac_Files.mm b/modules/juce_core/native/juce_mac_Files.mm index a88b4d444f..85ca9a39b3 100644 --- a/modules/juce_core/native/juce_mac_Files.mm +++ b/modules/juce_core/native/juce_mac_Files.mm @@ -399,9 +399,6 @@ bool JUCE_CALLTYPE Process::openDocument (const String& fileName, const String& #if JUCE_IOS ignoreUnused (parameters); - if (SystemStats::isRunningInAppExtensionSandbox()) - return false; - #if (! defined __IPHONE_OS_VERSION_MIN_REQUIRED) || (! defined __IPHONE_10_0) || (__IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_10_0) return [[UIApplication sharedApplication] openURL: filenameAsURL]; #else From 64e76146d916cb8fb36fb54073f50bc3240e5264 Mon Sep 17 00:00:00 2001 From: jules Date: Wed, 6 Sep 2017 14:12:41 +0100 Subject: [PATCH 055/129] Avoided a compiler error when using xcode with very old standard libraries --- modules/juce_core/text/juce_String.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/juce_core/text/juce_String.h b/modules/juce_core/text/juce_String.h index 563b67f0ae..8b5bf10e61 100644 --- a/modules/juce_core/text/juce_String.h +++ b/modules/juce_core/text/juce_String.h @@ -1412,6 +1412,7 @@ JUCE_API OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const Str JUCE_API OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, StringRef stringToWrite); +#if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS // just used to avoid compiling this under compilers that lack libc++ } // namespace juce namespace std @@ -1423,3 +1424,4 @@ namespace std } namespace juce { +#endif From 665b0a3e3adf076c4ec56f8884619ada9a186755 Mon Sep 17 00:00:00 2001 From: hogliux Date: Wed, 6 Sep 2017 14:29:50 +0100 Subject: [PATCH 056/129] VST3: Fixed the calculation of timeInSeconds AudioPlayHead information --- modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp b/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp index 3ef3e755cc..415a9d1519 100644 --- a/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp @@ -1651,7 +1651,7 @@ public: bool getCurrentPosition (CurrentPositionInfo& info) override { info.timeInSamples = jmax ((juce::int64) 0, processContext.projectTimeSamples); - info.timeInSeconds = processContext.systemTime / 1000000000.0; + info.timeInSeconds = static_cast (info.timeInSamples) / processContext.sampleRate; info.bpm = jmax (1.0, processContext.tempo); info.timeSigNumerator = jmax (1, (int) processContext.timeSigNumerator); info.timeSigDenominator = jmax (1, (int) processContext.timeSigDenominator); From d4e0ba0e4d1dd80ad4f49e5cfd9ed4280f896d41 Mon Sep 17 00:00:00 2001 From: hogliux Date: Wed, 6 Sep 2017 15:19:24 +0100 Subject: [PATCH 057/129] Android: Fixed an issue where the AlertWindow's callback would never be called if AlertWindows were dismissed by clicking outside the alert's window on Android --- .../native/java/JuceAppActivity.java | 33 +++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/modules/juce_core/native/java/JuceAppActivity.java b/modules/juce_core/native/java/JuceAppActivity.java index 6e8a898d99..16b3eeabc1 100644 --- a/modules/juce_core/native/java/JuceAppActivity.java +++ b/modules/juce_core/native/java/JuceAppActivity.java @@ -436,11 +436,18 @@ public class JuceAppActivity extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + JuceAppActivity.this.alertDismissed (callback, 0); + } + }) .setPositiveButton ("OK", new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); JuceAppActivity.this.alertDismissed (callback, 0); } }); @@ -455,11 +462,18 @@ public class JuceAppActivity extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + JuceAppActivity.this.alertDismissed (callback, 0); + } + }) .setPositiveButton (okButtonText.isEmpty() ? "OK" : okButtonText, new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); JuceAppActivity.this.alertDismissed (callback, 1); } }) @@ -467,7 +481,7 @@ public class JuceAppActivity extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); JuceAppActivity.this.alertDismissed (callback, 0); } }); @@ -481,11 +495,18 @@ public class JuceAppActivity extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + JuceAppActivity.this.alertDismissed (callback, 0); + } + }) .setPositiveButton ("Yes", new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); JuceAppActivity.this.alertDismissed (callback, 1); } }) @@ -493,7 +514,7 @@ public class JuceAppActivity extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); JuceAppActivity.this.alertDismissed (callback, 2); } }) @@ -501,7 +522,7 @@ public class JuceAppActivity extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); JuceAppActivity.this.alertDismissed (callback, 0); } }); From ede622c1effc9acfb09e2cb4b6c6960f4304c3cc Mon Sep 17 00:00:00 2001 From: hogliux Date: Wed, 6 Sep 2017 15:23:19 +0100 Subject: [PATCH 058/129] Re-saved all projects --- .../com/yourcompany/jucedemo/JuceDemo.java | 312 ++++++++++++------ .../Builds/Android/app/CMakeLists.txt | 2 +- .../InAppPurchase.java | 312 ++++++++++++------ .../InAppPurchase.xcodeproj/project.pbxproj | 2 + .../com/yourcompany/miditest/MidiTest.java | 312 ++++++++++++------ .../JUCENetworkGraphicsDemo.java | 312 ++++++++++++------ .../yourcompany/oscreceiver/OSCReceiver.java | 312 ++++++++++++------ .../com/yourcompany/oscsender/OSCSender.java | 312 ++++++++++++------ .../juce/jucedemoplugin/JuceDemoPlugin.java | 312 ++++++++++++------ .../AudioPerformanceTest.java | 312 ++++++++++++------ .../Projucer/JuceLibraryCode/BinaryData.cpp | 6 +- extras/Projucer/JuceLibraryCode/BinaryData.h | 2 +- 12 files changed, 1679 insertions(+), 829 deletions(-) diff --git a/examples/Demo/Builds/Android/app/src/main/java/com/yourcompany/jucedemo/JuceDemo.java b/examples/Demo/Builds/Android/app/src/main/java/com/yourcompany/jucedemo/JuceDemo.java index 4b248803c6..703e23abce 100644 --- a/examples/Demo/Builds/Android/app/src/main/java/com/yourcompany/jucedemo/JuceDemo.java +++ b/examples/Demo/Builds/Android/app/src/main/java/com/yourcompany/jucedemo/JuceDemo.java @@ -519,11 +519,18 @@ public class JuceDemo extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + JuceDemo.this.alertDismissed (callback, 0); + } + }) .setPositiveButton ("OK", new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); JuceDemo.this.alertDismissed (callback, 0); } }); @@ -538,11 +545,18 @@ public class JuceDemo extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + JuceDemo.this.alertDismissed (callback, 0); + } + }) .setPositiveButton (okButtonText.isEmpty() ? "OK" : okButtonText, new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); JuceDemo.this.alertDismissed (callback, 1); } }) @@ -550,7 +564,7 @@ public class JuceDemo extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); JuceDemo.this.alertDismissed (callback, 0); } }); @@ -564,11 +578,18 @@ public class JuceDemo extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + JuceDemo.this.alertDismissed (callback, 0); + } + }) .setPositiveButton ("Yes", new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); JuceDemo.this.alertDismissed (callback, 1); } }) @@ -576,7 +597,7 @@ public class JuceDemo extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); JuceDemo.this.alertDismissed (callback, 2); } }) @@ -584,7 +605,7 @@ public class JuceDemo extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); JuceDemo.this.alertDismissed (callback, 0); } }); @@ -982,13 +1003,75 @@ public class JuceDemo extends Activity //============================================================================== public static class HTTPStream { - public HTTPStream (HttpURLConnection connection_, - int[] statusCode_, - StringBuffer responseHeaders_) + public HTTPStream (String address, boolean isPostToUse, byte[] postDataToUse, + String headersToUse, int timeOutMsToUse, + int[] statusCodeToUse, StringBuffer responseHeadersToUse, + int numRedirectsToFollowToUse, String httpRequestCmdToUse) throws IOException { - connection = connection_; - statusCode = statusCode_; - responseHeaders = responseHeaders_; + isPost = isPostToUse; + postData = postDataToUse; + headers = headersToUse; + timeOutMs = timeOutMsToUse; + statusCode = statusCodeToUse; + responseHeaders = responseHeadersToUse; + totalLength = -1; + numRedirectsToFollow = numRedirectsToFollowToUse; + httpRequestCmd = httpRequestCmdToUse; + + connection = createConnection (address, isPost, postData, headers, timeOutMs, httpRequestCmd); + } + + private final HttpURLConnection createConnection (String address, boolean isPost, byte[] postData, + String headers, int timeOutMs, String httpRequestCmdToUse) throws IOException + { + HttpURLConnection newConnection = (HttpURLConnection) (new URL(address).openConnection()); + + try + { + newConnection.setInstanceFollowRedirects (false); + newConnection.setConnectTimeout (timeOutMs); + newConnection.setReadTimeout (timeOutMs); + + // headers - if not empty, this string is appended onto the headers that are used for the request. It must therefore be a valid set of HTML header directives, separated by newlines. + // So convert headers string to an array, with an element for each line + String headerLines[] = headers.split("\\n"); + + // Set request headers + for (int i = 0; i < headerLines.length; ++i) + { + int pos = headerLines[i].indexOf (":"); + + if (pos > 0 && pos < headerLines[i].length()) + { + String field = headerLines[i].substring (0, pos); + String value = headerLines[i].substring (pos + 1); + + if (value.length() > 0) + newConnection.setRequestProperty (field, value); + } + } + + newConnection.setRequestMethod (httpRequestCmd); + + if (isPost) + { + newConnection.setDoOutput (true); + + if (postData != null) + { + OutputStream out = newConnection.getOutputStream(); + out.write(postData); + out.flush(); + } + } + + return newConnection; + } + catch (Throwable e) + { + newConnection.disconnect(); + throw new IOException ("Connection error"); + } } private final InputStream getCancellableStream (final boolean isInput) throws ExecutionException @@ -1011,19 +1094,12 @@ public class JuceDemo extends Activity try { - if (connection.getConnectTimeout() > 0) - return streamFuture.get (connection.getConnectTimeout(), TimeUnit.MILLISECONDS); - else - return streamFuture.get(); + return streamFuture.get(); } catch (InterruptedException e) { return null; } - catch (TimeoutException e) - { - return null; - } catch (CancellationException e) { return null; @@ -1031,6 +1107,89 @@ public class JuceDemo extends Activity } public final boolean connect() + { + boolean result = false; + int numFollowedRedirects = 0; + + while (true) + { + result = doConnect(); + + if (! result) + return false; + + if (++numFollowedRedirects > numRedirectsToFollow) + break; + + int status = statusCode[0]; + + if (status == 301 || status == 302 || status == 303 || status == 307) + { + // Assumes only one occurrence of "Location" + int pos1 = responseHeaders.indexOf ("Location:") + 10; + int pos2 = responseHeaders.indexOf ("\n", pos1); + + if (pos2 > pos1) + { + String currentLocation = connection.getURL().toString(); + String newLocation = responseHeaders.substring (pos1, pos2); + + try + { + // Handle newLocation whether it's absolute or relative + URL baseUrl = new URL (currentLocation); + URL newUrl = new URL (baseUrl, newLocation); + String transformedNewLocation = newUrl.toString(); + + if (transformedNewLocation != currentLocation) + { + // Clear responseHeaders before next iteration + responseHeaders.delete (0, responseHeaders.length()); + + synchronized (createStreamLock) + { + if (hasBeenCancelled.get()) + return false; + + connection.disconnect(); + + try + { + connection = createConnection (transformedNewLocation, isPost, + postData, headers, timeOutMs, + httpRequestCmd); + } + catch (Throwable e) + { + return false; + } + } + } + else + { + break; + } + } + catch (Throwable e) + { + return false; + } + } + else + { + break; + } + } + else + { + break; + } + } + + return result; + } + + private final boolean doConnect() { synchronized (createStreamLock) { @@ -1068,9 +1227,16 @@ public class JuceDemo extends Activity {} for (java.util.Map.Entry> entry : connection.getHeaderFields().entrySet()) + { if (entry.getKey() != null && entry.getValue() != null) - responseHeaders.append (entry.getKey() + ": " - + android.text.TextUtils.join (",", entry.getValue()) + "\n"); + { + responseHeaders.append(entry.getKey() + ": " + + android.text.TextUtils.join(",", entry.getValue()) + "\n"); + + if (entry.getKey().compareTo ("Content-Length") == 0) + totalLength = Integer.decode (entry.getValue().get (0)); + } + } return true; } @@ -1173,13 +1339,20 @@ public class JuceDemo extends Activity } public final long getPosition() { return position; } - public final long getTotalLength() { return -1; } + public final long getTotalLength() { return totalLength; } public final boolean isExhausted() { return false; } public final boolean setPosition (long newPos) { return false; } + private boolean isPost; + private byte[] postData; + private String headers; + private int timeOutMs; + String httpRequestCmd; private HttpURLConnection connection; private int[] statusCode; private StringBuffer responseHeaders; + private int totalLength; + private int numRedirectsToFollow; private InputStream inputStream; private long position; private final ReentrantLock createStreamLock = new ReentrantLock(); @@ -1201,89 +1374,15 @@ public class JuceDemo extends Activity else if (timeOutMs == 0) timeOutMs = 30000; - // headers - if not empty, this string is appended onto the headers that are used for the request. It must therefore be a valid set of HTML header directives, separated by newlines. - // So convert headers string to an array, with an element for each line - String headerLines[] = headers.split("\\n"); - for (;;) { try { - HttpURLConnection connection = (HttpURLConnection) (new URL(address).openConnection()); - - if (connection != null) - { - try - { - connection.setInstanceFollowRedirects (false); - connection.setConnectTimeout (timeOutMs); - connection.setReadTimeout (timeOutMs); + HTTPStream httpStream = new HTTPStream (address, isPost, postData, headers, + timeOutMs, statusCode, responseHeaders, + numRedirectsToFollow, httpRequestCmd); - // Set request headers - for (int i = 0; i < headerLines.length; ++i) - { - int pos = headerLines[i].indexOf (":"); - - if (pos > 0 && pos < headerLines[i].length()) - { - String field = headerLines[i].substring (0, pos); - String value = headerLines[i].substring (pos + 1); - - if (value.length() > 0) - connection.setRequestProperty (field, value); - } - } - - connection.setRequestMethod (httpRequestCmd); - if (isPost) - { - connection.setDoOutput (true); - - if (postData != null) - { - OutputStream out = connection.getOutputStream(); - out.write(postData); - out.flush(); - } - } - - HTTPStream httpStream = new HTTPStream (connection, statusCode, responseHeaders); - - // Process redirect & continue as necessary - int status = statusCode[0]; - - if (--numRedirectsToFollow >= 0 - && (status == 301 || status == 302 || status == 303 || status == 307)) - { - // Assumes only one occurrence of "Location" - int pos1 = responseHeaders.indexOf ("Location:") + 10; - int pos2 = responseHeaders.indexOf ("\n", pos1); - - if (pos2 > pos1) - { - String newLocation = responseHeaders.substring(pos1, pos2); - // Handle newLocation whether it's absolute or relative - URL baseUrl = new URL (address); - URL newUrl = new URL (baseUrl, newLocation); - String transformedNewLocation = newUrl.toString(); - - if (transformedNewLocation != address) - { - address = transformedNewLocation; - // Clear responseHeaders before next iteration - responseHeaders.delete (0, responseHeaders.length()); - continue; - } - } - } - - return httpStream; - } - catch (Throwable e) - { - connection.disconnect(); - } - } + return httpStream; } catch (Throwable e) {} @@ -1309,7 +1408,14 @@ public class JuceDemo extends Activity return Environment.getExternalStoragePublicDirectory (type).getAbsolutePath(); } - public static final String getDocumentsFolder() { return Environment.getDataDirectory().getAbsolutePath(); } + public static final String getDocumentsFolder() + { + if (getAndroidSDKVersion() >= 19) + return getFileLocation ("Documents"); + + return Environment.getDataDirectory().getAbsolutePath(); + } + public static final String getPicturesFolder() { return getFileLocation (Environment.DIRECTORY_PICTURES); } public static final String getMusicFolder() { return getFileLocation (Environment.DIRECTORY_MUSIC); } public static final String getMoviesFolder() { return getFileLocation (Environment.DIRECTORY_MOVIES); } @@ -1404,7 +1510,7 @@ public class JuceDemo extends Activity return null; } - public final int getAndroidSDKVersion() + public static final int getAndroidSDKVersion() { return android.os.Build.VERSION.SDK_INT; } diff --git a/examples/InAppPurchase/Builds/Android/app/CMakeLists.txt b/examples/InAppPurchase/Builds/Android/app/CMakeLists.txt index 089a14d0b7..eedb74d85b 100644 --- a/examples/InAppPurchase/Builds/Android/app/CMakeLists.txt +++ b/examples/InAppPurchase/Builds/Android/app/CMakeLists.txt @@ -8,7 +8,7 @@ SET(BINARY_NAME "juce_jni") add_library("cpufeatures" STATIC "${ANDROID_NDK}/sources/android/cpufeatures/cpu-features.c") set_source_files_properties("${ANDROID_NDK}/sources/android/cpufeatures/cpu-features.c" PROPERTIES COMPILE_FLAGS "-Wno-sign-conversion -Wno-gnu-statement-expression") -add_definitions("-DJUCE_ANDROID=1" "-DJUCE_ANDROID_API_VERSION=10" "-DJUCE_ANDROID_ACTIVITY_CLASSNAME=com_roli_juceinapppurchasesample_InAppPurchase" "-DJUCE_ANDROID_ACTIVITY_CLASSPATH=\"com/roli/juceinapppurchasesample/InAppPurchase\"" "-DJUCER_ANDROIDSTUDIO_7F0E4A25=1" "-DJUCE_APP_VERSION=0.0.2" "-DJUCE_APP_VERSION_HEX=0x2") +add_definitions("-DJUCE_ANDROID=1" "-DJUCE_ANDROID_API_VERSION=10" "-DJUCE_ANDROID_ACTIVITY_CLASSNAME=com_roli_juceinapppurchasesample_InAppPurchase" "-DJUCE_ANDROID_ACTIVITY_CLASSPATH=\"com/roli/juceinapppurchasesample/InAppPurchase\"" "-DJUCE_IN_APP_PURCHASES=1" "-DJUCER_ANDROIDSTUDIO_7F0E4A25=1" "-DJUCE_APP_VERSION=0.0.2" "-DJUCE_APP_VERSION_HEX=0x2") include_directories( AFTER "../../../JuceLibraryCode" diff --git a/examples/InAppPurchase/Builds/Android/app/src/main/java/com/roli/juceinapppurchasesample/InAppPurchase.java b/examples/InAppPurchase/Builds/Android/app/src/main/java/com/roli/juceinapppurchasesample/InAppPurchase.java index 3843d8fa1c..05a6ab9409 100644 --- a/examples/InAppPurchase/Builds/Android/app/src/main/java/com/roli/juceinapppurchasesample/InAppPurchase.java +++ b/examples/InAppPurchase/Builds/Android/app/src/main/java/com/roli/juceinapppurchasesample/InAppPurchase.java @@ -519,11 +519,18 @@ public class InAppPurchase extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + InAppPurchase.this.alertDismissed (callback, 0); + } + }) .setPositiveButton ("OK", new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); InAppPurchase.this.alertDismissed (callback, 0); } }); @@ -538,11 +545,18 @@ public class InAppPurchase extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + InAppPurchase.this.alertDismissed (callback, 0); + } + }) .setPositiveButton (okButtonText.isEmpty() ? "OK" : okButtonText, new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); InAppPurchase.this.alertDismissed (callback, 1); } }) @@ -550,7 +564,7 @@ public class InAppPurchase extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); InAppPurchase.this.alertDismissed (callback, 0); } }); @@ -564,11 +578,18 @@ public class InAppPurchase extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + InAppPurchase.this.alertDismissed (callback, 0); + } + }) .setPositiveButton ("Yes", new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); InAppPurchase.this.alertDismissed (callback, 1); } }) @@ -576,7 +597,7 @@ public class InAppPurchase extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); InAppPurchase.this.alertDismissed (callback, 2); } }) @@ -584,7 +605,7 @@ public class InAppPurchase extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); InAppPurchase.this.alertDismissed (callback, 0); } }); @@ -982,13 +1003,75 @@ public class InAppPurchase extends Activity //============================================================================== public static class HTTPStream { - public HTTPStream (HttpURLConnection connection_, - int[] statusCode_, - StringBuffer responseHeaders_) + public HTTPStream (String address, boolean isPostToUse, byte[] postDataToUse, + String headersToUse, int timeOutMsToUse, + int[] statusCodeToUse, StringBuffer responseHeadersToUse, + int numRedirectsToFollowToUse, String httpRequestCmdToUse) throws IOException { - connection = connection_; - statusCode = statusCode_; - responseHeaders = responseHeaders_; + isPost = isPostToUse; + postData = postDataToUse; + headers = headersToUse; + timeOutMs = timeOutMsToUse; + statusCode = statusCodeToUse; + responseHeaders = responseHeadersToUse; + totalLength = -1; + numRedirectsToFollow = numRedirectsToFollowToUse; + httpRequestCmd = httpRequestCmdToUse; + + connection = createConnection (address, isPost, postData, headers, timeOutMs, httpRequestCmd); + } + + private final HttpURLConnection createConnection (String address, boolean isPost, byte[] postData, + String headers, int timeOutMs, String httpRequestCmdToUse) throws IOException + { + HttpURLConnection newConnection = (HttpURLConnection) (new URL(address).openConnection()); + + try + { + newConnection.setInstanceFollowRedirects (false); + newConnection.setConnectTimeout (timeOutMs); + newConnection.setReadTimeout (timeOutMs); + + // headers - if not empty, this string is appended onto the headers that are used for the request. It must therefore be a valid set of HTML header directives, separated by newlines. + // So convert headers string to an array, with an element for each line + String headerLines[] = headers.split("\\n"); + + // Set request headers + for (int i = 0; i < headerLines.length; ++i) + { + int pos = headerLines[i].indexOf (":"); + + if (pos > 0 && pos < headerLines[i].length()) + { + String field = headerLines[i].substring (0, pos); + String value = headerLines[i].substring (pos + 1); + + if (value.length() > 0) + newConnection.setRequestProperty (field, value); + } + } + + newConnection.setRequestMethod (httpRequestCmd); + + if (isPost) + { + newConnection.setDoOutput (true); + + if (postData != null) + { + OutputStream out = newConnection.getOutputStream(); + out.write(postData); + out.flush(); + } + } + + return newConnection; + } + catch (Throwable e) + { + newConnection.disconnect(); + throw new IOException ("Connection error"); + } } private final InputStream getCancellableStream (final boolean isInput) throws ExecutionException @@ -1011,19 +1094,12 @@ public class InAppPurchase extends Activity try { - if (connection.getConnectTimeout() > 0) - return streamFuture.get (connection.getConnectTimeout(), TimeUnit.MILLISECONDS); - else - return streamFuture.get(); + return streamFuture.get(); } catch (InterruptedException e) { return null; } - catch (TimeoutException e) - { - return null; - } catch (CancellationException e) { return null; @@ -1031,6 +1107,89 @@ public class InAppPurchase extends Activity } public final boolean connect() + { + boolean result = false; + int numFollowedRedirects = 0; + + while (true) + { + result = doConnect(); + + if (! result) + return false; + + if (++numFollowedRedirects > numRedirectsToFollow) + break; + + int status = statusCode[0]; + + if (status == 301 || status == 302 || status == 303 || status == 307) + { + // Assumes only one occurrence of "Location" + int pos1 = responseHeaders.indexOf ("Location:") + 10; + int pos2 = responseHeaders.indexOf ("\n", pos1); + + if (pos2 > pos1) + { + String currentLocation = connection.getURL().toString(); + String newLocation = responseHeaders.substring (pos1, pos2); + + try + { + // Handle newLocation whether it's absolute or relative + URL baseUrl = new URL (currentLocation); + URL newUrl = new URL (baseUrl, newLocation); + String transformedNewLocation = newUrl.toString(); + + if (transformedNewLocation != currentLocation) + { + // Clear responseHeaders before next iteration + responseHeaders.delete (0, responseHeaders.length()); + + synchronized (createStreamLock) + { + if (hasBeenCancelled.get()) + return false; + + connection.disconnect(); + + try + { + connection = createConnection (transformedNewLocation, isPost, + postData, headers, timeOutMs, + httpRequestCmd); + } + catch (Throwable e) + { + return false; + } + } + } + else + { + break; + } + } + catch (Throwable e) + { + return false; + } + } + else + { + break; + } + } + else + { + break; + } + } + + return result; + } + + private final boolean doConnect() { synchronized (createStreamLock) { @@ -1068,9 +1227,16 @@ public class InAppPurchase extends Activity {} for (java.util.Map.Entry> entry : connection.getHeaderFields().entrySet()) + { if (entry.getKey() != null && entry.getValue() != null) - responseHeaders.append (entry.getKey() + ": " - + android.text.TextUtils.join (",", entry.getValue()) + "\n"); + { + responseHeaders.append(entry.getKey() + ": " + + android.text.TextUtils.join(",", entry.getValue()) + "\n"); + + if (entry.getKey().compareTo ("Content-Length") == 0) + totalLength = Integer.decode (entry.getValue().get (0)); + } + } return true; } @@ -1173,13 +1339,20 @@ public class InAppPurchase extends Activity } public final long getPosition() { return position; } - public final long getTotalLength() { return -1; } + public final long getTotalLength() { return totalLength; } public final boolean isExhausted() { return false; } public final boolean setPosition (long newPos) { return false; } + private boolean isPost; + private byte[] postData; + private String headers; + private int timeOutMs; + String httpRequestCmd; private HttpURLConnection connection; private int[] statusCode; private StringBuffer responseHeaders; + private int totalLength; + private int numRedirectsToFollow; private InputStream inputStream; private long position; private final ReentrantLock createStreamLock = new ReentrantLock(); @@ -1201,89 +1374,15 @@ public class InAppPurchase extends Activity else if (timeOutMs == 0) timeOutMs = 30000; - // headers - if not empty, this string is appended onto the headers that are used for the request. It must therefore be a valid set of HTML header directives, separated by newlines. - // So convert headers string to an array, with an element for each line - String headerLines[] = headers.split("\\n"); - for (;;) { try { - HttpURLConnection connection = (HttpURLConnection) (new URL(address).openConnection()); - - if (connection != null) - { - try - { - connection.setInstanceFollowRedirects (false); - connection.setConnectTimeout (timeOutMs); - connection.setReadTimeout (timeOutMs); + HTTPStream httpStream = new HTTPStream (address, isPost, postData, headers, + timeOutMs, statusCode, responseHeaders, + numRedirectsToFollow, httpRequestCmd); - // Set request headers - for (int i = 0; i < headerLines.length; ++i) - { - int pos = headerLines[i].indexOf (":"); - - if (pos > 0 && pos < headerLines[i].length()) - { - String field = headerLines[i].substring (0, pos); - String value = headerLines[i].substring (pos + 1); - - if (value.length() > 0) - connection.setRequestProperty (field, value); - } - } - - connection.setRequestMethod (httpRequestCmd); - if (isPost) - { - connection.setDoOutput (true); - - if (postData != null) - { - OutputStream out = connection.getOutputStream(); - out.write(postData); - out.flush(); - } - } - - HTTPStream httpStream = new HTTPStream (connection, statusCode, responseHeaders); - - // Process redirect & continue as necessary - int status = statusCode[0]; - - if (--numRedirectsToFollow >= 0 - && (status == 301 || status == 302 || status == 303 || status == 307)) - { - // Assumes only one occurrence of "Location" - int pos1 = responseHeaders.indexOf ("Location:") + 10; - int pos2 = responseHeaders.indexOf ("\n", pos1); - - if (pos2 > pos1) - { - String newLocation = responseHeaders.substring(pos1, pos2); - // Handle newLocation whether it's absolute or relative - URL baseUrl = new URL (address); - URL newUrl = new URL (baseUrl, newLocation); - String transformedNewLocation = newUrl.toString(); - - if (transformedNewLocation != address) - { - address = transformedNewLocation; - // Clear responseHeaders before next iteration - responseHeaders.delete (0, responseHeaders.length()); - continue; - } - } - } - - return httpStream; - } - catch (Throwable e) - { - connection.disconnect(); - } - } + return httpStream; } catch (Throwable e) {} @@ -1309,7 +1408,14 @@ public class InAppPurchase extends Activity return Environment.getExternalStoragePublicDirectory (type).getAbsolutePath(); } - public static final String getDocumentsFolder() { return Environment.getDataDirectory().getAbsolutePath(); } + public static final String getDocumentsFolder() + { + if (getAndroidSDKVersion() >= 19) + return getFileLocation ("Documents"); + + return Environment.getDataDirectory().getAbsolutePath(); + } + public static final String getPicturesFolder() { return getFileLocation (Environment.DIRECTORY_PICTURES); } public static final String getMusicFolder() { return getFileLocation (Environment.DIRECTORY_MUSIC); } public static final String getMoviesFolder() { return getFileLocation (Environment.DIRECTORY_MOVIES); } @@ -1404,7 +1510,7 @@ public class InAppPurchase extends Activity return null; } - public final int getAndroidSDKVersion() + public static final int getAndroidSDKVersion() { return android.os.Build.VERSION.SDK_INT; } diff --git a/examples/InAppPurchase/Builds/iOS/InAppPurchase.xcodeproj/project.pbxproj b/examples/InAppPurchase/Builds/iOS/InAppPurchase.xcodeproj/project.pbxproj index 92aa55501a..e74d1b597e 100644 --- a/examples/InAppPurchase/Builds/iOS/InAppPurchase.xcodeproj/project.pbxproj +++ b/examples/InAppPurchase/Builds/iOS/InAppPurchase.xcodeproj/project.pbxproj @@ -223,6 +223,7 @@ GCC_PREPROCESSOR_DEFINITIONS = ( "_DEBUG=1", "DEBUG=1", + "JUCE_IN_APP_PURCHASES=1", "JUCER_XCODE_IPHONE_5BC26AE3=1", "JUCE_APP_VERSION=0.0.2", "JUCE_APP_VERSION_HEX=0x2", @@ -254,6 +255,7 @@ GCC_PREPROCESSOR_DEFINITIONS = ( "_NDEBUG=1", "NDEBUG=1", + "JUCE_IN_APP_PURCHASES=1", "JUCER_XCODE_IPHONE_5BC26AE3=1", "JUCE_APP_VERSION=0.0.2", "JUCE_APP_VERSION_HEX=0x2", diff --git a/examples/MidiTest/Builds/Android/app/src/main/java/com/yourcompany/miditest/MidiTest.java b/examples/MidiTest/Builds/Android/app/src/main/java/com/yourcompany/miditest/MidiTest.java index 9afbb4fa1d..5eeb94785f 100644 --- a/examples/MidiTest/Builds/Android/app/src/main/java/com/yourcompany/miditest/MidiTest.java +++ b/examples/MidiTest/Builds/Android/app/src/main/java/com/yourcompany/miditest/MidiTest.java @@ -1448,11 +1448,18 @@ public class MidiTest extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + MidiTest.this.alertDismissed (callback, 0); + } + }) .setPositiveButton ("OK", new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); MidiTest.this.alertDismissed (callback, 0); } }); @@ -1467,11 +1474,18 @@ public class MidiTest extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + MidiTest.this.alertDismissed (callback, 0); + } + }) .setPositiveButton (okButtonText.isEmpty() ? "OK" : okButtonText, new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); MidiTest.this.alertDismissed (callback, 1); } }) @@ -1479,7 +1493,7 @@ public class MidiTest extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); MidiTest.this.alertDismissed (callback, 0); } }); @@ -1493,11 +1507,18 @@ public class MidiTest extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + MidiTest.this.alertDismissed (callback, 0); + } + }) .setPositiveButton ("Yes", new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); MidiTest.this.alertDismissed (callback, 1); } }) @@ -1505,7 +1526,7 @@ public class MidiTest extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); MidiTest.this.alertDismissed (callback, 2); } }) @@ -1513,7 +1534,7 @@ public class MidiTest extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); MidiTest.this.alertDismissed (callback, 0); } }); @@ -1911,13 +1932,75 @@ public class MidiTest extends Activity //============================================================================== public static class HTTPStream { - public HTTPStream (HttpURLConnection connection_, - int[] statusCode_, - StringBuffer responseHeaders_) + public HTTPStream (String address, boolean isPostToUse, byte[] postDataToUse, + String headersToUse, int timeOutMsToUse, + int[] statusCodeToUse, StringBuffer responseHeadersToUse, + int numRedirectsToFollowToUse, String httpRequestCmdToUse) throws IOException { - connection = connection_; - statusCode = statusCode_; - responseHeaders = responseHeaders_; + isPost = isPostToUse; + postData = postDataToUse; + headers = headersToUse; + timeOutMs = timeOutMsToUse; + statusCode = statusCodeToUse; + responseHeaders = responseHeadersToUse; + totalLength = -1; + numRedirectsToFollow = numRedirectsToFollowToUse; + httpRequestCmd = httpRequestCmdToUse; + + connection = createConnection (address, isPost, postData, headers, timeOutMs, httpRequestCmd); + } + + private final HttpURLConnection createConnection (String address, boolean isPost, byte[] postData, + String headers, int timeOutMs, String httpRequestCmdToUse) throws IOException + { + HttpURLConnection newConnection = (HttpURLConnection) (new URL(address).openConnection()); + + try + { + newConnection.setInstanceFollowRedirects (false); + newConnection.setConnectTimeout (timeOutMs); + newConnection.setReadTimeout (timeOutMs); + + // headers - if not empty, this string is appended onto the headers that are used for the request. It must therefore be a valid set of HTML header directives, separated by newlines. + // So convert headers string to an array, with an element for each line + String headerLines[] = headers.split("\\n"); + + // Set request headers + for (int i = 0; i < headerLines.length; ++i) + { + int pos = headerLines[i].indexOf (":"); + + if (pos > 0 && pos < headerLines[i].length()) + { + String field = headerLines[i].substring (0, pos); + String value = headerLines[i].substring (pos + 1); + + if (value.length() > 0) + newConnection.setRequestProperty (field, value); + } + } + + newConnection.setRequestMethod (httpRequestCmd); + + if (isPost) + { + newConnection.setDoOutput (true); + + if (postData != null) + { + OutputStream out = newConnection.getOutputStream(); + out.write(postData); + out.flush(); + } + } + + return newConnection; + } + catch (Throwable e) + { + newConnection.disconnect(); + throw new IOException ("Connection error"); + } } private final InputStream getCancellableStream (final boolean isInput) throws ExecutionException @@ -1940,19 +2023,12 @@ public class MidiTest extends Activity try { - if (connection.getConnectTimeout() > 0) - return streamFuture.get (connection.getConnectTimeout(), TimeUnit.MILLISECONDS); - else - return streamFuture.get(); + return streamFuture.get(); } catch (InterruptedException e) { return null; } - catch (TimeoutException e) - { - return null; - } catch (CancellationException e) { return null; @@ -1960,6 +2036,89 @@ public class MidiTest extends Activity } public final boolean connect() + { + boolean result = false; + int numFollowedRedirects = 0; + + while (true) + { + result = doConnect(); + + if (! result) + return false; + + if (++numFollowedRedirects > numRedirectsToFollow) + break; + + int status = statusCode[0]; + + if (status == 301 || status == 302 || status == 303 || status == 307) + { + // Assumes only one occurrence of "Location" + int pos1 = responseHeaders.indexOf ("Location:") + 10; + int pos2 = responseHeaders.indexOf ("\n", pos1); + + if (pos2 > pos1) + { + String currentLocation = connection.getURL().toString(); + String newLocation = responseHeaders.substring (pos1, pos2); + + try + { + // Handle newLocation whether it's absolute or relative + URL baseUrl = new URL (currentLocation); + URL newUrl = new URL (baseUrl, newLocation); + String transformedNewLocation = newUrl.toString(); + + if (transformedNewLocation != currentLocation) + { + // Clear responseHeaders before next iteration + responseHeaders.delete (0, responseHeaders.length()); + + synchronized (createStreamLock) + { + if (hasBeenCancelled.get()) + return false; + + connection.disconnect(); + + try + { + connection = createConnection (transformedNewLocation, isPost, + postData, headers, timeOutMs, + httpRequestCmd); + } + catch (Throwable e) + { + return false; + } + } + } + else + { + break; + } + } + catch (Throwable e) + { + return false; + } + } + else + { + break; + } + } + else + { + break; + } + } + + return result; + } + + private final boolean doConnect() { synchronized (createStreamLock) { @@ -1997,9 +2156,16 @@ public class MidiTest extends Activity {} for (java.util.Map.Entry> entry : connection.getHeaderFields().entrySet()) + { if (entry.getKey() != null && entry.getValue() != null) - responseHeaders.append (entry.getKey() + ": " - + android.text.TextUtils.join (",", entry.getValue()) + "\n"); + { + responseHeaders.append(entry.getKey() + ": " + + android.text.TextUtils.join(",", entry.getValue()) + "\n"); + + if (entry.getKey().compareTo ("Content-Length") == 0) + totalLength = Integer.decode (entry.getValue().get (0)); + } + } return true; } @@ -2102,13 +2268,20 @@ public class MidiTest extends Activity } public final long getPosition() { return position; } - public final long getTotalLength() { return -1; } + public final long getTotalLength() { return totalLength; } public final boolean isExhausted() { return false; } public final boolean setPosition (long newPos) { return false; } + private boolean isPost; + private byte[] postData; + private String headers; + private int timeOutMs; + String httpRequestCmd; private HttpURLConnection connection; private int[] statusCode; private StringBuffer responseHeaders; + private int totalLength; + private int numRedirectsToFollow; private InputStream inputStream; private long position; private final ReentrantLock createStreamLock = new ReentrantLock(); @@ -2130,89 +2303,15 @@ public class MidiTest extends Activity else if (timeOutMs == 0) timeOutMs = 30000; - // headers - if not empty, this string is appended onto the headers that are used for the request. It must therefore be a valid set of HTML header directives, separated by newlines. - // So convert headers string to an array, with an element for each line - String headerLines[] = headers.split("\\n"); - for (;;) { try { - HttpURLConnection connection = (HttpURLConnection) (new URL(address).openConnection()); + HTTPStream httpStream = new HTTPStream (address, isPost, postData, headers, + timeOutMs, statusCode, responseHeaders, + numRedirectsToFollow, httpRequestCmd); - if (connection != null) - { - try - { - connection.setInstanceFollowRedirects (false); - connection.setConnectTimeout (timeOutMs); - connection.setReadTimeout (timeOutMs); - - // Set request headers - for (int i = 0; i < headerLines.length; ++i) - { - int pos = headerLines[i].indexOf (":"); - - if (pos > 0 && pos < headerLines[i].length()) - { - String field = headerLines[i].substring (0, pos); - String value = headerLines[i].substring (pos + 1); - - if (value.length() > 0) - connection.setRequestProperty (field, value); - } - } - - connection.setRequestMethod (httpRequestCmd); - if (isPost) - { - connection.setDoOutput (true); - - if (postData != null) - { - OutputStream out = connection.getOutputStream(); - out.write(postData); - out.flush(); - } - } - - HTTPStream httpStream = new HTTPStream (connection, statusCode, responseHeaders); - - // Process redirect & continue as necessary - int status = statusCode[0]; - - if (--numRedirectsToFollow >= 0 - && (status == 301 || status == 302 || status == 303 || status == 307)) - { - // Assumes only one occurrence of "Location" - int pos1 = responseHeaders.indexOf ("Location:") + 10; - int pos2 = responseHeaders.indexOf ("\n", pos1); - - if (pos2 > pos1) - { - String newLocation = responseHeaders.substring(pos1, pos2); - // Handle newLocation whether it's absolute or relative - URL baseUrl = new URL (address); - URL newUrl = new URL (baseUrl, newLocation); - String transformedNewLocation = newUrl.toString(); - - if (transformedNewLocation != address) - { - address = transformedNewLocation; - // Clear responseHeaders before next iteration - responseHeaders.delete (0, responseHeaders.length()); - continue; - } - } - } - - return httpStream; - } - catch (Throwable e) - { - connection.disconnect(); - } - } + return httpStream; } catch (Throwable e) {} @@ -2238,7 +2337,14 @@ public class MidiTest extends Activity return Environment.getExternalStoragePublicDirectory (type).getAbsolutePath(); } - public static final String getDocumentsFolder() { return Environment.getDataDirectory().getAbsolutePath(); } + public static final String getDocumentsFolder() + { + if (getAndroidSDKVersion() >= 19) + return getFileLocation ("Documents"); + + return Environment.getDataDirectory().getAbsolutePath(); + } + public static final String getPicturesFolder() { return getFileLocation (Environment.DIRECTORY_PICTURES); } public static final String getMusicFolder() { return getFileLocation (Environment.DIRECTORY_MUSIC); } public static final String getMoviesFolder() { return getFileLocation (Environment.DIRECTORY_MOVIES); } @@ -2333,7 +2439,7 @@ public class MidiTest extends Activity return null; } - public final int getAndroidSDKVersion() + public static final int getAndroidSDKVersion() { return android.os.Build.VERSION.SDK_INT; } diff --git a/examples/NetworkGraphicsDemo/Builds/Android/app/src/main/java/com/juce/networkgraphicsdemo/JUCENetworkGraphicsDemo.java b/examples/NetworkGraphicsDemo/Builds/Android/app/src/main/java/com/juce/networkgraphicsdemo/JUCENetworkGraphicsDemo.java index c8085c28d3..bac81b0d10 100644 --- a/examples/NetworkGraphicsDemo/Builds/Android/app/src/main/java/com/juce/networkgraphicsdemo/JUCENetworkGraphicsDemo.java +++ b/examples/NetworkGraphicsDemo/Builds/Android/app/src/main/java/com/juce/networkgraphicsdemo/JUCENetworkGraphicsDemo.java @@ -519,11 +519,18 @@ public class JUCENetworkGraphicsDemo extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + JUCENetworkGraphicsDemo.this.alertDismissed (callback, 0); + } + }) .setPositiveButton ("OK", new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); JUCENetworkGraphicsDemo.this.alertDismissed (callback, 0); } }); @@ -538,11 +545,18 @@ public class JUCENetworkGraphicsDemo extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + JUCENetworkGraphicsDemo.this.alertDismissed (callback, 0); + } + }) .setPositiveButton (okButtonText.isEmpty() ? "OK" : okButtonText, new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); JUCENetworkGraphicsDemo.this.alertDismissed (callback, 1); } }) @@ -550,7 +564,7 @@ public class JUCENetworkGraphicsDemo extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); JUCENetworkGraphicsDemo.this.alertDismissed (callback, 0); } }); @@ -564,11 +578,18 @@ public class JUCENetworkGraphicsDemo extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + JUCENetworkGraphicsDemo.this.alertDismissed (callback, 0); + } + }) .setPositiveButton ("Yes", new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); JUCENetworkGraphicsDemo.this.alertDismissed (callback, 1); } }) @@ -576,7 +597,7 @@ public class JUCENetworkGraphicsDemo extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); JUCENetworkGraphicsDemo.this.alertDismissed (callback, 2); } }) @@ -584,7 +605,7 @@ public class JUCENetworkGraphicsDemo extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); JUCENetworkGraphicsDemo.this.alertDismissed (callback, 0); } }); @@ -982,13 +1003,75 @@ public class JUCENetworkGraphicsDemo extends Activity //============================================================================== public static class HTTPStream { - public HTTPStream (HttpURLConnection connection_, - int[] statusCode_, - StringBuffer responseHeaders_) + public HTTPStream (String address, boolean isPostToUse, byte[] postDataToUse, + String headersToUse, int timeOutMsToUse, + int[] statusCodeToUse, StringBuffer responseHeadersToUse, + int numRedirectsToFollowToUse, String httpRequestCmdToUse) throws IOException { - connection = connection_; - statusCode = statusCode_; - responseHeaders = responseHeaders_; + isPost = isPostToUse; + postData = postDataToUse; + headers = headersToUse; + timeOutMs = timeOutMsToUse; + statusCode = statusCodeToUse; + responseHeaders = responseHeadersToUse; + totalLength = -1; + numRedirectsToFollow = numRedirectsToFollowToUse; + httpRequestCmd = httpRequestCmdToUse; + + connection = createConnection (address, isPost, postData, headers, timeOutMs, httpRequestCmd); + } + + private final HttpURLConnection createConnection (String address, boolean isPost, byte[] postData, + String headers, int timeOutMs, String httpRequestCmdToUse) throws IOException + { + HttpURLConnection newConnection = (HttpURLConnection) (new URL(address).openConnection()); + + try + { + newConnection.setInstanceFollowRedirects (false); + newConnection.setConnectTimeout (timeOutMs); + newConnection.setReadTimeout (timeOutMs); + + // headers - if not empty, this string is appended onto the headers that are used for the request. It must therefore be a valid set of HTML header directives, separated by newlines. + // So convert headers string to an array, with an element for each line + String headerLines[] = headers.split("\\n"); + + // Set request headers + for (int i = 0; i < headerLines.length; ++i) + { + int pos = headerLines[i].indexOf (":"); + + if (pos > 0 && pos < headerLines[i].length()) + { + String field = headerLines[i].substring (0, pos); + String value = headerLines[i].substring (pos + 1); + + if (value.length() > 0) + newConnection.setRequestProperty (field, value); + } + } + + newConnection.setRequestMethod (httpRequestCmd); + + if (isPost) + { + newConnection.setDoOutput (true); + + if (postData != null) + { + OutputStream out = newConnection.getOutputStream(); + out.write(postData); + out.flush(); + } + } + + return newConnection; + } + catch (Throwable e) + { + newConnection.disconnect(); + throw new IOException ("Connection error"); + } } private final InputStream getCancellableStream (final boolean isInput) throws ExecutionException @@ -1011,19 +1094,12 @@ public class JUCENetworkGraphicsDemo extends Activity try { - if (connection.getConnectTimeout() > 0) - return streamFuture.get (connection.getConnectTimeout(), TimeUnit.MILLISECONDS); - else - return streamFuture.get(); + return streamFuture.get(); } catch (InterruptedException e) { return null; } - catch (TimeoutException e) - { - return null; - } catch (CancellationException e) { return null; @@ -1031,6 +1107,89 @@ public class JUCENetworkGraphicsDemo extends Activity } public final boolean connect() + { + boolean result = false; + int numFollowedRedirects = 0; + + while (true) + { + result = doConnect(); + + if (! result) + return false; + + if (++numFollowedRedirects > numRedirectsToFollow) + break; + + int status = statusCode[0]; + + if (status == 301 || status == 302 || status == 303 || status == 307) + { + // Assumes only one occurrence of "Location" + int pos1 = responseHeaders.indexOf ("Location:") + 10; + int pos2 = responseHeaders.indexOf ("\n", pos1); + + if (pos2 > pos1) + { + String currentLocation = connection.getURL().toString(); + String newLocation = responseHeaders.substring (pos1, pos2); + + try + { + // Handle newLocation whether it's absolute or relative + URL baseUrl = new URL (currentLocation); + URL newUrl = new URL (baseUrl, newLocation); + String transformedNewLocation = newUrl.toString(); + + if (transformedNewLocation != currentLocation) + { + // Clear responseHeaders before next iteration + responseHeaders.delete (0, responseHeaders.length()); + + synchronized (createStreamLock) + { + if (hasBeenCancelled.get()) + return false; + + connection.disconnect(); + + try + { + connection = createConnection (transformedNewLocation, isPost, + postData, headers, timeOutMs, + httpRequestCmd); + } + catch (Throwable e) + { + return false; + } + } + } + else + { + break; + } + } + catch (Throwable e) + { + return false; + } + } + else + { + break; + } + } + else + { + break; + } + } + + return result; + } + + private final boolean doConnect() { synchronized (createStreamLock) { @@ -1068,9 +1227,16 @@ public class JUCENetworkGraphicsDemo extends Activity {} for (java.util.Map.Entry> entry : connection.getHeaderFields().entrySet()) + { if (entry.getKey() != null && entry.getValue() != null) - responseHeaders.append (entry.getKey() + ": " - + android.text.TextUtils.join (",", entry.getValue()) + "\n"); + { + responseHeaders.append(entry.getKey() + ": " + + android.text.TextUtils.join(",", entry.getValue()) + "\n"); + + if (entry.getKey().compareTo ("Content-Length") == 0) + totalLength = Integer.decode (entry.getValue().get (0)); + } + } return true; } @@ -1173,13 +1339,20 @@ public class JUCENetworkGraphicsDemo extends Activity } public final long getPosition() { return position; } - public final long getTotalLength() { return -1; } + public final long getTotalLength() { return totalLength; } public final boolean isExhausted() { return false; } public final boolean setPosition (long newPos) { return false; } + private boolean isPost; + private byte[] postData; + private String headers; + private int timeOutMs; + String httpRequestCmd; private HttpURLConnection connection; private int[] statusCode; private StringBuffer responseHeaders; + private int totalLength; + private int numRedirectsToFollow; private InputStream inputStream; private long position; private final ReentrantLock createStreamLock = new ReentrantLock(); @@ -1201,89 +1374,15 @@ public class JUCENetworkGraphicsDemo extends Activity else if (timeOutMs == 0) timeOutMs = 30000; - // headers - if not empty, this string is appended onto the headers that are used for the request. It must therefore be a valid set of HTML header directives, separated by newlines. - // So convert headers string to an array, with an element for each line - String headerLines[] = headers.split("\\n"); - for (;;) { try { - HttpURLConnection connection = (HttpURLConnection) (new URL(address).openConnection()); - - if (connection != null) - { - try - { - connection.setInstanceFollowRedirects (false); - connection.setConnectTimeout (timeOutMs); - connection.setReadTimeout (timeOutMs); + HTTPStream httpStream = new HTTPStream (address, isPost, postData, headers, + timeOutMs, statusCode, responseHeaders, + numRedirectsToFollow, httpRequestCmd); - // Set request headers - for (int i = 0; i < headerLines.length; ++i) - { - int pos = headerLines[i].indexOf (":"); - - if (pos > 0 && pos < headerLines[i].length()) - { - String field = headerLines[i].substring (0, pos); - String value = headerLines[i].substring (pos + 1); - - if (value.length() > 0) - connection.setRequestProperty (field, value); - } - } - - connection.setRequestMethod (httpRequestCmd); - if (isPost) - { - connection.setDoOutput (true); - - if (postData != null) - { - OutputStream out = connection.getOutputStream(); - out.write(postData); - out.flush(); - } - } - - HTTPStream httpStream = new HTTPStream (connection, statusCode, responseHeaders); - - // Process redirect & continue as necessary - int status = statusCode[0]; - - if (--numRedirectsToFollow >= 0 - && (status == 301 || status == 302 || status == 303 || status == 307)) - { - // Assumes only one occurrence of "Location" - int pos1 = responseHeaders.indexOf ("Location:") + 10; - int pos2 = responseHeaders.indexOf ("\n", pos1); - - if (pos2 > pos1) - { - String newLocation = responseHeaders.substring(pos1, pos2); - // Handle newLocation whether it's absolute or relative - URL baseUrl = new URL (address); - URL newUrl = new URL (baseUrl, newLocation); - String transformedNewLocation = newUrl.toString(); - - if (transformedNewLocation != address) - { - address = transformedNewLocation; - // Clear responseHeaders before next iteration - responseHeaders.delete (0, responseHeaders.length()); - continue; - } - } - } - - return httpStream; - } - catch (Throwable e) - { - connection.disconnect(); - } - } + return httpStream; } catch (Throwable e) {} @@ -1309,7 +1408,14 @@ public class JUCENetworkGraphicsDemo extends Activity return Environment.getExternalStoragePublicDirectory (type).getAbsolutePath(); } - public static final String getDocumentsFolder() { return Environment.getDataDirectory().getAbsolutePath(); } + public static final String getDocumentsFolder() + { + if (getAndroidSDKVersion() >= 19) + return getFileLocation ("Documents"); + + return Environment.getDataDirectory().getAbsolutePath(); + } + public static final String getPicturesFolder() { return getFileLocation (Environment.DIRECTORY_PICTURES); } public static final String getMusicFolder() { return getFileLocation (Environment.DIRECTORY_MUSIC); } public static final String getMoviesFolder() { return getFileLocation (Environment.DIRECTORY_MOVIES); } @@ -1404,7 +1510,7 @@ public class JUCENetworkGraphicsDemo extends Activity return null; } - public final int getAndroidSDKVersion() + public static final int getAndroidSDKVersion() { return android.os.Build.VERSION.SDK_INT; } diff --git a/examples/OSCReceiver/Builds/Android/app/src/main/java/com/yourcompany/oscreceiver/OSCReceiver.java b/examples/OSCReceiver/Builds/Android/app/src/main/java/com/yourcompany/oscreceiver/OSCReceiver.java index a49408d60b..d08af129e5 100644 --- a/examples/OSCReceiver/Builds/Android/app/src/main/java/com/yourcompany/oscreceiver/OSCReceiver.java +++ b/examples/OSCReceiver/Builds/Android/app/src/main/java/com/yourcompany/oscreceiver/OSCReceiver.java @@ -519,11 +519,18 @@ public class OSCReceiver extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + OSCReceiver.this.alertDismissed (callback, 0); + } + }) .setPositiveButton ("OK", new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); OSCReceiver.this.alertDismissed (callback, 0); } }); @@ -538,11 +545,18 @@ public class OSCReceiver extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + OSCReceiver.this.alertDismissed (callback, 0); + } + }) .setPositiveButton (okButtonText.isEmpty() ? "OK" : okButtonText, new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); OSCReceiver.this.alertDismissed (callback, 1); } }) @@ -550,7 +564,7 @@ public class OSCReceiver extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); OSCReceiver.this.alertDismissed (callback, 0); } }); @@ -564,11 +578,18 @@ public class OSCReceiver extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + OSCReceiver.this.alertDismissed (callback, 0); + } + }) .setPositiveButton ("Yes", new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); OSCReceiver.this.alertDismissed (callback, 1); } }) @@ -576,7 +597,7 @@ public class OSCReceiver extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); OSCReceiver.this.alertDismissed (callback, 2); } }) @@ -584,7 +605,7 @@ public class OSCReceiver extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); OSCReceiver.this.alertDismissed (callback, 0); } }); @@ -982,13 +1003,75 @@ public class OSCReceiver extends Activity //============================================================================== public static class HTTPStream { - public HTTPStream (HttpURLConnection connection_, - int[] statusCode_, - StringBuffer responseHeaders_) + public HTTPStream (String address, boolean isPostToUse, byte[] postDataToUse, + String headersToUse, int timeOutMsToUse, + int[] statusCodeToUse, StringBuffer responseHeadersToUse, + int numRedirectsToFollowToUse, String httpRequestCmdToUse) throws IOException { - connection = connection_; - statusCode = statusCode_; - responseHeaders = responseHeaders_; + isPost = isPostToUse; + postData = postDataToUse; + headers = headersToUse; + timeOutMs = timeOutMsToUse; + statusCode = statusCodeToUse; + responseHeaders = responseHeadersToUse; + totalLength = -1; + numRedirectsToFollow = numRedirectsToFollowToUse; + httpRequestCmd = httpRequestCmdToUse; + + connection = createConnection (address, isPost, postData, headers, timeOutMs, httpRequestCmd); + } + + private final HttpURLConnection createConnection (String address, boolean isPost, byte[] postData, + String headers, int timeOutMs, String httpRequestCmdToUse) throws IOException + { + HttpURLConnection newConnection = (HttpURLConnection) (new URL(address).openConnection()); + + try + { + newConnection.setInstanceFollowRedirects (false); + newConnection.setConnectTimeout (timeOutMs); + newConnection.setReadTimeout (timeOutMs); + + // headers - if not empty, this string is appended onto the headers that are used for the request. It must therefore be a valid set of HTML header directives, separated by newlines. + // So convert headers string to an array, with an element for each line + String headerLines[] = headers.split("\\n"); + + // Set request headers + for (int i = 0; i < headerLines.length; ++i) + { + int pos = headerLines[i].indexOf (":"); + + if (pos > 0 && pos < headerLines[i].length()) + { + String field = headerLines[i].substring (0, pos); + String value = headerLines[i].substring (pos + 1); + + if (value.length() > 0) + newConnection.setRequestProperty (field, value); + } + } + + newConnection.setRequestMethod (httpRequestCmd); + + if (isPost) + { + newConnection.setDoOutput (true); + + if (postData != null) + { + OutputStream out = newConnection.getOutputStream(); + out.write(postData); + out.flush(); + } + } + + return newConnection; + } + catch (Throwable e) + { + newConnection.disconnect(); + throw new IOException ("Connection error"); + } } private final InputStream getCancellableStream (final boolean isInput) throws ExecutionException @@ -1011,19 +1094,12 @@ public class OSCReceiver extends Activity try { - if (connection.getConnectTimeout() > 0) - return streamFuture.get (connection.getConnectTimeout(), TimeUnit.MILLISECONDS); - else - return streamFuture.get(); + return streamFuture.get(); } catch (InterruptedException e) { return null; } - catch (TimeoutException e) - { - return null; - } catch (CancellationException e) { return null; @@ -1031,6 +1107,89 @@ public class OSCReceiver extends Activity } public final boolean connect() + { + boolean result = false; + int numFollowedRedirects = 0; + + while (true) + { + result = doConnect(); + + if (! result) + return false; + + if (++numFollowedRedirects > numRedirectsToFollow) + break; + + int status = statusCode[0]; + + if (status == 301 || status == 302 || status == 303 || status == 307) + { + // Assumes only one occurrence of "Location" + int pos1 = responseHeaders.indexOf ("Location:") + 10; + int pos2 = responseHeaders.indexOf ("\n", pos1); + + if (pos2 > pos1) + { + String currentLocation = connection.getURL().toString(); + String newLocation = responseHeaders.substring (pos1, pos2); + + try + { + // Handle newLocation whether it's absolute or relative + URL baseUrl = new URL (currentLocation); + URL newUrl = new URL (baseUrl, newLocation); + String transformedNewLocation = newUrl.toString(); + + if (transformedNewLocation != currentLocation) + { + // Clear responseHeaders before next iteration + responseHeaders.delete (0, responseHeaders.length()); + + synchronized (createStreamLock) + { + if (hasBeenCancelled.get()) + return false; + + connection.disconnect(); + + try + { + connection = createConnection (transformedNewLocation, isPost, + postData, headers, timeOutMs, + httpRequestCmd); + } + catch (Throwable e) + { + return false; + } + } + } + else + { + break; + } + } + catch (Throwable e) + { + return false; + } + } + else + { + break; + } + } + else + { + break; + } + } + + return result; + } + + private final boolean doConnect() { synchronized (createStreamLock) { @@ -1068,9 +1227,16 @@ public class OSCReceiver extends Activity {} for (java.util.Map.Entry> entry : connection.getHeaderFields().entrySet()) + { if (entry.getKey() != null && entry.getValue() != null) - responseHeaders.append (entry.getKey() + ": " - + android.text.TextUtils.join (",", entry.getValue()) + "\n"); + { + responseHeaders.append(entry.getKey() + ": " + + android.text.TextUtils.join(",", entry.getValue()) + "\n"); + + if (entry.getKey().compareTo ("Content-Length") == 0) + totalLength = Integer.decode (entry.getValue().get (0)); + } + } return true; } @@ -1173,13 +1339,20 @@ public class OSCReceiver extends Activity } public final long getPosition() { return position; } - public final long getTotalLength() { return -1; } + public final long getTotalLength() { return totalLength; } public final boolean isExhausted() { return false; } public final boolean setPosition (long newPos) { return false; } + private boolean isPost; + private byte[] postData; + private String headers; + private int timeOutMs; + String httpRequestCmd; private HttpURLConnection connection; private int[] statusCode; private StringBuffer responseHeaders; + private int totalLength; + private int numRedirectsToFollow; private InputStream inputStream; private long position; private final ReentrantLock createStreamLock = new ReentrantLock(); @@ -1201,89 +1374,15 @@ public class OSCReceiver extends Activity else if (timeOutMs == 0) timeOutMs = 30000; - // headers - if not empty, this string is appended onto the headers that are used for the request. It must therefore be a valid set of HTML header directives, separated by newlines. - // So convert headers string to an array, with an element for each line - String headerLines[] = headers.split("\\n"); - for (;;) { try { - HttpURLConnection connection = (HttpURLConnection) (new URL(address).openConnection()); - - if (connection != null) - { - try - { - connection.setInstanceFollowRedirects (false); - connection.setConnectTimeout (timeOutMs); - connection.setReadTimeout (timeOutMs); + HTTPStream httpStream = new HTTPStream (address, isPost, postData, headers, + timeOutMs, statusCode, responseHeaders, + numRedirectsToFollow, httpRequestCmd); - // Set request headers - for (int i = 0; i < headerLines.length; ++i) - { - int pos = headerLines[i].indexOf (":"); - - if (pos > 0 && pos < headerLines[i].length()) - { - String field = headerLines[i].substring (0, pos); - String value = headerLines[i].substring (pos + 1); - - if (value.length() > 0) - connection.setRequestProperty (field, value); - } - } - - connection.setRequestMethod (httpRequestCmd); - if (isPost) - { - connection.setDoOutput (true); - - if (postData != null) - { - OutputStream out = connection.getOutputStream(); - out.write(postData); - out.flush(); - } - } - - HTTPStream httpStream = new HTTPStream (connection, statusCode, responseHeaders); - - // Process redirect & continue as necessary - int status = statusCode[0]; - - if (--numRedirectsToFollow >= 0 - && (status == 301 || status == 302 || status == 303 || status == 307)) - { - // Assumes only one occurrence of "Location" - int pos1 = responseHeaders.indexOf ("Location:") + 10; - int pos2 = responseHeaders.indexOf ("\n", pos1); - - if (pos2 > pos1) - { - String newLocation = responseHeaders.substring(pos1, pos2); - // Handle newLocation whether it's absolute or relative - URL baseUrl = new URL (address); - URL newUrl = new URL (baseUrl, newLocation); - String transformedNewLocation = newUrl.toString(); - - if (transformedNewLocation != address) - { - address = transformedNewLocation; - // Clear responseHeaders before next iteration - responseHeaders.delete (0, responseHeaders.length()); - continue; - } - } - } - - return httpStream; - } - catch (Throwable e) - { - connection.disconnect(); - } - } + return httpStream; } catch (Throwable e) {} @@ -1309,7 +1408,14 @@ public class OSCReceiver extends Activity return Environment.getExternalStoragePublicDirectory (type).getAbsolutePath(); } - public static final String getDocumentsFolder() { return Environment.getDataDirectory().getAbsolutePath(); } + public static final String getDocumentsFolder() + { + if (getAndroidSDKVersion() >= 19) + return getFileLocation ("Documents"); + + return Environment.getDataDirectory().getAbsolutePath(); + } + public static final String getPicturesFolder() { return getFileLocation (Environment.DIRECTORY_PICTURES); } public static final String getMusicFolder() { return getFileLocation (Environment.DIRECTORY_MUSIC); } public static final String getMoviesFolder() { return getFileLocation (Environment.DIRECTORY_MOVIES); } @@ -1404,7 +1510,7 @@ public class OSCReceiver extends Activity return null; } - public final int getAndroidSDKVersion() + public static final int getAndroidSDKVersion() { return android.os.Build.VERSION.SDK_INT; } diff --git a/examples/OSCSender/Builds/Android/app/src/main/java/com/yourcompany/oscsender/OSCSender.java b/examples/OSCSender/Builds/Android/app/src/main/java/com/yourcompany/oscsender/OSCSender.java index fa138371bf..b22efadf57 100644 --- a/examples/OSCSender/Builds/Android/app/src/main/java/com/yourcompany/oscsender/OSCSender.java +++ b/examples/OSCSender/Builds/Android/app/src/main/java/com/yourcompany/oscsender/OSCSender.java @@ -519,11 +519,18 @@ public class OSCSender extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + OSCSender.this.alertDismissed (callback, 0); + } + }) .setPositiveButton ("OK", new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); OSCSender.this.alertDismissed (callback, 0); } }); @@ -538,11 +545,18 @@ public class OSCSender extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + OSCSender.this.alertDismissed (callback, 0); + } + }) .setPositiveButton (okButtonText.isEmpty() ? "OK" : okButtonText, new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); OSCSender.this.alertDismissed (callback, 1); } }) @@ -550,7 +564,7 @@ public class OSCSender extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); OSCSender.this.alertDismissed (callback, 0); } }); @@ -564,11 +578,18 @@ public class OSCSender extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + OSCSender.this.alertDismissed (callback, 0); + } + }) .setPositiveButton ("Yes", new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); OSCSender.this.alertDismissed (callback, 1); } }) @@ -576,7 +597,7 @@ public class OSCSender extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); OSCSender.this.alertDismissed (callback, 2); } }) @@ -584,7 +605,7 @@ public class OSCSender extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); OSCSender.this.alertDismissed (callback, 0); } }); @@ -982,13 +1003,75 @@ public class OSCSender extends Activity //============================================================================== public static class HTTPStream { - public HTTPStream (HttpURLConnection connection_, - int[] statusCode_, - StringBuffer responseHeaders_) + public HTTPStream (String address, boolean isPostToUse, byte[] postDataToUse, + String headersToUse, int timeOutMsToUse, + int[] statusCodeToUse, StringBuffer responseHeadersToUse, + int numRedirectsToFollowToUse, String httpRequestCmdToUse) throws IOException { - connection = connection_; - statusCode = statusCode_; - responseHeaders = responseHeaders_; + isPost = isPostToUse; + postData = postDataToUse; + headers = headersToUse; + timeOutMs = timeOutMsToUse; + statusCode = statusCodeToUse; + responseHeaders = responseHeadersToUse; + totalLength = -1; + numRedirectsToFollow = numRedirectsToFollowToUse; + httpRequestCmd = httpRequestCmdToUse; + + connection = createConnection (address, isPost, postData, headers, timeOutMs, httpRequestCmd); + } + + private final HttpURLConnection createConnection (String address, boolean isPost, byte[] postData, + String headers, int timeOutMs, String httpRequestCmdToUse) throws IOException + { + HttpURLConnection newConnection = (HttpURLConnection) (new URL(address).openConnection()); + + try + { + newConnection.setInstanceFollowRedirects (false); + newConnection.setConnectTimeout (timeOutMs); + newConnection.setReadTimeout (timeOutMs); + + // headers - if not empty, this string is appended onto the headers that are used for the request. It must therefore be a valid set of HTML header directives, separated by newlines. + // So convert headers string to an array, with an element for each line + String headerLines[] = headers.split("\\n"); + + // Set request headers + for (int i = 0; i < headerLines.length; ++i) + { + int pos = headerLines[i].indexOf (":"); + + if (pos > 0 && pos < headerLines[i].length()) + { + String field = headerLines[i].substring (0, pos); + String value = headerLines[i].substring (pos + 1); + + if (value.length() > 0) + newConnection.setRequestProperty (field, value); + } + } + + newConnection.setRequestMethod (httpRequestCmd); + + if (isPost) + { + newConnection.setDoOutput (true); + + if (postData != null) + { + OutputStream out = newConnection.getOutputStream(); + out.write(postData); + out.flush(); + } + } + + return newConnection; + } + catch (Throwable e) + { + newConnection.disconnect(); + throw new IOException ("Connection error"); + } } private final InputStream getCancellableStream (final boolean isInput) throws ExecutionException @@ -1011,19 +1094,12 @@ public class OSCSender extends Activity try { - if (connection.getConnectTimeout() > 0) - return streamFuture.get (connection.getConnectTimeout(), TimeUnit.MILLISECONDS); - else - return streamFuture.get(); + return streamFuture.get(); } catch (InterruptedException e) { return null; } - catch (TimeoutException e) - { - return null; - } catch (CancellationException e) { return null; @@ -1031,6 +1107,89 @@ public class OSCSender extends Activity } public final boolean connect() + { + boolean result = false; + int numFollowedRedirects = 0; + + while (true) + { + result = doConnect(); + + if (! result) + return false; + + if (++numFollowedRedirects > numRedirectsToFollow) + break; + + int status = statusCode[0]; + + if (status == 301 || status == 302 || status == 303 || status == 307) + { + // Assumes only one occurrence of "Location" + int pos1 = responseHeaders.indexOf ("Location:") + 10; + int pos2 = responseHeaders.indexOf ("\n", pos1); + + if (pos2 > pos1) + { + String currentLocation = connection.getURL().toString(); + String newLocation = responseHeaders.substring (pos1, pos2); + + try + { + // Handle newLocation whether it's absolute or relative + URL baseUrl = new URL (currentLocation); + URL newUrl = new URL (baseUrl, newLocation); + String transformedNewLocation = newUrl.toString(); + + if (transformedNewLocation != currentLocation) + { + // Clear responseHeaders before next iteration + responseHeaders.delete (0, responseHeaders.length()); + + synchronized (createStreamLock) + { + if (hasBeenCancelled.get()) + return false; + + connection.disconnect(); + + try + { + connection = createConnection (transformedNewLocation, isPost, + postData, headers, timeOutMs, + httpRequestCmd); + } + catch (Throwable e) + { + return false; + } + } + } + else + { + break; + } + } + catch (Throwable e) + { + return false; + } + } + else + { + break; + } + } + else + { + break; + } + } + + return result; + } + + private final boolean doConnect() { synchronized (createStreamLock) { @@ -1068,9 +1227,16 @@ public class OSCSender extends Activity {} for (java.util.Map.Entry> entry : connection.getHeaderFields().entrySet()) + { if (entry.getKey() != null && entry.getValue() != null) - responseHeaders.append (entry.getKey() + ": " - + android.text.TextUtils.join (",", entry.getValue()) + "\n"); + { + responseHeaders.append(entry.getKey() + ": " + + android.text.TextUtils.join(",", entry.getValue()) + "\n"); + + if (entry.getKey().compareTo ("Content-Length") == 0) + totalLength = Integer.decode (entry.getValue().get (0)); + } + } return true; } @@ -1173,13 +1339,20 @@ public class OSCSender extends Activity } public final long getPosition() { return position; } - public final long getTotalLength() { return -1; } + public final long getTotalLength() { return totalLength; } public final boolean isExhausted() { return false; } public final boolean setPosition (long newPos) { return false; } + private boolean isPost; + private byte[] postData; + private String headers; + private int timeOutMs; + String httpRequestCmd; private HttpURLConnection connection; private int[] statusCode; private StringBuffer responseHeaders; + private int totalLength; + private int numRedirectsToFollow; private InputStream inputStream; private long position; private final ReentrantLock createStreamLock = new ReentrantLock(); @@ -1201,89 +1374,15 @@ public class OSCSender extends Activity else if (timeOutMs == 0) timeOutMs = 30000; - // headers - if not empty, this string is appended onto the headers that are used for the request. It must therefore be a valid set of HTML header directives, separated by newlines. - // So convert headers string to an array, with an element for each line - String headerLines[] = headers.split("\\n"); - for (;;) { try { - HttpURLConnection connection = (HttpURLConnection) (new URL(address).openConnection()); - - if (connection != null) - { - try - { - connection.setInstanceFollowRedirects (false); - connection.setConnectTimeout (timeOutMs); - connection.setReadTimeout (timeOutMs); + HTTPStream httpStream = new HTTPStream (address, isPost, postData, headers, + timeOutMs, statusCode, responseHeaders, + numRedirectsToFollow, httpRequestCmd); - // Set request headers - for (int i = 0; i < headerLines.length; ++i) - { - int pos = headerLines[i].indexOf (":"); - - if (pos > 0 && pos < headerLines[i].length()) - { - String field = headerLines[i].substring (0, pos); - String value = headerLines[i].substring (pos + 1); - - if (value.length() > 0) - connection.setRequestProperty (field, value); - } - } - - connection.setRequestMethod (httpRequestCmd); - if (isPost) - { - connection.setDoOutput (true); - - if (postData != null) - { - OutputStream out = connection.getOutputStream(); - out.write(postData); - out.flush(); - } - } - - HTTPStream httpStream = new HTTPStream (connection, statusCode, responseHeaders); - - // Process redirect & continue as necessary - int status = statusCode[0]; - - if (--numRedirectsToFollow >= 0 - && (status == 301 || status == 302 || status == 303 || status == 307)) - { - // Assumes only one occurrence of "Location" - int pos1 = responseHeaders.indexOf ("Location:") + 10; - int pos2 = responseHeaders.indexOf ("\n", pos1); - - if (pos2 > pos1) - { - String newLocation = responseHeaders.substring(pos1, pos2); - // Handle newLocation whether it's absolute or relative - URL baseUrl = new URL (address); - URL newUrl = new URL (baseUrl, newLocation); - String transformedNewLocation = newUrl.toString(); - - if (transformedNewLocation != address) - { - address = transformedNewLocation; - // Clear responseHeaders before next iteration - responseHeaders.delete (0, responseHeaders.length()); - continue; - } - } - } - - return httpStream; - } - catch (Throwable e) - { - connection.disconnect(); - } - } + return httpStream; } catch (Throwable e) {} @@ -1309,7 +1408,14 @@ public class OSCSender extends Activity return Environment.getExternalStoragePublicDirectory (type).getAbsolutePath(); } - public static final String getDocumentsFolder() { return Environment.getDataDirectory().getAbsolutePath(); } + public static final String getDocumentsFolder() + { + if (getAndroidSDKVersion() >= 19) + return getFileLocation ("Documents"); + + return Environment.getDataDirectory().getAbsolutePath(); + } + public static final String getPicturesFolder() { return getFileLocation (Environment.DIRECTORY_PICTURES); } public static final String getMusicFolder() { return getFileLocation (Environment.DIRECTORY_MUSIC); } public static final String getMoviesFolder() { return getFileLocation (Environment.DIRECTORY_MOVIES); } @@ -1404,7 +1510,7 @@ public class OSCSender extends Activity return null; } - public final int getAndroidSDKVersion() + public static final int getAndroidSDKVersion() { return android.os.Build.VERSION.SDK_INT; } diff --git a/examples/audio plugin demo/Builds/Android/app/src/main/java/com/juce/jucedemoplugin/JuceDemoPlugin.java b/examples/audio plugin demo/Builds/Android/app/src/main/java/com/juce/jucedemoplugin/JuceDemoPlugin.java index c76005c03c..59ac9dc0cf 100644 --- a/examples/audio plugin demo/Builds/Android/app/src/main/java/com/juce/jucedemoplugin/JuceDemoPlugin.java +++ b/examples/audio plugin demo/Builds/Android/app/src/main/java/com/juce/jucedemoplugin/JuceDemoPlugin.java @@ -1448,11 +1448,18 @@ public class JuceDemoPlugin extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + JuceDemoPlugin.this.alertDismissed (callback, 0); + } + }) .setPositiveButton ("OK", new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); JuceDemoPlugin.this.alertDismissed (callback, 0); } }); @@ -1467,11 +1474,18 @@ public class JuceDemoPlugin extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + JuceDemoPlugin.this.alertDismissed (callback, 0); + } + }) .setPositiveButton (okButtonText.isEmpty() ? "OK" : okButtonText, new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); JuceDemoPlugin.this.alertDismissed (callback, 1); } }) @@ -1479,7 +1493,7 @@ public class JuceDemoPlugin extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); JuceDemoPlugin.this.alertDismissed (callback, 0); } }); @@ -1493,11 +1507,18 @@ public class JuceDemoPlugin extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + JuceDemoPlugin.this.alertDismissed (callback, 0); + } + }) .setPositiveButton ("Yes", new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); JuceDemoPlugin.this.alertDismissed (callback, 1); } }) @@ -1505,7 +1526,7 @@ public class JuceDemoPlugin extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); JuceDemoPlugin.this.alertDismissed (callback, 2); } }) @@ -1513,7 +1534,7 @@ public class JuceDemoPlugin extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); JuceDemoPlugin.this.alertDismissed (callback, 0); } }); @@ -1911,13 +1932,75 @@ public class JuceDemoPlugin extends Activity //============================================================================== public static class HTTPStream { - public HTTPStream (HttpURLConnection connection_, - int[] statusCode_, - StringBuffer responseHeaders_) + public HTTPStream (String address, boolean isPostToUse, byte[] postDataToUse, + String headersToUse, int timeOutMsToUse, + int[] statusCodeToUse, StringBuffer responseHeadersToUse, + int numRedirectsToFollowToUse, String httpRequestCmdToUse) throws IOException { - connection = connection_; - statusCode = statusCode_; - responseHeaders = responseHeaders_; + isPost = isPostToUse; + postData = postDataToUse; + headers = headersToUse; + timeOutMs = timeOutMsToUse; + statusCode = statusCodeToUse; + responseHeaders = responseHeadersToUse; + totalLength = -1; + numRedirectsToFollow = numRedirectsToFollowToUse; + httpRequestCmd = httpRequestCmdToUse; + + connection = createConnection (address, isPost, postData, headers, timeOutMs, httpRequestCmd); + } + + private final HttpURLConnection createConnection (String address, boolean isPost, byte[] postData, + String headers, int timeOutMs, String httpRequestCmdToUse) throws IOException + { + HttpURLConnection newConnection = (HttpURLConnection) (new URL(address).openConnection()); + + try + { + newConnection.setInstanceFollowRedirects (false); + newConnection.setConnectTimeout (timeOutMs); + newConnection.setReadTimeout (timeOutMs); + + // headers - if not empty, this string is appended onto the headers that are used for the request. It must therefore be a valid set of HTML header directives, separated by newlines. + // So convert headers string to an array, with an element for each line + String headerLines[] = headers.split("\\n"); + + // Set request headers + for (int i = 0; i < headerLines.length; ++i) + { + int pos = headerLines[i].indexOf (":"); + + if (pos > 0 && pos < headerLines[i].length()) + { + String field = headerLines[i].substring (0, pos); + String value = headerLines[i].substring (pos + 1); + + if (value.length() > 0) + newConnection.setRequestProperty (field, value); + } + } + + newConnection.setRequestMethod (httpRequestCmd); + + if (isPost) + { + newConnection.setDoOutput (true); + + if (postData != null) + { + OutputStream out = newConnection.getOutputStream(); + out.write(postData); + out.flush(); + } + } + + return newConnection; + } + catch (Throwable e) + { + newConnection.disconnect(); + throw new IOException ("Connection error"); + } } private final InputStream getCancellableStream (final boolean isInput) throws ExecutionException @@ -1940,19 +2023,12 @@ public class JuceDemoPlugin extends Activity try { - if (connection.getConnectTimeout() > 0) - return streamFuture.get (connection.getConnectTimeout(), TimeUnit.MILLISECONDS); - else - return streamFuture.get(); + return streamFuture.get(); } catch (InterruptedException e) { return null; } - catch (TimeoutException e) - { - return null; - } catch (CancellationException e) { return null; @@ -1960,6 +2036,89 @@ public class JuceDemoPlugin extends Activity } public final boolean connect() + { + boolean result = false; + int numFollowedRedirects = 0; + + while (true) + { + result = doConnect(); + + if (! result) + return false; + + if (++numFollowedRedirects > numRedirectsToFollow) + break; + + int status = statusCode[0]; + + if (status == 301 || status == 302 || status == 303 || status == 307) + { + // Assumes only one occurrence of "Location" + int pos1 = responseHeaders.indexOf ("Location:") + 10; + int pos2 = responseHeaders.indexOf ("\n", pos1); + + if (pos2 > pos1) + { + String currentLocation = connection.getURL().toString(); + String newLocation = responseHeaders.substring (pos1, pos2); + + try + { + // Handle newLocation whether it's absolute or relative + URL baseUrl = new URL (currentLocation); + URL newUrl = new URL (baseUrl, newLocation); + String transformedNewLocation = newUrl.toString(); + + if (transformedNewLocation != currentLocation) + { + // Clear responseHeaders before next iteration + responseHeaders.delete (0, responseHeaders.length()); + + synchronized (createStreamLock) + { + if (hasBeenCancelled.get()) + return false; + + connection.disconnect(); + + try + { + connection = createConnection (transformedNewLocation, isPost, + postData, headers, timeOutMs, + httpRequestCmd); + } + catch (Throwable e) + { + return false; + } + } + } + else + { + break; + } + } + catch (Throwable e) + { + return false; + } + } + else + { + break; + } + } + else + { + break; + } + } + + return result; + } + + private final boolean doConnect() { synchronized (createStreamLock) { @@ -1997,9 +2156,16 @@ public class JuceDemoPlugin extends Activity {} for (java.util.Map.Entry> entry : connection.getHeaderFields().entrySet()) + { if (entry.getKey() != null && entry.getValue() != null) - responseHeaders.append (entry.getKey() + ": " - + android.text.TextUtils.join (",", entry.getValue()) + "\n"); + { + responseHeaders.append(entry.getKey() + ": " + + android.text.TextUtils.join(",", entry.getValue()) + "\n"); + + if (entry.getKey().compareTo ("Content-Length") == 0) + totalLength = Integer.decode (entry.getValue().get (0)); + } + } return true; } @@ -2102,13 +2268,20 @@ public class JuceDemoPlugin extends Activity } public final long getPosition() { return position; } - public final long getTotalLength() { return -1; } + public final long getTotalLength() { return totalLength; } public final boolean isExhausted() { return false; } public final boolean setPosition (long newPos) { return false; } + private boolean isPost; + private byte[] postData; + private String headers; + private int timeOutMs; + String httpRequestCmd; private HttpURLConnection connection; private int[] statusCode; private StringBuffer responseHeaders; + private int totalLength; + private int numRedirectsToFollow; private InputStream inputStream; private long position; private final ReentrantLock createStreamLock = new ReentrantLock(); @@ -2130,89 +2303,15 @@ public class JuceDemoPlugin extends Activity else if (timeOutMs == 0) timeOutMs = 30000; - // headers - if not empty, this string is appended onto the headers that are used for the request. It must therefore be a valid set of HTML header directives, separated by newlines. - // So convert headers string to an array, with an element for each line - String headerLines[] = headers.split("\\n"); - for (;;) { try { - HttpURLConnection connection = (HttpURLConnection) (new URL(address).openConnection()); + HTTPStream httpStream = new HTTPStream (address, isPost, postData, headers, + timeOutMs, statusCode, responseHeaders, + numRedirectsToFollow, httpRequestCmd); - if (connection != null) - { - try - { - connection.setInstanceFollowRedirects (false); - connection.setConnectTimeout (timeOutMs); - connection.setReadTimeout (timeOutMs); - - // Set request headers - for (int i = 0; i < headerLines.length; ++i) - { - int pos = headerLines[i].indexOf (":"); - - if (pos > 0 && pos < headerLines[i].length()) - { - String field = headerLines[i].substring (0, pos); - String value = headerLines[i].substring (pos + 1); - - if (value.length() > 0) - connection.setRequestProperty (field, value); - } - } - - connection.setRequestMethod (httpRequestCmd); - if (isPost) - { - connection.setDoOutput (true); - - if (postData != null) - { - OutputStream out = connection.getOutputStream(); - out.write(postData); - out.flush(); - } - } - - HTTPStream httpStream = new HTTPStream (connection, statusCode, responseHeaders); - - // Process redirect & continue as necessary - int status = statusCode[0]; - - if (--numRedirectsToFollow >= 0 - && (status == 301 || status == 302 || status == 303 || status == 307)) - { - // Assumes only one occurrence of "Location" - int pos1 = responseHeaders.indexOf ("Location:") + 10; - int pos2 = responseHeaders.indexOf ("\n", pos1); - - if (pos2 > pos1) - { - String newLocation = responseHeaders.substring(pos1, pos2); - // Handle newLocation whether it's absolute or relative - URL baseUrl = new URL (address); - URL newUrl = new URL (baseUrl, newLocation); - String transformedNewLocation = newUrl.toString(); - - if (transformedNewLocation != address) - { - address = transformedNewLocation; - // Clear responseHeaders before next iteration - responseHeaders.delete (0, responseHeaders.length()); - continue; - } - } - } - - return httpStream; - } - catch (Throwable e) - { - connection.disconnect(); - } - } + return httpStream; } catch (Throwable e) {} @@ -2238,7 +2337,14 @@ public class JuceDemoPlugin extends Activity return Environment.getExternalStoragePublicDirectory (type).getAbsolutePath(); } - public static final String getDocumentsFolder() { return Environment.getDataDirectory().getAbsolutePath(); } + public static final String getDocumentsFolder() + { + if (getAndroidSDKVersion() >= 19) + return getFileLocation ("Documents"); + + return Environment.getDataDirectory().getAbsolutePath(); + } + public static final String getPicturesFolder() { return getFileLocation (Environment.DIRECTORY_PICTURES); } public static final String getMusicFolder() { return getFileLocation (Environment.DIRECTORY_MUSIC); } public static final String getMoviesFolder() { return getFileLocation (Environment.DIRECTORY_MOVIES); } @@ -2333,7 +2439,7 @@ public class JuceDemoPlugin extends Activity return null; } - public final int getAndroidSDKVersion() + public static final int getAndroidSDKVersion() { return android.os.Build.VERSION.SDK_INT; } diff --git a/extras/AudioPerformanceTest/Builds/Android/app/src/main/java/com/juce/audioperformancetest/AudioPerformanceTest.java b/extras/AudioPerformanceTest/Builds/Android/app/src/main/java/com/juce/audioperformancetest/AudioPerformanceTest.java index 5feced2ee7..5f1a6c3451 100644 --- a/extras/AudioPerformanceTest/Builds/Android/app/src/main/java/com/juce/audioperformancetest/AudioPerformanceTest.java +++ b/extras/AudioPerformanceTest/Builds/Android/app/src/main/java/com/juce/audioperformancetest/AudioPerformanceTest.java @@ -1448,11 +1448,18 @@ public class AudioPerformanceTest extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + AudioPerformanceTest.this.alertDismissed (callback, 0); + } + }) .setPositiveButton ("OK", new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); AudioPerformanceTest.this.alertDismissed (callback, 0); } }); @@ -1467,11 +1474,18 @@ public class AudioPerformanceTest extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + AudioPerformanceTest.this.alertDismissed (callback, 0); + } + }) .setPositiveButton (okButtonText.isEmpty() ? "OK" : okButtonText, new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); AudioPerformanceTest.this.alertDismissed (callback, 1); } }) @@ -1479,7 +1493,7 @@ public class AudioPerformanceTest extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); AudioPerformanceTest.this.alertDismissed (callback, 0); } }); @@ -1493,11 +1507,18 @@ public class AudioPerformanceTest extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + AudioPerformanceTest.this.alertDismissed (callback, 0); + } + }) .setPositiveButton ("Yes", new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); AudioPerformanceTest.this.alertDismissed (callback, 1); } }) @@ -1505,7 +1526,7 @@ public class AudioPerformanceTest extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); AudioPerformanceTest.this.alertDismissed (callback, 2); } }) @@ -1513,7 +1534,7 @@ public class AudioPerformanceTest extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); AudioPerformanceTest.this.alertDismissed (callback, 0); } }); @@ -1911,13 +1932,75 @@ public class AudioPerformanceTest extends Activity //============================================================================== public static class HTTPStream { - public HTTPStream (HttpURLConnection connection_, - int[] statusCode_, - StringBuffer responseHeaders_) + public HTTPStream (String address, boolean isPostToUse, byte[] postDataToUse, + String headersToUse, int timeOutMsToUse, + int[] statusCodeToUse, StringBuffer responseHeadersToUse, + int numRedirectsToFollowToUse, String httpRequestCmdToUse) throws IOException { - connection = connection_; - statusCode = statusCode_; - responseHeaders = responseHeaders_; + isPost = isPostToUse; + postData = postDataToUse; + headers = headersToUse; + timeOutMs = timeOutMsToUse; + statusCode = statusCodeToUse; + responseHeaders = responseHeadersToUse; + totalLength = -1; + numRedirectsToFollow = numRedirectsToFollowToUse; + httpRequestCmd = httpRequestCmdToUse; + + connection = createConnection (address, isPost, postData, headers, timeOutMs, httpRequestCmd); + } + + private final HttpURLConnection createConnection (String address, boolean isPost, byte[] postData, + String headers, int timeOutMs, String httpRequestCmdToUse) throws IOException + { + HttpURLConnection newConnection = (HttpURLConnection) (new URL(address).openConnection()); + + try + { + newConnection.setInstanceFollowRedirects (false); + newConnection.setConnectTimeout (timeOutMs); + newConnection.setReadTimeout (timeOutMs); + + // headers - if not empty, this string is appended onto the headers that are used for the request. It must therefore be a valid set of HTML header directives, separated by newlines. + // So convert headers string to an array, with an element for each line + String headerLines[] = headers.split("\\n"); + + // Set request headers + for (int i = 0; i < headerLines.length; ++i) + { + int pos = headerLines[i].indexOf (":"); + + if (pos > 0 && pos < headerLines[i].length()) + { + String field = headerLines[i].substring (0, pos); + String value = headerLines[i].substring (pos + 1); + + if (value.length() > 0) + newConnection.setRequestProperty (field, value); + } + } + + newConnection.setRequestMethod (httpRequestCmd); + + if (isPost) + { + newConnection.setDoOutput (true); + + if (postData != null) + { + OutputStream out = newConnection.getOutputStream(); + out.write(postData); + out.flush(); + } + } + + return newConnection; + } + catch (Throwable e) + { + newConnection.disconnect(); + throw new IOException ("Connection error"); + } } private final InputStream getCancellableStream (final boolean isInput) throws ExecutionException @@ -1940,19 +2023,12 @@ public class AudioPerformanceTest extends Activity try { - if (connection.getConnectTimeout() > 0) - return streamFuture.get (connection.getConnectTimeout(), TimeUnit.MILLISECONDS); - else - return streamFuture.get(); + return streamFuture.get(); } catch (InterruptedException e) { return null; } - catch (TimeoutException e) - { - return null; - } catch (CancellationException e) { return null; @@ -1960,6 +2036,89 @@ public class AudioPerformanceTest extends Activity } public final boolean connect() + { + boolean result = false; + int numFollowedRedirects = 0; + + while (true) + { + result = doConnect(); + + if (! result) + return false; + + if (++numFollowedRedirects > numRedirectsToFollow) + break; + + int status = statusCode[0]; + + if (status == 301 || status == 302 || status == 303 || status == 307) + { + // Assumes only one occurrence of "Location" + int pos1 = responseHeaders.indexOf ("Location:") + 10; + int pos2 = responseHeaders.indexOf ("\n", pos1); + + if (pos2 > pos1) + { + String currentLocation = connection.getURL().toString(); + String newLocation = responseHeaders.substring (pos1, pos2); + + try + { + // Handle newLocation whether it's absolute or relative + URL baseUrl = new URL (currentLocation); + URL newUrl = new URL (baseUrl, newLocation); + String transformedNewLocation = newUrl.toString(); + + if (transformedNewLocation != currentLocation) + { + // Clear responseHeaders before next iteration + responseHeaders.delete (0, responseHeaders.length()); + + synchronized (createStreamLock) + { + if (hasBeenCancelled.get()) + return false; + + connection.disconnect(); + + try + { + connection = createConnection (transformedNewLocation, isPost, + postData, headers, timeOutMs, + httpRequestCmd); + } + catch (Throwable e) + { + return false; + } + } + } + else + { + break; + } + } + catch (Throwable e) + { + return false; + } + } + else + { + break; + } + } + else + { + break; + } + } + + return result; + } + + private final boolean doConnect() { synchronized (createStreamLock) { @@ -1997,9 +2156,16 @@ public class AudioPerformanceTest extends Activity {} for (java.util.Map.Entry> entry : connection.getHeaderFields().entrySet()) + { if (entry.getKey() != null && entry.getValue() != null) - responseHeaders.append (entry.getKey() + ": " - + android.text.TextUtils.join (",", entry.getValue()) + "\n"); + { + responseHeaders.append(entry.getKey() + ": " + + android.text.TextUtils.join(",", entry.getValue()) + "\n"); + + if (entry.getKey().compareTo ("Content-Length") == 0) + totalLength = Integer.decode (entry.getValue().get (0)); + } + } return true; } @@ -2102,13 +2268,20 @@ public class AudioPerformanceTest extends Activity } public final long getPosition() { return position; } - public final long getTotalLength() { return -1; } + public final long getTotalLength() { return totalLength; } public final boolean isExhausted() { return false; } public final boolean setPosition (long newPos) { return false; } + private boolean isPost; + private byte[] postData; + private String headers; + private int timeOutMs; + String httpRequestCmd; private HttpURLConnection connection; private int[] statusCode; private StringBuffer responseHeaders; + private int totalLength; + private int numRedirectsToFollow; private InputStream inputStream; private long position; private final ReentrantLock createStreamLock = new ReentrantLock(); @@ -2130,89 +2303,15 @@ public class AudioPerformanceTest extends Activity else if (timeOutMs == 0) timeOutMs = 30000; - // headers - if not empty, this string is appended onto the headers that are used for the request. It must therefore be a valid set of HTML header directives, separated by newlines. - // So convert headers string to an array, with an element for each line - String headerLines[] = headers.split("\\n"); - for (;;) { try { - HttpURLConnection connection = (HttpURLConnection) (new URL(address).openConnection()); + HTTPStream httpStream = new HTTPStream (address, isPost, postData, headers, + timeOutMs, statusCode, responseHeaders, + numRedirectsToFollow, httpRequestCmd); - if (connection != null) - { - try - { - connection.setInstanceFollowRedirects (false); - connection.setConnectTimeout (timeOutMs); - connection.setReadTimeout (timeOutMs); - - // Set request headers - for (int i = 0; i < headerLines.length; ++i) - { - int pos = headerLines[i].indexOf (":"); - - if (pos > 0 && pos < headerLines[i].length()) - { - String field = headerLines[i].substring (0, pos); - String value = headerLines[i].substring (pos + 1); - - if (value.length() > 0) - connection.setRequestProperty (field, value); - } - } - - connection.setRequestMethod (httpRequestCmd); - if (isPost) - { - connection.setDoOutput (true); - - if (postData != null) - { - OutputStream out = connection.getOutputStream(); - out.write(postData); - out.flush(); - } - } - - HTTPStream httpStream = new HTTPStream (connection, statusCode, responseHeaders); - - // Process redirect & continue as necessary - int status = statusCode[0]; - - if (--numRedirectsToFollow >= 0 - && (status == 301 || status == 302 || status == 303 || status == 307)) - { - // Assumes only one occurrence of "Location" - int pos1 = responseHeaders.indexOf ("Location:") + 10; - int pos2 = responseHeaders.indexOf ("\n", pos1); - - if (pos2 > pos1) - { - String newLocation = responseHeaders.substring(pos1, pos2); - // Handle newLocation whether it's absolute or relative - URL baseUrl = new URL (address); - URL newUrl = new URL (baseUrl, newLocation); - String transformedNewLocation = newUrl.toString(); - - if (transformedNewLocation != address) - { - address = transformedNewLocation; - // Clear responseHeaders before next iteration - responseHeaders.delete (0, responseHeaders.length()); - continue; - } - } - } - - return httpStream; - } - catch (Throwable e) - { - connection.disconnect(); - } - } + return httpStream; } catch (Throwable e) {} @@ -2238,7 +2337,14 @@ public class AudioPerformanceTest extends Activity return Environment.getExternalStoragePublicDirectory (type).getAbsolutePath(); } - public static final String getDocumentsFolder() { return Environment.getDataDirectory().getAbsolutePath(); } + public static final String getDocumentsFolder() + { + if (getAndroidSDKVersion() >= 19) + return getFileLocation ("Documents"); + + return Environment.getDataDirectory().getAbsolutePath(); + } + public static final String getPicturesFolder() { return getFileLocation (Environment.DIRECTORY_PICTURES); } public static final String getMusicFolder() { return getFileLocation (Environment.DIRECTORY_MUSIC); } public static final String getMoviesFolder() { return getFileLocation (Environment.DIRECTORY_MOVIES); } @@ -2333,7 +2439,7 @@ public class AudioPerformanceTest extends Activity return null; } - public final int getAndroidSDKVersion() + public static final int getAndroidSDKVersion() { return android.os.Build.VERSION.SDK_INT; } diff --git a/extras/Projucer/JuceLibraryCode/BinaryData.cpp b/extras/Projucer/JuceLibraryCode/BinaryData.cpp index 4b70bc30e4..ab7a9dda7e 100644 --- a/extras/Projucer/JuceLibraryCode/BinaryData.cpp +++ b/extras/Projucer/JuceLibraryCode/BinaryData.cpp @@ -1540,9 +1540,9 @@ static const unsigned char temp_binary_data_8[] = " #endif\r\n" "}\r\n" "\r\n" -"bool FILTERCLASSNAME::isMidiEffect () const\r\n" +"bool FILTERCLASSNAME::isMidiEffect() const\r\n" "{\r\n" -" #ifdef JucePlugin_IsMidiEffect\r\n" +" #if JucePlugin_IsMidiEffect\r\n" " return true;\r\n" " #else\r\n" " return false;\r\n" @@ -7028,7 +7028,7 @@ const char* getNamedResource (const char* resourceNameUTF8, int& numBytes) throw case 0xafccbd3f: numBytes = 3141; return jucer_AudioComponentTemplate_cpp; case 0x27c5a93a: numBytes = 1310; return jucer_AudioPluginEditorTemplate_cpp; case 0x4d0721bf: numBytes = 938; return jucer_AudioPluginEditorTemplate_h; - case 0x51b49ac5: numBytes = 5615; return jucer_AudioPluginFilterTemplate_cpp; + case 0x51b49ac5: numBytes = 5611; return jucer_AudioPluginFilterTemplate_cpp; case 0x488afa0a: numBytes = 2245; return jucer_AudioPluginFilterTemplate_h; case 0xabad7041: numBytes = 2151; return jucer_ComponentTemplate_cpp; case 0xfc72fe86: numBytes = 2064; return jucer_ComponentTemplate_h; diff --git a/extras/Projucer/JuceLibraryCode/BinaryData.h b/extras/Projucer/JuceLibraryCode/BinaryData.h index 8c93be578b..1ad41adb5c 100644 --- a/extras/Projucer/JuceLibraryCode/BinaryData.h +++ b/extras/Projucer/JuceLibraryCode/BinaryData.h @@ -33,7 +33,7 @@ namespace BinaryData const int jucer_AudioPluginEditorTemplate_hSize = 938; extern const char* jucer_AudioPluginFilterTemplate_cpp; - const int jucer_AudioPluginFilterTemplate_cppSize = 5615; + const int jucer_AudioPluginFilterTemplate_cppSize = 5611; extern const char* jucer_AudioPluginFilterTemplate_h; const int jucer_AudioPluginFilterTemplate_hSize = 2245; From 11d031f9f025fbd159d693b1630d7f81edae469b Mon Sep 17 00:00:00 2001 From: hogliux Date: Wed, 6 Sep 2017 16:22:03 +0100 Subject: [PATCH 059/129] DSP: Added missing snapToZero in the StateVariableFilter --- .../juce_dsp/containers/juce_SIMDRegister.h | 8 +++++ modules/juce_dsp/juce_dsp.h | 15 +++++++++ .../juce_dsp/processors/juce_IIRFilter_Impl.h | 33 ++++--------------- .../processors/juce_StateVariableFilter.h | 3 ++ 4 files changed, 33 insertions(+), 26 deletions(-) diff --git a/modules/juce_dsp/containers/juce_SIMDRegister.h b/modules/juce_dsp/containers/juce_SIMDRegister.h index 059f5c5bef..1eb4964a73 100644 --- a/modules/juce_dsp/containers/juce_SIMDRegister.h +++ b/modules/juce_dsp/containers/juce_SIMDRegister.h @@ -386,6 +386,14 @@ struct CmplxSIMDOps > } }; +//============================================================================== +#ifndef DOXYGEN + namespace util + { + template + inline void snapToZero (SIMDRegister&) noexcept {} + } +#endif //============================================================================== // Extend some common used global functions to SIMDRegister types diff --git a/modules/juce_dsp/juce_dsp.h b/modules/juce_dsp/juce_dsp.h index 5a2cc076a5..d0c803b128 100644 --- a/modules/juce_dsp/juce_dsp.h +++ b/modules/juce_dsp/juce_dsp.h @@ -177,6 +177,21 @@ namespace juce template using Complex = ::std::complex; + //============================================================================== + namespace util + { + /** Use this function to prevent denormals on intel CPUs. + + This function will work with both primitives and simple containers. + */ + inline void snapToZero (float& x) noexcept { JUCE_SNAP_TO_ZERO (x); } + #ifndef DOXYGEN + inline void snapToZero (double& x) noexcept { JUCE_SNAP_TO_ZERO (x); } + inline void snapToZero (long double& x) noexcept { JUCE_SNAP_TO_ZERO (x); } + #endif + } + + //============================================================================== #if JUCE_USE_SIMD #include "native/juce_fallback_SIMDNativeOps.h" diff --git a/modules/juce_dsp/processors/juce_IIRFilter_Impl.h b/modules/juce_dsp/processors/juce_IIRFilter_Impl.h index cb31cbdf13..c096f5d114 100644 --- a/modules/juce_dsp/processors/juce_IIRFilter_Impl.h +++ b/modules/juce_dsp/processors/juce_IIRFilter_Impl.h @@ -26,25 +26,6 @@ #ifndef DOXYGEN -template -struct SnapToZeroHelper -{ - static void snap (Type& x) noexcept - { - for (size_t i = 0; i < Type::size(); ++i) - JUCE_SNAP_TO_ZERO (x[i]); - } -}; - -template <> struct SnapToZeroHelper { static void snap (float& x) noexcept { JUCE_SNAP_TO_ZERO (x); } }; -template <> struct SnapToZeroHelper { static void snap (double& x) noexcept { JUCE_SNAP_TO_ZERO (x); } }; -template <> struct SnapToZeroHelper { static void snap (long double& x) noexcept { JUCE_SNAP_TO_ZERO (x); } }; - -#if JUCE_USE_SIMD -template -struct SnapToZeroHelper> { static void snap (SIMDRegister&) noexcept {} }; -#endif - //============================================================================== template Filter::Filter() @@ -120,7 +101,7 @@ void Filter::process (const ProcessContext& context) noexcept lv1 = (in * b1) - (out * a1); } - SnapToZeroHelper::snap (lv1); state[0] = lv1; + util::snapToZero (lv1); state[0] = lv1; } break; @@ -145,8 +126,8 @@ void Filter::process (const ProcessContext& context) noexcept lv2 = (in * b2) - (out * a2); } - SnapToZeroHelper::snap (lv1); state[0] = lv1; - SnapToZeroHelper::snap (lv2); state[1] = lv2; + util::snapToZero (lv1); state[0] = lv1; + util::snapToZero (lv2); state[1] = lv2; } break; @@ -175,9 +156,9 @@ void Filter::process (const ProcessContext& context) noexcept lv3 = (in * b3) - (out * a3); } - SnapToZeroHelper::snap (lv1); state[0] = lv1; - SnapToZeroHelper::snap (lv2); state[1] = lv2; - SnapToZeroHelper::snap (lv3); state[2] = lv3; + util::snapToZero (lv1); state[0] = lv1; + util::snapToZero (lv2); state[1] = lv2; + util::snapToZero (lv3); state[2] = lv3; } break; @@ -220,7 +201,7 @@ template void Filter::snapToZero() noexcept { for (size_t i = 0; i < order; ++i) - SnapToZeroHelper::snap (state[i]); + util::snapToZero (state[i]); } template diff --git a/modules/juce_dsp/processors/juce_StateVariableFilter.h b/modules/juce_dsp/processors/juce_StateVariableFilter.h index 98d3d4750b..437f6995cf 100644 --- a/modules/juce_dsp/processors/juce_StateVariableFilter.h +++ b/modules/juce_dsp/processors/juce_StateVariableFilter.h @@ -141,6 +141,9 @@ namespace StateVariableFilter for (size_t i = 0 ; i < n; ++i) output[i] = processLoop (input[i], state); + util::snapToZero (s1); + util::snapToZero (s2); + *parameters = state; } From 4dcce5083c9128989577617facf6bd7ed3bc67a3 Mon Sep 17 00:00:00 2001 From: tpoole Date: Tue, 5 Sep 2017 14:56:47 +0100 Subject: [PATCH 060/129] Added an option to declare plug-in parameters as either continuous or discrete, irrespective of their number of steps --- BREAKING-CHANGES.txt | 46 +++++++++++--- .../AAX/juce_AAX_Wrapper.cpp | 20 ++++-- .../AU/juce_AU_Wrapper.mm | 62 ++++++++++++++----- .../VST3/juce_VST3_Wrapper.cpp | 29 ++++++--- .../juce_audio_plugin_client.h | 19 +++++- .../juce_AudioUnitPluginFormat.mm | 21 ++++++- .../format_types/juce_VST3PluginFormat.cpp | 42 ++++++++++--- .../juce_audio_processors.h | 12 ++++ .../processors/juce_AudioProcessor.cpp | 19 ++++-- .../processors/juce_AudioProcessor.h | 25 ++++++++ .../processors/juce_AudioProcessorParameter.h | 22 ++++++- .../utilities/juce_AudioParameterBool.h | 1 + .../utilities/juce_AudioParameterChoice.h | 1 + .../juce_AudioProcessorParameters.cpp | 2 + .../juce_AudioProcessorValueTreeState.cpp | 15 +++-- .../juce_AudioProcessorValueTreeState.h | 5 +- 16 files changed, 276 insertions(+), 65 deletions(-) diff --git a/BREAKING-CHANGES.txt b/BREAKING-CHANGES.txt index 20235c65ba..8881e6c93e 100644 --- a/BREAKING-CHANGES.txt +++ b/BREAKING-CHANGES.txt @@ -6,14 +6,44 @@ Develop Branch Change ------ -A new FrameRateType fps23976 has been added to AudioPlayHead +The method used to classify AudioUnit, VST3 and AAX plug-in parameters as +either continuous or discrete has changed. Possible Issues --------------- -Previously JUCE would report the FrameRateType fps24 for both 24 and -23.976 fps. If your code uses switch statements (or similar) to handle -all possible frame rate types, then this change may cause it to fall -through. +Plug-ins: DAW projects with automation data written by an AudioUnit, VST3 or +AAX plug-in built with JUCE version 5.1.1 or earlier may load incorrectly when +opened by an AudioUnit, VST3 or AAX plug-in built with JUCE version 5.2.0 and +later. + +Hosts: The AudioPluginInstance::getParameterNumSteps method now returns correct +values for AU and VST3 plug-ins. + +Workaround +---------- +Plug-ins: Enable JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE in the +juce_audio_plugin_client module config page in the Projucer. + +Hosts: Use AudioPluginInstance::getDefaultNumParameterSteps as the number of +steps for all parameters. + +Rationale +--------- +The old system for presenting plug-in parameters to a host as either continuous +or discrete is inconsistent between plug-in types and lacks sufficient +flexibility. This change harmonises the behaviour and allows individual +parameters to be marked as continuous or discrete. + + +Change +------ +A new FrameRateType fps23976 has been added to AudioPlayHead, + +Possible Issues +--------------- +Previously JUCE would report the FrameRateType fps24 for both 24 and 23.976 +fps. If your code uses switch statements (or similar) to handle all possible +frame rate types, then this change may cause it to fall through. Workaround ---------- @@ -21,8 +51,8 @@ Add fps23976 to your switch statement and handle it appropriately. Rationale --------- -JUCE should be able to handle all popular frame rate codes but was -missing support for 23.976. +JUCE should be able to handle all popular frame rate codes but was missing +support for 23.976. Change @@ -120,7 +150,7 @@ or 2. Override the Look&Feel method PopupMenu::LookAndFeelMethods::shouldPopupMenuScaleWithTargetComponent and - return false. See + return false. See https://github.com/WeAreROLI/JUCE/blob/c288c94c2914af20f36c03ca9c5401fcb555e4e9/modules/juce_gui_basics/menus/juce_PopupMenu.h#725 Rationale diff --git a/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp b/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp index 897b573075..e809d86c2a 100644 --- a/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp @@ -1319,12 +1319,14 @@ namespace AAXClasses for (int parameterIndex = 0; parameterIndex < numParameters; ++parameterIndex) { - const AudioProcessorParameter::Category category = audioProcessor.getParameterCategory (parameterIndex); + auto* processorParam = audioProcessor.getParameters().getUnchecked (parameterIndex); + + const AudioProcessorParameter::Category category = processorParam->getCategory(); aaxParamIDs.add (usingManagedParameters ? audioProcessor.getParameterID (parameterIndex) : String (parameterIndex)); - AAX_CString paramName (audioProcessor.getParameterName (parameterIndex, 31).toRawUTF8()); + AAX_CString paramName (processorParam->getName (31).toRawUTF8()); AAX_CParamID paramID = aaxParamIDs.getReference (parameterIndex).getCharPointer(); paramMap.set (AAXClasses::getAAXParamHash (paramID), parameterIndex); @@ -1339,19 +1341,25 @@ namespace AAXClasses AAX_IParameter* parameter = new AAX_CParameter (paramID, paramName, - audioProcessor.getParameterDefaultValue (parameterIndex), + processorParam->getDefaultValue(), AAX_CLinearTaperDelegate(), AAX_CNumberDisplayDelegate(), audioProcessor.isParameterAutomatable (parameterIndex)); - parameter->AddShortenedName (audioProcessor.getParameterName (parameterIndex, 4).toRawUTF8()); + parameter->AddShortenedName (processorParam->getName (4).toRawUTF8()); - const int parameterNumSteps = audioProcessor.getParameterNumSteps (parameterIndex); + const int parameterNumSteps = processorParam->getNumSteps(); parameter->SetNumberOfSteps ((uint32_t) parameterNumSteps); + + #if JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE parameter->SetType (parameterNumSteps > 1000 ? AAX_eParameterType_Continuous : AAX_eParameterType_Discrete); + #else + parameter->SetType (processorParam->isDiscrete() ? AAX_eParameterType_Discrete + : AAX_eParameterType_Continuous); + #endif - parameter->SetOrientation (audioProcessor.isParameterOrientationInverted (parameterIndex) + parameter->SetOrientation (processorParam->isOrientationInverted() ? (AAX_eParameterOrientation_RightMinLeftMax | AAX_eParameterOrientation_TopMinBottomMax | AAX_eParameterOrientation_RotarySingleDotMode | AAX_eParameterOrientation_RotaryRightMinLeftMax) : (AAX_eParameterOrientation_LeftMinRightMax | AAX_eParameterOrientation_BottomMinTopMax diff --git a/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm b/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm index e3ee1d7d1f..ac92ab10a4 100644 --- a/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm +++ b/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm @@ -525,7 +525,7 @@ public: const String text (String::fromCFString (pv->inString)); if (AudioProcessorParameter* param = juceFilter->getParameters() [paramID]) - pv->outValue = param->getValueForText (text); + pv->outValue = param->getValueForText (text) * getMaximumParameterValue (param); else pv->outValue = text.getFloatValue(); @@ -546,11 +546,12 @@ public: String text; if (AudioProcessorParameter* param = juceFilter->getParameters() [paramID]) - text = param->getText (value, 0); + text = param->getText (value / getMaximumParameterValue (param), 0); else text = String (value); pv->outString = text.toCFString(); + return noErr; } } @@ -803,6 +804,17 @@ public: } //============================================================================== + // When parameters are discrete we need to use integer values. + static float getMaximumParameterValue (AudioProcessorParameter* param) + { + #if JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE + ignoreUnused (param); + return 1.0f; + #else + return param->isDiscrete() ? (float) (param->getNumSteps() - 1) : 1.0f; + #endif + } + ComponentResult GetParameterInfo (AudioUnitScope inScope, AudioUnitParameterID inParameterID, AudioUnitParameterInfo& outParameterInfo) override @@ -811,7 +823,7 @@ public: if (inScope == kAudioUnitScope_Global && juceFilter != nullptr - && index < juceFilter->getNumParameters()) + && isPositiveAndBelow (index, juceFilter->getNumParameters())) { outParameterInfo.unit = kAudioUnitParameterUnit_Generic; outParameterInfo.flags = (UInt32) (kAudioUnitParameterFlag_IsWritable @@ -823,28 +835,40 @@ public: outParameterInfo.flags |= (UInt32) kAudioUnitParameterFlag_IsHighResolution; #endif - const String name (juceFilter->getParameterName (index)); + auto* param = juceFilter->getParameters().getUnchecked (index); + + const String name (param->getName (512)); - // set whether the param is automatable (unnamed parameters aren't allowed to be automated) - if (name.isEmpty() || ! juceFilter->isParameterAutomatable (index)) + // Set whether the param is automatable (unnamed parameters aren't allowed to be automated) + if (name.isEmpty() || ! param->isAutomatable()) outParameterInfo.flags |= kAudioUnitParameterFlag_NonRealTime; - if (juceFilter->isMetaParameter (index)) + if (! param->isDiscrete()) + outParameterInfo.flags |= kAudioUnitParameterFlag_CanRamp; + + if (param->isMetaParameter()) outParameterInfo.flags |= kAudioUnitParameterFlag_IsGlobalMeta; - // is this a meter? - if (((juceFilter->getParameterCategory (index) & 0xffff0000) >> 16) == 2) + // Is this a meter? + if (((param->getCategory() & 0xffff0000) >> 16) == 2) { outParameterInfo.flags &= ~kAudioUnitParameterFlag_IsWritable; outParameterInfo.flags |= kAudioUnitParameterFlag_MeterReadOnly | kAudioUnitParameterFlag_DisplayLogarithmic; outParameterInfo.unit = kAudioUnitParameterUnit_LinearGain; } + else + { + #if ! JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE + outParameterInfo.unit = param->isDiscrete() ? kAudioUnitParameterUnit_Indexed + : kAudioUnitParameterUnit_Generic; + #endif + } MusicDeviceBase::FillInParameterName (outParameterInfo, name.toCFString(), true); outParameterInfo.minValue = 0.0f; - outParameterInfo.maxValue = 1.0f; - outParameterInfo.defaultValue = juceFilter->getParameterDefaultValue (index); + outParameterInfo.maxValue = getMaximumParameterValue (param); + outParameterInfo.defaultValue = param->getDefaultValue(); jassert (outParameterInfo.defaultValue >= outParameterInfo.minValue && outParameterInfo.defaultValue <= outParameterInfo.maxValue); @@ -861,9 +885,9 @@ public: { if (inScope == kAudioUnitScope_Global && juceFilter != nullptr) { - const int index = getJuceIndexForAUParameterID (inID); + auto* param = juceFilter->getParameters().getUnchecked (getJuceIndexForAUParameterID (inID)); - outValue = juceFilter->getParameter (index); + outValue = param->getValue() * getMaximumParameterValue (param); return noErr; } @@ -878,9 +902,9 @@ public: { if (inScope == kAudioUnitScope_Global && juceFilter != nullptr) { - const int index = getJuceIndexForAUParameterID (inID); + auto* param = juceFilter->getParameters().getUnchecked (getJuceIndexForAUParameterID (inID)); - juceFilter->setParameter (index, inValue); + param->setValue (inValue / getMaximumParameterValue (param)); return noErr; } @@ -1727,6 +1751,14 @@ private: { Globals()->UseIndexedParameters (numParams); } + + #if JUCE_DEBUG + // Some hosts can't handle the huge numbers of discrete parameter values created when + // using the default number of steps. + for (auto* param : juceFilter->getParameters()) + if (param->isDiscrete()) + jassert (param->getNumSteps() != juceFilter->getDefaultNumParameterSteps()); + #endif } //============================================================================== diff --git a/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp b/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp index 415a9d1519..bea056cfd7 100644 --- a/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp @@ -204,21 +204,32 @@ public: Param (AudioProcessor& p, int index, Vst::ParamID paramID) : owner (p), paramIndex (index) { info.id = paramID; - toString128 (info.title, p.getParameterName (index)); - toString128 (info.shortTitle, p.getParameterName (index, 8)); - toString128 (info.units, p.getParameterLabel (index)); - const int numSteps = p.getParameterNumSteps (index); - info.stepCount = (Steinberg::int32) (numSteps > 0 && numSteps < 0x7fffffff ? numSteps - 1 : 0); - info.defaultNormalizedValue = p.getParameterDefaultValue (index); + auto* param = p.getParameters().getUnchecked (index); + + toString128 (info.title, param->getName (128)); + toString128 (info.shortTitle, param->getName (8)); + toString128 (info.units, param->getLabel()); + + info.stepCount = (Steinberg::int32) 0; + + #if ! JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE + if (param->isDiscrete()) + #endif + { + const int numSteps = param->getNumSteps(); + info.stepCount = (Steinberg::int32) (numSteps > 0 && numSteps < 0x7fffffff ? numSteps - 1 : 0); + } + + info.defaultNormalizedValue = param->getDefaultValue(); jassert (info.defaultNormalizedValue >= 0 && info.defaultNormalizedValue <= 1.0f); info.unitId = Vst::kRootUnitId; - // is this a meter? - if (((p.getParameterCategory (index) & 0xffff0000) >> 16) == 2) + // Is this a meter? + if (((param->getCategory() & 0xffff0000) >> 16) == 2) info.flags = Vst::ParameterInfo::kIsReadOnly; else - info.flags = p.isParameterAutomatable (index) ? Vst::ParameterInfo::kCanAutomate : 0; + info.flags = param->isAutomatable() ? Vst::ParameterInfo::kCanAutomate : 0; valueNormalized = info.defaultNormalizedValue; } diff --git a/modules/juce_audio_plugin_client/juce_audio_plugin_client.h b/modules/juce_audio_plugin_client/juce_audio_plugin_client.h index f30ac91462..d5f034c2a2 100644 --- a/modules/juce_audio_plugin_client/juce_audio_plugin_client.h +++ b/modules/juce_audio_plugin_client/juce_audio_plugin_client.h @@ -65,15 +65,28 @@ #define JUCE_FORCE_USE_LEGACY_PARAM_IDS 0 #endif +/** Config: JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE + + Enable this if you want to force JUCE to use a legacy scheme for + identifying plug-in parameters as either continuous or discrete. + DAW projects with automation data written by an AudioUnit, VST3 or + AAX plug-in built with JUCE version 5.1.1 or earlier may load + incorrectly when opened by an AudioUnit, VST3 or AAX plug-in built + with JUCE version 5.2.0 and later. +*/ +#ifndef JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE + #define JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE 0 +#endif + /** Config: JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS Enable this if you want JUCE to use parameter ids which are compatible - to Studio One. Studio One ignores any parameter ids which are negative. + with Studio One. Studio One ignores any parameter ids which are negative. Enabling this option will make JUCE generate only positive parameter ids. - Note that if you have already released a plug-in prio to JUCE 4.3.0 then + Note that if you have already released a plug-in prior to JUCE 4.3.0 then enabling this will change your parameter ids making your plug-in incompatible to old automation data. - */ +*/ #ifndef JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS #define JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS 1 #endif diff --git a/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm b/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm index fb3ae77b7f..fa379c3659 100644 --- a/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm +++ b/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm @@ -986,6 +986,22 @@ public: const String getParameterText (int index) override { return String (getParameter (index)); } + int getParameterNumSteps (int index) override + { + if (auto* p = parameters[index]) + return p->numSteps; + + return AudioProcessor::getDefaultNumParameterSteps(); + } + + bool isParameterDiscrete (int index) const override + { + if (auto* p = parameters[index]) + return p->discrete; + + return false; + } + bool isParameterAutomatable (int index) const override { if (auto* p = parameters[index]) @@ -1178,6 +1194,8 @@ public: param->minValue = info.minValue; param->maxValue = info.maxValue; param->automatable = (info.flags & kAudioUnitParameterFlag_NonRealTime) == 0; + param->discrete = (info.unit == kAudioUnitParameterUnit_Indexed); + param->numSteps = param->discrete ? (int) (info.maxValue + 1.0f) : AudioProcessor::getDefaultNumParameterSteps(); if ((info.flags & kAudioUnitParameterFlag_HasCFNameString) != 0) { @@ -1263,7 +1281,8 @@ private: UInt32 paramID; String name; AudioUnitParameterValue minValue, maxValue; - bool automatable; + bool automatable, discrete; + int numSteps; }; OwnedArray parameters; diff --git a/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp b/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp index 938c6b736c..892e302eda 100644 --- a/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp +++ b/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp @@ -2247,30 +2247,54 @@ struct VST3PluginInstance : public AudioPluginInstance return toString (getParameterInfoForIndex (parameterIndex).title); } - float getParameter (int parameterIndex) override + const String getParameterText (int parameterIndex) override { if (editController != nullptr) { auto id = getParameterInfoForIndex (parameterIndex).id; - return (float) editController->getParamNormalized (id); + + Vst::String128 result; + warnOnFailure (editController->getParamStringByValue (id, editController->getParamNormalized (id), result)); + + return toString (result); } - return 0.0f; + return {}; } - const String getParameterText (int parameterIndex) override + int getParameterNumSteps (int parameterIndex) override { if (editController != nullptr) { - auto id = getParameterInfoForIndex (parameterIndex).id; + const auto numSteps = getParameterInfoForIndex (parameterIndex).stepCount; - Vst::String128 result; - warnOnFailure (editController->getParamStringByValue (id, editController->getParamNormalized (id), result)); + if (numSteps > 0) + return numSteps; + } - return toString (result); + return AudioProcessor::getDefaultNumParameterSteps(); + } + + bool isParameterDiscrete (int parameterIndex) const override + { + if (editController != nullptr) + { + const auto numSteps = getParameterInfoForIndex (parameterIndex).stepCount; + return numSteps > 0; } - return {}; + return false; + } + + float getParameter (int parameterIndex) override + { + if (editController != nullptr) + { + auto id = getParameterInfoForIndex (parameterIndex).id; + return (float) editController->getParamNormalized (id); + } + + return 0.0f; } void setParameter (int parameterIndex, float newValue) override diff --git a/modules/juce_audio_processors/juce_audio_processors.h b/modules/juce_audio_processors/juce_audio_processors.h index fb8e13e0bf..6589718c02 100644 --- a/modules/juce_audio_processors/juce_audio_processors.h +++ b/modules/juce_audio_processors/juce_audio_processors.h @@ -56,6 +56,18 @@ #include #include +/** Config: JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE + + Enable this if you want to force JUCE to use an old scheme for selecting + when parameters are classified as discrete or continuous in a host. If this + is not enabled then DAW projects with automation data written by an + AudioUnit, VST3 or AAX plug-in built with JUCE version 5.1.1 or earlier may + load incorrectly when opened by an AudioUnit, VST3 or AAX plug-in built + with JUCE version 5.2.0 and later. +*/ +#ifndef JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE + #define JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE 0 +#endif //============================================================================== /** Config: JUCE_PLUGINHOST_VST diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessor.cpp b/modules/juce_audio_processors/processors/juce_AudioProcessor.cpp index b19d9bb572..e33eee651b 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessor.cpp +++ b/modules/juce_audio_processors/processors/juce_AudioProcessor.cpp @@ -625,6 +625,14 @@ int AudioProcessor::getDefaultNumParameterSteps() noexcept return 0x7fffffff; } +bool AudioProcessor::isParameterDiscrete (int index) const +{ + if (auto* p = managedParameters[index]) + return p->isDiscrete(); + + return false; +} + String AudioProcessor::getParameterLabel (int index) const { if (auto* p = managedParameters[index]) @@ -1401,11 +1409,12 @@ void AudioProcessorParameter::endChangeGesture() processor->endParameterChangeGesture (parameterIndex); } -bool AudioProcessorParameter::isOrientationInverted() const { return false; } -bool AudioProcessorParameter::isAutomatable() const { return true; } -bool AudioProcessorParameter::isMetaParameter() const { return false; } -AudioProcessorParameter::Category AudioProcessorParameter::getCategory() const { return genericParameter; } -int AudioProcessorParameter::getNumSteps() const { return AudioProcessor::getDefaultNumParameterSteps(); } +bool AudioProcessorParameter::isOrientationInverted() const { return false; } +bool AudioProcessorParameter::isAutomatable() const { return true; } +bool AudioProcessorParameter::isMetaParameter() const { return false; } +AudioProcessorParameter::Category AudioProcessorParameter::getCategory() const { return genericParameter; } +int AudioProcessorParameter::getNumSteps() const { return AudioProcessor::getDefaultNumParameterSteps(); } +bool AudioProcessorParameter::isDiscrete() const { return false; } String AudioProcessorParameter::getText (float value, int /*maximumStringLength*/) const { diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessor.h b/modules/juce_audio_processors/processors/juce_AudioProcessor.h index e9e13618c1..a39b111373 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessor.h +++ b/modules/juce_audio_processors/processors/juce_AudioProcessor.h @@ -1020,13 +1020,22 @@ public: virtual String getParameterText (int parameterIndex, int maximumStringLength); /** Returns the number of discrete steps that this parameter can represent. + The default return value if you don't implement this method is AudioProcessor::getDefaultNumParameterSteps(). + If your parameter is boolean, then you may want to make this return 2. + + If you want the host to display stepped automation values, rather than a + continuous interpolation between successive values, you should ensure that + isParameterDiscrete returns true. + The value that is returned may or may not be used, depending on the host. NOTE! This method will eventually be deprecated! It's recommended that you use AudioProcessorParameter::getNumSteps() instead. + + @see isParameterDiscrete */ virtual int getParameterNumSteps (int parameterIndex); @@ -1034,10 +1043,26 @@ public: NOTE! This method will eventually be deprecated! It's recommended that you use AudioProcessorParameter::getNumSteps() instead. + @see getParameterNumSteps */ static int getDefaultNumParameterSteps() noexcept; + /** Returns true if the parameter should take discrete, rather than continuous + values. + + If the parameter is boolean, this should return true (with getParameterNumSteps + returning 2). + + The value that is returned may or may not be used, depending on the host. + + NOTE! This method will eventually be deprecated! It's recommended that you use + AudioProcessorParameter::isDiscrete() instead. + + @see getParameterNumSteps + */ + virtual bool isParameterDiscrete (int parameterIndex) const; + /** Returns the default value for the parameter. By default, this just returns 0. The value that is returned may or may not be used, depending on the host. diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessorParameter.h b/modules/juce_audio_processors/processors/juce_AudioProcessorParameter.h index 4d4be65814..d6ef2ddf5a 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessorParameter.h +++ b/modules/juce_audio_processors/processors/juce_AudioProcessorParameter.h @@ -106,16 +106,32 @@ public: */ virtual String getLabel() const = 0; - /** Returns the number of discrete interval steps that this parameter's range - should be quantised into. + /** Returns the number of steps that this parameter's range should be quantised into. If you want a continuous range of values, don't override this method, and allow the default implementation to return AudioProcessor::getDefaultNumParameterSteps(). + If your parameter is boolean, then you may want to make this return 2. - The value that is returned may or may not be used, depending on the host. + + The value that is returned may or may not be used, depending on the host. If you + want the host to display stepped automation values, rather than a continuous + interpolation between successive values, you should override isDiscrete to return true. + + @see isDiscrete */ virtual int getNumSteps() const; + /** Returns whether the parameter uses discrete values, based on the result of + getNumSteps, or allows the host to select values continuously. + + This information may or may not be used, depending on the host. If you + want the host to display stepped automation values, rather than a continuous + interpolation between successive values, override this method to return true. + + @see getNumSteps + */ + virtual bool isDiscrete() const; + /** Returns a textual version of the supplied parameter value. The default implementation just returns the floating point value as a string, but this could do anything you need for a custom type diff --git a/modules/juce_audio_processors/utilities/juce_AudioParameterBool.h b/modules/juce_audio_processors/utilities/juce_AudioParameterBool.h index ff65cff8be..5c6f7153e3 100644 --- a/modules/juce_audio_processors/utilities/juce_AudioParameterBool.h +++ b/modules/juce_audio_processors/utilities/juce_AudioParameterBool.h @@ -58,6 +58,7 @@ private: void setValue (float newValue) override; float getDefaultValue() const override; int getNumSteps() const override; + bool isDiscrete() const override; String getText (float, int) const override; float getValueForText (const String&) const override; diff --git a/modules/juce_audio_processors/utilities/juce_AudioParameterChoice.h b/modules/juce_audio_processors/utilities/juce_AudioParameterChoice.h index c12432db07..784107bc02 100644 --- a/modules/juce_audio_processors/utilities/juce_AudioParameterChoice.h +++ b/modules/juce_audio_processors/utilities/juce_AudioParameterChoice.h @@ -69,6 +69,7 @@ private: void setValue (float newValue) override; float getDefaultValue() const override; int getNumSteps() const override; + bool isDiscrete() const override; String getText (float, int) const override; float getValueForText (const String&) const override; diff --git a/modules/juce_audio_processors/utilities/juce_AudioProcessorParameters.cpp b/modules/juce_audio_processors/utilities/juce_AudioProcessorParameters.cpp index eecd0cc6d3..f0b2c0b99c 100644 --- a/modules/juce_audio_processors/utilities/juce_AudioProcessorParameters.cpp +++ b/modules/juce_audio_processors/utilities/juce_AudioProcessorParameters.cpp @@ -124,6 +124,7 @@ float AudioParameterBool::getValue() const { retur void AudioParameterBool::setValue (float newValue) { value = newValue; } float AudioParameterBool::getDefaultValue() const { return defaultValue; } int AudioParameterBool::getNumSteps() const { return 2; } +bool AudioParameterBool::isDiscrete() const { return true; } float AudioParameterBool::getValueForText (const String& text) const { return text.getIntValue() != 0 ? 1.0f : 0.0f; } String AudioParameterBool::getText (float v, int /*length*/) const { return String ((int) (v > 0.5f ? 1 : 0)); } @@ -156,6 +157,7 @@ float AudioParameterChoice::getValue() const { retur void AudioParameterChoice::setValue (float newValue) { value = (float) convertFrom0to1 (newValue); } float AudioParameterChoice::getDefaultValue() const { return defaultValue; } int AudioParameterChoice::getNumSteps() const { return choices.size(); } +bool AudioParameterChoice::isDiscrete() const { return true; } float AudioParameterChoice::getValueForText (const String& text) const { return convertTo0to1 (choices.indexOf (text)); } String AudioParameterChoice::getText (float v, int /*length*/) const { return choices [convertFrom0to1 (v)]; } diff --git a/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.cpp b/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.cpp index d5540cac7d..da4462f0d5 100644 --- a/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.cpp +++ b/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.cpp @@ -34,13 +34,15 @@ struct AudioProcessorValueTreeState::Parameter : public AudioProcessorParamete std::function valueToText, std::function textToValue, bool meta, - bool automatable) + bool automatable, + bool discrete) : AudioProcessorParameterWithID (parameterID, paramName, labelText), owner (s), valueToTextFunction (valueToText), textToValueFunction (textToValue), range (r), value (defaultVal), defaultValue (defaultVal), listenersNeedCalling (true), isMetaParam (meta), - isAutomatableParam (automatable) + isAutomatableParam (automatable), + isDiscreteParam (discrete) { state.addListener (this); needsUpdate.set (1); @@ -150,6 +152,7 @@ struct AudioProcessorValueTreeState::Parameter : public AudioProcessorParamete bool isMetaParameter() const override { return isMetaParam; } bool isAutomatable() const override { return isAutomatableParam; } + bool isDiscrete() const override { return isDiscreteParam; } AudioProcessorValueTreeState& owner; ValueTree state; @@ -160,7 +163,7 @@ struct AudioProcessorValueTreeState::Parameter : public AudioProcessorParamete float value, defaultValue; Atomic needsUpdate; bool listenersNeedCalling; - const bool isMetaParam, isAutomatableParam; + const bool isMetaParam, isAutomatableParam, isDiscreteParam; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Parameter) }; @@ -185,7 +188,8 @@ AudioProcessorParameterWithID* AudioProcessorValueTreeState::createAndAddParamet float defaultVal, std::function valueToTextFunction, std::function textToValueFunction, bool isMetaParameter, - bool isAutomatableParameter) + bool isAutomatableParameter, + bool isDiscreteParameter) { // All parameters must be created before giving this manager a ValueTree state! jassert (! state.isValid()); @@ -195,7 +199,8 @@ AudioProcessorParameterWithID* AudioProcessorValueTreeState::createAndAddParamet Parameter* p = new Parameter (*this, paramID, paramName, labelText, r, defaultVal, valueToTextFunction, textToValueFunction, - isMetaParameter, isAutomatableParameter); + isMetaParameter, isAutomatableParameter, + isDiscreteParameter); processor.addParameter (p); return p; } diff --git a/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.h b/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.h index aa276b470d..d1b3ec8c42 100644 --- a/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.h +++ b/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.h @@ -77,6 +77,8 @@ public: @param textToValueFunction The inverse of valueToTextFunction @param isMetaParameter Set this value to true if this should be a meta parameter @param isAutomatableParameter Set this value to false if this parameter should not be automatable + @param isDiscrete Set this value to true to make this parameter take discrete values in a host. + @see AudioProcessorParameter::isDiscrete @returns the parameter object that was created */ @@ -88,7 +90,8 @@ public: std::function valueToTextFunction, std::function textToValueFunction, bool isMetaParameter = false, - bool isAutomatableParameter = true); + bool isAutomatableParameter = true, + bool isDiscrete = false); /** Returns a parameter by its ID string. */ AudioProcessorParameterWithID* getParameter (StringRef parameterID) const noexcept; From 8aca5604eb197c3c1ad8bfd2e3914eaae550b4e1 Mon Sep 17 00:00:00 2001 From: tpoole Date: Thu, 7 Sep 2017 10:31:23 +0100 Subject: [PATCH 061/129] Fixed a VS2013 compiler error --- modules/juce_gui_basics/widgets/juce_TreeView.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/juce_gui_basics/widgets/juce_TreeView.cpp b/modules/juce_gui_basics/widgets/juce_TreeView.cpp index d4a24d59dd..68874a224b 100644 --- a/modules/juce_gui_basics/widgets/juce_TreeView.cpp +++ b/modules/juce_gui_basics/widgets/juce_TreeView.cpp @@ -1082,7 +1082,7 @@ void TreeView::fileDragEnter (const StringArray& files, int x, int y) void TreeView::fileDragMove (const StringArray& files, int x, int y) { - handleDrag (files, SourceDetails ({}, this, { x, y })); + handleDrag (files, SourceDetails (var(), this, { x, y })); } void TreeView::fileDragExit (const StringArray&) @@ -1092,7 +1092,7 @@ void TreeView::fileDragExit (const StringArray&) void TreeView::filesDropped (const StringArray& files, int x, int y) { - handleDrop (files, SourceDetails ({}, this, { x, y })); + handleDrop (files, SourceDetails (var(), this, { x, y })); } bool TreeView::isInterestedInDragSource (const SourceDetails& /*dragSourceDetails*/) From 142bebbb92eda73da4382604b46d8fd3fe84b77b Mon Sep 17 00:00:00 2001 From: tpoole Date: Thu, 7 Sep 2017 11:30:39 +0100 Subject: [PATCH 062/129] A small documentation fix --- modules/juce_gui_basics/windows/juce_DocumentWindow.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/juce_gui_basics/windows/juce_DocumentWindow.h b/modules/juce_gui_basics/windows/juce_DocumentWindow.h index 9c48db1303..493f30141c 100644 --- a/modules/juce_gui_basics/windows/juce_DocumentWindow.h +++ b/modules/juce_gui_basics/windows/juce_DocumentWindow.h @@ -106,8 +106,8 @@ public: /** Sets an icon to show in the title bar, next to the title. A copy is made internally of the image, so the caller can delete the - image after calling this. If 0 is passed-in, any existing icon will be - removed. + image after calling this. If an empty Image is passed-in, any existing icon + will be removed. */ void setIcon (const Image& imageToUse); From 56e6d69364c5eb19bf2a7517a2e9d622e01dc23f Mon Sep 17 00:00:00 2001 From: hogliux Date: Thu, 7 Sep 2017 15:19:38 +0100 Subject: [PATCH 063/129] VST3: Fix plug-in resize issue in Bitwig studio --- modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp b/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp index bea056cfd7..93302ce8b5 100644 --- a/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp @@ -1031,7 +1031,7 @@ private: #if JUCE_WINDOWS setSize (w, h); #else - if (owner.macHostWindow != nullptr && ! (host.isWavelab() || host.isReaper())) + if (owner.macHostWindow != nullptr && ! (host.isWavelab() || host.isReaper() || host.isBitwigStudio())) juce::setNativeHostWindowSizeVST (owner.macHostWindow, this, w, h, owner.isNSView); #endif From 5900e076f92dcdf5185494d23129d1c9178b2f00 Mon Sep 17 00:00:00 2001 From: ed Date: Thu, 7 Sep 2017 15:23:55 +0100 Subject: [PATCH 064/129] Added some missing HTML colours --- modules/juce_graphics/colour/juce_Colours.cpp | 8 +++ modules/juce_graphics/colour/juce_Colours.h | 67 ++++++++++--------- 2 files changed, 42 insertions(+), 33 deletions(-) diff --git a/modules/juce_graphics/colour/juce_Colours.cpp b/modules/juce_graphics/colour/juce_Colours.cpp index 375ab4e3e5..be02669aa1 100644 --- a/modules/juce_graphics/colour/juce_Colours.cpp +++ b/modules/juce_graphics/colour/juce_Colours.cpp @@ -74,6 +74,7 @@ const Colour Colours::floralwhite (0xfffffaf0); const Colour Colours::forestgreen (0xff228b22); const Colour Colours::fuchsia (0xffff00ff); const Colour Colours::gainsboro (0xffdcdcdc); +const Colour Colours::ghostwhite (0xfff8f8ff); const Colour Colours::gold (0xffffd700); const Colour Colours::goldenrod (0xffdaa520); const Colour Colours::grey (0xff808080); @@ -87,6 +88,7 @@ const Colour Colours::ivory (0xfffffff0); const Colour Colours::khaki (0xfff0e68c); const Colour Colours::lavender (0xffe6e6fa); const Colour Colours::lavenderblush (0xfffff0f5); +const Colour Colours::lawngreen (0xff7cfc00); const Colour Colours::lemonchiffon (0xfffffacd); const Colour Colours::lightblue (0xffadd8e6); const Colour Colours::lightcoral (0xfff08080); @@ -118,6 +120,7 @@ const Colour Colours::mediumvioletred (0xffc71585); const Colour Colours::midnightblue (0xff191970); const Colour Colours::mintcream (0xfff5fffa); const Colour Colours::mistyrose (0xffffe4e1); +const Colour Colours::moccasin (0xffffe4b5); const Colour Colours::navajowhite (0xffffdead); const Colour Colours::navy (0xff000080); const Colour Colours::oldlace (0xfffdf5e6); @@ -137,6 +140,7 @@ const Colour Colours::pink (0xffffc0cb); const Colour Colours::plum (0xffdda0dd); const Colour Colours::powderblue (0xffb0e0e6); const Colour Colours::purple (0xff800080); +const Colour Colours::rebeccapurple (0xff663399); const Colour Colours::red (0xffff0000); const Colour Colours::rosybrown (0xffbc8f8f); const Colour Colours::royalblue (0xff4169e1); @@ -225,6 +229,7 @@ Colour Colours::findColourForName (const String& colourName, 0xd086fd06, 0xff228b22, /* forestgreen */ 0xe106b6d7, 0xffff00ff, /* fuchsia */ 0x7880d61e, 0xffdcdcdc, /* gainsboro */ + 0x2018a2fa, 0xfff8f8ff, /* ghostwhite */ 0x00308060, 0xffffd700, /* gold */ 0xb3b3bc1e, 0xffdaa520, /* goldenrod */ 0xbab8a537, 0xffadff2f, /* greenyellow */ @@ -236,6 +241,7 @@ Colour Colours::findColourForName (const String& colourName, 0x06149302, 0xfff0e68c, /* khaki */ 0xad5a05c7, 0xffe6e6fa, /* lavender */ 0x7c4d5b99, 0xfffff0f5, /* lavenderblush */ + 0x41cc4377, 0xff7cfc00, /* lawngreen */ 0x195756f0, 0xfffffacd, /* lemonchiffon */ 0x28e4ea70, 0xffadd8e6, /* lightblue */ 0xf3c7ccdb, 0xfff08080, /* lightcoral */ @@ -267,6 +273,7 @@ Colour Colours::findColourForName (const String& colourName, 0x168eb32a, 0xff191970, /* midnightblue */ 0x4306b960, 0xfff5fffa, /* mintcream */ 0x4cbc0e6b, 0xffffe4e1, /* mistyrose */ + 0xd9447d59, 0xffffe4b5, /* moccasin */ 0xe97218a6, 0xffffdead, /* navajowhite */ 0x00337bb6, 0xff000080, /* navy */ 0xadd2d33e, 0xfffdf5e6, /* oldlace */ @@ -286,6 +293,7 @@ Colour Colours::findColourForName (const String& colourName, 0x00348d94, 0xffdda0dd, /* plum */ 0xd036be93, 0xffb0e0e6, /* powderblue */ 0xc5c507bc, 0xff800080, /* purple */ + 0xf381f607, 0xff663399, /* rebeccapurple */ 0xa89d65b3, 0xffbc8f8f, /* rosybrown */ 0xbd9413e1, 0xff4169e1, /* royalblue */ 0xf456044f, 0xff8b4513, /* saddlebrown */ diff --git a/modules/juce_graphics/colour/juce_Colours.h b/modules/juce_graphics/colour/juce_Colours.h index 1c8db415f6..76c3d1da4b 100644 --- a/modules/juce_graphics/colour/juce_Colours.h +++ b/modules/juce_graphics/colour/juce_Colours.h @@ -52,39 +52,40 @@ public: yellow, /**< ARGB = 0xffffff00 */ //============================================================================== - aliceblue, antiquewhite, aqua, aquamarine, - azure, beige, bisque, blanchedalmond, - blueviolet, brown, burlywood, cadetblue, - chartreuse, chocolate, coral, cornflowerblue, - cornsilk, crimson, cyan, darkblue, - darkcyan, darkgoldenrod, darkgrey, darkgreen, - darkkhaki, darkmagenta, darkolivegreen, darkorange, - darkorchid, darkred, darksalmon, darkseagreen, - darkslateblue, darkslategrey, darkturquoise, darkviolet, - deeppink, deepskyblue, dimgrey, dodgerblue, - firebrick, floralwhite, forestgreen, fuchsia, - gainsboro, gold, goldenrod, greenyellow, - honeydew, hotpink, indianred, indigo, - ivory, khaki, lavender, lavenderblush, - lemonchiffon, lightblue, lightcoral, lightcyan, - lightgoldenrodyellow, lightgreen, lightgrey, lightpink, - lightsalmon, lightseagreen, lightskyblue, lightslategrey, - lightsteelblue, lightyellow, lime, limegreen, - linen, magenta, maroon, mediumaquamarine, - mediumblue, mediumorchid, mediumpurple, mediumseagreen, - mediumslateblue, mediumspringgreen, mediumturquoise, mediumvioletred, - midnightblue, mintcream, mistyrose, navajowhite, - navy, oldlace, olive, olivedrab, - orange, orangered, orchid, palegoldenrod, - palegreen, paleturquoise, palevioletred, papayawhip, - peachpuff, peru, pink, plum, - powderblue, purple, rosybrown, royalblue, - saddlebrown, salmon, sandybrown, seagreen, - seashell, sienna, silver, skyblue, - slateblue, slategrey, snow, springgreen, - steelblue, tan, teal, thistle, - tomato, turquoise, violet, wheat, - whitesmoke, yellowgreen; + aliceblue, antiquewhite, aqua, aquamarine, + azure, beige, bisque, blanchedalmond, + blueviolet, brown, burlywood, cadetblue, + chartreuse, chocolate, coral, cornflowerblue, + cornsilk, crimson, cyan, darkblue, + darkcyan, darkgoldenrod, darkgrey, darkgreen, + darkkhaki, darkmagenta, darkolivegreen, darkorange, + darkorchid, darkred, darksalmon, darkseagreen, + darkslateblue, darkslategrey, darkturquoise, darkviolet, + deeppink, deepskyblue, dimgrey, dodgerblue, + firebrick, floralwhite, forestgreen, fuchsia, + gainsboro, ghostwhite, gold, goldenrod, + greenyellow, honeydew, hotpink, indianred, + indigo, ivory, khaki, lavender, + lavenderblush, lawngreen, lemonchiffon, lightblue, + lightcoral, lightcyan, lightgoldenrodyellow, lightgreen, + lightgrey, lightpink, lightsalmon, lightseagreen, + lightskyblue, lightslategrey, lightsteelblue, lightyellow, + lime, limegreen, linen, magenta, + maroon, mediumaquamarine, mediumblue, mediumorchid, + mediumpurple, mediumseagreen, mediumslateblue, mediumspringgreen, + mediumturquoise, mediumvioletred, midnightblue, mintcream, + mistyrose, moccasin, navajowhite, navy, + oldlace, olive, olivedrab, orange, + orangered, orchid, palegoldenrod, palegreen, + paleturquoise, palevioletred, papayawhip, peachpuff, + peru, pink, plum, powderblue, + purple, rebeccapurple, rosybrown, royalblue, + saddlebrown, salmon, sandybrown, seagreen, + seashell, sienna, silver, skyblue, + slateblue, slategrey, snow, springgreen, + steelblue, tan, teal, thistle, + tomato, turquoise, violet, wheat, + whitesmoke, yellowgreen; /** Attempts to look up a string in the list of known colour names, and return the appropriate colour. From 05624e835456d19aa24042edc4c6e92affbfebf5 Mon Sep 17 00:00:00 2001 From: hogliux Date: Thu, 7 Sep 2017 16:19:14 +0100 Subject: [PATCH 065/129] AU: Disable CoreAnimation resizing transitions for AU plug-in windows --- .../AU/juce_AU_Wrapper.mm | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm b/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm index ac92ab10a4..7c05c6de7a 100644 --- a/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm +++ b/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm @@ -23,7 +23,6 @@ ============================================================================== */ - #include "../../juce_core/system/juce_TargetPlatform.h" #include "../utility/juce_CheckSettingMacros.h" @@ -51,6 +50,7 @@ #include #include #include +#include #include "CoreAudioUtilityClasses/MusicDeviceBase.h" /** The BUILD_AU_CARBON_UI flag lets you specify whether old-school carbon hosts are supported as @@ -1320,8 +1320,15 @@ public: r.origin.y = r.origin.y + r.size.height - component.getHeight(); r.size.width = component.getWidth(); r.size.height = component.getHeight(); + + [CATransaction begin]; + [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; + [[view superview] setFrame: r]; [view setFrame: makeNSRect (component.getLocalBounds())]; + + [CATransaction commit]; + [view setNeedsDisplay: YES]; } @@ -1389,8 +1396,14 @@ public: NSRect r = [[view superview] frame]; r.size.width = editor->getWidth(); r.size.height = editor->getHeight(); + + [CATransaction begin]; + [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; + [[view superview] setFrame: r]; [view setFrame: makeNSRect (editor->getLocalBounds())]; + [CATransaction commit]; + [view setNeedsDisplay: YES]; } } From f346de10c36a09e6523358c3cf26c8d1fbdb5db7 Mon Sep 17 00:00:00 2001 From: tpoole Date: Thu, 7 Sep 2017 16:26:00 +0100 Subject: [PATCH 066/129] Fixed 4dcce50 to support AudioProcessor based parameter selection --- .../AAX/juce_AAX_Wrapper.cpp | 18 ++++----- .../AU/juce_AU_Wrapper.mm | 40 ++++++++++--------- .../VST3/juce_VST3_Wrapper.cpp | 18 ++++----- 3 files changed, 37 insertions(+), 39 deletions(-) diff --git a/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp b/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp index e809d86c2a..222de07caf 100644 --- a/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp @@ -1319,14 +1319,12 @@ namespace AAXClasses for (int parameterIndex = 0; parameterIndex < numParameters; ++parameterIndex) { - auto* processorParam = audioProcessor.getParameters().getUnchecked (parameterIndex); - - const AudioProcessorParameter::Category category = processorParam->getCategory(); + const AudioProcessorParameter::Category category = audioProcessor.getParameterCategory (parameterIndex); aaxParamIDs.add (usingManagedParameters ? audioProcessor.getParameterID (parameterIndex) : String (parameterIndex)); - AAX_CString paramName (processorParam->getName (31).toRawUTF8()); + AAX_CString paramName (audioProcessor.getParameterName (parameterIndex, 31).toRawUTF8()); AAX_CParamID paramID = aaxParamIDs.getReference (parameterIndex).getCharPointer(); paramMap.set (AAXClasses::getAAXParamHash (paramID), parameterIndex); @@ -1341,25 +1339,25 @@ namespace AAXClasses AAX_IParameter* parameter = new AAX_CParameter (paramID, paramName, - processorParam->getDefaultValue(), + audioProcessor.getParameterDefaultValue (parameterIndex), AAX_CLinearTaperDelegate(), AAX_CNumberDisplayDelegate(), audioProcessor.isParameterAutomatable (parameterIndex)); - parameter->AddShortenedName (processorParam->getName (4).toRawUTF8()); + parameter->AddShortenedName (audioProcessor.getParameterName (parameterIndex, 4).toRawUTF8()); - const int parameterNumSteps = processorParam->getNumSteps(); + const int parameterNumSteps = audioProcessor.getParameterNumSteps (parameterIndex); parameter->SetNumberOfSteps ((uint32_t) parameterNumSteps); #if JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE parameter->SetType (parameterNumSteps > 1000 ? AAX_eParameterType_Continuous : AAX_eParameterType_Discrete); #else - parameter->SetType (processorParam->isDiscrete() ? AAX_eParameterType_Discrete - : AAX_eParameterType_Continuous); + parameter->SetType (audioProcessor.isParameterDiscrete (parameterIndex) ? AAX_eParameterType_Discrete + : AAX_eParameterType_Continuous); #endif - parameter->SetOrientation (processorParam->isOrientationInverted() + parameter->SetOrientation (audioProcessor.isParameterOrientationInverted (parameterIndex) ? (AAX_eParameterOrientation_RightMinLeftMax | AAX_eParameterOrientation_TopMinBottomMax | AAX_eParameterOrientation_RotarySingleDotMode | AAX_eParameterOrientation_RotaryRightMinLeftMax) : (AAX_eParameterOrientation_LeftMinRightMax | AAX_eParameterOrientation_BottomMinTopMax diff --git a/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm b/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm index 7c05c6de7a..7ee4f4e1d2 100644 --- a/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm +++ b/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm @@ -525,7 +525,7 @@ public: const String text (String::fromCFString (pv->inString)); if (AudioProcessorParameter* param = juceFilter->getParameters() [paramID]) - pv->outValue = param->getValueForText (text) * getMaximumParameterValue (param); + pv->outValue = param->getValueForText (text) * getMaximumParameterValue (paramID); else pv->outValue = text.getFloatValue(); @@ -546,7 +546,7 @@ public: String text; if (AudioProcessorParameter* param = juceFilter->getParameters() [paramID]) - text = param->getText (value / getMaximumParameterValue (param), 0); + text = param->getText (value / getMaximumParameterValue (paramID), 0); else text = String (value); @@ -805,13 +805,13 @@ public: //============================================================================== // When parameters are discrete we need to use integer values. - static float getMaximumParameterValue (AudioProcessorParameter* param) + float getMaximumParameterValue (int parameterIndex) { #if JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE - ignoreUnused (param); + ignoreUnused (parameterIndex); return 1.0f; #else - return param->isDiscrete() ? (float) (param->getNumSteps() - 1) : 1.0f; + return juceFilter->isParameterDiscrete (parameterIndex) ? (float) (juceFilter->getParameterNumSteps (parameterIndex) - 1) : 1.0f; #endif } @@ -835,22 +835,22 @@ public: outParameterInfo.flags |= (UInt32) kAudioUnitParameterFlag_IsHighResolution; #endif - auto* param = juceFilter->getParameters().getUnchecked (index); - - const String name (param->getName (512)); + const String name (juceFilter->getParameterName (index)); // Set whether the param is automatable (unnamed parameters aren't allowed to be automated) - if (name.isEmpty() || ! param->isAutomatable()) + if (name.isEmpty() || ! juceFilter->isParameterAutomatable (index)) outParameterInfo.flags |= kAudioUnitParameterFlag_NonRealTime; - if (! param->isDiscrete()) + const bool isParameterDiscrete = juceFilter->isParameterDiscrete (index); + + if (! isParameterDiscrete) outParameterInfo.flags |= kAudioUnitParameterFlag_CanRamp; - if (param->isMetaParameter()) + if (juceFilter->isMetaParameter (index)) outParameterInfo.flags |= kAudioUnitParameterFlag_IsGlobalMeta; // Is this a meter? - if (((param->getCategory() & 0xffff0000) >> 16) == 2) + if (((juceFilter->getParameterCategory (index) & 0xffff0000) >> 16) == 2) { outParameterInfo.flags &= ~kAudioUnitParameterFlag_IsWritable; outParameterInfo.flags |= kAudioUnitParameterFlag_MeterReadOnly | kAudioUnitParameterFlag_DisplayLogarithmic; @@ -859,7 +859,7 @@ public: else { #if ! JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE - outParameterInfo.unit = param->isDiscrete() ? kAudioUnitParameterUnit_Indexed + outParameterInfo.unit = isParameterDiscrete ? kAudioUnitParameterUnit_Indexed : kAudioUnitParameterUnit_Generic; #endif } @@ -867,8 +867,8 @@ public: MusicDeviceBase::FillInParameterName (outParameterInfo, name.toCFString(), true); outParameterInfo.minValue = 0.0f; - outParameterInfo.maxValue = getMaximumParameterValue (param); - outParameterInfo.defaultValue = param->getDefaultValue(); + outParameterInfo.maxValue = getMaximumParameterValue (index); + outParameterInfo.defaultValue = juceFilter->getParameterDefaultValue (index); jassert (outParameterInfo.defaultValue >= outParameterInfo.minValue && outParameterInfo.defaultValue <= outParameterInfo.maxValue); @@ -885,9 +885,10 @@ public: { if (inScope == kAudioUnitScope_Global && juceFilter != nullptr) { - auto* param = juceFilter->getParameters().getUnchecked (getJuceIndexForAUParameterID (inID)); + const auto index = getJuceIndexForAUParameterID (inID); + auto* param = juceFilter->getParameters().getUnchecked (index); - outValue = param->getValue() * getMaximumParameterValue (param); + outValue = param->getValue() * getMaximumParameterValue (index); return noErr; } @@ -902,9 +903,10 @@ public: { if (inScope == kAudioUnitScope_Global && juceFilter != nullptr) { - auto* param = juceFilter->getParameters().getUnchecked (getJuceIndexForAUParameterID (inID)); + const auto index = getJuceIndexForAUParameterID (inID); + auto* param = juceFilter->getParameters().getUnchecked (index); - param->setValue (inValue / getMaximumParameterValue (param)); + param->setValue (inValue / getMaximumParameterValue (index)); return noErr; } diff --git a/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp b/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp index 93302ce8b5..7f02cc0da0 100644 --- a/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp @@ -205,31 +205,29 @@ public: { info.id = paramID; - auto* param = p.getParameters().getUnchecked (index); - - toString128 (info.title, param->getName (128)); - toString128 (info.shortTitle, param->getName (8)); - toString128 (info.units, param->getLabel()); + toString128 (info.title, p.getParameterName (index)); + toString128 (info.shortTitle, p.getParameterName (index, 8)); + toString128 (info.units, p.getParameterLabel (index)); info.stepCount = (Steinberg::int32) 0; #if ! JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE - if (param->isDiscrete()) + if (p.isParameterDiscrete (index)) #endif { - const int numSteps = param->getNumSteps(); + const int numSteps = p.getParameterNumSteps (index); info.stepCount = (Steinberg::int32) (numSteps > 0 && numSteps < 0x7fffffff ? numSteps - 1 : 0); } - info.defaultNormalizedValue = param->getDefaultValue(); + info.defaultNormalizedValue = p.getParameterDefaultValue (index); jassert (info.defaultNormalizedValue >= 0 && info.defaultNormalizedValue <= 1.0f); info.unitId = Vst::kRootUnitId; // Is this a meter? - if (((param->getCategory() & 0xffff0000) >> 16) == 2) + if (((p.getParameterCategory (index) & 0xffff0000) >> 16) == 2) info.flags = Vst::ParameterInfo::kIsReadOnly; else - info.flags = param->isAutomatable() ? Vst::ParameterInfo::kCanAutomate : 0; + info.flags = p.isParameterAutomatable (index) ? Vst::ParameterInfo::kCanAutomate : 0; valueNormalized = info.defaultNormalizedValue; } From b58a0f4be7a0c30d6e7ed3c93650bfa21c16d3f1 Mon Sep 17 00:00:00 2001 From: tpoole Date: Thu, 7 Sep 2017 16:28:01 +0100 Subject: [PATCH 067/129] Fixed some VS2013 compiler errors --- examples/Demo/Source/Demos/GridDemo.cpp | 4 ++-- .../processors/juce_AudioProcessorEditor.h | 2 ++ modules/juce_core/containers/juce_SortedSet.h | 9 ++++++--- modules/juce_gui_basics/juce_gui_basics.cpp | 10 ++++++---- modules/juce_gui_basics/juce_gui_basics.h | 3 +++ 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/examples/Demo/Source/Demos/GridDemo.cpp b/examples/Demo/Source/Demos/GridDemo.cpp index caaf6eed27..41c8e4d8d4 100644 --- a/examples/Demo/Source/Demos/GridDemo.cpp +++ b/examples/Demo/Source/Demos/GridDemo.cpp @@ -27,7 +27,7 @@ #include "../JuceDemoHeader.h" // these classes are C++11-only -#if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS +#if JUCE_HAS_CONSTEXPR struct GridDemo : public Component { @@ -119,4 +119,4 @@ struct GridDemo : public Component // This static object will register this demo type in a global list of demos.. static JuceDemoType demo ("10 Components: GridDemo"); -#endif // JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS +#endif // JUCE_HAS_CONSTEXPR diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.h b/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.h index e0c0bbbe87..a4286c26dc 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.h +++ b/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.h @@ -184,6 +184,8 @@ private: void componentParentHierarchyChanged (Component&) override { ed.updatePeer(); } AudioProcessorEditor& ed; + + JUCE_DECLARE_NON_COPYABLE (AudioProcessorEditorListener) }; //============================================================================== diff --git a/modules/juce_core/containers/juce_SortedSet.h b/modules/juce_core/containers/juce_SortedSet.h index 632b659d2b..3007f43f46 100644 --- a/modules/juce_core/containers/juce_SortedSet.h +++ b/modules/juce_core/containers/juce_SortedSet.h @@ -55,19 +55,22 @@ class SortedSet public: //============================================================================== /** Creates an empty set. */ - SortedSet() noexcept = default; + // VS2013 doesn't allow defaulted noexcept constructors. + SortedSet() noexcept {} /** Creates a copy of another set. */ SortedSet (const SortedSet&) = default; /** Creates a copy of another set. */ - SortedSet (SortedSet&&) noexcept = default; + // VS2013 doesn't allow defaulted noexcept constructors. + SortedSet (SortedSet&& other) noexcept : data (std::move (other.data)) {} /** Makes a copy of another set. */ SortedSet& operator= (const SortedSet&) = default; /** Makes a copy of another set. */ - SortedSet& operator= (SortedSet&&) noexcept = default; + // VS2013 doesn't allow defaulted noexcept constructors. + SortedSet& operator= (SortedSet&& other) noexcept { data = std::move (other.data); return *this; } /** Destructor. */ ~SortedSet() noexcept {} diff --git a/modules/juce_gui_basics/juce_gui_basics.cpp b/modules/juce_gui_basics/juce_gui_basics.cpp index c3eaa28dc0..828632769c 100644 --- a/modules/juce_gui_basics/juce_gui_basics.cpp +++ b/modules/juce_gui_basics/juce_gui_basics.cpp @@ -259,10 +259,12 @@ extern bool juce_areThereAnyAlwaysOnTopWindows(); // these classes are C++11-only #if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS #include "layout/juce_FlexBox.cpp" - #include "layout/juce_GridItem.cpp" - #include "layout/juce_Grid.cpp" - #if JUCE_UNIT_TESTS - #include "layout/juce_GridUnitTests.cpp" + #if JUCE_HAS_CONSTEXPR + #include "layout/juce_GridItem.cpp" + #include "layout/juce_Grid.cpp" + #if JUCE_UNIT_TESTS + #include "layout/juce_GridUnitTests.cpp" + #endif #endif #endif diff --git a/modules/juce_gui_basics/juce_gui_basics.h b/modules/juce_gui_basics/juce_gui_basics.h index 4405ff0c88..2597c67028 100644 --- a/modules/juce_gui_basics/juce_gui_basics.h +++ b/modules/juce_gui_basics/juce_gui_basics.h @@ -299,6 +299,9 @@ class DrawableButton; #if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS #include "layout/juce_FlexItem.h" #include "layout/juce_FlexBox.h" +#endif + +#if JUCE_HAS_CONSTEXPR #include "layout/juce_GridItem.h" #include "layout/juce_Grid.h" From eda613c6db698f31ab2189cc289c9de2db821142 Mon Sep 17 00:00:00 2001 From: jules Date: Fri, 8 Sep 2017 08:59:55 +0100 Subject: [PATCH 068/129] Moved all "namespace juce" declarations from module headers to the individual .h and .cpp source files. This makes life a lot easier for Intellisense and other IDE autocompletion tools --- examples/OSCMonitor/Source/OSCLogListBox.h | 5 +- .../audio_play_head/juce_AudioPlayHead.h | 6 +- .../buffers/juce_AudioChannelSet.cpp | 5 + .../buffers/juce_AudioChannelSet.h | 6 +- .../buffers/juce_AudioDataConverters.cpp | 5 + .../buffers/juce_AudioDataConverters.h | 6 +- .../buffers/juce_AudioSampleBuffer.h | 6 +- .../buffers/juce_FloatVectorOperations.cpp | 5 + .../buffers/juce_FloatVectorOperations.h | 5 +- .../effects/juce_CatmullRomInterpolator.cpp | 5 + .../effects/juce_CatmullRomInterpolator.h | 5 + .../juce_audio_basics/effects/juce_Decibels.h | 6 +- .../effects/juce_IIRFilter.cpp | 6 +- .../effects/juce_IIRFilter.h | 5 +- .../effects/juce_LagrangeInterpolator.cpp | 5 + .../effects/juce_LagrangeInterpolator.h | 5 + .../effects/juce_LinearSmoothedValue.h | 6 +- .../juce_audio_basics/effects/juce_Reverb.h | 6 +- .../juce_audio_basics/juce_audio_basics.cpp | 5 - modules/juce_audio_basics/juce_audio_basics.h | 5 - .../midi/juce_MidiBuffer.cpp | 5 + .../juce_audio_basics/midi/juce_MidiBuffer.h | 6 +- .../juce_audio_basics/midi/juce_MidiFile.cpp | 5 + .../juce_audio_basics/midi/juce_MidiFile.h | 6 +- .../midi/juce_MidiKeyboardState.cpp | 5 + .../midi/juce_MidiKeyboardState.h | 5 +- .../midi/juce_MidiMessage.cpp | 5 + .../juce_audio_basics/midi/juce_MidiMessage.h | 6 +- .../midi/juce_MidiMessageSequence.cpp | 4 + .../midi/juce_MidiMessageSequence.h | 6 +- .../juce_audio_basics/midi/juce_MidiRPN.cpp | 5 + modules/juce_audio_basics/midi/juce_MidiRPN.h | 6 +- .../mpe/juce_MPEInstrument.cpp | 5 + .../mpe/juce_MPEInstrument.h | 6 +- .../mpe/juce_MPEMessages.cpp | 5 + .../juce_audio_basics/mpe/juce_MPEMessages.h | 6 +- .../juce_audio_basics/mpe/juce_MPENote.cpp | 5 + modules/juce_audio_basics/mpe/juce_MPENote.h | 6 +- .../mpe/juce_MPESynthesiser.cpp | 5 + .../mpe/juce_MPESynthesiser.h | 6 +- .../mpe/juce_MPESynthesiserBase.cpp | 5 + .../mpe/juce_MPESynthesiserBase.h | 6 +- .../mpe/juce_MPESynthesiserVoice.cpp | 5 + .../mpe/juce_MPESynthesiserVoice.h | 5 +- .../juce_audio_basics/mpe/juce_MPEValue.cpp | 5 + modules/juce_audio_basics/mpe/juce_MPEValue.h | 6 +- .../juce_audio_basics/mpe/juce_MPEZone.cpp | 5 + modules/juce_audio_basics/mpe/juce_MPEZone.h | 6 +- .../mpe/juce_MPEZoneLayout.cpp | 5 + .../mpe/juce_MPEZoneLayout.h | 6 +- .../native/juce_mac_CoreAudioLayouts.h | 5 +- .../sources/juce_AudioSource.h | 6 +- .../sources/juce_BufferingAudioSource.cpp | 5 + .../sources/juce_BufferingAudioSource.h | 6 +- .../juce_ChannelRemappingAudioSource.cpp | 5 + .../juce_ChannelRemappingAudioSource.h | 6 +- .../sources/juce_IIRFilterAudioSource.cpp | 5 + .../sources/juce_IIRFilterAudioSource.h | 6 +- .../sources/juce_MemoryAudioSource.cpp | 6 +- .../sources/juce_MemoryAudioSource.h | 6 +- .../sources/juce_MixerAudioSource.cpp | 5 + .../sources/juce_MixerAudioSource.h | 6 +- .../sources/juce_PositionableAudioSource.h | 6 +- .../sources/juce_ResamplingAudioSource.cpp | 5 + .../sources/juce_ResamplingAudioSource.h | 6 +- .../sources/juce_ReverbAudioSource.cpp | 5 + .../sources/juce_ReverbAudioSource.h | 6 +- .../sources/juce_ToneGeneratorAudioSource.cpp | 5 + .../sources/juce_ToneGeneratorAudioSource.h | 6 +- .../synthesisers/juce_Synthesiser.cpp | 5 + .../synthesisers/juce_Synthesiser.h | 6 +- .../audio_io/juce_AudioDeviceManager.cpp | 5 + .../audio_io/juce_AudioDeviceManager.h | 6 +- .../audio_io/juce_AudioIODevice.cpp | 5 + .../audio_io/juce_AudioIODevice.h | 5 +- .../audio_io/juce_AudioIODeviceType.cpp | 5 + .../audio_io/juce_AudioIODeviceType.h | 6 +- .../audio_io/juce_SystemAudioVolume.h | 6 +- .../juce_audio_devices/juce_audio_devices.cpp | 18 +-- .../juce_audio_devices/juce_audio_devices.h | 5 - .../midi_io/juce_MidiInput.h | 5 +- .../midi_io/juce_MidiMessageCollector.cpp | 5 + .../midi_io/juce_MidiMessageCollector.h | 6 +- .../midi_io/juce_MidiOutput.cpp | 5 + .../midi_io/juce_MidiOutput.h | 6 +- .../native/juce_MidiDataConcatenator.h | 16 +- .../native/juce_android_Audio.cpp | 6 +- .../native/juce_android_Midi.cpp | 5 + .../native/juce_android_OpenSL.cpp | 6 +- .../native/juce_ios_Audio.cpp | 13 +- .../native/juce_ios_Audio.h | 5 +- .../native/juce_linux_ALSA.cpp | 5 + .../native/juce_linux_JackAudio.cpp | 6 +- .../native/juce_linux_Midi.cpp | 5 + .../native/juce_mac_CoreAudio.cpp | 5 + .../native/juce_mac_CoreMidi.cpp | 5 + .../native/juce_win32_ASIO.cpp | 5 + .../native/juce_win32_DirectSound.cpp | 4 +- .../native/juce_win32_Midi.cpp | 32 ++-- .../native/juce_win32_WASAPI.cpp | 5 + .../sources/juce_AudioSourcePlayer.cpp | 5 + .../sources/juce_AudioSourcePlayer.h | 6 +- .../sources/juce_AudioTransportSource.cpp | 20 +-- .../sources/juce_AudioTransportSource.h | 26 +-- .../codecs/juce_AiffAudioFormat.cpp | 5 + .../codecs/juce_AiffAudioFormat.h | 5 + .../codecs/juce_CoreAudioFormat.cpp | 6 + .../codecs/juce_CoreAudioFormat.h | 5 + .../codecs/juce_FlacAudioFormat.cpp | 5 + .../codecs/juce_FlacAudioFormat.h | 5 + .../codecs/juce_LAMEEncoderAudioFormat.cpp | 5 + .../codecs/juce_LAMEEncoderAudioFormat.h | 5 + .../codecs/juce_MP3AudioFormat.cpp | 5 + .../codecs/juce_MP3AudioFormat.h | 5 + .../codecs/juce_OggVorbisAudioFormat.cpp | 5 + .../codecs/juce_OggVorbisAudioFormat.h | 5 + .../codecs/juce_WavAudioFormat.cpp | 5 + .../codecs/juce_WavAudioFormat.h | 5 + .../codecs/juce_WindowsMediaAudioFormat.cpp | 5 + .../codecs/juce_WindowsMediaAudioFormat.h | 5 + .../format/juce_AudioFormat.cpp | 5 + .../format/juce_AudioFormat.h | 6 +- .../format/juce_AudioFormatManager.cpp | 5 + .../format/juce_AudioFormatManager.h | 6 +- .../format/juce_AudioFormatReader.cpp | 5 + .../format/juce_AudioFormatReader.h | 7 +- .../format/juce_AudioFormatReaderSource.cpp | 5 + .../format/juce_AudioFormatReaderSource.h | 6 +- .../format/juce_AudioFormatWriter.cpp | 5 + .../format/juce_AudioFormatWriter.h | 6 +- .../format/juce_AudioSubsectionReader.cpp | 5 + .../format/juce_AudioSubsectionReader.h | 6 +- .../juce_BufferingAudioFormatReader.cpp | 5 + .../format/juce_BufferingAudioFormatReader.h | 5 +- .../juce_MemoryMappedAudioFormatReader.h | 6 +- .../juce_audio_formats/juce_audio_formats.cpp | 5 - .../juce_audio_formats/juce_audio_formats.h | 6 - .../sampler/juce_Sampler.cpp | 5 + .../juce_audio_formats/sampler/juce_Sampler.h | 6 +- .../AAX/juce_AAX_Modifier_Injector.h | 5 +- .../AAX/juce_AAX_Wrapper.cpp | 7 +- .../AU/juce_AU_Wrapper.mm | 2 + .../AU/juce_AUv3_Wrapper.mm | 7 +- .../RTAS/juce_RTAS_DigiCode1.cpp | 5 + .../RTAS/juce_RTAS_DigiCode2.cpp | 5 + .../RTAS/juce_RTAS_DigiCode3.cpp | 5 + .../RTAS/juce_RTAS_DigiCode_Header.h | 5 +- .../RTAS/juce_RTAS_WinUtilities.cpp | 5 + .../RTAS/juce_RTAS_Wrapper.cpp | 5 + .../Standalone/juce_StandaloneFilterApp.cpp | 16 +- .../Standalone/juce_StandaloneFilterWindow.h | 5 +- .../VST/juce_VSTCallbackHandler.h | 5 +- .../VST/juce_VST_Wrapper.cpp | 1 + .../juce_audio_plugin_client.h | 7 +- .../juce_audio_plugin_client_Standalone.cpp | 2 +- .../utility/juce_CarbonVisibility.h | 5 +- .../utility/juce_FakeMouseMoveGenerator.h | 5 +- .../utility/juce_IncludeModuleHeaders.h | 6 +- .../utility/juce_PluginHostType.h | 5 + .../utility/juce_PluginUtilities.cpp | 11 +- .../utility/juce_WindowsHooks.h | 16 +- .../format/juce_AudioPluginFormat.cpp | 5 + .../format/juce_AudioPluginFormat.h | 6 +- .../format/juce_AudioPluginFormatManager.cpp | 5 + .../format/juce_AudioPluginFormatManager.h | 6 +- .../format_types/juce_AU_Shared.h | 148 +++++++++--------- .../format_types/juce_AudioUnitPluginFormat.h | 5 + .../juce_AudioUnitPluginFormat.mm | 17 +- .../format_types/juce_LADSPAPluginFormat.cpp | 4 +- .../format_types/juce_LADSPAPluginFormat.h | 5 + .../format_types/juce_VST3Common.h | 5 +- .../format_types/juce_VST3Headers.h | 2 - .../format_types/juce_VST3PluginFormat.cpp | 9 +- .../format_types/juce_VST3PluginFormat.h | 7 +- .../format_types/juce_VSTCommon.h | 5 +- .../format_types/juce_VSTInterface.h | 3 - .../format_types/juce_VSTMidiEventList.h | 9 +- .../format_types/juce_VSTPluginFormat.cpp | 7 +- .../format_types/juce_VSTPluginFormat.h | 4 + .../juce_audio_processors.cpp | 9 +- .../juce_audio_processors.h | 6 - .../processors/juce_AudioPluginInstance.h | 6 +- .../processors/juce_AudioProcessor.cpp | 5 + .../processors/juce_AudioProcessor.h | 5 +- .../processors/juce_AudioProcessorEditor.cpp | 5 + .../processors/juce_AudioProcessorEditor.h | 7 +- .../processors/juce_AudioProcessorGraph.cpp | 5 + .../processors/juce_AudioProcessorGraph.h | 5 +- .../processors/juce_AudioProcessorListener.h | 6 +- .../processors/juce_AudioProcessorParameter.h | 6 +- .../juce_GenericAudioProcessorEditor.cpp | 5 + .../juce_GenericAudioProcessorEditor.h | 6 +- .../processors/juce_PluginDescription.cpp | 5 + .../processors/juce_PluginDescription.h | 6 +- .../scanning/juce_KnownPluginList.cpp | 5 + .../scanning/juce_KnownPluginList.h | 6 +- .../scanning/juce_PluginDirectoryScanner.cpp | 5 + .../scanning/juce_PluginDirectoryScanner.h | 6 +- .../scanning/juce_PluginListComponent.cpp | 5 + .../scanning/juce_PluginListComponent.h | 6 +- .../utilities/juce_AudioParameterBool.h | 5 + .../utilities/juce_AudioParameterChoice.h | 5 + .../utilities/juce_AudioParameterFloat.h | 5 + .../utilities/juce_AudioParameterInt.h | 5 + .../juce_AudioProcessorParameterWithID.h | 5 + .../juce_AudioProcessorParameters.cpp | 5 + .../juce_AudioProcessorValueTreeState.cpp | 6 +- .../juce_AudioProcessorValueTreeState.h | 5 +- .../audio_cd/juce_AudioCDBurner.h | 5 +- .../audio_cd/juce_AudioCDReader.cpp | 5 + .../audio_cd/juce_AudioCDReader.h | 5 +- .../gui/juce_AudioAppComponent.cpp | 5 + .../gui/juce_AudioAppComponent.h | 6 +- .../gui/juce_AudioDeviceSelectorComponent.cpp | 5 + .../gui/juce_AudioDeviceSelectorComponent.h | 6 +- .../gui/juce_AudioThumbnail.cpp | 5 + .../gui/juce_AudioThumbnail.h | 6 +- .../gui/juce_AudioThumbnailBase.h | 5 +- .../gui/juce_AudioThumbnailCache.cpp | 5 + .../gui/juce_AudioThumbnailCache.h | 6 +- .../gui/juce_AudioVisualiserComponent.cpp | 5 + .../gui/juce_AudioVisualiserComponent.h | 6 +- .../juce_BluetoothMidiDevicePairingDialogue.h | 5 +- .../gui/juce_MidiKeyboardComponent.cpp | 5 + .../gui/juce_MidiKeyboardComponent.h | 6 +- modules/juce_audio_utils/juce_audio_utils.cpp | 16 +- modules/juce_audio_utils/juce_audio_utils.h | 5 - ...oid_BluetoothMidiDevicePairingDialogue.cpp | 6 +- ..._ios_BluetoothMidiDevicePairingDialogue.mm | 16 +- .../native/juce_linux_AudioCDReader.cpp | 5 + ...nux_BluetoothMidiDevicePairingDialogue.cpp | 5 + .../native/juce_mac_AudioCDReader.mm | 7 +- ..._mac_BluetoothMidiDevicePairingDialogue.mm | 5 + .../native/juce_win32_AudioCDBurner.cpp | 5 + .../native/juce_win32_AudioCDReader.cpp | 11 +- ...win_BluetoothMidiDevicePairingDialogue.cpp | 5 + .../players/juce_AudioProcessorPlayer.cpp | 5 + .../players/juce_AudioProcessorPlayer.h | 5 +- .../players/juce_SoundPlayer.cpp | 6 +- .../players/juce_SoundPlayer.h | 5 +- .../juce_blocks_basics/blocks/juce_Block.cpp | 4 + .../juce_blocks_basics/blocks/juce_Block.h | 4 + .../blocks/juce_BlockConfigManager.h | 5 +- .../blocks/juce_ControlButton.h | 4 + .../juce_blocks_basics/blocks/juce_LEDGrid.h | 4 + .../juce_blocks_basics/blocks/juce_LEDRow.h | 4 + .../blocks/juce_StatusLight.h | 4 + .../blocks/juce_TouchList.h | 4 + .../blocks/juce_TouchSurface.h | 4 + .../juce_blocks_basics/juce_blocks_basics.cpp | 30 ++-- .../juce_blocks_basics/juce_blocks_basics.h | 50 +++--- .../littlefoot/juce_LittleFootCompiler.h | 2 - .../littlefoot/juce_LittleFootRemoteHeap.h | 2 - .../protocol/juce_BitPackingUtilities.h | 7 + .../protocol/juce_BlockModels.h | 7 + .../protocol/juce_BlocksProtocolDefinitions.h | 7 + .../protocol/juce_HostPacketBuilder.h | 7 + .../protocol/juce_HostPacketDecoder.h | 7 + .../topology/juce_PhysicalTopologySource.cpp | 5 + .../topology/juce_PhysicalTopologySource.h | 4 + .../topology/juce_RuleBasedTopologySource.cpp | 4 + .../topology/juce_RuleBasedTopologySource.h | 4 + .../topology/juce_Topology.h | 4 + .../topology/juce_TopologySource.h | 4 + .../visualisers/juce_BitmapLEDProgram.cpp | 4 + .../visualisers/juce_BitmapLEDProgram.h | 4 + .../visualisers/juce_DrumPadLEDProgram.cpp | 4 + .../visualisers/juce_DrumPadLEDProgram.h | 5 + modules/juce_box2d/juce_box2d.cpp | 3 - modules/juce_box2d/juce_box2d.h | 5 +- .../juce_box2d/utils/juce_Box2DRenderer.cpp | 5 + modules/juce_box2d/utils/juce_Box2DRenderer.h | 5 +- .../containers/juce_AbstractFifo.cpp | 5 + .../juce_core/containers/juce_AbstractFifo.h | 6 +- modules/juce_core/containers/juce_Array.h | 6 +- .../containers/juce_ArrayAllocationBase.h | 6 +- .../containers/juce_DynamicObject.cpp | 5 + .../juce_core/containers/juce_DynamicObject.h | 6 +- .../containers/juce_ElementComparator.h | 5 +- modules/juce_core/containers/juce_HashMap.h | 6 +- .../containers/juce_HashMap_test.cpp | 5 + .../containers/juce_LinkedListPointer.h | 6 +- .../containers/juce_ListenerList.cpp | 5 + .../juce_core/containers/juce_ListenerList.h | 6 +- .../containers/juce_NamedValueSet.cpp | 6 +- .../juce_core/containers/juce_NamedValueSet.h | 6 +- .../juce_core/containers/juce_OwnedArray.h | 6 +- .../juce_core/containers/juce_PropertySet.cpp | 5 + .../juce_core/containers/juce_PropertySet.h | 6 +- .../containers/juce_ReferenceCountedArray.h | 6 +- .../containers/juce_ScopedValueSetter.h | 6 +- modules/juce_core/containers/juce_SortedSet.h | 5 +- modules/juce_core/containers/juce_SparseSet.h | 6 +- modules/juce_core/containers/juce_Variant.cpp | 5 + modules/juce_core/containers/juce_Variant.h | 6 +- .../files/juce_DirectoryIterator.cpp | 5 + .../juce_core/files/juce_DirectoryIterator.h | 6 +- modules/juce_core/files/juce_File.cpp | 5 + modules/juce_core/files/juce_File.h | 6 +- modules/juce_core/files/juce_FileFilter.cpp | 5 + modules/juce_core/files/juce_FileFilter.h | 6 +- .../juce_core/files/juce_FileInputStream.cpp | 5 + .../juce_core/files/juce_FileInputStream.h | 6 +- .../juce_core/files/juce_FileOutputStream.cpp | 5 + .../juce_core/files/juce_FileOutputStream.h | 6 +- .../juce_core/files/juce_FileSearchPath.cpp | 5 + modules/juce_core/files/juce_FileSearchPath.h | 6 +- .../juce_core/files/juce_MemoryMappedFile.h | 6 +- .../juce_core/files/juce_TemporaryFile.cpp | 5 + modules/juce_core/files/juce_TemporaryFile.h | 6 +- .../files/juce_WildcardFileFilter.cpp | 5 + .../juce_core/files/juce_WildcardFileFilter.h | 6 +- modules/juce_core/javascript/juce_JSON.cpp | 11 +- modules/juce_core/javascript/juce_JSON.h | 6 +- .../juce_core/javascript/juce_Javascript.cpp | 5 + .../juce_core/javascript/juce_Javascript.h | 6 +- modules/juce_core/juce_core.cpp | 11 +- modules/juce_core/juce_core.h | 33 ++-- modules/juce_core/logging/juce_FileLogger.cpp | 5 + modules/juce_core/logging/juce_FileLogger.h | 6 +- modules/juce_core/logging/juce_Logger.cpp | 5 + modules/juce_core/logging/juce_Logger.h | 6 +- modules/juce_core/maths/juce_BigInteger.cpp | 5 + modules/juce_core/maths/juce_BigInteger.h | 6 +- modules/juce_core/maths/juce_Expression.cpp | 5 + modules/juce_core/maths/juce_Expression.h | 6 +- modules/juce_core/maths/juce_MathsFunctions.h | 6 +- .../juce_core/maths/juce_NormalisableRange.h | 6 +- modules/juce_core/maths/juce_Random.cpp | 7 +- modules/juce_core/maths/juce_Random.h | 6 +- modules/juce_core/maths/juce_Range.h | 6 +- .../maths/juce_StatisticsAccumulator.h | 6 +- modules/juce_core/memory/juce_Atomic.h | 5 +- modules/juce_core/memory/juce_ByteOrder.h | 6 +- .../memory/juce_ContainerDeletePolicy.h | 5 +- modules/juce_core/memory/juce_HeapBlock.h | 5 +- .../memory/juce_LeakedObjectDetector.h | 6 +- modules/juce_core/memory/juce_Memory.h | 8 +- modules/juce_core/memory/juce_MemoryBlock.cpp | 8 +- modules/juce_core/memory/juce_MemoryBlock.h | 6 +- .../memory/juce_OptionalScopedPointer.h | 6 +- .../memory/juce_ReferenceCountedObject.h | 6 +- modules/juce_core/memory/juce_ScopedPointer.h | 5 +- .../memory/juce_SharedResourcePointer.h | 6 +- modules/juce_core/memory/juce_Singleton.h | 6 +- modules/juce_core/memory/juce_WeakReference.h | 6 +- modules/juce_core/misc/juce_Result.cpp | 5 + modules/juce_core/misc/juce_Result.h | 6 +- .../misc/juce_RuntimePermissions.cpp | 22 +-- .../juce_core/misc/juce_RuntimePermissions.h | 5 +- .../juce_core/misc/juce_StdFunctionCompat.cpp | 5 + .../juce_core/misc/juce_StdFunctionCompat.h | 2 - modules/juce_core/misc/juce_Uuid.cpp | 5 + modules/juce_core/misc/juce_Uuid.h | 6 +- modules/juce_core/misc/juce_WindowsRegistry.h | 5 +- .../juce_core/native/juce_android_Files.cpp | 6 +- .../native/juce_android_JNIHelpers.h | 5 +- .../juce_core/native/juce_android_Misc.cpp | 5 + .../juce_core/native/juce_android_Network.cpp | 6 +- .../juce_android_RuntimePermissions.cpp | 28 ++-- .../native/juce_android_SystemStats.cpp | 6 +- .../juce_core/native/juce_android_Threads.cpp | 5 + .../juce_core/native/juce_curl_Network.cpp | 5 + .../native/juce_linux_CommonFile.cpp | 5 + modules/juce_core/native/juce_linux_Files.cpp | 5 + .../juce_core/native/juce_linux_Network.cpp | 5 + .../native/juce_linux_SystemStats.cpp | 5 + .../juce_core/native/juce_linux_Threads.cpp | 5 + modules/juce_core/native/juce_mac_Files.mm | 5 + modules/juce_core/native/juce_mac_Network.mm | 5 + modules/juce_core/native/juce_mac_Strings.mm | 5 + .../juce_core/native/juce_mac_SystemStats.mm | 5 + modules/juce_core/native/juce_mac_Threads.mm | 5 + .../juce_core/native/juce_osx_ObjCHelpers.h | 137 ++++++++-------- .../juce_core/native/juce_posix_NamedPipe.cpp | 5 + .../juce_core/native/juce_posix_SharedCode.h | 5 + .../juce_core/native/juce_win32_ComSmartPtr.h | 5 +- modules/juce_core/native/juce_win32_Files.cpp | 5 + .../juce_core/native/juce_win32_Network.cpp | 5 + .../juce_core/native/juce_win32_Registry.cpp | 5 + .../native/juce_win32_SystemStats.cpp | 5 + .../juce_core/native/juce_win32_Threads.cpp | 9 +- modules/juce_core/network/juce_IPAddress.cpp | 5 + modules/juce_core/network/juce_IPAddress.h | 6 +- modules/juce_core/network/juce_MACAddress.cpp | 5 + modules/juce_core/network/juce_MACAddress.h | 6 +- modules/juce_core/network/juce_NamedPipe.cpp | 7 +- modules/juce_core/network/juce_NamedPipe.h | 6 +- modules/juce_core/network/juce_Socket.cpp | 5 + modules/juce_core/network/juce_Socket.h | 6 +- modules/juce_core/network/juce_URL.cpp | 5 + modules/juce_core/network/juce_URL.h | 6 +- .../juce_core/network/juce_WebInputStream.cpp | 5 + .../juce_core/network/juce_WebInputStream.h | 5 +- .../streams/juce_BufferedInputStream.cpp | 5 + .../streams/juce_BufferedInputStream.h | 6 +- .../streams/juce_FileInputSource.cpp | 5 + .../juce_core/streams/juce_FileInputSource.h | 6 +- modules/juce_core/streams/juce_InputSource.h | 6 +- .../juce_core/streams/juce_InputStream.cpp | 5 + modules/juce_core/streams/juce_InputStream.h | 6 +- .../streams/juce_MemoryInputStream.cpp | 5 + .../streams/juce_MemoryInputStream.h | 6 +- .../streams/juce_MemoryOutputStream.cpp | 5 + .../streams/juce_MemoryOutputStream.h | 6 +- .../juce_core/streams/juce_OutputStream.cpp | 5 + modules/juce_core/streams/juce_OutputStream.h | 6 +- .../streams/juce_SubregionStream.cpp | 5 + .../juce_core/streams/juce_SubregionStream.h | 6 +- modules/juce_core/system/juce_PlatformDefs.h | 7 +- modules/juce_core/system/juce_SystemStats.cpp | 5 + modules/juce_core/system/juce_SystemStats.h | 6 +- modules/juce_core/text/juce_Base64.cpp | 5 + modules/juce_core/text/juce_Base64.h | 6 +- .../juce_core/text/juce_CharPointer_ASCII.h | 6 +- .../juce_core/text/juce_CharPointer_UTF16.h | 6 +- .../juce_core/text/juce_CharPointer_UTF32.h | 6 +- .../juce_core/text/juce_CharPointer_UTF8.h | 5 +- .../text/juce_CharacterFunctions.cpp | 6 +- .../juce_core/text/juce_CharacterFunctions.h | 6 +- modules/juce_core/text/juce_Identifier.cpp | 5 + modules/juce_core/text/juce_Identifier.h | 6 +- .../juce_core/text/juce_LocalisedStrings.cpp | 5 + .../juce_core/text/juce_LocalisedStrings.h | 6 +- modules/juce_core/text/juce_NewLine.h | 6 +- modules/juce_core/text/juce_String.cpp | 5 + modules/juce_core/text/juce_String.h | 9 +- modules/juce_core/text/juce_StringArray.cpp | 5 + modules/juce_core/text/juce_StringArray.h | 6 +- .../juce_core/text/juce_StringPairArray.cpp | 8 +- modules/juce_core/text/juce_StringPairArray.h | 6 +- modules/juce_core/text/juce_StringPool.cpp | 5 + modules/juce_core/text/juce_StringPool.h | 6 +- modules/juce_core/text/juce_StringRef.h | 5 +- modules/juce_core/text/juce_TextDiff.cpp | 5 + modules/juce_core/text/juce_TextDiff.h | 6 +- .../juce_core/threads/juce_ChildProcess.cpp | 7 +- modules/juce_core/threads/juce_ChildProcess.h | 6 +- .../juce_core/threads/juce_CriticalSection.h | 6 +- .../juce_core/threads/juce_DynamicLibrary.h | 13 +- .../threads/juce_HighResolutionTimer.cpp | 5 + .../threads/juce_HighResolutionTimer.h | 5 +- .../juce_core/threads/juce_InterProcessLock.h | 6 +- modules/juce_core/threads/juce_Process.h | 6 +- .../juce_core/threads/juce_ReadWriteLock.cpp | 5 + .../juce_core/threads/juce_ReadWriteLock.h | 6 +- modules/juce_core/threads/juce_ScopedLock.h | 6 +- .../juce_core/threads/juce_ScopedReadLock.h | 6 +- .../juce_core/threads/juce_ScopedWriteLock.h | 6 +- modules/juce_core/threads/juce_SpinLock.h | 6 +- modules/juce_core/threads/juce_Thread.cpp | 5 + modules/juce_core/threads/juce_Thread.h | 6 +- .../juce_core/threads/juce_ThreadLocalValue.h | 5 +- modules/juce_core/threads/juce_ThreadPool.cpp | 5 + modules/juce_core/threads/juce_ThreadPool.h | 5 +- .../threads/juce_TimeSliceThread.cpp | 9 +- .../juce_core/threads/juce_TimeSliceThread.h | 7 +- .../juce_core/threads/juce_WaitableEvent.h | 6 +- .../time/juce_PerformanceCounter.cpp | 5 + .../juce_core/time/juce_PerformanceCounter.h | 6 +- modules/juce_core/time/juce_RelativeTime.cpp | 5 + modules/juce_core/time/juce_RelativeTime.h | 6 +- modules/juce_core/time/juce_Time.cpp | 5 + modules/juce_core/time/juce_Time.h | 6 +- .../juce_core/unit_tests/juce_UnitTest.cpp | 5 + modules/juce_core/unit_tests/juce_UnitTest.h | 5 +- modules/juce_core/xml/juce_XmlDocument.cpp | 19 +-- modules/juce_core/xml/juce_XmlDocument.h | 13 +- modules/juce_core/xml/juce_XmlElement.cpp | 62 ++++---- modules/juce_core/xml/juce_XmlElement.h | 6 +- .../zip/juce_GZIPCompressorOutputStream.cpp | 15 +- .../zip/juce_GZIPCompressorOutputStream.h | 6 +- .../zip/juce_GZIPDecompressorInputStream.cpp | 21 ++- .../zip/juce_GZIPDecompressorInputStream.h | 6 +- modules/juce_core/zip/juce_ZipFile.cpp | 5 + modules/juce_core/zip/juce_ZipFile.h | 6 +- .../encryption/juce_BlowFish.cpp | 5 + .../encryption/juce_BlowFish.h | 6 +- .../encryption/juce_Primes.cpp | 5 + .../encryption/juce_Primes.h | 6 +- .../encryption/juce_RSAKey.cpp | 5 + .../encryption/juce_RSAKey.h | 6 +- .../juce_cryptography/hashing/juce_MD5.cpp | 5 + modules/juce_cryptography/hashing/juce_MD5.h | 6 +- .../juce_cryptography/hashing/juce_SHA256.cpp | 5 + .../juce_cryptography/hashing/juce_SHA256.h | 6 +- .../hashing/juce_Whirlpool.cpp | 5 + .../hashing/juce_Whirlpool.h | 6 +- .../juce_cryptography/juce_cryptography.cpp | 5 - modules/juce_cryptography/juce_cryptography.h | 5 - .../juce_ApplicationProperties.cpp | 5 + .../juce_ApplicationProperties.h | 6 +- .../app_properties/juce_PropertiesFile.cpp | 5 + .../app_properties/juce_PropertiesFile.h | 6 +- .../juce_data_structures.cpp | 5 - .../juce_data_structures.h | 5 - .../undomanager/juce_UndoManager.cpp | 5 + .../undomanager/juce_UndoManager.h | 6 +- .../undomanager/juce_UndoableAction.h | 6 +- .../values/juce_CachedValue.cpp | 5 + .../values/juce_CachedValue.h | 6 +- .../values/juce_Value.cpp | 5 + .../juce_data_structures/values/juce_Value.h | 6 +- .../values/juce_ValueTree.cpp | 5 + .../values/juce_ValueTree.h | 6 +- .../values/juce_ValueTreeSynchroniser.cpp | 5 + .../values/juce_ValueTreeSynchroniser.h | 6 +- modules/juce_dsp/containers/juce_AudioBlock.h | 8 + .../juce_dsp/containers/juce_SIMDRegister.h | 12 +- .../containers/juce_SIMDRegister_test.cpp | 7 + .../filter_design/juce_FilterDesign.cpp | 7 + .../filter_design/juce_FilterDesign.h | 7 + .../juce_dsp/frequency/juce_Convolution.cpp | 7 + modules/juce_dsp/frequency/juce_Convolution.h | 7 + modules/juce_dsp/frequency/juce_FFT.cpp | 7 + modules/juce_dsp/frequency/juce_FFT.h | 7 + modules/juce_dsp/frequency/juce_FFT_test.cpp | 7 + modules/juce_dsp/frequency/juce_Windowing.cpp | 8 + modules/juce_dsp/frequency/juce_Windowing.h | 7 + modules/juce_dsp/juce_dsp.cpp | 68 ++++---- modules/juce_dsp/juce_dsp.h | 91 +++++------ .../maths/juce_FastMathApproximations.h | 7 + modules/juce_dsp/maths/juce_LookupTable.cpp | 8 + modules/juce_dsp/maths/juce_LookupTable.h | 7 + modules/juce_dsp/maths/juce_Matrix.cpp | 7 + modules/juce_dsp/maths/juce_Matrix.h | 8 + modules/juce_dsp/maths/juce_Matrix_test.cpp | 7 + modules/juce_dsp/maths/juce_Polynomial.h | 7 + .../juce_dsp/maths/juce_SpecialFunctions.cpp | 7 + .../juce_dsp/maths/juce_SpecialFunctions.h | 7 + .../native/juce_avx_SIMDNativeOps.cpp | 43 ++--- .../juce_dsp/native/juce_avx_SIMDNativeOps.h | 7 + .../native/juce_fallback_SIMDNativeOps.h | 7 + .../native/juce_neon_SIMDNativeOps.cpp | 31 ++-- .../juce_dsp/native/juce_neon_SIMDNativeOps.h | 8 + .../native/juce_sse_SIMDNativeOps.cpp | 43 ++--- .../juce_dsp/native/juce_sse_SIMDNativeOps.h | 8 + modules/juce_dsp/processors/juce_Bias.h | 7 + .../juce_dsp/processors/juce_FIRFilter.cpp | 7 + modules/juce_dsp/processors/juce_FIRFilter.h | 7 + .../processors/juce_FIRFilter_test.cpp | 7 + modules/juce_dsp/processors/juce_Gain.h | 7 + .../juce_dsp/processors/juce_IIRFilter.cpp | 7 + modules/juce_dsp/processors/juce_IIRFilter.h | 12 +- .../juce_dsp/processors/juce_IIRFilter_Impl.h | 11 ++ modules/juce_dsp/processors/juce_Oscillator.h | 7 + .../juce_dsp/processors/juce_Oversampling.cpp | 8 +- .../juce_dsp/processors/juce_Oversampling.h | 8 + .../juce_dsp/processors/juce_ProcessContext.h | 7 + .../juce_dsp/processors/juce_ProcessorChain.h | 7 + .../processors/juce_ProcessorDuplicator.h | 7 + .../processors/juce_ProcessorWrapper.h | 7 + .../processors/juce_StateVariableFilter.h | 7 + modules/juce_dsp/processors/juce_WaveShaper.h | 7 + .../broadcasters/juce_ActionBroadcaster.cpp | 5 + .../broadcasters/juce_ActionBroadcaster.h | 6 +- .../broadcasters/juce_ActionListener.h | 6 +- .../broadcasters/juce_AsyncUpdater.cpp | 5 + .../broadcasters/juce_AsyncUpdater.h | 6 +- .../broadcasters/juce_ChangeBroadcaster.cpp | 5 + .../broadcasters/juce_ChangeBroadcaster.h | 6 +- .../broadcasters/juce_ChangeListener.h | 5 +- .../juce_ConnectedChildProcess.cpp | 5 + .../interprocess/juce_ConnectedChildProcess.h | 5 +- .../juce_InterprocessConnection.cpp | 5 + .../juce_InterprocessConnection.h | 5 +- .../juce_InterprocessConnectionServer.cpp | 5 + .../juce_InterprocessConnectionServer.h | 6 +- modules/juce_events/juce_events.cpp | 5 - modules/juce_events/juce_events.h | 6 - .../messages/juce_ApplicationBase.cpp | 5 + .../messages/juce_ApplicationBase.h | 6 +- .../messages/juce_CallbackMessage.h | 6 +- .../messages/juce_DeletedAtShutdown.cpp | 5 + .../messages/juce_DeletedAtShutdown.h | 6 +- .../messages/juce_Initialisation.h | 6 +- modules/juce_events/messages/juce_Message.h | 5 +- .../messages/juce_MessageListener.cpp | 5 + .../messages/juce_MessageListener.h | 6 +- .../messages/juce_MessageManager.cpp | 5 + .../messages/juce_MessageManager.h | 5 +- .../juce_MountedVolumeListChangeDetector.h | 5 +- .../messages/juce_NotificationType.h | 5 +- .../native/juce_android_Messaging.cpp | 6 +- .../native/juce_ios_MessageManager.mm | 5 + .../juce_events/native/juce_linux_EventLoop.h | 5 +- .../native/juce_linux_Messaging.cpp | 43 +++-- .../native/juce_mac_MessageManager.mm | 5 + .../native/juce_osx_MessageQueue.h | 5 +- .../native/juce_win32_HiddenMessageWindow.h | 7 +- .../native/juce_win32_Messaging.cpp | 5 + .../native/juce_win32_WinRTWrapper.cpp | 5 +- .../native/juce_win32_WinRTWrapper.h | 11 +- .../juce_events/timers/juce_MultiTimer.cpp | 5 + modules/juce_events/timers/juce_MultiTimer.h | 6 +- modules/juce_events/timers/juce_Timer.cpp | 5 + modules/juce_events/timers/juce_Timer.h | 6 +- modules/juce_graphics/colour/juce_Colour.cpp | 5 + modules/juce_graphics/colour/juce_Colour.h | 6 +- .../colour/juce_ColourGradient.cpp | 5 + .../colour/juce_ColourGradient.h | 6 +- modules/juce_graphics/colour/juce_Colours.cpp | 5 + modules/juce_graphics/colour/juce_Colours.h | 6 +- .../juce_graphics/colour/juce_FillType.cpp | 5 + modules/juce_graphics/colour/juce_FillType.h | 6 +- .../juce_graphics/colour/juce_PixelFormats.h | 6 +- .../contexts/juce_GraphicsContext.cpp | 5 + .../contexts/juce_GraphicsContext.h | 6 +- .../contexts/juce_LowLevelGraphicsContext.h | 6 +- ...uce_LowLevelGraphicsPostScriptRenderer.cpp | 5 + .../juce_LowLevelGraphicsPostScriptRenderer.h | 6 +- .../juce_LowLevelGraphicsSoftwareRenderer.cpp | 5 + .../juce_LowLevelGraphicsSoftwareRenderer.h | 6 +- .../effects/juce_DropShadowEffect.cpp | 5 + .../effects/juce_DropShadowEffect.h | 6 +- .../juce_graphics/effects/juce_GlowEffect.cpp | 5 + .../juce_graphics/effects/juce_GlowEffect.h | 6 +- .../effects/juce_ImageEffectFilter.h | 6 +- .../fonts/juce_AttributedString.cpp | 5 + .../fonts/juce_AttributedString.h | 6 +- .../fonts/juce_CustomTypeface.cpp | 5 + .../juce_graphics/fonts/juce_CustomTypeface.h | 6 +- modules/juce_graphics/fonts/juce_Font.cpp | 5 + modules/juce_graphics/fonts/juce_Font.h | 6 +- .../fonts/juce_GlyphArrangement.cpp | 5 + .../fonts/juce_GlyphArrangement.h | 6 +- .../juce_graphics/fonts/juce_TextLayout.cpp | 5 + modules/juce_graphics/fonts/juce_TextLayout.h | 6 +- modules/juce_graphics/fonts/juce_Typeface.cpp | 5 + modules/juce_graphics/fonts/juce_Typeface.h | 6 +- .../geometry/juce_AffineTransform.cpp | 5 + .../geometry/juce_AffineTransform.h | 6 +- .../juce_graphics/geometry/juce_BorderSize.h | 6 +- .../juce_graphics/geometry/juce_EdgeTable.cpp | 5 + .../juce_graphics/geometry/juce_EdgeTable.h | 6 +- modules/juce_graphics/geometry/juce_Line.h | 6 +- modules/juce_graphics/geometry/juce_Path.cpp | 5 + modules/juce_graphics/geometry/juce_Path.h | 6 +- .../geometry/juce_PathIterator.cpp | 5 + .../geometry/juce_PathIterator.h | 6 +- .../geometry/juce_PathStrokeType.cpp | 5 + .../geometry/juce_PathStrokeType.h | 6 +- modules/juce_graphics/geometry/juce_Point.h | 6 +- .../juce_graphics/geometry/juce_Rectangle.h | 6 +- .../geometry/juce_RectangleList.h | 6 +- .../image_formats/juce_GIFLoader.cpp | 5 + .../image_formats/juce_JPEGLoader.cpp | 5 + .../image_formats/juce_PNGLoader.cpp | 5 + modules/juce_graphics/images/juce_Image.cpp | 5 + modules/juce_graphics/images/juce_Image.h | 5 +- .../juce_graphics/images/juce_ImageCache.cpp | 5 + .../juce_graphics/images/juce_ImageCache.h | 6 +- .../images/juce_ImageConvolutionKernel.cpp | 5 + .../images/juce_ImageConvolutionKernel.h | 6 +- .../images/juce_ImageFileFormat.cpp | 5 + .../images/juce_ImageFileFormat.h | 6 +- modules/juce_graphics/juce_graphics.cpp | 4 - modules/juce_graphics/juce_graphics.h | 18 +-- .../native/juce_RenderingHelpers.h | 5 +- .../native/juce_android_Fonts.cpp | 5 + .../native/juce_android_GraphicsContext.cpp | 5 + .../native/juce_android_IconHelpers.cpp | 4 +- .../native/juce_freetype_Fonts.cpp | 5 + .../juce_graphics/native/juce_linux_Fonts.cpp | 5 + .../native/juce_linux_IconHelpers.cpp | 4 +- .../native/juce_mac_CoreGraphicsContext.h | 5 +- .../native/juce_mac_CoreGraphicsContext.mm | 6 +- .../native/juce_mac_CoreGraphicsHelpers.h | 8 +- .../juce_graphics/native/juce_mac_Fonts.mm | 5 + .../native/juce_mac_IconHelpers.cpp | 13 ++ .../juce_win32_Direct2DGraphicsContext.cpp | 5 + .../juce_win32_Direct2DGraphicsContext.h | 5 +- .../juce_win32_DirectWriteTypeLayout.cpp | 5 + .../native/juce_win32_DirectWriteTypeface.cpp | 5 + .../juce_graphics/native/juce_win32_Fonts.cpp | 5 + .../native/juce_win32_IconHelpers.cpp | 4 +- .../placement/juce_Justification.h | 6 +- .../placement/juce_RectanglePlacement.cpp | 5 + .../placement/juce_RectanglePlacement.h | 6 +- .../application/juce_Application.cpp | 5 + .../application/juce_Application.h | 6 +- .../buttons/juce_ArrowButton.cpp | 5 + .../buttons/juce_ArrowButton.h | 6 +- .../juce_gui_basics/buttons/juce_Button.cpp | 5 + modules/juce_gui_basics/buttons/juce_Button.h | 6 +- .../buttons/juce_DrawableButton.cpp | 5 + .../buttons/juce_DrawableButton.h | 6 +- .../buttons/juce_HyperlinkButton.cpp | 5 + .../buttons/juce_HyperlinkButton.h | 6 +- .../buttons/juce_ImageButton.cpp | 5 + .../buttons/juce_ImageButton.h | 6 +- .../buttons/juce_ShapeButton.cpp | 5 + .../buttons/juce_ShapeButton.h | 6 +- .../buttons/juce_TextButton.cpp | 5 + .../juce_gui_basics/buttons/juce_TextButton.h | 6 +- .../buttons/juce_ToggleButton.cpp | 5 + .../buttons/juce_ToggleButton.h | 6 +- .../buttons/juce_ToolbarButton.cpp | 5 + .../buttons/juce_ToolbarButton.h | 6 +- .../commands/juce_ApplicationCommandID.h | 6 +- .../commands/juce_ApplicationCommandInfo.cpp | 5 + .../commands/juce_ApplicationCommandInfo.h | 6 +- .../juce_ApplicationCommandManager.cpp | 5 + .../commands/juce_ApplicationCommandManager.h | 6 +- .../juce_ApplicationCommandTarget.cpp | 5 + .../commands/juce_ApplicationCommandTarget.h | 6 +- .../commands/juce_KeyPressMappingSet.cpp | 5 + .../commands/juce_KeyPressMappingSet.h | 6 +- .../components/juce_CachedComponentImage.h | 6 +- .../components/juce_Component.cpp | 5 + .../components/juce_Component.h | 6 +- .../components/juce_ComponentListener.cpp | 5 + .../components/juce_ComponentListener.h | 6 +- .../components/juce_Desktop.cpp | 5 + .../juce_gui_basics/components/juce_Desktop.h | 6 +- .../components/juce_ModalComponentManager.cpp | 5 + .../components/juce_ModalComponentManager.h | 6 +- .../drawables/juce_Drawable.cpp | 5 + .../juce_gui_basics/drawables/juce_Drawable.h | 6 +- .../drawables/juce_DrawableComposite.cpp | 5 + .../drawables/juce_DrawableComposite.h | 6 +- .../drawables/juce_DrawableImage.cpp | 5 + .../drawables/juce_DrawableImage.h | 6 +- .../drawables/juce_DrawablePath.cpp | 5 + .../drawables/juce_DrawablePath.h | 6 +- .../drawables/juce_DrawableRectangle.cpp | 5 + .../drawables/juce_DrawableRectangle.h | 6 +- .../drawables/juce_DrawableShape.cpp | 5 + .../drawables/juce_DrawableShape.h | 6 +- .../drawables/juce_DrawableText.cpp | 5 + .../drawables/juce_DrawableText.h | 6 +- .../drawables/juce_SVGParser.cpp | 5 + ...juce_DirectoryContentsDisplayComponent.cpp | 5 + .../juce_DirectoryContentsDisplayComponent.h | 6 +- .../juce_DirectoryContentsList.cpp | 5 + .../filebrowser/juce_DirectoryContentsList.h | 6 +- .../filebrowser/juce_FileBrowserComponent.cpp | 5 + .../filebrowser/juce_FileBrowserComponent.h | 6 +- .../filebrowser/juce_FileBrowserListener.h | 6 +- .../filebrowser/juce_FileChooser.cpp | 5 + .../filebrowser/juce_FileChooser.h | 6 +- .../filebrowser/juce_FileChooserDialogBox.cpp | 5 + .../filebrowser/juce_FileChooserDialogBox.h | 6 +- .../filebrowser/juce_FileListComponent.cpp | 5 + .../filebrowser/juce_FileListComponent.h | 6 +- .../filebrowser/juce_FilePreviewComponent.h | 6 +- .../juce_FileSearchPathListComponent.cpp | 5 + .../juce_FileSearchPathListComponent.h | 6 +- .../filebrowser/juce_FileTreeComponent.cpp | 5 + .../filebrowser/juce_FileTreeComponent.h | 6 +- .../filebrowser/juce_FilenameComponent.cpp | 5 + .../filebrowser/juce_FilenameComponent.h | 6 +- .../juce_ImagePreviewComponent.cpp | 5 + .../filebrowser/juce_ImagePreviewComponent.h | 6 +- modules/juce_gui_basics/juce_gui_basics.cpp | 10 +- modules/juce_gui_basics/juce_gui_basics.h | 118 +++++++------- .../keyboard/juce_CaretComponent.cpp | 5 + .../keyboard/juce_CaretComponent.h | 6 +- .../keyboard/juce_KeyListener.cpp | 5 + .../keyboard/juce_KeyListener.h | 6 +- .../keyboard/juce_KeyPress.cpp | 5 + .../juce_gui_basics/keyboard/juce_KeyPress.h | 6 +- .../keyboard/juce_KeyboardFocusTraverser.cpp | 5 + .../keyboard/juce_KeyboardFocusTraverser.h | 6 +- .../keyboard/juce_ModifierKeys.cpp | 5 + .../keyboard/juce_ModifierKeys.h | 6 +- .../keyboard/juce_SystemClipboard.h | 6 +- .../keyboard/juce_TextEditorKeyMapper.h | 6 +- .../keyboard/juce_TextInputTarget.h | 6 +- .../layout/juce_AnimatedPosition.h | 6 +- .../layout/juce_AnimatedPositionBehaviours.h | 6 +- .../layout/juce_ComponentAnimator.cpp | 5 + .../layout/juce_ComponentAnimator.h | 6 +- .../juce_ComponentBoundsConstrainer.cpp | 5 + .../layout/juce_ComponentBoundsConstrainer.h | 6 +- .../layout/juce_ComponentBuilder.cpp | 5 + .../layout/juce_ComponentBuilder.h | 6 +- .../layout/juce_ComponentMovementWatcher.cpp | 5 + .../layout/juce_ComponentMovementWatcher.h | 6 +- .../layout/juce_ConcertinaPanel.cpp | 5 + .../layout/juce_ConcertinaPanel.h | 6 +- .../juce_gui_basics/layout/juce_FlexBox.cpp | 5 + modules/juce_gui_basics/layout/juce_FlexBox.h | 4 + .../juce_gui_basics/layout/juce_FlexItem.h | 4 + modules/juce_gui_basics/layout/juce_Grid.cpp | 4 + modules/juce_gui_basics/layout/juce_Grid.h | 8 + .../juce_gui_basics/layout/juce_GridItem.cpp | 4 + .../juce_gui_basics/layout/juce_GridItem.h | 4 + .../layout/juce_GridUnitTests.cpp | 5 + .../layout/juce_GroupComponent.cpp | 5 + .../layout/juce_GroupComponent.h | 6 +- .../layout/juce_MultiDocumentPanel.cpp | 5 + .../layout/juce_MultiDocumentPanel.h | 5 +- .../layout/juce_ResizableBorderComponent.cpp | 5 + .../layout/juce_ResizableBorderComponent.h | 6 +- .../layout/juce_ResizableCornerComponent.cpp | 5 + .../layout/juce_ResizableCornerComponent.h | 6 +- .../layout/juce_ResizableEdgeComponent.cpp | 5 + .../layout/juce_ResizableEdgeComponent.h | 6 +- .../juce_gui_basics/layout/juce_ScrollBar.cpp | 5 + .../juce_gui_basics/layout/juce_ScrollBar.h | 6 +- .../layout/juce_StretchableLayoutManager.cpp | 5 + .../layout/juce_StretchableLayoutManager.h | 6 +- .../juce_StretchableLayoutResizerBar.cpp | 5 + .../layout/juce_StretchableLayoutResizerBar.h | 6 +- .../layout/juce_StretchableObjectResizer.cpp | 5 + .../layout/juce_StretchableObjectResizer.h | 6 +- .../layout/juce_TabbedButtonBar.cpp | 5 + .../layout/juce_TabbedButtonBar.h | 5 +- .../layout/juce_TabbedComponent.cpp | 5 + .../layout/juce_TabbedComponent.h | 6 +- .../juce_gui_basics/layout/juce_Viewport.cpp | 5 + .../juce_gui_basics/layout/juce_Viewport.h | 6 +- .../lookandfeel/juce_LookAndFeel.cpp | 6 +- .../lookandfeel/juce_LookAndFeel.h | 5 +- .../lookandfeel/juce_LookAndFeel_V1.cpp | 5 + .../lookandfeel/juce_LookAndFeel_V1.h | 5 +- .../lookandfeel/juce_LookAndFeel_V2.cpp | 5 + .../lookandfeel/juce_LookAndFeel_V2.h | 6 +- .../lookandfeel/juce_LookAndFeel_V3.cpp | 5 + .../lookandfeel/juce_LookAndFeel_V3.h | 5 +- .../lookandfeel/juce_LookAndFeel_V4.cpp | 4 + .../lookandfeel/juce_LookAndFeel_V4.h | 6 +- .../menus/juce_MenuBarComponent.cpp | 5 + .../menus/juce_MenuBarComponent.h | 6 +- .../menus/juce_MenuBarModel.cpp | 5 + .../juce_gui_basics/menus/juce_MenuBarModel.h | 6 +- .../juce_gui_basics/menus/juce_PopupMenu.cpp | 5 + .../juce_gui_basics/menus/juce_PopupMenu.h | 6 +- .../misc/juce_BubbleComponent.cpp | 5 + .../misc/juce_BubbleComponent.h | 6 +- .../misc/juce_DropShadower.cpp | 5 + .../juce_gui_basics/misc/juce_DropShadower.h | 6 +- .../misc/juce_JUCESplashScreen.cpp | 5 + .../misc/juce_JUCESplashScreen.h | 5 +- .../mouse/juce_ComponentDragger.cpp | 5 + .../mouse/juce_ComponentDragger.h | 6 +- .../mouse/juce_DragAndDropContainer.cpp | 5 + .../mouse/juce_DragAndDropContainer.h | 6 +- .../mouse/juce_DragAndDropTarget.h | 6 +- .../mouse/juce_FileDragAndDropTarget.h | 5 +- .../mouse/juce_LassoComponent.h | 6 +- .../mouse/juce_MouseCursor.cpp | 5 + .../juce_gui_basics/mouse/juce_MouseCursor.h | 6 +- .../juce_gui_basics/mouse/juce_MouseEvent.cpp | 5 + .../juce_gui_basics/mouse/juce_MouseEvent.h | 5 +- .../mouse/juce_MouseInactivityDetector.cpp | 5 + .../mouse/juce_MouseInactivityDetector.h | 6 +- .../mouse/juce_MouseInputSource.cpp | 5 + .../mouse/juce_MouseInputSource.h | 6 +- .../mouse/juce_MouseListener.cpp | 5 + .../mouse/juce_MouseListener.h | 6 +- .../mouse/juce_SelectedItemSet.h | 6 +- .../mouse/juce_TextDragAndDropTarget.h | 6 +- .../mouse/juce_TooltipClient.h | 6 +- .../native/juce_MultiTouchMapper.h | 9 +- .../native/juce_android_FileChooser.cpp | 5 + .../native/juce_android_Windowing.cpp | 4 +- .../native/juce_ios_UIViewComponentPeer.mm | 10 +- .../native/juce_ios_Windowing.mm | 21 +-- .../native/juce_linux_FileChooser.cpp | 5 + .../juce_gui_basics/native/juce_linux_X11.cpp | 5 + .../juce_gui_basics/native/juce_linux_X11.h | 9 +- .../native/juce_linux_X11_Clipboard.cpp | 5 + .../native/juce_linux_X11_Windowing.cpp | 5 + .../native/juce_mac_FileChooser.mm | 5 + .../native/juce_mac_MainMenu.mm | 5 + .../native/juce_mac_MouseCursor.mm | 7 +- .../native/juce_mac_NSViewComponentPeer.mm | 18 ++- .../native/juce_mac_Windowing.mm | 10 +- .../native/juce_win32_DragAndDrop.cpp | 5 + .../native/juce_win32_FileChooser.cpp | 5 + .../native/juce_win32_Windowing.cpp | 13 +- .../positioning/juce_MarkerList.cpp | 5 + .../positioning/juce_MarkerList.h | 6 +- .../positioning/juce_RelativeCoordinate.cpp | 5 + .../positioning/juce_RelativeCoordinate.h | 6 +- .../juce_RelativeCoordinatePositioner.cpp | 5 + .../juce_RelativeCoordinatePositioner.h | 6 +- .../juce_RelativeParallelogram.cpp | 5 + .../positioning/juce_RelativeParallelogram.h | 6 +- .../positioning/juce_RelativePoint.cpp | 5 + .../positioning/juce_RelativePoint.h | 6 +- .../positioning/juce_RelativePointPath.cpp | 5 + .../positioning/juce_RelativePointPath.h | 6 +- .../positioning/juce_RelativeRectangle.cpp | 5 + .../positioning/juce_RelativeRectangle.h | 6 +- .../juce_BooleanPropertyComponent.cpp | 5 + .../juce_BooleanPropertyComponent.h | 6 +- .../juce_ButtonPropertyComponent.cpp | 5 + .../properties/juce_ButtonPropertyComponent.h | 6 +- .../juce_ChoicePropertyComponent.cpp | 5 + .../properties/juce_ChoicePropertyComponent.h | 6 +- .../properties/juce_PropertyComponent.cpp | 5 + .../properties/juce_PropertyComponent.h | 6 +- .../properties/juce_PropertyPanel.cpp | 5 + .../properties/juce_PropertyPanel.h | 6 +- .../juce_SliderPropertyComponent.cpp | 5 + .../properties/juce_SliderPropertyComponent.h | 6 +- .../properties/juce_TextPropertyComponent.cpp | 5 + .../properties/juce_TextPropertyComponent.h | 6 +- .../juce_gui_basics/widgets/juce_ComboBox.cpp | 5 + .../juce_gui_basics/widgets/juce_ComboBox.h | 6 +- .../widgets/juce_ImageComponent.cpp | 5 + .../widgets/juce_ImageComponent.h | 6 +- .../juce_gui_basics/widgets/juce_Label.cpp | 5 + modules/juce_gui_basics/widgets/juce_Label.h | 6 +- .../juce_gui_basics/widgets/juce_ListBox.cpp | 5 + .../juce_gui_basics/widgets/juce_ListBox.h | 6 +- .../widgets/juce_ProgressBar.cpp | 5 + .../widgets/juce_ProgressBar.h | 6 +- .../juce_gui_basics/widgets/juce_Slider.cpp | 5 + modules/juce_gui_basics/widgets/juce_Slider.h | 6 +- .../widgets/juce_TableHeaderComponent.cpp | 5 + .../widgets/juce_TableHeaderComponent.h | 6 +- .../widgets/juce_TableListBox.cpp | 5 + .../widgets/juce_TableListBox.h | 6 +- .../widgets/juce_TextEditor.cpp | 5 + .../juce_gui_basics/widgets/juce_TextEditor.h | 6 +- .../juce_gui_basics/widgets/juce_Toolbar.cpp | 5 + .../juce_gui_basics/widgets/juce_Toolbar.h | 5 +- .../widgets/juce_ToolbarItemComponent.cpp | 5 + .../widgets/juce_ToolbarItemComponent.h | 6 +- .../widgets/juce_ToolbarItemFactory.h | 6 +- .../widgets/juce_ToolbarItemPalette.cpp | 5 + .../widgets/juce_ToolbarItemPalette.h | 6 +- .../juce_gui_basics/widgets/juce_TreeView.cpp | 5 + .../juce_gui_basics/widgets/juce_TreeView.h | 5 +- .../windows/juce_AlertWindow.cpp | 5 + .../windows/juce_AlertWindow.h | 6 +- .../windows/juce_CallOutBox.cpp | 5 + .../juce_gui_basics/windows/juce_CallOutBox.h | 6 +- .../windows/juce_ComponentPeer.cpp | 5 + .../windows/juce_ComponentPeer.h | 6 +- .../windows/juce_DialogWindow.cpp | 5 + .../windows/juce_DialogWindow.h | 6 +- .../windows/juce_DocumentWindow.cpp | 5 + .../windows/juce_DocumentWindow.h | 6 +- .../windows/juce_NativeMessageBox.h | 5 +- .../windows/juce_ResizableWindow.cpp | 5 + .../windows/juce_ResizableWindow.h | 6 +- .../windows/juce_ThreadWithProgressWindow.cpp | 5 + .../windows/juce_ThreadWithProgressWindow.h | 6 +- .../windows/juce_TooltipWindow.cpp | 5 + .../windows/juce_TooltipWindow.h | 6 +- .../windows/juce_TopLevelWindow.cpp | 5 + .../windows/juce_TopLevelWindow.h | 6 +- .../juce_CPlusPlusCodeTokeniser.cpp | 6 +- .../code_editor/juce_CPlusPlusCodeTokeniser.h | 6 +- .../juce_CPlusPlusCodeTokeniserFunctions.h | 6 +- .../code_editor/juce_CodeDocument.cpp | 5 + .../code_editor/juce_CodeDocument.h | 5 +- .../code_editor/juce_CodeEditorComponent.cpp | 5 + .../code_editor/juce_CodeEditorComponent.h | 5 +- .../code_editor/juce_CodeTokeniser.h | 6 +- .../code_editor/juce_LuaCodeTokeniser.cpp | 5 + .../code_editor/juce_LuaCodeTokeniser.h | 6 +- .../code_editor/juce_XMLCodeTokeniser.cpp | 5 + .../code_editor/juce_XMLCodeTokeniser.h | 6 +- .../documents/juce_FileBasedDocument.cpp | 5 + .../documents/juce_FileBasedDocument.h | 6 +- .../embedding/juce_ActiveXControlComponent.h | 5 +- .../embedding/juce_NSViewComponent.h | 5 +- .../embedding/juce_UIViewComponent.h | 5 +- .../embedding/juce_XEmbedComponent.h | 5 +- modules/juce_gui_extra/juce_gui_extra.cpp | 24 +-- modules/juce_gui_extra/juce_gui_extra.h | 5 - .../misc/juce_AnimatedAppComponent.cpp | 5 + .../misc/juce_AnimatedAppComponent.h | 6 +- .../juce_gui_extra/misc/juce_AppleRemote.h | 6 +- .../misc/juce_BubbleMessageComponent.cpp | 5 + .../misc/juce_BubbleMessageComponent.h | 6 +- .../misc/juce_ColourSelector.cpp | 7 +- .../juce_gui_extra/misc/juce_ColourSelector.h | 6 +- .../misc/juce_KeyMappingEditorComponent.cpp | 5 + .../misc/juce_KeyMappingEditorComponent.h | 6 +- .../misc/juce_LiveConstantEditor.cpp | 5 + .../misc/juce_LiveConstantEditor.h | 5 +- .../misc/juce_PreferencesPanel.cpp | 5 + .../misc/juce_PreferencesPanel.h | 6 +- .../misc/juce_RecentlyOpenedFilesList.cpp | 5 + .../misc/juce_RecentlyOpenedFilesList.h | 6 +- .../juce_gui_extra/misc/juce_SplashScreen.cpp | 5 + .../juce_gui_extra/misc/juce_SplashScreen.h | 6 +- .../misc/juce_SystemTrayIconComponent.cpp | 5 + .../misc/juce_SystemTrayIconComponent.h | 5 +- .../misc/juce_WebBrowserComponent.h | 5 +- .../juce_android_WebBrowserComponent.cpp | 5 + .../native/juce_ios_UIViewComponent.mm | 18 ++- .../native/juce_linux_X11_SystemTrayIcon.cpp | 6 +- .../juce_linux_X11_WebBrowserComponent.cpp | 6 +- .../native/juce_linux_XEmbedComponent.cpp | 10 +- .../native/juce_mac_AppleRemote.mm | 5 + .../juce_mac_CarbonViewWrapperComponent.h | 6 +- .../native/juce_mac_NSViewComponent.mm | 5 + .../native/juce_mac_SystemTrayIcon.cpp | 5 + .../native/juce_mac_WebBrowserComponent.mm | 18 ++- .../native/juce_win32_ActiveXComponent.cpp | 5 + .../native/juce_win32_SystemTrayIcon.cpp | 5 + .../native/juce_win32_WebBrowserComponent.cpp | 5 + .../geometry/juce_Draggable3DOrientation.h | 6 +- modules/juce_opengl/geometry/juce_Matrix3D.h | 5 +- .../juce_opengl/geometry/juce_Quaternion.h | 8 +- modules/juce_opengl/geometry/juce_Vector3D.h | 5 +- modules/juce_opengl/juce_opengl.cpp | 8 +- modules/juce_opengl/juce_opengl.h | 16 +- .../native/juce_MissingGLDefinitions.h | 5 + .../native/juce_OpenGLExtensions.h | 6 +- .../juce_opengl/native/juce_OpenGL_android.h | 6 +- modules/juce_opengl/native/juce_OpenGL_ios.h | 4 +- .../native/juce_OpenGL_linux_X11.h | 5 + modules/juce_opengl/native/juce_OpenGL_osx.h | 5 + .../juce_opengl/native/juce_OpenGL_win32.h | 5 + .../juce_opengl/opengl/juce_OpenGLContext.cpp | 5 + .../juce_opengl/opengl/juce_OpenGLContext.h | 6 +- .../opengl/juce_OpenGLFrameBuffer.cpp | 5 + .../opengl/juce_OpenGLFrameBuffer.h | 6 +- .../opengl/juce_OpenGLGraphicsContext.cpp | 5 + .../opengl/juce_OpenGLGraphicsContext.h | 6 +- .../juce_opengl/opengl/juce_OpenGLHelpers.cpp | 5 + .../juce_opengl/opengl/juce_OpenGLHelpers.h | 6 +- .../juce_opengl/opengl/juce_OpenGLImage.cpp | 5 + modules/juce_opengl/opengl/juce_OpenGLImage.h | 6 +- .../opengl/juce_OpenGLPixelFormat.cpp | 5 + .../opengl/juce_OpenGLPixelFormat.h | 6 +- .../juce_opengl/opengl/juce_OpenGLRenderer.h | 6 +- .../opengl/juce_OpenGLShaderProgram.cpp | 5 + .../opengl/juce_OpenGLShaderProgram.h | 5 +- .../juce_opengl/opengl/juce_OpenGLTexture.cpp | 5 + .../juce_opengl/opengl/juce_OpenGLTexture.h | 5 +- .../utils/juce_OpenGLAppComponent.cpp | 5 + .../utils/juce_OpenGLAppComponent.h | 6 +- modules/juce_osc/juce_osc.cpp | 3 - modules/juce_osc/juce_osc.h | 5 - modules/juce_osc/osc/juce_OSCAddress.cpp | 5 + modules/juce_osc/osc/juce_OSCAddress.h | 6 +- modules/juce_osc/osc/juce_OSCArgument.cpp | 5 + modules/juce_osc/osc/juce_OSCArgument.h | 6 +- modules/juce_osc/osc/juce_OSCBundle.cpp | 5 + modules/juce_osc/osc/juce_OSCBundle.h | 5 +- modules/juce_osc/osc/juce_OSCMessage.cpp | 6 +- modules/juce_osc/osc/juce_OSCMessage.h | 6 +- modules/juce_osc/osc/juce_OSCReceiver.cpp | 5 + modules/juce_osc/osc/juce_OSCReceiver.h | 5 +- modules/juce_osc/osc/juce_OSCSender.cpp | 5 + modules/juce_osc/osc/juce_OSCSender.h | 6 +- modules/juce_osc/osc/juce_OSCTimeTag.cpp | 5 + modules/juce_osc/osc/juce_OSCTimeTag.h | 6 +- modules/juce_osc/osc/juce_OSCTypes.cpp | 11 +- modules/juce_osc/osc/juce_OSCTypes.h | 5 +- .../in_app_purchases/juce_InAppPurchases.cpp | 5 + .../in_app_purchases/juce_InAppPurchases.h | 5 + .../juce_product_unlocking.cpp | 41 +++-- .../juce_product_unlocking.h | 30 ++-- .../marketplace/juce_KeyFileGeneration.h | 5 + .../marketplace/juce_OnlineUnlockForm.cpp | 5 + .../marketplace/juce_OnlineUnlockForm.h | 5 + .../marketplace/juce_OnlineUnlockStatus.cpp | 5 + .../marketplace/juce_OnlineUnlockStatus.h | 5 + .../juce_TracktionMarketplaceStatus.cpp | 5 + .../juce_TracktionMarketplaceStatus.h | 5 + .../native/juce_android_InAppPurchases.cpp | 4 + .../native/juce_ios_InAppPurchases.cpp | 5 + .../juce_video/capture/juce_CameraDevice.cpp | 4 + .../juce_video/capture/juce_CameraDevice.h | 5 +- modules/juce_video/juce_video.cpp | 7 - modules/juce_video/juce_video.h | 8 - .../playback/juce_VideoComponent.cpp | 5 + .../juce_video/playback/juce_VideoComponent.h | 4 + 1069 files changed, 5350 insertions(+), 1828 deletions(-) diff --git a/examples/OSCMonitor/Source/OSCLogListBox.h b/examples/OSCMonitor/Source/OSCLogListBox.h index 996a92fb7d..0fa9b3aa58 100644 --- a/examples/OSCMonitor/Source/OSCLogListBox.h +++ b/examples/OSCMonitor/Source/OSCLogListBox.h @@ -128,13 +128,12 @@ public: else if (arg.isBlob()) { typeAsString = "blob"; - const MemoryBlock& blob = arg.getBlob(); - valueAsString = String::fromUTF8( (const char*)blob.getData(), blob.getSize()); + auto& blob = arg.getBlob(); + valueAsString = String::fromUTF8 ((const char*) blob.getData(), (int) blob.getSize()); } else { typeAsString = "(unknown)"; - valueAsString = ""; } oscLogList.add (getIndentationString (level + 1) + "- " + typeAsString.paddedRight(' ', 12) + valueAsString); diff --git a/modules/juce_audio_basics/audio_play_head/juce_AudioPlayHead.h b/modules/juce_audio_basics/audio_play_head/juce_AudioPlayHead.h index 45f916238b..16e729db2b 100644 --- a/modules/juce_audio_basics/audio_play_head/juce_AudioPlayHead.h +++ b/modules/juce_audio_basics/audio_play_head/juce_AudioPlayHead.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -151,3 +151,5 @@ public: /** Rewinds the audio. */ virtual void transportRewind() {} }; + +} // namespace juce diff --git a/modules/juce_audio_basics/buffers/juce_AudioChannelSet.cpp b/modules/juce_audio_basics/buffers/juce_AudioChannelSet.cpp index e75f90b4e9..754291d5bf 100644 --- a/modules/juce_audio_basics/buffers/juce_AudioChannelSet.cpp +++ b/modules/juce_audio_basics/buffers/juce_AudioChannelSet.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + AudioChannelSet::AudioChannelSet (uint32 c) : channels (c) {} AudioChannelSet::AudioChannelSet (const Array& c) { @@ -414,3 +417,5 @@ int32 AudioChannelSet::getWaveChannelMask() const noexcept return (channels.toInteger() >> 1); } + +} // namespace juce diff --git a/modules/juce_audio_basics/buffers/juce_AudioChannelSet.h b/modules/juce_audio_basics/buffers/juce_AudioChannelSet.h index 14c0ff900a..bb99cff93e 100644 --- a/modules/juce_audio_basics/buffers/juce_AudioChannelSet.h +++ b/modules/juce_audio_basics/buffers/juce_AudioChannelSet.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -388,3 +388,5 @@ private: explicit AudioChannelSet (uint32); explicit AudioChannelSet (const Array&); }; + +} // namespace juce diff --git a/modules/juce_audio_basics/buffers/juce_AudioDataConverters.cpp b/modules/juce_audio_basics/buffers/juce_AudioDataConverters.cpp index e46de33503..3f31379dd8 100644 --- a/modules/juce_audio_basics/buffers/juce_AudioDataConverters.cpp +++ b/modules/juce_audio_basics/buffers/juce_AudioDataConverters.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + void AudioDataConverters::convertFloatToInt16LE (const float* source, void* dest, int numSamples, const int destBytesPerSample) { const double maxVal = (double) 0x7fff; @@ -596,3 +599,5 @@ public: static AudioConversionTests audioConversionUnitTests; #endif + +} // namespace juce diff --git a/modules/juce_audio_basics/buffers/juce_AudioDataConverters.h b/modules/juce_audio_basics/buffers/juce_AudioDataConverters.h index 91907c0285..6af6822009 100644 --- a/modules/juce_audio_basics/buffers/juce_AudioDataConverters.h +++ b/modules/juce_audio_basics/buffers/juce_AudioDataConverters.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -708,3 +708,5 @@ private: AudioDataConverters(); JUCE_DECLARE_NON_COPYABLE (AudioDataConverters) }; + +} // namespace juce diff --git a/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h b/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h index 6ef06a177f..ac9addd564 100644 --- a/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h +++ b/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -1122,3 +1122,5 @@ private: @see AudioBuffer */ typedef AudioBuffer AudioSampleBuffer; + +} // namespace juce diff --git a/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp b/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp index 7813c81abc..5523a4a2f7 100644 --- a/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp +++ b/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + namespace FloatVectorHelpers { #define JUCE_INCREMENT_SRC_DEST dest += (16 / sizeof (*dest)); src += (16 / sizeof (*dest)); @@ -1200,3 +1203,5 @@ public: static FloatVectorOperationsTests vectorOpTests; #endif + +} // namespace juce diff --git a/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.h b/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.h index 9cb7895fcf..708f5ac2aa 100644 --- a/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.h +++ b/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ #if JUCE_INTEL #define JUCE_SNAP_TO_ZERO(n) if (! (n < -1.0e-8f || n > 1.0e-8f)) n = 0; @@ -219,3 +220,5 @@ public: */ static void JUCE_CALLTYPE disableDenormalisedNumberSupport() noexcept; }; + +} // namespace juce diff --git a/modules/juce_audio_basics/effects/juce_CatmullRomInterpolator.cpp b/modules/juce_audio_basics/effects/juce_CatmullRomInterpolator.cpp index 11f996b023..3d210938c6 100644 --- a/modules/juce_audio_basics/effects/juce_CatmullRomInterpolator.cpp +++ b/modules/juce_audio_basics/effects/juce_CatmullRomInterpolator.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + struct CatmullRomAlgorithm { static forcedinline float valueAtOffset (const float* const inputs, const float offset) noexcept @@ -58,3 +61,5 @@ int CatmullRomInterpolator::processAdding (double actualRatio, const float* in, { return interpolateAdding (lastInputSamples, subSamplePos, actualRatio, in, out, numOut, gain); } + +} // namespace juce diff --git a/modules/juce_audio_basics/effects/juce_CatmullRomInterpolator.h b/modules/juce_audio_basics/effects/juce_CatmullRomInterpolator.h index 75eaeeca4b..3876ae612e 100644 --- a/modules/juce_audio_basics/effects/juce_CatmullRomInterpolator.h +++ b/modules/juce_audio_basics/effects/juce_CatmullRomInterpolator.h @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + /** Interpolator for resampling a stream of floats using Catmull-Rom interpolation. @@ -84,3 +87,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CatmullRomInterpolator) }; + +} // namespace juce diff --git a/modules/juce_audio_basics/effects/juce_Decibels.h b/modules/juce_audio_basics/effects/juce_Decibels.h index e144f11e09..4fc2d2fdbf 100644 --- a/modules/juce_audio_basics/effects/juce_Decibels.h +++ b/modules/juce_audio_basics/effects/juce_Decibels.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -96,3 +96,5 @@ private: Decibels(); // This class can't be instantiated, it's just a holder for static methods.. JUCE_DECLARE_NON_COPYABLE (Decibels) }; + +} // namespace juce diff --git a/modules/juce_audio_basics/effects/juce_IIRFilter.cpp b/modules/juce_audio_basics/effects/juce_IIRFilter.cpp index 39def04d38..01338c8d9d 100644 --- a/modules/juce_audio_basics/effects/juce_IIRFilter.cpp +++ b/modules/juce_audio_basics/effects/juce_IIRFilter.cpp @@ -20,7 +20,9 @@ ============================================================================== */ -//============================================================================== +namespace juce +{ + IIRCoefficients::IIRCoefficients() noexcept { zeromem (coefficients, sizeof (coefficients)); @@ -335,3 +337,5 @@ void IIRFilter::processSamples (float* const samples, const int numSamples) noex } #undef JUCE_SNAP_TO_ZERO + +} // namespace juce diff --git a/modules/juce_audio_basics/effects/juce_IIRFilter.h b/modules/juce_audio_basics/effects/juce_IIRFilter.h index b0ef1fa11f..9db85b5828 100644 --- a/modules/juce_audio_basics/effects/juce_IIRFilter.h +++ b/modules/juce_audio_basics/effects/juce_IIRFilter.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ class IIRFilter; @@ -205,3 +206,5 @@ protected: IIRFilter& operator= (const IIRFilter&); JUCE_LEAK_DETECTOR (IIRFilter) }; + +} // namespace juce diff --git a/modules/juce_audio_basics/effects/juce_LagrangeInterpolator.cpp b/modules/juce_audio_basics/effects/juce_LagrangeInterpolator.cpp index ecd892d722..eca8e98e62 100644 --- a/modules/juce_audio_basics/effects/juce_LagrangeInterpolator.cpp +++ b/modules/juce_audio_basics/effects/juce_LagrangeInterpolator.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + namespace { static forcedinline void pushInterpolationSample (float* lastInputSamples, const float newValue) noexcept @@ -196,3 +199,5 @@ int LagrangeInterpolator::processAdding (double actualRatio, const float* in, fl { return interpolateAdding (lastInputSamples, subSamplePos, actualRatio, in, out, numOut, gain); } + +} // namespace juce diff --git a/modules/juce_audio_basics/effects/juce_LagrangeInterpolator.h b/modules/juce_audio_basics/effects/juce_LagrangeInterpolator.h index 7143842e3a..d527574513 100644 --- a/modules/juce_audio_basics/effects/juce_LagrangeInterpolator.h +++ b/modules/juce_audio_basics/effects/juce_LagrangeInterpolator.h @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + /** Interpolator for resampling a stream of floats using 4-point lagrange interpolation. @@ -84,3 +87,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LagrangeInterpolator) }; + +} // namespace juce diff --git a/modules/juce_audio_basics/effects/juce_LinearSmoothedValue.h b/modules/juce_audio_basics/effects/juce_LinearSmoothedValue.h index d39dc91734..3dc342c418 100644 --- a/modules/juce_audio_basics/effects/juce_LinearSmoothedValue.h +++ b/modules/juce_audio_basics/effects/juce_LinearSmoothedValue.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -182,3 +182,5 @@ private: FloatType currentValue = 0, target = 0, step = 0; int countdown = 0, stepsToTarget = 0; }; + +} // namespace juce diff --git a/modules/juce_audio_basics/effects/juce_Reverb.h b/modules/juce_audio_basics/effects/juce_Reverb.h index 375fda0903..02b95b3c31 100644 --- a/modules/juce_audio_basics/effects/juce_Reverb.h +++ b/modules/juce_audio_basics/effects/juce_Reverb.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -316,3 +316,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Reverb) }; + +} // namespace juce diff --git a/modules/juce_audio_basics/juce_audio_basics.cpp b/modules/juce_audio_basics/juce_audio_basics.cpp index 258de8fe44..09e13e49c8 100644 --- a/modules/juce_audio_basics/juce_audio_basics.cpp +++ b/modules/juce_audio_basics/juce_audio_basics.cpp @@ -76,9 +76,6 @@ #include #endif -namespace juce -{ - #include "buffers/juce_AudioDataConverters.cpp" #include "buffers/juce_FloatVectorOperations.cpp" #include "buffers/juce_AudioChannelSet.cpp" @@ -109,5 +106,3 @@ namespace juce #include "sources/juce_ReverbAudioSource.cpp" #include "sources/juce_ToneGeneratorAudioSource.cpp" #include "synthesisers/juce_Synthesiser.cpp" - -} diff --git a/modules/juce_audio_basics/juce_audio_basics.h b/modules/juce_audio_basics/juce_audio_basics.h index feb2a6e804..023fa4760b 100644 --- a/modules/juce_audio_basics/juce_audio_basics.h +++ b/modules/juce_audio_basics/juce_audio_basics.h @@ -51,9 +51,6 @@ #include -namespace juce -{ - #undef Complex // apparently some C libraries actually define these symbols (!) #undef Factor @@ -94,5 +91,3 @@ namespace juce #include "sources/juce_ToneGeneratorAudioSource.h" #include "synthesisers/juce_Synthesiser.h" #include "audio_play_head/juce_AudioPlayHead.h" - -} diff --git a/modules/juce_audio_basics/midi/juce_MidiBuffer.cpp b/modules/juce_audio_basics/midi/juce_MidiBuffer.cpp index 8795756c70..94d19898f7 100644 --- a/modules/juce_audio_basics/midi/juce_MidiBuffer.cpp +++ b/modules/juce_audio_basics/midi/juce_MidiBuffer.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + namespace MidiBufferHelpers { inline int getEventTime (const void* const d) noexcept @@ -225,3 +228,5 @@ bool MidiBuffer::Iterator::getNextEvent (MidiMessage& result, int& samplePositio return true; } + +} // namespace juce diff --git a/modules/juce_audio_basics/midi/juce_MidiBuffer.h b/modules/juce_audio_basics/midi/juce_MidiBuffer.h index b69d8796cf..d4bfead789 100644 --- a/modules/juce_audio_basics/midi/juce_MidiBuffer.h +++ b/modules/juce_audio_basics/midi/juce_MidiBuffer.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -227,3 +227,5 @@ public: private: JUCE_LEAK_DETECTOR (MidiBuffer) }; + +} // namespace juce diff --git a/modules/juce_audio_basics/midi/juce_MidiFile.cpp b/modules/juce_audio_basics/midi/juce_MidiFile.cpp index 727f9f62d0..6a67a0890f 100644 --- a/modules/juce_audio_basics/midi/juce_MidiFile.cpp +++ b/modules/juce_audio_basics/midi/juce_MidiFile.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + namespace MidiFileHelpers { static void writeVariableLengthInt (OutputStream& out, unsigned int v) @@ -443,3 +446,5 @@ bool MidiFile::writeTrack (OutputStream& mainOut, const int trackNum) return true; } + +} // namespace juce diff --git a/modules/juce_audio_basics/midi/juce_MidiFile.h b/modules/juce_audio_basics/midi/juce_MidiFile.h index 47a1fab983..b06589d299 100644 --- a/modules/juce_audio_basics/midi/juce_MidiFile.h +++ b/modules/juce_audio_basics/midi/juce_MidiFile.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -178,3 +178,5 @@ private: JUCE_LEAK_DETECTOR (MidiFile) }; + +} // namespace juce diff --git a/modules/juce_audio_basics/midi/juce_MidiKeyboardState.cpp b/modules/juce_audio_basics/midi/juce_MidiKeyboardState.cpp index 9f093628b8..ad52ceb8fd 100644 --- a/modules/juce_audio_basics/midi/juce_MidiKeyboardState.cpp +++ b/modules/juce_audio_basics/midi/juce_MidiKeyboardState.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + MidiKeyboardState::MidiKeyboardState() { zerostruct (noteStates); @@ -179,3 +182,5 @@ void MidiKeyboardState::removeListener (MidiKeyboardStateListener* const listene const ScopedLock sl (lock); listeners.removeFirstMatchingValue (listener); } + +} // namespace juce diff --git a/modules/juce_audio_basics/midi/juce_MidiKeyboardState.h b/modules/juce_audio_basics/midi/juce_MidiKeyboardState.h index ef9a8f43c4..b3fc4e61e0 100644 --- a/modules/juce_audio_basics/midi/juce_MidiKeyboardState.h +++ b/modules/juce_audio_basics/midi/juce_MidiKeyboardState.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ class MidiKeyboardState; @@ -197,3 +198,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MidiKeyboardState) }; + +} // namespace juce diff --git a/modules/juce_audio_basics/midi/juce_MidiMessage.cpp b/modules/juce_audio_basics/midi/juce_MidiMessage.cpp index e9e6c1be3a..bf2eb56cd3 100644 --- a/modules/juce_audio_basics/midi/juce_MidiMessage.cpp +++ b/modules/juce_audio_basics/midi/juce_MidiMessage.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + namespace MidiHelpers { inline uint8 initialByte (const int type, const int channel) noexcept @@ -1119,3 +1122,5 @@ const char* MidiMessage::getControllerName (const int n) return isPositiveAndBelow (n, numElementsInArray (names)) ? names[n] : nullptr; } + +} // namespace juce diff --git a/modules/juce_audio_basics/midi/juce_MidiMessage.h b/modules/juce_audio_basics/midi/juce_MidiMessage.h index aea8d42079..7fcefe2a2e 100644 --- a/modules/juce_audio_basics/midi/juce_MidiMessage.h +++ b/modules/juce_audio_basics/midi/juce_MidiMessage.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -936,3 +936,5 @@ private: inline uint8* getData() const noexcept { return isHeapAllocated() ? packedData.allocatedData : (uint8*) packedData.asBytes; } uint8* allocateSpace (int); }; + +} // namespace juce diff --git a/modules/juce_audio_basics/midi/juce_MidiMessageSequence.cpp b/modules/juce_audio_basics/midi/juce_MidiMessageSequence.cpp index 6a3f851cbf..fe8b2c083d 100644 --- a/modules/juce_audio_basics/midi/juce_MidiMessageSequence.cpp +++ b/modules/juce_audio_basics/midi/juce_MidiMessageSequence.cpp @@ -20,6 +20,8 @@ ============================================================================== */ +namespace juce +{ MidiMessageSequence::MidiEventHolder::MidiEventHolder (const MidiMessage& mm) : message (mm) {} MidiMessageSequence::MidiEventHolder::MidiEventHolder (MidiMessage&& mm) : message (static_cast (mm)) {} @@ -334,3 +336,5 @@ void MidiMessageSequence::createControllerUpdatesForTime (int channelNumber, dou } } } + +} // namespace juce diff --git a/modules/juce_audio_basics/midi/juce_MidiMessageSequence.h b/modules/juce_audio_basics/midi/juce_MidiMessageSequence.h index 916431b986..8f5e3f6994 100644 --- a/modules/juce_audio_basics/midi/juce_MidiMessageSequence.h +++ b/modules/juce_audio_basics/midi/juce_MidiMessageSequence.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -294,3 +294,5 @@ private: JUCE_LEAK_DETECTOR (MidiMessageSequence) }; + +} // namespace juce diff --git a/modules/juce_audio_basics/midi/juce_MidiRPN.cpp b/modules/juce_audio_basics/midi/juce_MidiRPN.cpp index a5189566c4..9e2c2df329 100644 --- a/modules/juce_audio_basics/midi/juce_MidiRPN.cpp +++ b/modules/juce_audio_basics/midi/juce_MidiRPN.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + MidiRPNDetector::MidiRPNDetector() noexcept { } @@ -369,3 +372,5 @@ private: static MidiRPNGeneratorTests MidiRPNGeneratorUnitTests; #endif // JUCE_UNIT_TESTS + +} // namespace juce diff --git a/modules/juce_audio_basics/midi/juce_MidiRPN.h b/modules/juce_audio_basics/midi/juce_MidiRPN.h index 53219c1f9e..e8a74d1071 100644 --- a/modules/juce_audio_basics/midi/juce_MidiRPN.h +++ b/modules/juce_audio_basics/midi/juce_MidiRPN.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** Represents a MIDI RPN (registered parameter number) or NRPN (non-registered @@ -144,3 +144,5 @@ public: bool isNRPN = false, bool use14BitValue = true); }; + +} // namespace juce diff --git a/modules/juce_audio_basics/mpe/juce_MPEInstrument.cpp b/modules/juce_audio_basics/mpe/juce_MPEInstrument.cpp index 70aee29fde..24bfd2e260 100644 --- a/modules/juce_audio_basics/mpe/juce_MPEInstrument.cpp +++ b/modules/juce_audio_basics/mpe/juce_MPEInstrument.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + namespace { const uint8 noLSBValueReceived = 0xff; @@ -2148,3 +2151,5 @@ private: static MPEInstrumentTests MPEInstrumentUnitTests; #endif // JUCE_UNIT_TESTS + +} // namespace juce diff --git a/modules/juce_audio_basics/mpe/juce_MPEInstrument.h b/modules/juce_audio_basics/mpe/juce_MPEInstrument.h index 8fe26ae919..b6d05ea843 100644 --- a/modules/juce_audio_basics/mpe/juce_MPEInstrument.h +++ b/modules/juce_audio_basics/mpe/juce_MPEInstrument.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /* @@ -374,3 +374,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MPEInstrument) }; + +} // namespace juce diff --git a/modules/juce_audio_basics/mpe/juce_MPEMessages.cpp b/modules/juce_audio_basics/mpe/juce_MPEMessages.cpp index 09939a1045..ebdc68993c 100644 --- a/modules/juce_audio_basics/mpe/juce_MPEMessages.cpp +++ b/modules/juce_audio_basics/mpe/juce_MPEMessages.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + MidiBuffer MPEMessages::addZone (MPEZone zone) { MidiBuffer buffer (MidiRPNGenerator::generate (zone.getFirstNoteChannel(), @@ -193,3 +196,5 @@ private: static MPEMessagesTests MPEMessagesUnitTests; #endif // JUCE_UNIT_TESTS + +} // namespace juce diff --git a/modules/juce_audio_basics/mpe/juce_MPEMessages.h b/modules/juce_audio_basics/mpe/juce_MPEMessages.h index 87b12f09d7..76b58b2013 100644 --- a/modules/juce_audio_basics/mpe/juce_MPEMessages.h +++ b/modules/juce_audio_basics/mpe/juce_MPEMessages.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -87,3 +87,5 @@ public: */ static const int zoneLayoutMessagesRpnNumber = 6; }; + +} // namespace juce diff --git a/modules/juce_audio_basics/mpe/juce_MPENote.cpp b/modules/juce_audio_basics/mpe/juce_MPENote.cpp index 1f47cec021..dad3ab6028 100644 --- a/modules/juce_audio_basics/mpe/juce_MPENote.cpp +++ b/modules/juce_audio_basics/mpe/juce_MPENote.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + namespace { uint16 generateNoteID (int midiChannel, int midiNoteNumber) noexcept @@ -128,3 +131,5 @@ private: static MPENoteTests MPENoteUnitTests; #endif // JUCE_UNIT_TESTS + +} // namespace juce diff --git a/modules/juce_audio_basics/mpe/juce_MPENote.h b/modules/juce_audio_basics/mpe/juce_MPENote.h index 874a03f3e9..8d549ddd9e 100644 --- a/modules/juce_audio_basics/mpe/juce_MPENote.h +++ b/modules/juce_audio_basics/mpe/juce_MPENote.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -172,3 +172,5 @@ struct JUCE_API MPENote /** Returns true if two notes are different notes, determined by their unique ID. */ bool operator!= (const MPENote& other) const noexcept; }; + +} // namespace juce diff --git a/modules/juce_audio_basics/mpe/juce_MPESynthesiser.cpp b/modules/juce_audio_basics/mpe/juce_MPESynthesiser.cpp index 3e965f434b..94763f1bc7 100644 --- a/modules/juce_audio_basics/mpe/juce_MPESynthesiser.cpp +++ b/modules/juce_audio_basics/mpe/juce_MPESynthesiser.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + MPESynthesiser::MPESynthesiser() { } @@ -352,3 +355,5 @@ void MPESynthesiser::renderNextSubBlock (AudioBuffer& buffer, int startS voice->renderNextBlock (buffer, startSample, numSamples); } } + +} // namespace juce diff --git a/modules/juce_audio_basics/mpe/juce_MPESynthesiser.h b/modules/juce_audio_basics/mpe/juce_MPESynthesiser.h index 73dcc9772f..408970e6c5 100644 --- a/modules/juce_audio_basics/mpe/juce_MPESynthesiser.h +++ b/modules/juce_audio_basics/mpe/juce_MPESynthesiser.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -305,3 +305,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MPESynthesiser) }; + +} // namespace juce diff --git a/modules/juce_audio_basics/mpe/juce_MPESynthesiserBase.cpp b/modules/juce_audio_basics/mpe/juce_MPESynthesiserBase.cpp index 671249a307..7759eea5e2 100644 --- a/modules/juce_audio_basics/mpe/juce_MPESynthesiserBase.cpp +++ b/modules/juce_audio_basics/mpe/juce_MPESynthesiserBase.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + MPESynthesiserBase::MPESynthesiserBase() : instrument (new MPEInstrument), sampleRate (0), @@ -178,3 +181,5 @@ void MPESynthesiserBase::setMinimumRenderingSubdivisionSize (int numSamples, boo minimumSubBlockSize = numSamples; subBlockSubdivisionIsStrict = shouldBeStrict; } + +} // namespace juce diff --git a/modules/juce_audio_basics/mpe/juce_MPESynthesiserBase.h b/modules/juce_audio_basics/mpe/juce_MPESynthesiserBase.h index 649abc884d..b2b787a58d 100644 --- a/modules/juce_audio_basics/mpe/juce_MPESynthesiserBase.h +++ b/modules/juce_audio_basics/mpe/juce_MPESynthesiserBase.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -204,3 +204,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MPESynthesiserBase) }; + +} // namespace juce diff --git a/modules/juce_audio_basics/mpe/juce_MPESynthesiserVoice.cpp b/modules/juce_audio_basics/mpe/juce_MPESynthesiserVoice.cpp index cdd35cfc04..6ac688eba9 100644 --- a/modules/juce_audio_basics/mpe/juce_MPESynthesiserVoice.cpp +++ b/modules/juce_audio_basics/mpe/juce_MPESynthesiserVoice.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + MPESynthesiserVoice::MPESynthesiserVoice() : currentSampleRate (0), noteStartTime (0) { @@ -49,3 +52,5 @@ void MPESynthesiserVoice::clearCurrentNote() noexcept { currentlyPlayingNote = MPENote(); } + +} // namespace juce diff --git a/modules/juce_audio_basics/mpe/juce_MPESynthesiserVoice.h b/modules/juce_audio_basics/mpe/juce_MPESynthesiserVoice.h index 9f8205e638..142c963783 100644 --- a/modules/juce_audio_basics/mpe/juce_MPESynthesiserVoice.h +++ b/modules/juce_audio_basics/mpe/juce_MPESynthesiserVoice.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -183,3 +184,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MPESynthesiserVoice) }; + +} // namespace juce diff --git a/modules/juce_audio_basics/mpe/juce_MPEValue.cpp b/modules/juce_audio_basics/mpe/juce_MPEValue.cpp index 9413057542..d9fbd7db39 100644 --- a/modules/juce_audio_basics/mpe/juce_MPEValue.cpp +++ b/modules/juce_audio_basics/mpe/juce_MPEValue.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + MPEValue::MPEValue() noexcept : normalisedValue (8192) { } @@ -166,3 +169,5 @@ private: static MPEValueTests MPEValueUnitTests; #endif // JUCE_UNIT_TESTS + +} // namespace juce diff --git a/modules/juce_audio_basics/mpe/juce_MPEValue.h b/modules/juce_audio_basics/mpe/juce_MPEValue.h index 5743410058..4bb5afc966 100644 --- a/modules/juce_audio_basics/mpe/juce_MPEValue.h +++ b/modules/juce_audio_basics/mpe/juce_MPEValue.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -88,3 +88,5 @@ private: MPEValue (int normalisedValue); int normalisedValue; }; + +} // namespace juce diff --git a/modules/juce_audio_basics/mpe/juce_MPEZone.cpp b/modules/juce_audio_basics/mpe/juce_MPEZone.cpp index 912a86c3c5..5b97f0677f 100644 --- a/modules/juce_audio_basics/mpe/juce_MPEZone.cpp +++ b/modules/juce_audio_basics/mpe/juce_MPEZone.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + namespace { void checkAndLimitZoneParameters (int minValue, @@ -312,3 +315,5 @@ private: static MPEZoneTests MPEZoneUnitTests; #endif // JUCE_UNIT_TESTS + +} // namespace juce diff --git a/modules/juce_audio_basics/mpe/juce_MPEZone.h b/modules/juce_audio_basics/mpe/juce_MPEZone.h index 9fdfb5548e..7284398267 100644 --- a/modules/juce_audio_basics/mpe/juce_MPEZone.h +++ b/modules/juce_audio_basics/mpe/juce_MPEZone.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -138,3 +138,5 @@ private: int perNotePitchbendRange; int masterPitchbendRange; }; + +} // namespace juce diff --git a/modules/juce_audio_basics/mpe/juce_MPEZoneLayout.cpp b/modules/juce_audio_basics/mpe/juce_MPEZoneLayout.cpp index 450dc09f6b..f0d525ad35 100644 --- a/modules/juce_audio_basics/mpe/juce_MPEZoneLayout.cpp +++ b/modules/juce_audio_basics/mpe/juce_MPEZoneLayout.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + MPEZoneLayout::MPEZoneLayout() noexcept { } @@ -378,3 +381,5 @@ static MPEZoneLayoutTests MPEZoneLayoutUnitTests; #endif // JUCE_UNIT_TESTS + +} // namespace juce diff --git a/modules/juce_audio_basics/mpe/juce_MPEZoneLayout.h b/modules/juce_audio_basics/mpe/juce_MPEZoneLayout.h index 0b08eb5618..5b0337c113 100644 --- a/modules/juce_audio_basics/mpe/juce_MPEZoneLayout.h +++ b/modules/juce_audio_basics/mpe/juce_MPEZoneLayout.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -157,3 +157,5 @@ private: void processZoneLayoutRpnMessage (MidiRPNMessage); void processPitchbendRangeRpnMessage (MidiRPNMessage); }; + +} // namespace juce diff --git a/modules/juce_audio_basics/native/juce_mac_CoreAudioLayouts.h b/modules/juce_audio_basics/native/juce_mac_CoreAudioLayouts.h index 1bf5cda274..0aaf6f6664 100644 --- a/modules/juce_audio_basics/native/juce_mac_CoreAudioLayouts.h +++ b/modules/juce_audio_basics/native/juce_mac_CoreAudioLayouts.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ #if JUCE_MAC || JUCE_IOS @@ -304,3 +305,5 @@ private: }; #endif + +} // namespace juce diff --git a/modules/juce_audio_basics/sources/juce_AudioSource.h b/modules/juce_audio_basics/sources/juce_AudioSource.h index e58f93b297..6e5ddba5df 100644 --- a/modules/juce_audio_basics/sources/juce_AudioSource.h +++ b/modules/juce_audio_basics/sources/juce_AudioSource.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -173,3 +173,5 @@ public: */ virtual void getNextAudioBlock (const AudioSourceChannelInfo& bufferToFill) = 0; }; + +} // namespace juce diff --git a/modules/juce_audio_basics/sources/juce_BufferingAudioSource.cpp b/modules/juce_audio_basics/sources/juce_BufferingAudioSource.cpp index 1cf4718393..ae33bea0db 100644 --- a/modules/juce_audio_basics/sources/juce_BufferingAudioSource.cpp +++ b/modules/juce_audio_basics/sources/juce_BufferingAudioSource.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + BufferingAudioSource::BufferingAudioSource (PositionableAudioSource* s, TimeSliceThread& thread, const bool deleteSourceWhenDeleted, @@ -307,3 +310,5 @@ int BufferingAudioSource::useTimeSlice() { return readNextBufferChunk() ? 1 : 100; } + +} // namespace juce diff --git a/modules/juce_audio_basics/sources/juce_BufferingAudioSource.h b/modules/juce_audio_basics/sources/juce_BufferingAudioSource.h index 803695ea44..5624f5ceb7 100644 --- a/modules/juce_audio_basics/sources/juce_BufferingAudioSource.h +++ b/modules/juce_audio_basics/sources/juce_BufferingAudioSource.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -113,3 +113,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (BufferingAudioSource) }; + +} // namespace juce diff --git a/modules/juce_audio_basics/sources/juce_ChannelRemappingAudioSource.cpp b/modules/juce_audio_basics/sources/juce_ChannelRemappingAudioSource.cpp index a70fe866e1..3cec22131c 100644 --- a/modules/juce_audio_basics/sources/juce_ChannelRemappingAudioSource.cpp +++ b/modules/juce_audio_basics/sources/juce_ChannelRemappingAudioSource.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + ChannelRemappingAudioSource::ChannelRemappingAudioSource (AudioSource* const source_, const bool deleteSourceWhenDeleted) : source (source_, deleteSourceWhenDeleted), @@ -180,3 +183,5 @@ void ChannelRemappingAudioSource::restoreFromXml (const XmlElement& e) remappedOutputs.add (outs[i].getIntValue()); } } + +} // namespace juce diff --git a/modules/juce_audio_basics/sources/juce_ChannelRemappingAudioSource.h b/modules/juce_audio_basics/sources/juce_ChannelRemappingAudioSource.h index 1ed44d8244..b5a5cf058b 100644 --- a/modules/juce_audio_basics/sources/juce_ChannelRemappingAudioSource.h +++ b/modules/juce_audio_basics/sources/juce_ChannelRemappingAudioSource.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -135,3 +135,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ChannelRemappingAudioSource) }; + +} // namespace juce diff --git a/modules/juce_audio_basics/sources/juce_IIRFilterAudioSource.cpp b/modules/juce_audio_basics/sources/juce_IIRFilterAudioSource.cpp index be4479fbb5..cbea3b8c29 100644 --- a/modules/juce_audio_basics/sources/juce_IIRFilterAudioSource.cpp +++ b/modules/juce_audio_basics/sources/juce_IIRFilterAudioSource.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + IIRFilterAudioSource::IIRFilterAudioSource (AudioSource* const inputSource, const bool deleteInputWhenDeleted) : input (inputSource, deleteInputWhenDeleted) @@ -73,3 +76,5 @@ void IIRFilterAudioSource::getNextAudioBlock (const AudioSourceChannelInfo& buff ->processSamples (bufferToFill.buffer->getWritePointer (i, bufferToFill.startSample), bufferToFill.numSamples); } + +} // namespace juce diff --git a/modules/juce_audio_basics/sources/juce_IIRFilterAudioSource.h b/modules/juce_audio_basics/sources/juce_IIRFilterAudioSource.h index 9f38d1ce80..38faf285bc 100644 --- a/modules/juce_audio_basics/sources/juce_IIRFilterAudioSource.h +++ b/modules/juce_audio_basics/sources/juce_IIRFilterAudioSource.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -62,3 +62,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (IIRFilterAudioSource) }; + +} // namespace juce diff --git a/modules/juce_audio_basics/sources/juce_MemoryAudioSource.cpp b/modules/juce_audio_basics/sources/juce_MemoryAudioSource.cpp index 220debfd1f..6adec04448 100644 --- a/modules/juce_audio_basics/sources/juce_MemoryAudioSource.cpp +++ b/modules/juce_audio_basics/sources/juce_MemoryAudioSource.cpp @@ -20,7 +20,9 @@ ============================================================================== */ -//============================================================================== +namespace juce +{ + MemoryAudioSource::MemoryAudioSource (AudioBuffer& bufferToUse, bool copyMemory, bool shouldLoop) : isLooping (shouldLoop) { @@ -64,3 +66,5 @@ void MemoryAudioSource::getNextAudioBlock (const AudioSourceChannelInfo& bufferT if (pos < m) dst.clear (bufferToFill.startSample + pos, m - pos); } + +} // namespace juce diff --git a/modules/juce_audio_basics/sources/juce_MemoryAudioSource.h b/modules/juce_audio_basics/sources/juce_MemoryAudioSource.h index 1a6fabf1b8..50b11c7b93 100644 --- a/modules/juce_audio_basics/sources/juce_MemoryAudioSource.h +++ b/modules/juce_audio_basics/sources/juce_MemoryAudioSource.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -59,3 +59,5 @@ private: //============================================================================== JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MemoryAudioSource) }; + +} // namespace juce diff --git a/modules/juce_audio_basics/sources/juce_MixerAudioSource.cpp b/modules/juce_audio_basics/sources/juce_MixerAudioSource.cpp index 70b2658652..b3f1d148c0 100644 --- a/modules/juce_audio_basics/sources/juce_MixerAudioSource.cpp +++ b/modules/juce_audio_basics/sources/juce_MixerAudioSource.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + MixerAudioSource::MixerAudioSource() : currentSampleRate (0.0), bufferSizeExpected (0) { @@ -151,3 +154,5 @@ void MixerAudioSource::getNextAudioBlock (const AudioSourceChannelInfo& info) info.clearActiveBufferRegion(); } } + +} // namespace juce diff --git a/modules/juce_audio_basics/sources/juce_MixerAudioSource.h b/modules/juce_audio_basics/sources/juce_MixerAudioSource.h index 5a3883f8e9..0c2b6e22c7 100644 --- a/modules/juce_audio_basics/sources/juce_MixerAudioSource.h +++ b/modules/juce_audio_basics/sources/juce_MixerAudioSource.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -93,3 +93,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MixerAudioSource) }; + +} // namespace juce diff --git a/modules/juce_audio_basics/sources/juce_PositionableAudioSource.h b/modules/juce_audio_basics/sources/juce_PositionableAudioSource.h index c9195dc90e..5908bb82bd 100644 --- a/modules/juce_audio_basics/sources/juce_PositionableAudioSource.h +++ b/modules/juce_audio_basics/sources/juce_PositionableAudioSource.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -70,3 +70,5 @@ public: /** Tells the source whether you'd like it to play in a loop. */ virtual void setLooping (bool shouldLoop) { ignoreUnused (shouldLoop); } }; + +} // namespace juce diff --git a/modules/juce_audio_basics/sources/juce_ResamplingAudioSource.cpp b/modules/juce_audio_basics/sources/juce_ResamplingAudioSource.cpp index 386f894ca4..67ff49ccd4 100644 --- a/modules/juce_audio_basics/sources/juce_ResamplingAudioSource.cpp +++ b/modules/juce_audio_basics/sources/juce_ResamplingAudioSource.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + ResamplingAudioSource::ResamplingAudioSource (AudioSource* const inputSource, const bool deleteInputWhenDeleted, const int channels) @@ -259,3 +262,5 @@ void ResamplingAudioSource::applyFilter (float* samples, int num, FilterState& f *samples++ = (float) out; } } + +} // namespace juce diff --git a/modules/juce_audio_basics/sources/juce_ResamplingAudioSource.h b/modules/juce_audio_basics/sources/juce_ResamplingAudioSource.h index 72134f9837..9f8fcd239a 100644 --- a/modules/juce_audio_basics/sources/juce_ResamplingAudioSource.h +++ b/modules/juce_audio_basics/sources/juce_ResamplingAudioSource.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -99,3 +99,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ResamplingAudioSource) }; + +} // namespace juce diff --git a/modules/juce_audio_basics/sources/juce_ReverbAudioSource.cpp b/modules/juce_audio_basics/sources/juce_ReverbAudioSource.cpp index 86e54eaf96..dd4e7ab03f 100644 --- a/modules/juce_audio_basics/sources/juce_ReverbAudioSource.cpp +++ b/modules/juce_audio_basics/sources/juce_ReverbAudioSource.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + ReverbAudioSource::ReverbAudioSource (AudioSource* const inputSource, const bool deleteInputWhenDeleted) : input (inputSource, deleteInputWhenDeleted), bypass (false) @@ -76,3 +79,5 @@ void ReverbAudioSource::setBypassed (bool b) noexcept reverb.reset(); } } + +} // namespace juce diff --git a/modules/juce_audio_basics/sources/juce_ReverbAudioSource.h b/modules/juce_audio_basics/sources/juce_ReverbAudioSource.h index fbdf48c943..1d2591b649 100644 --- a/modules/juce_audio_basics/sources/juce_ReverbAudioSource.h +++ b/modules/juce_audio_basics/sources/juce_ReverbAudioSource.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -68,3 +68,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ReverbAudioSource) }; + +} // namespace juce diff --git a/modules/juce_audio_basics/sources/juce_ToneGeneratorAudioSource.cpp b/modules/juce_audio_basics/sources/juce_ToneGeneratorAudioSource.cpp index b0f24d3901..b33a922494 100644 --- a/modules/juce_audio_basics/sources/juce_ToneGeneratorAudioSource.cpp +++ b/modules/juce_audio_basics/sources/juce_ToneGeneratorAudioSource.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + ToneGeneratorAudioSource::ToneGeneratorAudioSource() : frequency (1000.0), sampleRate (44100.0), @@ -71,3 +74,5 @@ void ToneGeneratorAudioSource::getNextAudioBlock (const AudioSourceChannelInfo& info.buffer->setSample (j, info.startSample + i, sample); } } + +} // namespace juce diff --git a/modules/juce_audio_basics/sources/juce_ToneGeneratorAudioSource.h b/modules/juce_audio_basics/sources/juce_ToneGeneratorAudioSource.h index a5fc03b4f1..9c8e939d94 100644 --- a/modules/juce_audio_basics/sources/juce_ToneGeneratorAudioSource.h +++ b/modules/juce_audio_basics/sources/juce_ToneGeneratorAudioSource.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -65,3 +65,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ToneGeneratorAudioSource) }; + +} // namespace juce diff --git a/modules/juce_audio_basics/synthesisers/juce_Synthesiser.cpp b/modules/juce_audio_basics/synthesisers/juce_Synthesiser.cpp index fa12e84033..cb2eaf904d 100644 --- a/modules/juce_audio_basics/synthesisers/juce_Synthesiser.cpp +++ b/modules/juce_audio_basics/synthesisers/juce_Synthesiser.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + SynthesiserSound::SynthesiserSound() {} SynthesiserSound::~SynthesiserSound() {} @@ -567,3 +570,5 @@ SynthesiserVoice* Synthesiser::findVoiceToSteal (SynthesiserSound* soundToPlay, return low; } + +} // namespace juce diff --git a/modules/juce_audio_basics/synthesisers/juce_Synthesiser.h b/modules/juce_audio_basics/synthesisers/juce_Synthesiser.h index 1089960628..b8e50876f0 100644 --- a/modules/juce_audio_basics/synthesisers/juce_Synthesiser.h +++ b/modules/juce_audio_basics/synthesisers/juce_Synthesiser.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -645,3 +645,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Synthesiser) }; + +} // namespace juce diff --git a/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp b/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp index a6e74c570f..6f0be5db75 100644 --- a/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp +++ b/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + AudioDeviceManager::AudioDeviceSetup::AudioDeviceSetup() : sampleRate (0), bufferSize (0), @@ -1000,3 +1003,5 @@ double AudioDeviceManager::getCurrentOutputLevel() const noexcept { return out void AudioDeviceManager::enableInputLevelMeasurement (bool enable) noexcept { inputLevelMeter.setEnabled (enable); } void AudioDeviceManager::enableOutputLevelMeasurement (bool enable) noexcept { outputLevelMeter.setEnabled (enable); } + +} // namespace juce diff --git a/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.h b/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.h index f4169644c6..5d7ae84038 100644 --- a/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.h +++ b/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -518,3 +518,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioDeviceManager) }; + +} // namespace juce diff --git a/modules/juce_audio_devices/audio_io/juce_AudioIODevice.cpp b/modules/juce_audio_devices/audio_io/juce_AudioIODevice.cpp index 0fd48370f1..95ae0c8e41 100644 --- a/modules/juce_audio_devices/audio_io/juce_AudioIODevice.cpp +++ b/modules/juce_audio_devices/audio_io/juce_AudioIODevice.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + AudioIODevice::AudioIODevice (const String& deviceName, const String& deviceTypeName) : name (deviceName), typeName (deviceTypeName) { @@ -37,3 +40,5 @@ bool AudioIODevice::showControlPanel() // their hasControlPanel() method. return false; } + +} // namespace juce diff --git a/modules/juce_audio_devices/audio_io/juce_AudioIODevice.h b/modules/juce_audio_devices/audio_io/juce_AudioIODevice.h index 6c3b8300f1..d1cb0d52f0 100644 --- a/modules/juce_audio_devices/audio_io/juce_AudioIODevice.h +++ b/modules/juce_audio_devices/audio_io/juce_AudioIODevice.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ class AudioIODevice; @@ -301,3 +302,5 @@ protected: /** @internal */ String name, typeName; }; + +} // namespace juce diff --git a/modules/juce_audio_devices/audio_io/juce_AudioIODeviceType.cpp b/modules/juce_audio_devices/audio_io/juce_AudioIODeviceType.cpp index aef772d0a3..838aaa6547 100644 --- a/modules/juce_audio_devices/audio_io/juce_AudioIODeviceType.cpp +++ b/modules/juce_audio_devices/audio_io/juce_AudioIODeviceType.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + AudioIODeviceType::AudioIODeviceType (const String& name) : typeName (name) { @@ -74,3 +77,5 @@ AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_Android() #if ! (JUCE_ANDROID && JUCE_USE_ANDROID_OPENSLES) AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_OpenSLES() { return nullptr; } #endif + +} // namespace juce diff --git a/modules/juce_audio_devices/audio_io/juce_AudioIODeviceType.h b/modules/juce_audio_devices/audio_io/juce_AudioIODeviceType.h index eaba0080e0..c11f711a41 100644 --- a/modules/juce_audio_devices/audio_io/juce_AudioIODeviceType.h +++ b/modules/juce_audio_devices/audio_io/juce_AudioIODeviceType.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -174,3 +174,5 @@ private: JUCE_DECLARE_NON_COPYABLE (AudioIODeviceType) }; + +} // namespace juce diff --git a/modules/juce_audio_devices/audio_io/juce_SystemAudioVolume.h b/modules/juce_audio_devices/audio_io/juce_SystemAudioVolume.h index 592215c9d6..bf5c44c6af 100644 --- a/modules/juce_audio_devices/audio_io/juce_SystemAudioVolume.h +++ b/modules/juce_audio_devices/audio_io/juce_SystemAudioVolume.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -53,3 +53,5 @@ private: SystemAudioVolume(); // Don't instantiate this class, just call its static fns. JUCE_DECLARE_NON_COPYABLE (SystemAudioVolume) }; + +} // namespace juce diff --git a/modules/juce_audio_devices/juce_audio_devices.cpp b/modules/juce_audio_devices/juce_audio_devices.cpp index 33c6fe0c92..6bdd8fe06e 100644 --- a/modules/juce_audio_devices/juce_audio_devices.cpp +++ b/modules/juce_audio_devices/juce_audio_devices.cpp @@ -155,9 +155,6 @@ #endif -namespace juce -{ - #include "audio_io/juce_AudioDeviceManager.cpp" #include "audio_io/juce_AudioIODevice.cpp" #include "audio_io/juce_AudioIODeviceType.cpp" @@ -214,14 +211,15 @@ namespace juce #if JUCE_USE_ANDROID_OPENSLES #include "native/juce_android_OpenSL.cpp" #endif - #endif #if ! JUCE_SYSTEMAUDIOVOL_IMPLEMENTED - // None of these methods are available. (On Windows you might need to enable WASAPI for this) - float JUCE_CALLTYPE SystemAudioVolume::getGain() { jassertfalse; return 0.0f; } - bool JUCE_CALLTYPE SystemAudioVolume::setGain (float) { jassertfalse; return false; } - bool JUCE_CALLTYPE SystemAudioVolume::isMuted() { jassertfalse; return false; } - bool JUCE_CALLTYPE SystemAudioVolume::setMuted (bool) { jassertfalse; return false; } -#endif +namespace juce +{ + // None of these methods are available. (On Windows you might need to enable WASAPI for this) + float JUCE_CALLTYPE SystemAudioVolume::getGain() { jassertfalse; return 0.0f; } + bool JUCE_CALLTYPE SystemAudioVolume::setGain (float) { jassertfalse; return false; } + bool JUCE_CALLTYPE SystemAudioVolume::isMuted() { jassertfalse; return false; } + bool JUCE_CALLTYPE SystemAudioVolume::setMuted (bool) { jassertfalse; return false; } } +#endif diff --git a/modules/juce_audio_devices/juce_audio_devices.h b/modules/juce_audio_devices/juce_audio_devices.h index 533bcd1af3..6dddca865e 100644 --- a/modules/juce_audio_devices/juce_audio_devices.h +++ b/modules/juce_audio_devices/juce_audio_devices.h @@ -140,9 +140,6 @@ //============================================================================== -namespace juce -{ - #include "midi_io/juce_MidiInput.h" #include "midi_io/juce_MidiMessageCollector.h" #include "midi_io/juce_MidiOutput.h" @@ -156,5 +153,3 @@ namespace juce #if JUCE_IOS #include "native/juce_ios_Audio.h" #endif - -} diff --git a/modules/juce_audio_devices/midi_io/juce_MidiInput.h b/modules/juce_audio_devices/midi_io/juce_MidiInput.h index 54cd0e4e77..52edd9fe09 100644 --- a/modules/juce_audio_devices/midi_io/juce_MidiInput.h +++ b/modules/juce_audio_devices/midi_io/juce_MidiInput.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ class MidiInput; @@ -171,3 +172,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MidiInput) }; + +} // namespace juce diff --git a/modules/juce_audio_devices/midi_io/juce_MidiMessageCollector.cpp b/modules/juce_audio_devices/midi_io/juce_MidiMessageCollector.cpp index 66bab1f852..50ca20569a 100644 --- a/modules/juce_audio_devices/midi_io/juce_MidiMessageCollector.cpp +++ b/modules/juce_audio_devices/midi_io/juce_MidiMessageCollector.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + MidiMessageCollector::MidiMessageCollector() { } @@ -151,3 +154,5 @@ void MidiMessageCollector::handleIncomingMidiMessage (MidiInput*, const MidiMess { addMessageToQueue (message); } + +} // namespace juce diff --git a/modules/juce_audio_devices/midi_io/juce_MidiMessageCollector.h b/modules/juce_audio_devices/midi_io/juce_MidiMessageCollector.h index 97f2dd6bb5..aa8bcdbeb6 100644 --- a/modules/juce_audio_devices/midi_io/juce_MidiMessageCollector.h +++ b/modules/juce_audio_devices/midi_io/juce_MidiMessageCollector.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -99,3 +99,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MidiMessageCollector) }; + +} // namespace juce diff --git a/modules/juce_audio_devices/midi_io/juce_MidiOutput.cpp b/modules/juce_audio_devices/midi_io/juce_MidiOutput.cpp index f364b31cd9..36b7cf6409 100644 --- a/modules/juce_audio_devices/midi_io/juce_MidiOutput.cpp +++ b/modules/juce_audio_devices/midi_io/juce_MidiOutput.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + struct MidiOutput::PendingMessage { PendingMessage (const void* const data, const int len, const double timeStamp) @@ -169,3 +172,5 @@ void MidiOutput::run() clearAllPendingMessages(); } + +} // namespace juce diff --git a/modules/juce_audio_devices/midi_io/juce_MidiOutput.h b/modules/juce_audio_devices/midi_io/juce_MidiOutput.h index f71553dc7e..f05dc32f14 100644 --- a/modules/juce_audio_devices/midi_io/juce_MidiOutput.h +++ b/modules/juce_audio_devices/midi_io/juce_MidiOutput.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -139,3 +139,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MidiOutput) }; + +} // namespace juce diff --git a/modules/juce_audio_devices/native/juce_MidiDataConcatenator.h b/modules/juce_audio_devices/native/juce_MidiDataConcatenator.h index 0cf7e285d1..1df491240a 100644 --- a/modules/juce_audio_devices/native/juce_MidiDataConcatenator.h +++ b/modules/juce_audio_devices/native/juce_MidiDataConcatenator.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -31,9 +32,8 @@ class MidiDataConcatenator { public: //============================================================================== - MidiDataConcatenator (const int initialBufferSize) - : pendingData ((size_t) initialBufferSize), - pendingDataTime (0), pendingBytes (0), runningStatus (0) + MidiDataConcatenator (int initialBufferSize) + : pendingData ((size_t) initialBufferSize) { } @@ -181,9 +181,11 @@ private: } MemoryBlock pendingData; - double pendingDataTime; - int pendingBytes; - uint8 runningStatus; + double pendingDataTime = 0; + int pendingBytes = 0; + uint8 runningStatus = 0; JUCE_DECLARE_NON_COPYABLE (MidiDataConcatenator) }; + +} // namespace juce diff --git a/modules/juce_audio_devices/native/juce_android_Audio.cpp b/modules/juce_audio_devices/native/juce_android_Audio.cpp index a22f0619fa..6ff8c32261 100644 --- a/modules/juce_audio_devices/native/juce_android_Audio.cpp +++ b/modules/juce_audio_devices/native/juce_android_Audio.cpp @@ -20,7 +20,9 @@ ============================================================================== */ -//============================================================================== +namespace juce +{ + #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ STATICMETHOD (getMinBufferSize, "getMinBufferSize", "(III)I") \ STATICMETHOD (getNativeOutputSampleRate, "getNativeOutputSampleRate", "(I)I") \ @@ -472,3 +474,5 @@ AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_Android() return new AndroidAudioIODeviceType(); } + +} // namespace juce diff --git a/modules/juce_audio_devices/native/juce_android_Midi.cpp b/modules/juce_audio_devices/native/juce_android_Midi.cpp index 3bcd3ea053..5afe6562c3 100644 --- a/modules/juce_audio_devices/native/juce_android_Midi.cpp +++ b/modules/juce_audio_devices/native/juce_android_Midi.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ METHOD (getJuceAndroidMidiInputDevices, "getJuceAndroidMidiInputDevices", "()[Ljava/lang/String;") \ METHOD (getJuceAndroidMidiOutputDevices, "getJuceAndroidMidiOutputDevices", "()[Ljava/lang/String;") \ @@ -357,3 +360,5 @@ MidiInput::~MidiInput() { delete reinterpret_cast (internal); } + +} // namespace juce diff --git a/modules/juce_audio_devices/native/juce_android_OpenSL.cpp b/modules/juce_audio_devices/native/juce_android_OpenSL.cpp index 400d0f54f8..65362b8565 100644 --- a/modules/juce_audio_devices/native/juce_android_OpenSL.cpp +++ b/modules/juce_audio_devices/native/juce_android_OpenSL.cpp @@ -20,7 +20,9 @@ ============================================================================== */ -//============================================================================== +namespace juce +{ + #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ STATICFIELD (SDK_INT, "SDK_INT", "I") \ @@ -1283,3 +1285,5 @@ pthread_t juce_createRealtimeAudioThread (void* (*entry) (void*), void* userPtr) return threadID; } + +} // namespace juce diff --git a/modules/juce_audio_devices/native/juce_ios_Audio.cpp b/modules/juce_audio_devices/native/juce_ios_Audio.cpp index ad69dad3c8..c123849b06 100644 --- a/modules/juce_audio_devices/native/juce_ios_Audio.cpp +++ b/modules/juce_audio_devices/native/juce_ios_Audio.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + class iOSAudioIODevice; static const char* const iOSAudioDeviceName = "iOS Audio"; @@ -183,6 +186,10 @@ bool getNotificationValueForKey (NSNotification* notification, NSString* key, NS @end //============================================================================== +#if JUCE_MODULE_AVAILABLE_juce_graphics + #include +#endif + namespace juce { #ifndef JUCE_IOS_AUDIO_LOGGING @@ -206,10 +213,6 @@ static void logNSError (NSError* e) #define JUCE_NSERROR_CHECK(X) { NSError* error = nil; X; logNSError (error); } -#if JUCE_MODULE_AVAILABLE_juce_graphics -#include -#endif - //============================================================================== struct iOSAudioIODevice::Pimpl : public AudioPlayHead, public AsyncUpdater @@ -1168,3 +1171,5 @@ void AudioSessionHolder::handleRouteChange (const char* reason) } #undef JUCE_NSERROR_CHECK + +} // namespace juce diff --git a/modules/juce_audio_devices/native/juce_ios_Audio.h b/modules/juce_audio_devices/native/juce_ios_Audio.h index bab7573845..f0b3733268 100644 --- a/modules/juce_audio_devices/native/juce_ios_Audio.h +++ b/modules/juce_audio_devices/native/juce_ios_Audio.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ struct iOSAudioIODeviceType; @@ -86,3 +87,5 @@ private: JUCE_DECLARE_NON_COPYABLE (iOSAudioIODevice) }; + +} // namespace juce diff --git a/modules/juce_audio_devices/native/juce_linux_ALSA.cpp b/modules/juce_audio_devices/native/juce_linux_ALSA.cpp index 84432055a6..db984ebd44 100644 --- a/modules/juce_audio_devices/native/juce_linux_ALSA.cpp +++ b/modules/juce_audio_devices/native/juce_linux_ALSA.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + namespace { @@ -1272,3 +1275,5 @@ AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_ALSA() { return createAudioIODeviceType_ALSA_PCMDevices(); } + +} // namespace juce diff --git a/modules/juce_audio_devices/native/juce_linux_JackAudio.cpp b/modules/juce_audio_devices/native/juce_linux_JackAudio.cpp index 482437e893..eb25bd7622 100644 --- a/modules/juce_audio_devices/native/juce_linux_JackAudio.cpp +++ b/modules/juce_audio_devices/native/juce_linux_JackAudio.cpp @@ -20,7 +20,9 @@ ============================================================================== */ -//============================================================================== +namespace juce +{ + static void* juce_libjackHandle = nullptr; static void* juce_loadJackFunction (const char* const name) @@ -602,3 +604,5 @@ AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_JACK() { return new JackAudioIODeviceType(); } + +} // namespace juce diff --git a/modules/juce_audio_devices/native/juce_linux_Midi.cpp b/modules/juce_audio_devices/native/juce_linux_Midi.cpp index 260fcc95d0..ef4dfade87 100644 --- a/modules/juce_audio_devices/native/juce_linux_Midi.cpp +++ b/modules/juce_audio_devices/native/juce_linux_Midi.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_ALSA // You can define these strings in your app if you want to override the default names: @@ -610,3 +613,5 @@ MidiInput* MidiInput::openDevice (int, MidiInputCallback*) { re MidiInput* MidiInput::createNewDevice (const String&, MidiInputCallback*) { return nullptr; } #endif + +} // namespace juce diff --git a/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp b/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp index 0cb091a7e6..4442d15603 100644 --- a/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp +++ b/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_COREAUDIO_LOGGING_ENABLED #define JUCE_COREAUDIOLOG(a) { String camsg ("CoreAudio: "); camsg << a; Logger::writeToLog (camsg); } #else @@ -2058,3 +2061,5 @@ AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_CoreAudio() } #undef JUCE_COREAUDIOLOG + +} // namespace juce diff --git a/modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp b/modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp index 4abff0f094..cd98d478e6 100644 --- a/modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp +++ b/modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + #ifndef JUCE_LOG_COREMIDI_ERRORS #define JUCE_LOG_COREMIDI_ERRORS 1 #endif @@ -555,3 +558,5 @@ void MidiInput::stop() } #undef CHECK_ERROR + +} // namespace juce diff --git a/modules/juce_audio_devices/native/juce_win32_ASIO.cpp b/modules/juce_audio_devices/native/juce_win32_ASIO.cpp index c919767207..54bc1e7b51 100644 --- a/modules/juce_audio_devices/native/juce_win32_ASIO.cpp +++ b/modules/juce_audio_devices/native/juce_win32_ASIO.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + #undef WINDOWS /* The ASIO SDK *should* declare its callback functions as being __cdecl, but different versions seem @@ -1639,3 +1642,5 @@ AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_ASIO() { return new ASIOAudioIODeviceType(); } + +} // namespace juce diff --git a/modules/juce_audio_devices/native/juce_win32_DirectSound.cpp b/modules/juce_audio_devices/native/juce_win32_DirectSound.cpp index 031be1892c..83b60ce691 100644 --- a/modules/juce_audio_devices/native/juce_win32_DirectSound.cpp +++ b/modules/juce_audio_devices/native/juce_win32_DirectSound.cpp @@ -20,8 +20,6 @@ ============================================================================== */ -} // (juce namespace) - extern "C" { // Declare just the minimum number of interfaces for the DSound objects that we need.. @@ -1271,3 +1269,5 @@ AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_DirectSound() { return new DSoundAudioIODeviceType(); } + +} // namespace juce diff --git a/modules/juce_audio_devices/native/juce_win32_Midi.cpp b/modules/juce_audio_devices/native/juce_win32_Midi.cpp index b614f71387..8aacbae9ce 100644 --- a/modules/juce_audio_devices/native/juce_win32_Midi.cpp +++ b/modules/juce_audio_devices/native/juce_win32_Midi.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + struct MidiServiceType { struct InputWrapper @@ -27,7 +30,6 @@ struct MidiServiceType virtual ~InputWrapper() {} virtual String getDeviceName() = 0; - virtual void start() = 0; virtual void stop() = 0; }; @@ -37,7 +39,6 @@ struct MidiServiceType virtual ~OutputWrapper() {} virtual String getDeviceName() = 0; - virtual void sendMessageNow (const MidiMessage&) = 0; }; @@ -47,10 +48,8 @@ struct MidiServiceType virtual StringArray getDevices (bool) = 0; virtual int getDefaultDeviceIndex (bool) = 0; - virtual InputWrapper* createInputWrapper (MidiInput* const, - const int, - MidiInputCallback* const callback) = 0; - virtual OutputWrapper* createOutputWrapper (const int) = 0; + virtual InputWrapper* createInputWrapper (MidiInput*, int, MidiInputCallback*) = 0; + virtual OutputWrapper* createOutputWrapper (int) = 0; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MidiServiceType) }; @@ -510,14 +509,12 @@ public: : WindowsOutputWrapper::getDefaultDeviceIndex(); } - InputWrapper* createInputWrapper (MidiInput* const input, - const int index, - MidiInputCallback* const callback) override + InputWrapper* createInputWrapper (MidiInput* input, int index, MidiInputCallback* callback) override { return new WindowsInputWrapper (*this, input, index, callback); } - OutputWrapper* createOutputWrapper (const int index) override + OutputWrapper* createOutputWrapper (int index) override { return new WindowsOutputWrapper (*this, index); } @@ -1081,14 +1078,12 @@ public: : outputDeviceWatcher->getDefaultDeviceIndex(); } - InputWrapper* createInputWrapper (MidiInput* const input, - const int index, - MidiInputCallback* const callback) override + InputWrapper* createInputWrapper (MidiInput* input, int index, MidiInputCallback* callback) override { return new WinRTInputWrapper (*this, input, index, *callback); } - OutputWrapper* createOutputWrapper (const int index) override + OutputWrapper* createOutputWrapper (int index) override { return new WinRTOutputWrapper (*this, index); } @@ -1169,8 +1164,9 @@ MidiInput* MidiInput::openDevice (const int index, MidiInputCallback* const call if (callback == nullptr) return nullptr; - ScopedPointer in (new MidiInput ("")); + ScopedPointer in (new MidiInput ({})); ScopedPointer wrapper; + try { wrapper = MidiService::getInstance()->getService()->createInputWrapper (in, index, callback); @@ -1207,6 +1203,7 @@ int MidiOutput::getDefaultDeviceIndex() MidiOutput* MidiOutput::openDevice (const int index) { ScopedPointer wrapper; + try { wrapper = MidiService::getInstance()->getService()->createOutputWrapper (index); @@ -1229,6 +1226,7 @@ MidiOutput::~MidiOutput() void MidiOutput::sendMessageNow (const MidiMessage& message) { - auto* const wrapper = static_cast (internal); - wrapper->sendMessageNow (message); + static_cast (internal)->sendMessageNow (message); } + +} // namespace juce diff --git a/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp b/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp index 7fb96aaee3..16ed54c5c0 100644 --- a/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp +++ b/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + #ifndef JUCE_WASAPI_LOGGING #define JUCE_WASAPI_LOGGING 0 #endif @@ -1715,3 +1718,5 @@ float JUCE_CALLTYPE SystemAudioVolume::getGain() { return WasapiCla bool JUCE_CALLTYPE SystemAudioVolume::setGain (float gain) { return WasapiClasses::MMDeviceMasterVolume().setGain (gain); } bool JUCE_CALLTYPE SystemAudioVolume::isMuted() { return WasapiClasses::MMDeviceMasterVolume().isMuted(); } bool JUCE_CALLTYPE SystemAudioVolume::setMuted (bool mute) { return WasapiClasses::MMDeviceMasterVolume().setMuted (mute); } + +} // namespace juce diff --git a/modules/juce_audio_devices/sources/juce_AudioSourcePlayer.cpp b/modules/juce_audio_devices/sources/juce_AudioSourcePlayer.cpp index 90525e01b8..b03ca9a93f 100644 --- a/modules/juce_audio_devices/sources/juce_AudioSourcePlayer.cpp +++ b/modules/juce_audio_devices/sources/juce_AudioSourcePlayer.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + AudioSourcePlayer::AudioSourcePlayer() : source (nullptr), sampleRate (0), @@ -178,3 +181,5 @@ void AudioSourcePlayer::audioDeviceStopped() tempBuffer.setSize (2, 8); } + +} // namespace juce diff --git a/modules/juce_audio_devices/sources/juce_AudioSourcePlayer.h b/modules/juce_audio_devices/sources/juce_AudioSourcePlayer.h index 8ef1760679..d624b0a578 100644 --- a/modules/juce_audio_devices/sources/juce_AudioSourcePlayer.h +++ b/modules/juce_audio_devices/sources/juce_AudioSourcePlayer.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -107,3 +107,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioSourcePlayer) }; + +} // namespace juce diff --git a/modules/juce_audio_devices/sources/juce_AudioTransportSource.cpp b/modules/juce_audio_devices/sources/juce_AudioTransportSource.cpp index 7d59f13c76..bbc3d8ae48 100644 --- a/modules/juce_audio_devices/sources/juce_AudioTransportSource.cpp +++ b/modules/juce_audio_devices/sources/juce_AudioTransportSource.cpp @@ -20,22 +20,10 @@ ============================================================================== */ +namespace juce +{ + AudioTransportSource::AudioTransportSource() - : source (nullptr), - resamplerSource (nullptr), - bufferingSource (nullptr), - positionableSource (nullptr), - masterSource (nullptr), - gain (1.0f), - lastGain (1.0f), - playing (false), - stopped (true), - sampleRate (44100.0), - sourceSampleRate (0.0), - blockSize (128), - readAheadBufferSize (0), - isPrepared (false), - inputStreamEOF (false) { } @@ -294,3 +282,5 @@ void AudioTransportSource::getNextAudioBlock (const AudioSourceChannelInfo& info lastGain = gain; } + +} // namespace juce diff --git a/modules/juce_audio_devices/sources/juce_AudioTransportSource.h b/modules/juce_audio_devices/sources/juce_AudioTransportSource.h index 36cb8f5a2a..90103dad6b 100644 --- a/modules/juce_audio_devices/sources/juce_AudioTransportSource.h +++ b/modules/juce_audio_devices/sources/juce_AudioTransportSource.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -155,20 +155,22 @@ public: private: //============================================================================== - PositionableAudioSource* source; - ResamplingAudioSource* resamplerSource; - BufferingAudioSource* bufferingSource; - PositionableAudioSource* positionableSource; - AudioSource* masterSource; + PositionableAudioSource* source = nullptr; + ResamplingAudioSource* resamplerSource = nullptr; + BufferingAudioSource* bufferingSource = nullptr; + PositionableAudioSource* positionableSource = nullptr; + AudioSource* masterSource = nullptr; CriticalSection callbackLock; - float volatile gain, lastGain; - bool volatile playing, stopped; - double sampleRate, sourceSampleRate; - int blockSize, readAheadBufferSize; - bool volatile isPrepared, inputStreamEOF; + float volatile gain = 1.0f, lastGain = 1.0f; + bool volatile playing = false, stopped = true; + double sampleRate = 44100.0, sourceSampleRate = 0; + int blockSize = 128, readAheadBufferSize = 0; + bool volatile isPrepared = false, inputStreamEOF = false; void releaseMasterResources(); JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioTransportSource) }; + +} // namespace juce diff --git a/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.cpp index 40619c54c8..f3c8c8053d 100644 --- a/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + static const char* const aiffFormatName = "AIFF file"; //============================================================================== @@ -1015,3 +1018,5 @@ AudioFormatWriter* AiffAudioFormat::createWriterFor (OutputStream* out, return nullptr; } + +} // namespace juce diff --git a/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.h b/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.h index efafaa73ad..cd4c5f43a6 100644 --- a/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.h +++ b/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + //============================================================================== /** Reads and Writes AIFF format audio files. @@ -85,3 +88,5 @@ public: private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(AiffAudioFormat) }; + +} // namespace juce diff --git a/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.cpp index 1b310579e4..72d0aa9740 100644 --- a/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.cpp @@ -28,6 +28,9 @@ #include "../../juce_audio_basics/native/juce_mac_CoreAudioLayouts.h" +namespace juce +{ + //============================================================================== namespace { @@ -831,4 +834,7 @@ private: static CoreAudioLayoutsUnitTest coreAudioLayoutsUnitTest; #endif + +} // namespace juce + #endif diff --git a/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.h b/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.h index dd5b54ab8b..878d84e0f6 100644 --- a/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.h +++ b/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_MAC || JUCE_IOS || DOXYGEN //============================================================================== @@ -77,3 +80,5 @@ private: }; #endif + +} // namespace juce diff --git a/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp index d8b97fc2f0..05c3c44eac 100644 --- a/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_USE_FLAC } @@ -621,3 +624,5 @@ StringArray FlacAudioFormat::getQualityOptions() } #endif + +} // namespace juce diff --git a/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.h b/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.h index 8b3c43e4fd..fe61e3c59e 100644 --- a/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.h +++ b/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_USE_FLAC || defined (DOXYGEN) //============================================================================== @@ -65,3 +68,5 @@ private: #endif + +} // namespace juce diff --git a/modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.cpp index 78b61d9045..01b39ea247 100644 --- a/modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_USE_LAME_AUDIO_FORMAT class LAMEEncoderAudioFormat::Writer : public AudioFormatWriter @@ -225,3 +228,5 @@ AudioFormatWriter* LAMEEncoderAudioFormat::createWriterFor (OutputStream* stream } #endif + +} // namespace juce diff --git a/modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.h b/modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.h index dc0290d944..45b578842d 100644 --- a/modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.h +++ b/modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_USE_LAME_AUDIO_FORMAT || defined (DOXYGEN) //============================================================================== @@ -71,3 +74,5 @@ private: }; #endif + +} // namespace juce diff --git a/modules/juce_audio_formats/codecs/juce_MP3AudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_MP3AudioFormat.cpp index bfc987db3d..238eb4f3ea 100644 --- a/modules/juce_audio_formats/codecs/juce_MP3AudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_MP3AudioFormat.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + /* IMPORTANT DISCLAIMER: By choosing to enable the JUCE_USE_MP3AUDIOFORMAT flag and to compile this MP3 code into your software, you do so AT YOUR OWN RISK! By doing so, @@ -3161,3 +3164,5 @@ AudioFormatWriter* MP3AudioFormat::createWriterFor (OutputStream*, double /*samp } #endif + +} // namespace juce diff --git a/modules/juce_audio_formats/codecs/juce_MP3AudioFormat.h b/modules/juce_audio_formats/codecs/juce_MP3AudioFormat.h index 5d952d42f7..cde3298ec7 100644 --- a/modules/juce_audio_formats/codecs/juce_MP3AudioFormat.h +++ b/modules/juce_audio_formats/codecs/juce_MP3AudioFormat.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_USE_MP3AUDIOFORMAT || DOXYGEN //============================================================================== @@ -64,3 +67,5 @@ public: }; #endif + +} // namespace juce diff --git a/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp index 34a83caba8..0a2737bcab 100644 --- a/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_USE_OGGVORBIS #if JUCE_MAC && ! defined (__MACOSX__) @@ -537,3 +540,5 @@ int OggVorbisAudioFormat::estimateOggFileQuality (const File& source) } #endif + +} // namespace juce diff --git a/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.h b/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.h index 416ecad200..c8f4704e54 100644 --- a/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.h +++ b/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_USE_OGGVORBIS || defined (DOXYGEN) //============================================================================== @@ -93,3 +96,5 @@ private: #endif + +} // namespace juce diff --git a/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp index d54bdc6f78..565fecb6b5 100644 --- a/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + static const char* const wavFormatName = "WAV file"; //============================================================================== @@ -1867,3 +1870,5 @@ private: static const WaveAudioFormatTests waveAudioFormatTests; #endif + +} // namespace juce diff --git a/modules/juce_audio_formats/codecs/juce_WavAudioFormat.h b/modules/juce_audio_formats/codecs/juce_WavAudioFormat.h index e18e8e207a..85580208f3 100644 --- a/modules/juce_audio_formats/codecs/juce_WavAudioFormat.h +++ b/modules/juce_audio_formats/codecs/juce_WavAudioFormat.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + //============================================================================== /** Reads and Writes WAV format audio files. @@ -218,3 +221,5 @@ public: private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (WavAudioFormat) }; + +} // namespace juce diff --git a/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.cpp index 6e75610d34..3167ff3d0d 100644 --- a/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace WindowsMediaCodec { @@ -353,3 +356,5 @@ AudioFormatWriter* WindowsMediaAudioFormat::createWriterFor (OutputStream* /*str jassertfalse; // not yet implemented! return nullptr; } + +} // namespace juce diff --git a/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.h b/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.h index 39566f9ef9..97c746e299 100644 --- a/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.h +++ b/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_WINDOWS || DOXYGEN //============================================================================== @@ -53,3 +56,5 @@ public: }; #endif + +} diff --git a/modules/juce_audio_formats/format/juce_AudioFormat.cpp b/modules/juce_audio_formats/format/juce_AudioFormat.cpp index a1cacb4b4a..5bad00afe9 100644 --- a/modules/juce_audio_formats/format/juce_AudioFormat.cpp +++ b/modules/juce_audio_formats/format/juce_AudioFormat.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + AudioFormat::AudioFormat (String name, StringArray extensions) : formatName (name), fileExtensions (extensions) { @@ -85,3 +88,5 @@ AudioFormatWriter* AudioFormat::createWriterFor (OutputStream* streamToWriteTo, return nullptr; } + +} // namespace juce diff --git a/modules/juce_audio_formats/format/juce_AudioFormat.h b/modules/juce_audio_formats/format/juce_AudioFormat.h index 1db42e9797..bd8113fa31 100644 --- a/modules/juce_audio_formats/format/juce_AudioFormat.h +++ b/modules/juce_audio_formats/format/juce_AudioFormat.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -216,3 +216,5 @@ private: String formatName; StringArray fileExtensions; }; + +} // namespace juce diff --git a/modules/juce_audio_formats/format/juce_AudioFormatManager.cpp b/modules/juce_audio_formats/format/juce_AudioFormatManager.cpp index 62406fea64..33f26d4370 100644 --- a/modules/juce_audio_formats/format/juce_AudioFormatManager.cpp +++ b/modules/juce_audio_formats/format/juce_AudioFormatManager.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + AudioFormatManager::AudioFormatManager() : defaultFormatIndex (0) {} AudioFormatManager::~AudioFormatManager() {} @@ -177,3 +180,5 @@ AudioFormatReader* AudioFormatManager::createReaderFor (InputStream* audioFileSt return nullptr; } + +} // namespace juce diff --git a/modules/juce_audio_formats/format/juce_AudioFormatManager.h b/modules/juce_audio_formats/format/juce_AudioFormatManager.h index 7c2f9d4f58..246908a415 100644 --- a/modules/juce_audio_formats/format/juce_AudioFormatManager.h +++ b/modules/juce_audio_formats/format/juce_AudioFormatManager.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -139,3 +139,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioFormatManager) }; + +} // namespace juce diff --git a/modules/juce_audio_formats/format/juce_AudioFormatReader.cpp b/modules/juce_audio_formats/format/juce_AudioFormatReader.cpp index d0521d2df5..7f29c83770 100644 --- a/modules/juce_audio_formats/format/juce_AudioFormatReader.cpp +++ b/modules/juce_audio_formats/format/juce_AudioFormatReader.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + AudioFormatReader::AudioFormatReader (InputStream* const in, const String& name) : sampleRate (0), bitsPerSample (0), @@ -419,3 +422,5 @@ void MemoryMappedAudioFormatReader::touchSample (int64 sample) const noexcept else jassertfalse; // you must make sure that the window contains all the samples you're going to attempt to read. } + +} // namespace juce diff --git a/modules/juce_audio_formats/format/juce_AudioFormatReader.h b/modules/juce_audio_formats/format/juce_AudioFormatReader.h index 8af863a8f2..5486892eea 100644 --- a/modules/juce_audio_formats/format/juce_AudioFormatReader.h +++ b/modules/juce_audio_formats/format/juce_AudioFormatReader.h @@ -24,7 +24,10 @@ ============================================================================== */ -#pragma once +namespace juce +{ + +class AudioFormat; //============================================================================== @@ -299,3 +302,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioFormatReader) }; + +} // namespace juce diff --git a/modules/juce_audio_formats/format/juce_AudioFormatReaderSource.cpp b/modules/juce_audio_formats/format/juce_AudioFormatReaderSource.cpp index 38c589304c..9e6c567570 100644 --- a/modules/juce_audio_formats/format/juce_AudioFormatReaderSource.cpp +++ b/modules/juce_audio_formats/format/juce_AudioFormatReaderSource.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + AudioFormatReaderSource::AudioFormatReaderSource (AudioFormatReader* const r, const bool deleteReaderWhenThisIsDeleted) : reader (r, deleteReaderWhenThisIsDeleted), @@ -85,3 +88,5 @@ void AudioFormatReaderSource::getNextAudioBlock (const AudioSourceChannelInfo& i } } } + +} // namespace juce diff --git a/modules/juce_audio_formats/format/juce_AudioFormatReaderSource.h b/modules/juce_audio_formats/format/juce_AudioFormatReaderSource.h index a44709ced7..3ad72c3601 100644 --- a/modules/juce_audio_formats/format/juce_AudioFormatReaderSource.h +++ b/modules/juce_audio_formats/format/juce_AudioFormatReaderSource.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -96,3 +96,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioFormatReaderSource) }; + +} // namespace juce diff --git a/modules/juce_audio_formats/format/juce_AudioFormatWriter.cpp b/modules/juce_audio_formats/format/juce_AudioFormatWriter.cpp index febf8a3259..c7ba031033 100644 --- a/modules/juce_audio_formats/format/juce_AudioFormatWriter.cpp +++ b/modules/juce_audio_formats/format/juce_AudioFormatWriter.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + AudioFormatWriter::AudioFormatWriter (OutputStream* const out, const String& formatName_, const double rate, @@ -358,3 +361,5 @@ void AudioFormatWriter::ThreadedWriter::setFlushInterval (int numSamplesPerFlush { buffer->setFlushInterval (numSamplesPerFlush); } + +} // namespace juce diff --git a/modules/juce_audio_formats/format/juce_AudioFormatWriter.h b/modules/juce_audio_formats/format/juce_AudioFormatWriter.h index de89989314..c817e0bc06 100644 --- a/modules/juce_audio_formats/format/juce_AudioFormatWriter.h +++ b/modules/juce_audio_formats/format/juce_AudioFormatWriter.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -294,3 +294,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioFormatWriter) }; + +} // namespace juce diff --git a/modules/juce_audio_formats/format/juce_AudioSubsectionReader.cpp b/modules/juce_audio_formats/format/juce_AudioSubsectionReader.cpp index 2ad71689dc..0fc827297a 100644 --- a/modules/juce_audio_formats/format/juce_AudioSubsectionReader.cpp +++ b/modules/juce_audio_formats/format/juce_AudioSubsectionReader.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + AudioSubsectionReader::AudioSubsectionReader (AudioFormatReader* const source_, const int64 startSample_, const int64 length_, @@ -66,3 +69,5 @@ void AudioSubsectionReader::readMaxLevels (int64 startSampleInFile, int64 numSam source->readMaxLevels (startSampleInFile + startSample, numSamples, results, numChannelsToRead); } + +} // namespace juce diff --git a/modules/juce_audio_formats/format/juce_AudioSubsectionReader.h b/modules/juce_audio_formats/format/juce_AudioSubsectionReader.h index 63936138f1..523fb59cbf 100644 --- a/modules/juce_audio_formats/format/juce_AudioSubsectionReader.h +++ b/modules/juce_audio_formats/format/juce_AudioSubsectionReader.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -80,3 +80,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioSubsectionReader) }; + +} // namespace juce diff --git a/modules/juce_audio_formats/format/juce_BufferingAudioFormatReader.cpp b/modules/juce_audio_formats/format/juce_BufferingAudioFormatReader.cpp index da87e650d2..0980c00b23 100644 --- a/modules/juce_audio_formats/format/juce_BufferingAudioFormatReader.cpp +++ b/modules/juce_audio_formats/format/juce_BufferingAudioFormatReader.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + BufferingAudioReader::BufferingAudioReader (AudioFormatReader* sourceReader, TimeSliceThread& timeSliceThread, int samplesToBuffer) @@ -173,3 +176,5 @@ bool BufferingAudioReader::readNextBufferChunk() return true; } + +} // namespace juce diff --git a/modules/juce_audio_formats/format/juce_BufferingAudioFormatReader.h b/modules/juce_audio_formats/format/juce_BufferingAudioFormatReader.h index 5bdd312186..c8a4e1d8e5 100644 --- a/modules/juce_audio_formats/format/juce_BufferingAudioFormatReader.h +++ b/modules/juce_audio_formats/format/juce_BufferingAudioFormatReader.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -89,3 +90,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (BufferingAudioReader) }; + +} // namespace juce diff --git a/modules/juce_audio_formats/format/juce_MemoryMappedAudioFormatReader.h b/modules/juce_audio_formats/format/juce_MemoryMappedAudioFormatReader.h index 93deee3862..4b9454c953 100644 --- a/modules/juce_audio_formats/format/juce_MemoryMappedAudioFormatReader.h +++ b/modules/juce_audio_formats/format/juce_MemoryMappedAudioFormatReader.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -108,3 +108,5 @@ protected: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MemoryMappedAudioFormatReader) }; + +} // namespace juce diff --git a/modules/juce_audio_formats/juce_audio_formats.cpp b/modules/juce_audio_formats/juce_audio_formats.cpp index ab3464dfc8..7f930e7e09 100644 --- a/modules/juce_audio_formats/juce_audio_formats.cpp +++ b/modules/juce_audio_formats/juce_audio_formats.cpp @@ -53,9 +53,6 @@ #endif //============================================================================== -namespace juce -{ - #include "format/juce_AudioFormat.cpp" #include "format/juce_AudioFormatManager.cpp" #include "format/juce_AudioFormatReader.cpp" @@ -75,5 +72,3 @@ namespace juce #if JUCE_WINDOWS && JUCE_USE_WINDOWS_MEDIA_FORMAT #include "codecs/juce_WindowsMediaAudioFormat.cpp" #endif - -} diff --git a/modules/juce_audio_formats/juce_audio_formats.h b/modules/juce_audio_formats/juce_audio_formats.h index deabf519ce..4fa9e79eeb 100644 --- a/modules/juce_audio_formats/juce_audio_formats.h +++ b/modules/juce_audio_formats/juce_audio_formats.h @@ -110,10 +110,6 @@ #endif //============================================================================== -namespace juce -{ - -class AudioFormat; #include "format/juce_AudioFormatReader.h" #include "format/juce_AudioFormatWriter.h" #include "format/juce_MemoryMappedAudioFormatReader.h" @@ -131,5 +127,3 @@ class AudioFormat; #include "codecs/juce_WavAudioFormat.h" #include "codecs/juce_WindowsMediaAudioFormat.h" #include "sampler/juce_Sampler.h" - -} diff --git a/modules/juce_audio_formats/sampler/juce_Sampler.cpp b/modules/juce_audio_formats/sampler/juce_Sampler.cpp index eab9b01c5b..cb9aa5cf60 100644 --- a/modules/juce_audio_formats/sampler/juce_Sampler.cpp +++ b/modules/juce_audio_formats/sampler/juce_Sampler.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + SamplerSound::SamplerSound (const String& soundName, AudioFormatReader& source, const BigInteger& notes, @@ -224,3 +227,5 @@ void SamplerVoice::renderNextBlock (AudioSampleBuffer& outputBuffer, int startSa } } } + +} // namespace juce diff --git a/modules/juce_audio_formats/sampler/juce_Sampler.h b/modules/juce_audio_formats/sampler/juce_Sampler.h index 77df8e891a..68482d86be 100644 --- a/modules/juce_audio_formats/sampler/juce_Sampler.h +++ b/modules/juce_audio_formats/sampler/juce_Sampler.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -142,3 +142,5 @@ private: JUCE_LEAK_DETECTOR (SamplerVoice) }; + +} // namespace juce diff --git a/modules/juce_audio_plugin_client/AAX/juce_AAX_Modifier_Injector.h b/modules/juce_audio_plugin_client/AAX/juce_AAX_Modifier_Injector.h index 7f2bb43815..bc73e38117 100644 --- a/modules/juce_audio_plugin_client/AAX/juce_AAX_Modifier_Injector.h +++ b/modules/juce_audio_plugin_client/AAX/juce_AAX_Modifier_Injector.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ struct ModifierKeyProvider { @@ -38,3 +39,5 @@ struct ModifierKeyReceiver virtual void setModifierKeyProvider (ModifierKeyProvider*) = 0; virtual void removeModifierKeyProvider() = 0; }; + +} // namespace juce diff --git a/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp b/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp index 222de07caf..c2b6820ded 100644 --- a/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp @@ -96,10 +96,9 @@ #undef check -namespace juce -{ - #include "juce_AAX_Modifier_Injector.h" -} +#include "juce_AAX_Modifier_Injector.h" + +using namespace juce; const int32_t juceChunkType = 'juce'; const int maxAAXChannels = 8; diff --git a/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm b/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm index 7ee4f4e1d2..de27773daf 100644 --- a/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm +++ b/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm @@ -84,6 +84,8 @@ #include "../../juce_audio_processors/format_types/juce_AU_Shared.h" //============================================================================== +using namespace juce; + static Array activePlugins, activeUIs; static const AudioUnitPropertyID juceFilterObjectPropertyID = 0x1a45ffe9; diff --git a/modules/juce_audio_plugin_client/AU/juce_AUv3_Wrapper.mm b/modules/juce_audio_plugin_client/AU/juce_AUv3_Wrapper.mm index 63e6a59676..c2fff35401 100644 --- a/modules/juce_audio_plugin_client/AU/juce_AUv3_Wrapper.mm +++ b/modules/juce_audio_plugin_client/AU/juce_AUv3_Wrapper.mm @@ -57,9 +57,10 @@ #error AUv3 needs Objective-C 2 support (compile with 64-bit) #endif +#define JUCE_CORE_INCLUDE_OBJC_HELPERS 1 + #include "../utility/juce_IncludeSystemHeaders.h" #include "../utility/juce_IncludeModuleHeaders.h" -#include "../../juce_core/native/juce_osx_ObjCHelpers.h" #include "../../juce_graphics/native/juce_mac_CoreGraphicsHelpers.h" #include "../../juce_audio_basics/native/juce_mac_CoreAudioLayouts.h" @@ -82,7 +83,9 @@ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wnullability-completeness" -// TODO: ask Timur: use SFINAE to automatically generate this for all NSObjects +using namespace juce; + +// TODO: use SFINAE to automatically generate this for all NSObjects template <> struct ContainerDeletePolicy { static void destroy (NSObject* o) { [o release]; } }; template <> struct ContainerDeletePolicy { static void destroy (NSObject* o) { [o release]; } }; template <> struct ContainerDeletePolicy > { static void destroy (NSObject* o) { [o release]; } }; diff --git a/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode1.cpp b/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode1.cpp index 8aa575d254..7cc182dff9 100644 --- a/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode1.cpp +++ b/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode1.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #include "../../juce_core/system/juce_TargetPlatform.h" #include "../utility/juce_CheckSettingMacros.h" @@ -75,3 +78,5 @@ #endif #endif + +} // namespace juce diff --git a/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode2.cpp b/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode2.cpp index fb11cdffb6..be77d203eb 100644 --- a/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode2.cpp +++ b/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode2.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #include "../../juce_core/system/juce_TargetPlatform.h" #include "../utility/juce_CheckSettingMacros.h" @@ -63,3 +66,5 @@ #endif #endif + +} // namespace juce diff --git a/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode3.cpp b/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode3.cpp index 725d412a82..83f8b5e92a 100644 --- a/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode3.cpp +++ b/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode3.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #include "../../juce_core/system/juce_TargetPlatform.h" #include "../utility/juce_CheckSettingMacros.h" @@ -78,3 +81,5 @@ #endif #endif + +} // namespace juce diff --git a/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode_Header.h b/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode_Header.h index 5e2a3094c7..d67f4e37e8 100644 --- a/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode_Header.h +++ b/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode_Header.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ #if JucePlugin_Build_RTAS #ifdef _MSC_VER @@ -67,3 +68,5 @@ #endif #endif + +} // namespace juce diff --git a/modules/juce_audio_plugin_client/RTAS/juce_RTAS_WinUtilities.cpp b/modules/juce_audio_plugin_client/RTAS/juce_RTAS_WinUtilities.cpp index 5317d09a17..ce6bce646c 100644 --- a/modules/juce_audio_plugin_client/RTAS/juce_RTAS_WinUtilities.cpp +++ b/modules/juce_audio_plugin_client/RTAS/juce_RTAS_WinUtilities.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #include "../../juce_core/system/juce_TargetPlatform.h" #include "../utility/juce_CheckSettingMacros.h" @@ -151,3 +154,5 @@ void JUCE_CALLTYPE passFocusToHostWindow (void* hostWindow) #endif #endif + +} // namespace juce diff --git a/modules/juce_audio_plugin_client/RTAS/juce_RTAS_Wrapper.cpp b/modules/juce_audio_plugin_client/RTAS/juce_RTAS_Wrapper.cpp index f97ec634c3..42c4f3f9f5 100644 --- a/modules/juce_audio_plugin_client/RTAS/juce_RTAS_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/RTAS/juce_RTAS_Wrapper.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #include "../../juce_core/system/juce_TargetPlatform.h" #include "../utility/juce_CheckSettingMacros.h" @@ -1043,3 +1046,5 @@ CProcessGroupInterface* CProcessGroup::CreateProcessGroup() } #endif + +} // namespace juce diff --git a/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterApp.cpp b/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterApp.cpp index a4c9a1e6b8..9b62d22870 100644 --- a/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterApp.cpp +++ b/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterApp.cpp @@ -41,16 +41,16 @@ // set it then by default we'll just create a simple one as below. #if ! JUCE_USE_CUSTOM_PLUGIN_STANDALONE_APP -extern AudioProcessor* JUCE_CALLTYPE createPluginFilter(); +extern juce::AudioProcessor* JUCE_CALLTYPE createPluginFilter(); + +#if JucePlugin_Enable_IAA && JUCE_IOS + #include "../../juce_audio_devices/native/juce_ios_Audio.h" +#endif + +#include "juce_StandaloneFilterWindow.h" namespace juce { - #if JucePlugin_Enable_IAA && JUCE_IOS - #include "../../juce_audio_devices/native/juce_ios_Audio.h" - #endif - - #include "juce_StandaloneFilterWindow.h" -} //============================================================================== class StandaloneFilterApp : public JUCEApplication @@ -160,4 +160,6 @@ Image JUCE_CALLTYPE juce_getIAAHostIcon (int size) #endif #endif +} // namespace juce + #endif diff --git a/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h b/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h index 45dafcd28a..c85641e90a 100644 --- a/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h +++ b/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -841,3 +842,5 @@ StandalonePluginHolder* StandalonePluginHolder::getInstance() return nullptr; } + +} // namespace juce diff --git a/modules/juce_audio_plugin_client/VST/juce_VSTCallbackHandler.h b/modules/juce_audio_plugin_client/VST/juce_VSTCallbackHandler.h index b08d8557f3..4a00dd3e20 100644 --- a/modules/juce_audio_plugin_client/VST/juce_VSTCallbackHandler.h +++ b/modules/juce_audio_plugin_client/VST/juce_VSTCallbackHandler.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ /** An interface to allow an AudioProcessor to receive VST specific calls from the host. @@ -41,3 +42,5 @@ struct VSTCallbackHandler void* ptr, float opt) = 0; }; + +} // namespace juce diff --git a/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp b/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp index e57d0f5776..ee89f838f5 100644 --- a/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp @@ -59,6 +59,7 @@ #pragma warning (disable : 4458) #endif +#include #include "../../juce_audio_processors/format_types/juce_VSTInterface.h" #ifdef _MSC_VER diff --git a/modules/juce_audio_plugin_client/juce_audio_plugin_client.h b/modules/juce_audio_plugin_client/juce_audio_plugin_client.h index d5f034c2a2..8dcb2d4adf 100644 --- a/modules/juce_audio_plugin_client/juce_audio_plugin_client.h +++ b/modules/juce_audio_plugin_client/juce_audio_plugin_client.h @@ -91,8 +91,5 @@ #define JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS 1 #endif -namespace juce -{ - #include "utility/juce_PluginHostType.h" - #include "VST/juce_VSTCallbackHandler.h" -} +#include "utility/juce_PluginHostType.h" +#include "VST/juce_VSTCallbackHandler.h" diff --git a/modules/juce_audio_plugin_client/juce_audio_plugin_client_Standalone.cpp b/modules/juce_audio_plugin_client/juce_audio_plugin_client_Standalone.cpp index e5bf500d87..bd8ad92284 100644 --- a/modules/juce_audio_plugin_client/juce_audio_plugin_client_Standalone.cpp +++ b/modules/juce_audio_plugin_client/juce_audio_plugin_client_Standalone.cpp @@ -38,7 +38,7 @@ #endif #else - JUCE_CREATE_APPLICATION_DEFINE(StandaloneFilterApp) + JUCE_CREATE_APPLICATION_DEFINE(juce::StandaloneFilterApp) #endif JUCE_MAIN_FUNCTION_DEFINITION diff --git a/modules/juce_audio_plugin_client/utility/juce_CarbonVisibility.h b/modules/juce_audio_plugin_client/utility/juce_CarbonVisibility.h index b3e4b18474..0d0f8aa99f 100644 --- a/modules/juce_audio_plugin_client/utility/juce_CarbonVisibility.h +++ b/modules/juce_audio_plugin_client/utility/juce_CarbonVisibility.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== #if JUCE_SUPPORT_CARBON && JUCE_MAC_WINDOW_VISIBITY_BODGE @@ -76,3 +77,5 @@ inline void removeWindowHidingHooks (Component* comp) inline void attachWindowHidingHooks (void*, void*, void*) {} inline void removeWindowHidingHooks (void*) {} #endif + +} // namespace juce diff --git a/modules/juce_audio_plugin_client/utility/juce_FakeMouseMoveGenerator.h b/modules/juce_audio_plugin_client/utility/juce_FakeMouseMoveGenerator.h index d78d3bd10d..299ca4ceb3 100644 --- a/modules/juce_audio_plugin_client/utility/juce_FakeMouseMoveGenerator.h +++ b/modules/juce_audio_plugin_client/utility/juce_FakeMouseMoveGenerator.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ #if JUCE_MAC @@ -88,3 +89,5 @@ private: #else struct FakeMouseMoveGenerator {}; #endif + +} // namespace juce diff --git a/modules/juce_audio_plugin_client/utility/juce_IncludeModuleHeaders.h b/modules/juce_audio_plugin_client/utility/juce_IncludeModuleHeaders.h index f2e9efde84..701c4df909 100644 --- a/modules/juce_audio_plugin_client/utility/juce_IncludeModuleHeaders.h +++ b/modules/juce_audio_plugin_client/utility/juce_IncludeModuleHeaders.h @@ -24,12 +24,8 @@ ============================================================================== */ -#pragma once - #include "../juce_audio_plugin_client.h" -using namespace juce; - namespace juce { #define Component juce::Component @@ -47,4 +43,4 @@ namespace juce } } -extern AudioProcessor* JUCE_API JUCE_CALLTYPE createPluginFilterOfType (AudioProcessor::WrapperType); +extern juce::AudioProcessor* JUCE_API JUCE_CALLTYPE createPluginFilterOfType (juce::AudioProcessor::WrapperType); diff --git a/modules/juce_audio_plugin_client/utility/juce_PluginHostType.h b/modules/juce_audio_plugin_client/utility/juce_PluginHostType.h index 97379a0768..d4a31a0fb6 100644 --- a/modules/juce_audio_plugin_client/utility/juce_PluginHostType.h +++ b/modules/juce_audio_plugin_client/utility/juce_PluginHostType.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + //============================================================================== class PluginHostType { @@ -311,3 +314,5 @@ private: return UnknownHost; } }; + +} // namespace juce diff --git a/modules/juce_audio_plugin_client/utility/juce_PluginUtilities.cpp b/modules/juce_audio_plugin_client/utility/juce_PluginUtilities.cpp index 4380839f4b..831f9ec4b5 100644 --- a/modules/juce_audio_plugin_client/utility/juce_PluginUtilities.cpp +++ b/modules/juce_audio_plugin_client/utility/juce_PluginUtilities.cpp @@ -32,14 +32,13 @@ #include "../utility/juce_CheckSettingMacros.h" #include "juce_IncludeModuleHeaders.h" -namespace juce -{ - AudioProcessor::WrapperType PluginHostType::jucePlugInClientCurrentWrapperType = AudioProcessor::wrapperType_Undefined; -} +using namespace juce; -//============================================================================== namespace juce { + +AudioProcessor::WrapperType PluginHostType::jucePlugInClientCurrentWrapperType = AudioProcessor::wrapperType_Undefined; + #ifndef JUCE_VST3_CAN_REPLACE_VST2 #define JUCE_VST3_CAN_REPLACE_VST2 1 #endif @@ -143,7 +142,7 @@ bool JUCE_API handleManufacturerSpecificVST2Opcode (int32 index, pointer_sized_i } #endif -} // namespace juce +} // namespace juce //============================================================================== /** Somewhere in the codebase of your plugin, you need to implement this function diff --git a/modules/juce_audio_plugin_client/utility/juce_WindowsHooks.h b/modules/juce_audio_plugin_client/utility/juce_WindowsHooks.h index 70f5503b1a..9407e7e710 100644 --- a/modules/juce_audio_plugin_client/utility/juce_WindowsHooks.h +++ b/modules/juce_audio_plugin_client/utility/juce_WindowsHooks.h @@ -28,9 +28,9 @@ namespace juce { - // This function is in juce_win32_Windowing.cpp - extern bool offerKeyMessageToJUCEWindow (MSG&); -} + +// This function is in juce_win32_Windowing.cpp +extern bool offerKeyMessageToJUCEWindow (MSG&); namespace { @@ -44,11 +44,11 @@ namespace if (numHookUsers++ == 0) { mouseWheelHook = SetWindowsHookEx (WH_MOUSE, mouseWheelHookCallback, - (HINSTANCE) Process::getCurrentModuleInstanceHandle(), + (HINSTANCE) juce::Process::getCurrentModuleInstanceHandle(), GetCurrentThreadId()); keyboardHook = SetWindowsHookEx (WH_GETMESSAGE, keyboardHookCallback, - (HINSTANCE) Process::getCurrentModuleInstanceHandle(), + (HINSTANCE) juce::Process::getCurrentModuleInstanceHandle(), GetCurrentThreadId()); } } @@ -78,9 +78,9 @@ namespace // using a local copy of this struct to support old mingw libraries struct MOUSEHOOKSTRUCTEX_ : public MOUSEHOOKSTRUCT { DWORD mouseData; }; - const MOUSEHOOKSTRUCTEX_& hs = *(MOUSEHOOKSTRUCTEX_*) lParam; + auto& hs = *(MOUSEHOOKSTRUCTEX_*) lParam; - if (Component* const comp = Desktop::getInstance().findComponentAt (Point (hs.pt.x, hs.pt.y))) + if (auto* comp = Desktop::getInstance().findComponentAt ({ hs.pt.x, hs.pt.y })) if (comp->getWindowHandle() != 0) return PostMessage ((HWND) comp->getWindowHandle(), WM_MOUSEWHEEL, hs.mouseData & 0xffff0000, (hs.pt.x & 0xffff) | (hs.pt.y << 16)); @@ -106,4 +106,6 @@ namespace }; } +} // juce namespace + #endif diff --git a/modules/juce_audio_processors/format/juce_AudioPluginFormat.cpp b/modules/juce_audio_processors/format/juce_AudioPluginFormat.cpp index 720260de4c..8b33d4d043 100644 --- a/modules/juce_audio_processors/format/juce_AudioPluginFormat.cpp +++ b/modules/juce_audio_processors/format/juce_AudioPluginFormat.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace AudioPluginFormatHelpers { struct CallbackInvoker @@ -207,3 +210,5 @@ void AudioPluginFormat::createPluginInstanceOnMessageThread (const PluginDescrip createPluginInstance (description, initialSampleRate, initialBufferSize, completion, AudioPluginFormatHelpers::CallbackInvoker::staticCompletionCallback); } + +} // namespace juce diff --git a/modules/juce_audio_processors/format/juce_AudioPluginFormat.h b/modules/juce_audio_processors/format/juce_AudioPluginFormat.h index f820257898..6eb08eb324 100644 --- a/modules/juce_audio_processors/format/juce_AudioPluginFormat.h +++ b/modules/juce_audio_processors/format/juce_AudioPluginFormat.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -164,3 +164,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioPluginFormat) }; + +} // namespace juce diff --git a/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.cpp b/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.cpp index d9e5551ce1..ceedf1705d 100644 --- a/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.cpp +++ b/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace PluginFormatManagerHelpers { struct ErrorCallbackOnMessageThread : public CallbackMessage @@ -176,3 +179,5 @@ bool AudioPluginFormatManager::doesPluginStillExist (const PluginDescription& de return false; } + +} // namespace juce diff --git a/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.h b/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.h index 0be2c06b54..495c222919 100644 --- a/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.h +++ b/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -134,3 +134,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioPluginFormatManager) }; + +} // namespace juce diff --git a/modules/juce_audio_processors/format_types/juce_AU_Shared.h b/modules/juce_audio_processors/format_types/juce_AU_Shared.h index 5b5e5fcf65..434326ff28 100644 --- a/modules/juce_audio_processors/format_types/juce_AU_Shared.h +++ b/modules/juce_audio_processors/format_types/juce_AU_Shared.h @@ -29,6 +29,9 @@ #define JUCE_STATE_DICTIONARY_KEY "jucePluginState" #endif +namespace juce +{ + struct AudioUnitHelpers { class ChannelRemapper @@ -342,102 +345,102 @@ struct AudioUnitHelpers info.inChannels = 0; info.outChannels = 0; - return {&info, 1}; + return { &info, 1 }; } - else - { - auto layout = processor.getBusesLayout(); - auto maxNumChanToCheckFor = 9; - auto defaultInputs = processor.getChannelCountOfBus (true, 0); - auto defaultOutputs = processor.getChannelCountOfBus (false, 0); + auto layout = processor.getBusesLayout(); + auto maxNumChanToCheckFor = 9; + + auto defaultInputs = processor.getChannelCountOfBus (true, 0); + auto defaultOutputs = processor.getChannelCountOfBus (false, 0); - SortedSet supportedChannels; + SortedSet supportedChannels; - // add the current configuration - if (defaultInputs != 0 || defaultOutputs != 0) - supportedChannels.add ((defaultInputs << 16) | defaultOutputs); + // add the current configuration + if (defaultInputs != 0 || defaultOutputs != 0) + supportedChannels.add ((defaultInputs << 16) | defaultOutputs); - for (auto inChanNum = hasMainInputBus ? 1 : 0; inChanNum <= (hasMainInputBus ? maxNumChanToCheckFor : 0); ++inChanNum) + for (auto inChanNum = hasMainInputBus ? 1 : 0; inChanNum <= (hasMainInputBus ? maxNumChanToCheckFor : 0); ++inChanNum) + { + auto inLayout = layout; + + if (auto* inBus = processor.getBus (true, 0)) + if (! isNumberOfChannelsSupported (inBus, inChanNum, inLayout)) + continue; + + for (auto outChanNum = hasMainOutputBus ? 1 : 0; outChanNum <= (hasMainOutputBus ? maxNumChanToCheckFor : 0); ++outChanNum) { - auto inLayout = layout; + auto outLayout = inLayout; - if (auto* inBus = processor.getBus (true, 0)) - if (! isNumberOfChannelsSupported (inBus, inChanNum, inLayout)) + if (auto* outBus = processor.getBus (false, 0)) + if (! isNumberOfChannelsSupported (outBus, outChanNum, outLayout)) continue; - for (auto outChanNum = hasMainOutputBus ? 1 : 0; outChanNum <= (hasMainOutputBus ? maxNumChanToCheckFor : 0); ++outChanNum) - { - auto outLayout = inLayout; + supportedChannels.add (((hasMainInputBus ? outLayout.getMainInputChannels() : 0) << 16) + | (hasMainOutputBus ? outLayout.getMainOutputChannels() : 0)); + } + } - if (auto* outBus = processor.getBus (false, 0)) - if (! isNumberOfChannelsSupported (outBus, outChanNum, outLayout)) - continue; + auto hasInOutMismatch = false; - supportedChannels.add (((hasMainInputBus ? outLayout.getMainInputChannels() : 0) << 16) - | (hasMainOutputBus ? outLayout.getMainOutputChannels() : 0)); - } - } + for (auto supported : supportedChannels) + { + auto numInputs = (supported >> 16) & 0xffff; + auto numOutputs = (supported >> 0) & 0xffff; - auto hasInOutMismatch = false; - for (auto supported : supportedChannels) + if (numInputs != numOutputs) { - auto numInputs = (supported >> 16) & 0xffff; - auto numOutputs = (supported >> 0) & 0xffff; - - if (numInputs != numOutputs) - { - hasInOutMismatch = true; - break; - } + hasInOutMismatch = true; + break; } + } - auto hasUnsupportedInput = ! hasMainInputBus, hasUnsupportedOutput = ! hasMainOutputBus; - for (auto inChanNum = hasMainInputBus ? 1 : 0; inChanNum <= (hasMainInputBus ? maxNumChanToCheckFor : 0); ++inChanNum) - { - auto channelConfiguration = (inChanNum << 16) | (hasInOutMismatch ? defaultOutputs : inChanNum); + auto hasUnsupportedInput = ! hasMainInputBus, hasUnsupportedOutput = ! hasMainOutputBus; - if (! supportedChannels.contains (channelConfiguration)) - { - hasUnsupportedInput = true; - break; - } - } + for (auto inChanNum = hasMainInputBus ? 1 : 0; inChanNum <= (hasMainInputBus ? maxNumChanToCheckFor : 0); ++inChanNum) + { + auto channelConfiguration = (inChanNum << 16) | (hasInOutMismatch ? defaultOutputs : inChanNum); - for (auto outChanNum = hasMainOutputBus ? 1 : 0; outChanNum <= (hasMainOutputBus ? maxNumChanToCheckFor : 0); ++outChanNum) + if (! supportedChannels.contains (channelConfiguration)) { - auto channelConfiguration = ((hasInOutMismatch ? defaultInputs : outChanNum) << 16) | outChanNum; - - if (! supportedChannels.contains (channelConfiguration)) - { - hasUnsupportedOutput = true; - break; - } + hasUnsupportedInput = true; + break; } + } - for (auto supported : supportedChannels) + for (auto outChanNum = hasMainOutputBus ? 1 : 0; outChanNum <= (hasMainOutputBus ? maxNumChanToCheckFor : 0); ++outChanNum) + { + auto channelConfiguration = ((hasInOutMismatch ? defaultInputs : outChanNum) << 16) | outChanNum; + + if (! supportedChannels.contains (channelConfiguration)) { - auto numInputs = (supported >> 16) & 0xffff; - auto numOutputs = (supported >> 0) & 0xffff; + hasUnsupportedOutput = true; + break; + } + } + + for (auto supported : supportedChannels) + { + auto numInputs = (supported >> 16) & 0xffff; + auto numOutputs = (supported >> 0) & 0xffff; - AUChannelInfo info; + AUChannelInfo info; - // see here: https://developer.apple.com/library/mac/documentation/MusicAudio/Conceptual/AudioUnitProgrammingGuide/TheAudioUnit/TheAudioUnit.html - info.inChannels = static_cast (hasMainInputBus ? (hasUnsupportedInput ? numInputs : (hasInOutMismatch && (! hasUnsupportedOutput) ? -2 : -1)) : 0); - info.outChannels = static_cast (hasMainOutputBus ? (hasUnsupportedOutput ? numOutputs : (hasInOutMismatch && (! hasUnsupportedInput) ? -2 : -1)) : 0); + // see here: https://developer.apple.com/library/mac/documentation/MusicAudio/Conceptual/AudioUnitProgrammingGuide/TheAudioUnit/TheAudioUnit.html + info.inChannels = static_cast (hasMainInputBus ? (hasUnsupportedInput ? numInputs : (hasInOutMismatch && (! hasUnsupportedOutput) ? -2 : -1)) : 0); + info.outChannels = static_cast (hasMainOutputBus ? (hasUnsupportedOutput ? numOutputs : (hasInOutMismatch && (! hasUnsupportedInput) ? -2 : -1)) : 0); - if (info.inChannels == -2 && info.outChannels == -2) - info.inChannels = -1; + if (info.inChannels == -2 && info.outChannels == -2) + info.inChannels = -1; - int j; - for (j = 0; j < channelInfo.size(); ++j) - if (info.inChannels == channelInfo.getReference (j).inChannels - && info.outChannels == channelInfo.getReference (j).outChannels) - break; + int j; + for (j = 0; j < channelInfo.size(); ++j) + if (info.inChannels == channelInfo.getReference (j).inChannels + && info.outChannels == channelInfo.getReference (j).outChannels) + break; - if (j >= channelInfo.size()) - channelInfo.add (info); - } + if (j >= channelInfo.size()) + channelInfo.add (info); } return channelInfo; @@ -447,7 +450,6 @@ struct AudioUnitHelpers { auto potentialSets = AudioChannelSet::channelSetsWithNumberOfChannels (static_cast (numChannels)); - for (auto set : potentialSets) { auto copy = inOutCurrentLayout; @@ -517,7 +519,7 @@ struct AudioUnitHelpers const int actualBuses = juceFilter->getBusCount (isInput); const int auNumBuses = getBusCount (juceFilter, isInput); - Array& buses = (isInput ? layout.inputBuses : layout.outputBuses); + auto& buses = (isInput ? layout.inputBuses : layout.outputBuses); for (int i = auNumBuses; i < actualBuses; ++i) buses.removeLast(); @@ -529,3 +531,5 @@ struct AudioUnitHelpers #endif } }; + +} // namespace juce diff --git a/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.h b/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.h index 9ade640df8..a4d0e1b169 100644 --- a/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.h +++ b/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #if (JUCE_PLUGINHOST_AU && (JUCE_MAC || JUCE_IOS)) || DOXYGEN //============================================================================== @@ -72,3 +75,5 @@ enum kAudioUnitProperty_SupportsMPE = 58 }; #endif + +} diff --git a/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm b/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm index fa379c3659..942441c2f2 100644 --- a/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm +++ b/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm @@ -26,8 +26,6 @@ #if JUCE_PLUGINHOST_AU && (JUCE_MAC || JUCE_IOS) -} // (juce namespace) - #include #if JUCE_MAC #include @@ -57,20 +55,17 @@ #include -namespace juce -{ - -#include "../../juce_audio_devices/native/juce_MidiDataConcatenator.h" - #if JUCE_SUPPORT_CARBON #include "../../juce_gui_extra/native/juce_mac_CarbonViewWrapperComponent.h" #endif -#include "../../juce_core/native/juce_osx_ObjCHelpers.h" - #include "../../juce_audio_basics/native/juce_mac_CoreAudioLayouts.h" +#include "../../juce_audio_devices/native/juce_MidiDataConcatenator.h" #include "juce_AU_Shared.h" +namespace juce +{ + // Change this to disable logging of various activities #ifndef AU_LOGGING #define AU_LOGGING 1 @@ -2463,9 +2458,11 @@ bool AudioUnitPluginFormat::doesPluginStillExist (const PluginDescription& desc) FileSearchPath AudioUnitPluginFormat::getDefaultLocationsToSearch() { - return FileSearchPath(); + return {}; } #undef JUCE_AU_LOG +} // namespace juce + #endif diff --git a/modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.cpp b/modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.cpp index 7ec05c1ed1..dfbc7bc9ae 100644 --- a/modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.cpp +++ b/modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.cpp @@ -26,8 +26,6 @@ #if JUCE_PLUGINHOST_LADSPA && JUCE_LINUX -} // (juce namespace) - #include namespace juce @@ -715,4 +713,6 @@ FileSearchPath LADSPAPluginFormat::getDefaultLocationsToSearch() .replace (":", ";")); } +} // namespace juce + #endif diff --git a/modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.h b/modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.h index 27f91276df..7002c51814 100644 --- a/modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.h +++ b/modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #if (JUCE_PLUGINHOST_LADSPA && JUCE_LINUX) || DOXYGEN //============================================================================== @@ -63,3 +66,5 @@ private: #endif + +} diff --git a/modules/juce_audio_processors/format_types/juce_VST3Common.h b/modules/juce_audio_processors/format_types/juce_VST3Common.h index 02a4b8a834..8df5f36ffa 100644 --- a/modules/juce_audio_processors/format_types/juce_VST3Common.h +++ b/modules/juce_audio_processors/format_types/juce_VST3Common.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== #define JUCE_DECLARE_VST3_COM_REF_METHODS \ @@ -620,3 +621,5 @@ template <> struct VST3FloatAndDoubleBusMapCompositeHelper { static inline VST3BufferExchange::BusMap& get (VST3FloatAndDoubleBusMapComposite& impl) { return impl.doubleVersion; } }; + +} // namespace juce diff --git a/modules/juce_audio_processors/format_types/juce_VST3Headers.h b/modules/juce_audio_processors/format_types/juce_VST3Headers.h index 57a47752af..ec062f0676 100644 --- a/modules/juce_audio_processors/format_types/juce_VST3Headers.h +++ b/modules/juce_audio_processors/format_types/juce_VST3Headers.h @@ -24,8 +24,6 @@ ============================================================================== */ -#pragma once - // Wow, those Steinberg guys really don't worry too much about compiler warnings. #if _MSC_VER #pragma warning (disable: 4505) diff --git a/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp b/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp index 892e302eda..18f3db32a6 100644 --- a/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp +++ b/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp @@ -26,16 +26,13 @@ #if JUCE_PLUGINHOST_VST3 && (JUCE_MAC || JUCE_WINDOWS) -} // namespace juce - #include #include "juce_VST3Headers.h" +#include "juce_VST3Common.h" namespace juce { -#include "juce_VST3Common.h" - using namespace Steinberg; //============================================================================== @@ -2978,4 +2975,6 @@ FileSearchPath VST3PluginFormat::getDefaultLocationsToSearch() #endif } -#endif //JUCE_PLUGINHOST_VST3 +} // namespace juce + +#endif // JUCE_PLUGINHOST_VST3 diff --git a/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.h b/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.h index 4adbcefafa..4c3f140b57 100644 --- a/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.h +++ b/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ #if (JUCE_PLUGINHOST_VST3 && (JUCE_MAC || JUCE_WINDOWS)) || DOXYGEN @@ -65,4 +66,6 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VST3PluginFormat) }; -#endif // JUCE_PLUGINHOST_VST3 +#endif // JUCE_PLUGINHOST_VST3 + +} // namespace juce diff --git a/modules/juce_audio_processors/format_types/juce_VSTCommon.h b/modules/juce_audio_processors/format_types/juce_VSTCommon.h index cbd5446d1b..50494a7484 100644 --- a/modules/juce_audio_processors/format_types/juce_VSTCommon.h +++ b/modules/juce_audio_processors/format_types/juce_VSTCommon.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== struct SpeakerMappings : private AudioChannelSet // (inheritance only to give easier access to items in the namespace) @@ -293,3 +294,5 @@ struct SpeakerMappings : private AudioChannelSet // (inheritance only to give e return AudioChannelSet::unknown; } }; + +} // namespace juce diff --git a/modules/juce_audio_processors/format_types/juce_VSTInterface.h b/modules/juce_audio_processors/format_types/juce_VSTInterface.h index c8310a0022..4d31c312a0 100644 --- a/modules/juce_audio_processors/format_types/juce_VSTInterface.h +++ b/modules/juce_audio_processors/format_types/juce_VSTInterface.h @@ -24,11 +24,8 @@ ============================================================================== */ -#pragma once #define JUCE_VSTINTERFACE_H_INCLUDED -#include "../../juce_core/juce_core.h" - using namespace juce; #if JUCE_MSVC diff --git a/modules/juce_audio_processors/format_types/juce_VSTMidiEventList.h b/modules/juce_audio_processors/format_types/juce_VSTMidiEventList.h index d78d7e0db6..6665cb9ae3 100644 --- a/modules/juce_audio_processors/format_types/juce_VSTMidiEventList.h +++ b/modules/juce_audio_processors/format_types/juce_VSTMidiEventList.h @@ -27,7 +27,8 @@ // NB: this must come first, *before* the header-guard. #ifdef JUCE_VSTINTERFACE_H_INCLUDED -#pragma once +namespace juce +{ //============================================================================== /** Holds a set of VSTMidiEvent objects and makes it easy to add @@ -169,8 +170,8 @@ private: static VstEvent* allocateVSTEvent() { - VstEvent* const e = (VstEvent*) std::calloc (1, sizeof (VstMidiEvent) > sizeof (VstSysExEvent) ? sizeof (VstMidiEvent) - : sizeof (VstSysExEvent)); + auto e = (VstEvent*) std::calloc (1, sizeof (VstMidiEvent) > sizeof (VstSysExEvent) ? sizeof (VstMidiEvent) + : sizeof (VstSysExEvent)); e->type = vstMidiEventType; e->size = sizeof (VstMidiEvent); return e; @@ -185,4 +186,6 @@ private: } }; +} // namespace juce + #endif // JUCE_VSTINTERFACE_H_INCLUDED diff --git a/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp b/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp index ea64a20085..cf741b43c9 100644 --- a/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp +++ b/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp @@ -55,7 +55,6 @@ using namespace Vst2; #pragma warning (disable: 4355) // ("this" used in initialiser list warning) #endif -//============================================================================== #include "juce_VSTMidiEventList.h" #if JUCE_MINGW @@ -78,6 +77,10 @@ using namespace Vst2; #define JUCE_VST_WRAPPER_INVOKE_MAIN effect = module->moduleMain (&audioMaster); #endif +//============================================================================== +namespace juce +{ + //============================================================================== namespace { @@ -2972,4 +2975,6 @@ pointer_sized_int JUCE_CALLTYPE VSTPluginFormat::dispatcher (AudioPluginInstance void VSTPluginFormat::aboutToScanVSTShellPlugin (const PluginDescription&) {} +} // namespace juce + #endif diff --git a/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.h b/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.h index c6793a20be..1edeb83e1e 100644 --- a/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.h +++ b/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.h @@ -26,6 +26,9 @@ #if (JUCE_PLUGINHOST_VST || DOXYGEN) +namespace juce +{ + //============================================================================== /** Implements a plugin format manager for VSTs. @@ -124,5 +127,6 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VSTPluginFormat) }; +} // namespace juce #endif diff --git a/modules/juce_audio_processors/juce_audio_processors.cpp b/modules/juce_audio_processors/juce_audio_processors.cpp index 20dee1058f..9f4e1e67bd 100644 --- a/modules/juce_audio_processors/juce_audio_processors.cpp +++ b/modules/juce_audio_processors/juce_audio_processors.cpp @@ -34,6 +34,7 @@ #endif #define JUCE_CORE_INCLUDE_NATIVE_HEADERS 1 +#define JUCE_CORE_INCLUDE_OBJC_HELPERS 1 #include "juce_audio_processors.h" #include @@ -65,8 +66,8 @@ namespace juce static inline bool arrayContainsPlugin (const OwnedArray& list, const PluginDescription& desc) { - for (int i = list.size(); --i >= 0;) - if (list.getUnchecked(i)->isDuplicateOf (desc)) + for (auto* p : list) + if (p->isDuplicateOf (desc)) return true; return false; @@ -140,6 +141,8 @@ struct AutoResizingNSViewComponentWithParent : public AutoResizingNSViewCompone }; #endif +} // namespace juce + #if JUCE_CLANG #pragma clang diagnostic ignored "-Wdeprecated-declarations" #endif @@ -160,5 +163,3 @@ struct AutoResizingNSViewComponentWithParent : public AutoResizingNSViewCompone #include "scanning/juce_PluginListComponent.cpp" #include "utilities/juce_AudioProcessorParameters.cpp" #include "utilities/juce_AudioProcessorValueTreeState.cpp" - -} diff --git a/modules/juce_audio_processors/juce_audio_processors.h b/modules/juce_audio_processors/juce_audio_processors.h index 6589718c02..abfcf43bf3 100644 --- a/modules/juce_audio_processors/juce_audio_processors.h +++ b/modules/juce_audio_processors/juce_audio_processors.h @@ -112,10 +112,6 @@ //============================================================================== //============================================================================== -namespace juce -{ - -class AudioProcessor; #include "processors/juce_AudioProcessorEditor.h" #include "processors/juce_AudioProcessorListener.h" #include "processors/juce_AudioProcessorParameter.h" @@ -140,5 +136,3 @@ class AudioProcessor; #include "utilities/juce_AudioParameterBool.h" #include "utilities/juce_AudioParameterChoice.h" #include "utilities/juce_AudioProcessorValueTreeState.h" - -} diff --git a/modules/juce_audio_processors/processors/juce_AudioPluginInstance.h b/modules/juce_audio_processors/processors/juce_AudioPluginInstance.h index 8acc557922..5e5c21c50a 100644 --- a/modules/juce_audio_processors/processors/juce_AudioPluginInstance.h +++ b/modules/juce_audio_processors/processors/juce_AudioPluginInstance.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -85,3 +85,5 @@ protected: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioPluginInstance) }; + +} // namespace juce diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessor.cpp b/modules/juce_audio_processors/processors/juce_AudioProcessor.cpp index e33eee651b..0e9a679cde 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessor.cpp +++ b/modules/juce_audio_processors/processors/juce_AudioProcessor.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + static ThreadLocalValue wrapperTypeBeingCreated; void JUCE_CALLTYPE AudioProcessor::setTypeOfNextNewPlugin (AudioProcessor::WrapperType type) @@ -1451,3 +1454,5 @@ void AudioPlayHead::CurrentPositionInfo::resetToDefault() timeSigDenominator = 4; bpm = 120; } + +} // namespace juce diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessor.h b/modules/juce_audio_processors/processors/juce_AudioProcessor.h index a39b111373..32e828fe84 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessor.h +++ b/modules/juce_audio_processors/processors/juce_AudioProcessor.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ struct PluginBusUtilities; @@ -1624,3 +1625,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioProcessor) }; + +} // namespace juce diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.cpp b/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.cpp index a061a44665..07097b5682 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.cpp +++ b/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + AudioProcessorEditor::AudioProcessorEditor (AudioProcessor& p) noexcept : processor (p) { initialise(); @@ -201,3 +204,5 @@ void AudioProcessorEditor::setScaleFactor (float newScale) setTransform (AffineTransform::scale (newScale)); editorResized (true); } + +} // namespace juce diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.h b/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.h index a4286c26dc..0b65f0400b 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.h +++ b/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.h @@ -24,9 +24,12 @@ ============================================================================== */ -#pragma once +namespace juce +{ +class AudioProcessor; class AudioProcessorEditorListener; + //============================================================================== /** Base class for the component that acts as the GUI for an AudioProcessor. @@ -203,3 +206,5 @@ private: JUCE_DECLARE_NON_COPYABLE (AudioProcessorEditor) }; + +} // namespace juce diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp b/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp index 8ae84d6fb4..2388c9930b 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp +++ b/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + const int AudioProcessorGraph::midiChannelIndex = 0x1000; //============================================================================== @@ -1693,3 +1696,5 @@ void AudioProcessorGraph::AudioGraphIOProcessor::setParentGraph (AudioProcessorG updateHostDisplay(); } } + +} // namespace juce diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.h b/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.h index b6ed9ea039..c9a2b1cd88 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.h +++ b/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -402,3 +403,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioProcessorGraph) }; + +} // namespace juce diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessorListener.h b/modules/juce_audio_processors/processors/juce_AudioProcessorListener.h index 7b6ef71e5e..7781af1fec 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessorListener.h +++ b/modules/juce_audio_processors/processors/juce_AudioProcessorListener.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -103,3 +103,5 @@ public: virtual void audioProcessorParameterChangeGestureEnd (AudioProcessor* processor, int parameterIndex); }; + +} // namespace juce diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessorParameter.h b/modules/juce_audio_processors/processors/juce_AudioProcessorParameter.h index d6ef2ddf5a..8dc6e5eb0a 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessorParameter.h +++ b/modules/juce_audio_processors/processors/juce_AudioProcessorParameter.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** An abstract base class for parameter objects that can be added to an @@ -193,3 +193,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioProcessorParameter) }; + +} // namespace juce diff --git a/modules/juce_audio_processors/processors/juce_GenericAudioProcessorEditor.cpp b/modules/juce_audio_processors/processors/juce_GenericAudioProcessorEditor.cpp index 32a2db8549..08f160932c 100644 --- a/modules/juce_audio_processors/processors/juce_GenericAudioProcessorEditor.cpp +++ b/modules/juce_audio_processors/processors/juce_GenericAudioProcessorEditor.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class ProcessorParameterPropertyComp : public PropertyComponent, private AudioProcessorListener, private Timer @@ -185,3 +188,5 @@ void GenericAudioProcessorEditor::resized() { panel.setBounds (getLocalBounds()); } + +} // namespace juce diff --git a/modules/juce_audio_processors/processors/juce_GenericAudioProcessorEditor.h b/modules/juce_audio_processors/processors/juce_GenericAudioProcessorEditor.h index e5d54e5fa7..611d62129a 100644 --- a/modules/juce_audio_processors/processors/juce_GenericAudioProcessorEditor.h +++ b/modules/juce_audio_processors/processors/juce_GenericAudioProcessorEditor.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -54,3 +54,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (GenericAudioProcessorEditor) }; + +} // namespace juce diff --git a/modules/juce_audio_processors/processors/juce_PluginDescription.cpp b/modules/juce_audio_processors/processors/juce_PluginDescription.cpp index 445ca73f2a..6d885d722b 100644 --- a/modules/juce_audio_processors/processors/juce_PluginDescription.cpp +++ b/modules/juce_audio_processors/processors/juce_PluginDescription.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + PluginDescription::PluginDescription() : uid (0), isInstrument (false), @@ -144,3 +147,5 @@ bool PluginDescription::loadFromXml (const XmlElement& xml) return false; } + +} // namespace juce diff --git a/modules/juce_audio_processors/processors/juce_PluginDescription.h b/modules/juce_audio_processors/processors/juce_PluginDescription.h index 046626a505..7642545a10 100644 --- a/modules/juce_audio_processors/processors/juce_PluginDescription.h +++ b/modules/juce_audio_processors/processors/juce_PluginDescription.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -152,3 +152,5 @@ private: //============================================================================== JUCE_LEAK_DETECTOR (PluginDescription) }; + +} // namespace juce diff --git a/modules/juce_audio_processors/scanning/juce_KnownPluginList.cpp b/modules/juce_audio_processors/scanning/juce_KnownPluginList.cpp index 352b6c1c0b..f7c0bf71e0 100644 --- a/modules/juce_audio_processors/scanning/juce_KnownPluginList.cpp +++ b/modules/juce_audio_processors/scanning/juce_KnownPluginList.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + KnownPluginList::KnownPluginList() {} KnownPluginList::~KnownPluginList() {} @@ -580,3 +583,5 @@ bool KnownPluginList::CustomScanner::shouldExit() const noexcept return false; } + +} // namespace juce diff --git a/modules/juce_audio_processors/scanning/juce_KnownPluginList.h b/modules/juce_audio_processors/scanning/juce_KnownPluginList.h index 9095873bd0..17ce28fb31 100644 --- a/modules/juce_audio_processors/scanning/juce_KnownPluginList.h +++ b/modules/juce_audio_processors/scanning/juce_KnownPluginList.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -221,3 +221,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (KnownPluginList) }; + +} // namespace juce diff --git a/modules/juce_audio_processors/scanning/juce_PluginDirectoryScanner.cpp b/modules/juce_audio_processors/scanning/juce_PluginDirectoryScanner.cpp index 680e17edd3..1c68861b6a 100644 --- a/modules/juce_audio_processors/scanning/juce_PluginDirectoryScanner.cpp +++ b/modules/juce_audio_processors/scanning/juce_PluginDirectoryScanner.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + static StringArray readDeadMansPedalFile (const File& file) { StringArray lines; @@ -129,3 +132,5 @@ void PluginDirectoryScanner::applyBlacklistingsFromDeadMansPedal (KnownPluginLis for (auto& crashedPlugin : readDeadMansPedalFile (file)) list.addToBlacklist (crashedPlugin); } + +} // namespace juce diff --git a/modules/juce_audio_processors/scanning/juce_PluginDirectoryScanner.h b/modules/juce_audio_processors/scanning/juce_PluginDirectoryScanner.h index c22ccf300c..200835a1e7 100644 --- a/modules/juce_audio_processors/scanning/juce_PluginDirectoryScanner.h +++ b/modules/juce_audio_processors/scanning/juce_PluginDirectoryScanner.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -127,3 +127,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PluginDirectoryScanner) }; + +} // namespace juce diff --git a/modules/juce_audio_processors/scanning/juce_PluginListComponent.cpp b/modules/juce_audio_processors/scanning/juce_PluginListComponent.cpp index dd18d45e81..733842ffbe 100644 --- a/modules/juce_audio_processors/scanning/juce_PluginListComponent.cpp +++ b/modules/juce_audio_processors/scanning/juce_PluginListComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class PluginListComponent::TableModel : public TableListBoxModel { public: @@ -586,3 +589,5 @@ void PluginListComponent::scanFinished (const StringArray& failedFiles) + ":\n\n" + shortNames.joinIntoString (", ")); } + +} // namespace juce diff --git a/modules/juce_audio_processors/scanning/juce_PluginListComponent.h b/modules/juce_audio_processors/scanning/juce_PluginListComponent.h index da60cd0ea9..df3ec367c8 100644 --- a/modules/juce_audio_processors/scanning/juce_PluginListComponent.h +++ b/modules/juce_audio_processors/scanning/juce_PluginListComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -128,3 +128,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PluginListComponent) }; + +} // namespace juce diff --git a/modules/juce_audio_processors/utilities/juce_AudioParameterBool.h b/modules/juce_audio_processors/utilities/juce_AudioParameterBool.h index 5c6f7153e3..c664ce8014 100644 --- a/modules/juce_audio_processors/utilities/juce_AudioParameterBool.h +++ b/modules/juce_audio_processors/utilities/juce_AudioParameterBool.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + /** Provides a class of AudioProcessorParameter that can be used as a boolean value. @@ -64,3 +67,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioParameterBool) }; + +} // namespace juce diff --git a/modules/juce_audio_processors/utilities/juce_AudioParameterChoice.h b/modules/juce_audio_processors/utilities/juce_AudioParameterChoice.h index 784107bc02..dc711d5830 100644 --- a/modules/juce_audio_processors/utilities/juce_AudioParameterChoice.h +++ b/modules/juce_audio_processors/utilities/juce_AudioParameterChoice.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + /** Provides a class of AudioProcessorParameter that can be used to select an indexed, named choice from a list. @@ -79,3 +82,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioParameterChoice) }; + +} // namespace juce diff --git a/modules/juce_audio_processors/utilities/juce_AudioParameterFloat.h b/modules/juce_audio_processors/utilities/juce_AudioParameterFloat.h index e4c27e2ba5..c422749edf 100644 --- a/modules/juce_audio_processors/utilities/juce_AudioParameterFloat.h +++ b/modules/juce_audio_processors/utilities/juce_AudioParameterFloat.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + /** A subclass of AudioProcessorParameter that provides an easy way to create a parameter which maps onto a given NormalisableRange. @@ -80,3 +83,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioParameterFloat) }; + +} // namespace juce diff --git a/modules/juce_audio_processors/utilities/juce_AudioParameterInt.h b/modules/juce_audio_processors/utilities/juce_AudioParameterInt.h index 91f0579769..4c2f02c33b 100644 --- a/modules/juce_audio_processors/utilities/juce_AudioParameterInt.h +++ b/modules/juce_audio_processors/utilities/juce_AudioParameterInt.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + /** Provides a class of AudioProcessorParameter that can be used as an integer value with a given range. @@ -77,3 +80,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioParameterInt) }; + +} // namespace juce diff --git a/modules/juce_audio_processors/utilities/juce_AudioProcessorParameterWithID.h b/modules/juce_audio_processors/utilities/juce_AudioProcessorParameterWithID.h index 2569c4d06e..d5d0052349 100644 --- a/modules/juce_audio_processors/utilities/juce_AudioProcessorParameterWithID.h +++ b/modules/juce_audio_processors/utilities/juce_AudioProcessorParameterWithID.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + /** This abstract base class is used by some AudioProcessorParameter helper classes. @@ -62,3 +65,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioProcessorParameterWithID) }; + +} // namespace juce diff --git a/modules/juce_audio_processors/utilities/juce_AudioProcessorParameters.cpp b/modules/juce_audio_processors/utilities/juce_AudioProcessorParameters.cpp index f0b2c0b99c..88da76bc00 100644 --- a/modules/juce_audio_processors/utilities/juce_AudioProcessorParameters.cpp +++ b/modules/juce_audio_processors/utilities/juce_AudioProcessorParameters.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + // This file contains the implementations of the various AudioParameter[XYZ] classes.. @@ -168,3 +171,5 @@ AudioParameterChoice& AudioParameterChoice::operator= (int newValue) return *this; } + +} // namespace juce diff --git a/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.cpp b/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.cpp index da4462f0d5..055b1566c4 100644 --- a/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.cpp +++ b/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.cpp @@ -24,7 +24,9 @@ ============================================================================== */ -//============================================================================== +namespace juce +{ + struct AudioProcessorValueTreeState::Parameter : public AudioProcessorParameterWithID, private ValueTree::Listener { @@ -570,3 +572,5 @@ AudioProcessorValueTreeState::ButtonAttachment::ButtonAttachment (AudioProcessor } AudioProcessorValueTreeState::ButtonAttachment::~ButtonAttachment() {} + +} // namespace juce diff --git a/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.h b/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.h index d1b3ec8c42..13ace95955 100644 --- a/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.h +++ b/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ /** This class contains a ValueTree which is used to manage an AudioProcessor's entire state. @@ -233,3 +234,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioProcessorValueTreeState) }; + +} // namespace juce diff --git a/modules/juce_audio_utils/audio_cd/juce_AudioCDBurner.h b/modules/juce_audio_utils/audio_cd/juce_AudioCDBurner.h index e8d541a90a..ad583d4c6e 100644 --- a/modules/juce_audio_utils/audio_cd/juce_AudioCDBurner.h +++ b/modules/juce_audio_utils/audio_cd/juce_AudioCDBurner.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ #if JUCE_USE_CDBURNER || DOXYGEN @@ -167,3 +168,5 @@ private: #endif + +} // namespace juce diff --git a/modules/juce_audio_utils/audio_cd/juce_AudioCDReader.cpp b/modules/juce_audio_utils/audio_cd/juce_AudioCDReader.cpp index c5f293835f..f632d65bff 100644 --- a/modules/juce_audio_utils/audio_cd/juce_AudioCDReader.cpp +++ b/modules/juce_audio_utils/audio_cd/juce_AudioCDReader.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_USE_CDREADER int AudioCDReader::getNumTracks() const @@ -57,3 +60,5 @@ int AudioCDReader::getCDDBId() } #endif + +} // namespace juce diff --git a/modules/juce_audio_utils/audio_cd/juce_AudioCDReader.h b/modules/juce_audio_utils/audio_cd/juce_AudioCDReader.h index ca94e101eb..540754c6c4 100644 --- a/modules/juce_audio_utils/audio_cd/juce_AudioCDReader.h +++ b/modules/juce_audio_utils/audio_cd/juce_AudioCDReader.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ #if JUCE_USE_CDREADER || DOXYGEN @@ -172,3 +173,5 @@ private: }; #endif + +} // namespace juce diff --git a/modules/juce_audio_utils/gui/juce_AudioAppComponent.cpp b/modules/juce_audio_utils/gui/juce_AudioAppComponent.cpp index df27b7d103..19dd48d241 100644 --- a/modules/juce_audio_utils/gui/juce_AudioAppComponent.cpp +++ b/modules/juce_audio_utils/gui/juce_AudioAppComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + AudioAppComponent::AudioAppComponent() { } @@ -50,3 +53,5 @@ void AudioAppComponent::shutdownAudio() deviceManager.removeAudioCallback (&audioSourcePlayer); deviceManager.closeAudioDevice(); } + +} // namespace juce diff --git a/modules/juce_audio_utils/gui/juce_AudioAppComponent.h b/modules/juce_audio_utils/gui/juce_AudioAppComponent.h index 98005c9198..d4bec5d046 100644 --- a/modules/juce_audio_utils/gui/juce_AudioAppComponent.h +++ b/modules/juce_audio_utils/gui/juce_AudioAppComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -113,3 +113,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioAppComponent) }; + +} // namespace juce diff --git a/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp b/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp index 5e4c83afb6..f2cb5350c7 100644 --- a/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp +++ b/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class SimpleDeviceManagerInputLevelMeter : public Component, public Timer { @@ -1217,3 +1220,5 @@ ListBox* AudioDeviceSelectorComponent::getMidiInputSelectorListBox() const noexc { return midiInputsList; } + +} // namespace juce diff --git a/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.h b/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.h index a52d0526cd..ca2d8df76c 100644 --- a/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.h +++ b/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -120,3 +120,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioDeviceSelectorComponent) }; + +} // namespace juce diff --git a/modules/juce_audio_utils/gui/juce_AudioThumbnail.cpp b/modules/juce_audio_utils/gui/juce_AudioThumbnail.cpp index 46f8dbac74..1e3ea0eea6 100644 --- a/modules/juce_audio_utils/gui/juce_AudioThumbnail.cpp +++ b/modules/juce_audio_utils/gui/juce_AudioThumbnail.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + struct AudioThumbnail::MinMaxValue { MinMaxValue() noexcept @@ -830,3 +833,5 @@ void AudioThumbnail::drawChannels (Graphics& g, const Rectangle& area, doub startTimeSeconds, endTimeSeconds, i, verticalZoomFactor); } } + +} // namespace juce diff --git a/modules/juce_audio_utils/gui/juce_AudioThumbnail.h b/modules/juce_audio_utils/gui/juce_AudioThumbnail.h index 2ba8359780..ecfc42a40e 100644 --- a/modules/juce_audio_utils/gui/juce_AudioThumbnail.h +++ b/modules/juce_audio_utils/gui/juce_AudioThumbnail.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -223,3 +223,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioThumbnail) }; + +} // namespace juce diff --git a/modules/juce_audio_utils/gui/juce_AudioThumbnailBase.h b/modules/juce_audio_utils/gui/juce_AudioThumbnailBase.h index 452179c6f9..2ee81e4a44 100644 --- a/modules/juce_audio_utils/gui/juce_AudioThumbnailBase.h +++ b/modules/juce_audio_utils/gui/juce_AudioThumbnailBase.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ class AudioThumbnailCache; @@ -152,3 +153,5 @@ public: /** Returns the hash code that was set by setSource() or setReader(). */ virtual int64 getHashCode() const = 0; }; + +} // namespace juce diff --git a/modules/juce_audio_utils/gui/juce_AudioThumbnailCache.cpp b/modules/juce_audio_utils/gui/juce_AudioThumbnailCache.cpp index 853fe333d2..7157cfbe21 100644 --- a/modules/juce_audio_utils/gui/juce_AudioThumbnailCache.cpp +++ b/modules/juce_audio_utils/gui/juce_AudioThumbnailCache.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class AudioThumbnailCache::ThumbnailCacheEntry { public: @@ -191,3 +194,5 @@ bool AudioThumbnailCache::loadNewThumb (AudioThumbnailBase&, int64) { return false; } + +} // namespace juce diff --git a/modules/juce_audio_utils/gui/juce_AudioThumbnailCache.h b/modules/juce_audio_utils/gui/juce_AudioThumbnailCache.h index bae7bc78b0..60057a6480 100644 --- a/modules/juce_audio_utils/gui/juce_AudioThumbnailCache.h +++ b/modules/juce_audio_utils/gui/juce_AudioThumbnailCache.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -114,3 +114,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioThumbnailCache) }; + +} // namespace juce diff --git a/modules/juce_audio_utils/gui/juce_AudioVisualiserComponent.cpp b/modules/juce_audio_utils/gui/juce_AudioVisualiserComponent.cpp index e7635cb81d..596c467174 100644 --- a/modules/juce_audio_utils/gui/juce_AudioVisualiserComponent.cpp +++ b/modules/juce_audio_utils/gui/juce_AudioVisualiserComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + struct AudioVisualiserComponent::ChannelInfo { ChannelInfo (AudioVisualiserComponent& o, int bufferSize) @@ -220,3 +223,5 @@ void AudioVisualiserComponent::paintChannel (Graphics& g, Rectangle area, 0.0f, 1.0f, area.getX(), area.getBottom(), (float) numLevels, -1.0f, area.getRight(), area.getY())); } + +} // namespace juce diff --git a/modules/juce_audio_utils/gui/juce_AudioVisualiserComponent.h b/modules/juce_audio_utils/gui/juce_AudioVisualiserComponent.h index 19448db2b8..8abd76704a 100644 --- a/modules/juce_audio_utils/gui/juce_AudioVisualiserComponent.h +++ b/modules/juce_audio_utils/gui/juce_AudioVisualiserComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -130,3 +130,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioVisualiserComponent) }; + +} // namespace juce diff --git a/modules/juce_audio_utils/gui/juce_BluetoothMidiDevicePairingDialogue.h b/modules/juce_audio_utils/gui/juce_BluetoothMidiDevicePairingDialogue.h index cf7e7bb984..a048d52f71 100644 --- a/modules/juce_audio_utils/gui/juce_BluetoothMidiDevicePairingDialogue.h +++ b/modules/juce_audio_utils/gui/juce_BluetoothMidiDevicePairingDialogue.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -74,3 +75,5 @@ public: */ static bool isAvailable(); }; + +} // namespace juce diff --git a/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.cpp b/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.cpp index c35ada229e..d6edfe25e3 100644 --- a/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.cpp +++ b/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class MidiKeyboardUpDownButton : public Button { public: @@ -936,3 +939,5 @@ void MidiKeyboardComponent::focusLost (FocusChangeType) { resetAnyKeysInUse(); } + +} // namespace juce diff --git a/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.h b/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.h index 47ccd8df62..7d40fc10f3 100644 --- a/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.h +++ b/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -420,3 +420,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MidiKeyboardComponent) }; + +} // namespace juce diff --git a/modules/juce_audio_utils/juce_audio_utils.cpp b/modules/juce_audio_utils/juce_audio_utils.cpp index 36a3d4e364..e0169121a9 100644 --- a/modules/juce_audio_utils/juce_audio_utils.cpp +++ b/modules/juce_audio_utils/juce_audio_utils.cpp @@ -33,8 +33,10 @@ #error "Incorrect use of JUCE cpp file" #endif -#define JUCE_CORE_INCLUDE_JNI_HELPERS 1 #define JUCE_CORE_INCLUDE_NATIVE_HEADERS 1 +#define JUCE_CORE_INCLUDE_JNI_HELPERS 1 +#define JUCE_CORE_INCLUDE_OBJC_HELPERS 1 +#define JUCE_CORE_INCLUDE_COM_SMART_PTR 1 #include "juce_audio_utils.h" @@ -55,9 +57,6 @@ #endif #endif -namespace juce -{ - #include "gui/juce_AudioDeviceSelectorComponent.cpp" #include "gui/juce_AudioThumbnail.cpp" #include "gui/juce_AudioThumbnailCache.cpp" @@ -69,9 +68,7 @@ namespace juce #include "audio_cd/juce_AudioCDReader.cpp" #if JUCE_MAC - #include "native/juce_mac_BluetoothMidiDevicePairingDialogue.mm" - #include "../juce_core/native/juce_osx_ObjCHelpers.h" #if JUCE_USE_CDREADER #include "native/juce_mac_AudioCDReader.mm" @@ -82,15 +79,12 @@ namespace juce #endif #elif JUCE_IOS - #include "native/juce_ios_BluetoothMidiDevicePairingDialogue.mm" #elif JUCE_ANDROID - #include "native/juce_android_BluetoothMidiDevicePairingDialogue.cpp" #elif JUCE_LINUX - #if JUCE_USE_CDREADER #include "native/juce_linux_AudioCDReader.cpp" #endif @@ -98,9 +92,7 @@ namespace juce #include "native/juce_linux_BluetoothMidiDevicePairingDialogue.cpp" #elif JUCE_WINDOWS - #include "native/juce_win_BluetoothMidiDevicePairingDialogue.cpp" - #include "../juce_core/native/juce_win32_ComSmartPtr.h" #if JUCE_USE_CDREADER #include "native/juce_win32_AudioCDReader.cpp" @@ -111,5 +103,3 @@ namespace juce #endif #endif - -} diff --git a/modules/juce_audio_utils/juce_audio_utils.h b/modules/juce_audio_utils/juce_audio_utils.h index 2ba9532ab2..d8816ef2d6 100644 --- a/modules/juce_audio_utils/juce_audio_utils.h +++ b/modules/juce_audio_utils/juce_audio_utils.h @@ -74,9 +74,6 @@ #endif //============================================================================== -namespace juce -{ - #include "gui/juce_AudioDeviceSelectorComponent.h" #include "gui/juce_AudioThumbnailBase.h" #include "gui/juce_AudioThumbnail.h" @@ -89,5 +86,3 @@ namespace juce #include "players/juce_AudioProcessorPlayer.h" #include "audio_cd/juce_AudioCDBurner.h" #include "audio_cd/juce_AudioCDReader.h" - -} diff --git a/modules/juce_audio_utils/native/juce_android_BluetoothMidiDevicePairingDialogue.cpp b/modules/juce_audio_utils/native/juce_android_BluetoothMidiDevicePairingDialogue.cpp index e9b03bab04..82681e77a8 100644 --- a/modules/juce_audio_utils/native/juce_android_BluetoothMidiDevicePairingDialogue.cpp +++ b/modules/juce_audio_utils/native/juce_android_BluetoothMidiDevicePairingDialogue.cpp @@ -24,7 +24,9 @@ ============================================================================== */ -//============================================================================== +namespace juce +{ + #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ METHOD (getMidiBluetoothAddresses, "getMidiBluetoothAddresses", "()[Ljava/lang/String;") \ METHOD (pairBluetoothMidiDevice, "pairBluetoothMidiDevice", "(Ljava/lang/String;)Z") \ @@ -482,3 +484,5 @@ bool BluetoothMidiDevicePairingDialogue::isAvailable() jobject btManager (android.activity.callObjectMethod (JuceAppActivity.getAndroidBluetoothManager)); return btManager != nullptr; } + +} // namespace juce diff --git a/modules/juce_audio_utils/native/juce_ios_BluetoothMidiDevicePairingDialogue.mm b/modules/juce_audio_utils/native/juce_ios_BluetoothMidiDevicePairingDialogue.mm index f0dabef5ce..befb3a0269 100644 --- a/modules/juce_audio_utils/native/juce_ios_BluetoothMidiDevicePairingDialogue.mm +++ b/modules/juce_audio_utils/native/juce_ios_BluetoothMidiDevicePairingDialogue.mm @@ -31,8 +31,6 @@ // It is also not available in the iPhone/iPad simulator. #if JUCE_MODULE_AVAILABLE_juce_gui_extra && ! TARGET_IPHONE_SIMULATOR -} // (juce namespace) - #include namespace juce @@ -118,14 +116,20 @@ bool BluetoothMidiDevicePairingDialogue::isAvailable() return NSClassFromString ([NSString stringWithUTF8String: "CABTMIDICentralViewController"]) != nil; } +} // namespace juce + //============================================================================== #else -bool BluetoothMidiDevicePairingDialogue::open (ModalComponentManager::Callback* exitCallback) +namespace juce { - ScopedPointer cb (exitCallback); - return false; + bool BluetoothMidiDevicePairingDialogue::open (ModalComponentManager::Callback* exitCallback) + { + ScopedPointer cb (exitCallback); + return false; + } + + bool BluetoothMidiDevicePairingDialogue::isAvailable() { return false; } } -bool BluetoothMidiDevicePairingDialogue::isAvailable() { return false; } #endif diff --git a/modules/juce_audio_utils/native/juce_linux_AudioCDReader.cpp b/modules/juce_audio_utils/native/juce_linux_AudioCDReader.cpp index 018ab26b8b..3af5291666 100644 --- a/modules/juce_audio_utils/native/juce_linux_AudioCDReader.cpp +++ b/modules/juce_audio_utils/native/juce_linux_AudioCDReader.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + AudioCDReader::AudioCDReader() : AudioFormatReader (0, "CD Audio") { @@ -77,3 +80,5 @@ Array AudioCDReader::findIndexesInTrack (const int) { return Array(); } + +} // namespace juce diff --git a/modules/juce_audio_utils/native/juce_linux_BluetoothMidiDevicePairingDialogue.cpp b/modules/juce_audio_utils/native/juce_linux_BluetoothMidiDevicePairingDialogue.cpp index 5f52be49e7..fc876dcbef 100644 --- a/modules/juce_audio_utils/native/juce_linux_BluetoothMidiDevicePairingDialogue.cpp +++ b/modules/juce_audio_utils/native/juce_linux_BluetoothMidiDevicePairingDialogue.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + bool BluetoothMidiDevicePairingDialogue::open (ModalComponentManager::Callback* exitCallback) { ScopedPointer cb (exitCallback); @@ -38,3 +41,5 @@ bool BluetoothMidiDevicePairingDialogue::isAvailable() { return false; } + +} // namespace juce diff --git a/modules/juce_audio_utils/native/juce_mac_AudioCDReader.mm b/modules/juce_audio_utils/native/juce_mac_AudioCDReader.mm index e0dd0a8a92..4066369713 100644 --- a/modules/juce_audio_utils/native/juce_mac_AudioCDReader.mm +++ b/modules/juce_audio_utils/native/juce_mac_AudioCDReader.mm @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace CDReaderHelpers { inline const XmlElement* getElementForKey (const XmlElement& xml, const String& key) @@ -258,5 +261,7 @@ int AudioCDReader::getLastIndex() const Array AudioCDReader::findIndexesInTrack (const int /*trackNumber*/) { - return Array(); + return {}; } + +} // namespace juce diff --git a/modules/juce_audio_utils/native/juce_mac_BluetoothMidiDevicePairingDialogue.mm b/modules/juce_audio_utils/native/juce_mac_BluetoothMidiDevicePairingDialogue.mm index ccdab0375b..65d0395ec9 100644 --- a/modules/juce_audio_utils/native/juce_mac_BluetoothMidiDevicePairingDialogue.mm +++ b/modules/juce_audio_utils/native/juce_mac_BluetoothMidiDevicePairingDialogue.mm @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + bool BluetoothMidiDevicePairingDialogue::open (ModalComponentManager::Callback* exitCallback) { ScopedPointer cb (exitCallback); @@ -37,3 +40,5 @@ bool BluetoothMidiDevicePairingDialogue::isAvailable() { return false; } + +} // namespace juce diff --git a/modules/juce_audio_utils/native/juce_win32_AudioCDBurner.cpp b/modules/juce_audio_utils/native/juce_win32_AudioCDBurner.cpp index 8977773f9c..89e6ec4e5a 100644 --- a/modules/juce_audio_utils/native/juce_win32_AudioCDBurner.cpp +++ b/modules/juce_audio_utils/native/juce_win32_AudioCDBurner.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace CDBurnerHelpers { IDiscRecorder* enumCDBurners (StringArray* list, int indexToOpen, IDiscMaster** master) @@ -411,3 +414,5 @@ bool AudioCDBurner::addAudioTrack (AudioSource* audioSource, int numSamples) hr = pimpl->redbook->CloseAudioTrack(); return ok && hr == S_OK; } + +} // namespace juce diff --git a/modules/juce_audio_utils/native/juce_win32_AudioCDReader.cpp b/modules/juce_audio_utils/native/juce_win32_AudioCDReader.cpp index 534268555d..bdcef8cf47 100644 --- a/modules/juce_audio_utils/native/juce_win32_AudioCDReader.cpp +++ b/modules/juce_audio_utils/native/juce_win32_AudioCDReader.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace CDReaderHelpers { @@ -1176,7 +1179,7 @@ int AudioCDReader::getLastIndex() const int AudioCDReader::getIndexAt (int samplePos) { using namespace CDReaderHelpers; - CDDeviceWrapper* const device = static_cast (handle); + auto* device = static_cast (handle); const int frameNeeded = samplePos / samplesPerFrame; @@ -1210,7 +1213,7 @@ int AudioCDReader::getIndexAt (int samplePos) Array AudioCDReader::findIndexesInTrack (const int trackNumber) { using namespace CDReaderHelpers; - Array indexes; + Array indexes; const int trackStart = getPositionOfTrackStart (trackNumber); const int trackEnd = getPositionOfTrackStart (trackNumber + 1); @@ -1257,7 +1260,7 @@ Array AudioCDReader::findIndexesInTrack (const int trackNumber) if (needToScan) { - CDDeviceWrapper* const device = static_cast (handle); + auto* device = static_cast (handle); int pos = trackStart; int last = -1; @@ -1309,3 +1312,5 @@ void AudioCDReader::ejectDisk() using namespace CDReaderHelpers; static_cast (handle)->deviceHandle.openDrawer (true); } + +} // namespace juce diff --git a/modules/juce_audio_utils/native/juce_win_BluetoothMidiDevicePairingDialogue.cpp b/modules/juce_audio_utils/native/juce_win_BluetoothMidiDevicePairingDialogue.cpp index e051e42fd0..ee17d80744 100644 --- a/modules/juce_audio_utils/native/juce_win_BluetoothMidiDevicePairingDialogue.cpp +++ b/modules/juce_audio_utils/native/juce_win_BluetoothMidiDevicePairingDialogue.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + bool BluetoothMidiDevicePairingDialogue::open (ModalComponentManager::Callback* exitCallback) { ScopedPointer cb (exitCallback); @@ -38,3 +41,5 @@ bool BluetoothMidiDevicePairingDialogue::isAvailable() { return false; } + +} // namespace juce diff --git a/modules/juce_audio_utils/players/juce_AudioProcessorPlayer.cpp b/modules/juce_audio_utils/players/juce_AudioProcessorPlayer.cpp index c10a8f4c98..9bfe2ca23c 100644 --- a/modules/juce_audio_utils/players/juce_AudioProcessorPlayer.cpp +++ b/modules/juce_audio_utils/players/juce_AudioProcessorPlayer.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + AudioProcessorPlayer::AudioProcessorPlayer (bool doDoublePrecisionProcessing) : isDoublePrecision (doDoublePrecisionProcessing) { @@ -214,3 +217,5 @@ void AudioProcessorPlayer::handleIncomingMidiMessage (MidiInput*, const MidiMess { messageCollector.addMessageToQueue (message); } + +} // namespace juce diff --git a/modules/juce_audio_utils/players/juce_AudioProcessorPlayer.h b/modules/juce_audio_utils/players/juce_AudioProcessorPlayer.h index 10f62abb13..d93956474a 100644 --- a/modules/juce_audio_utils/players/juce_AudioProcessorPlayer.h +++ b/modules/juce_audio_utils/players/juce_AudioProcessorPlayer.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -107,3 +108,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioProcessorPlayer) }; + +} // namespace juce diff --git a/modules/juce_audio_utils/players/juce_SoundPlayer.cpp b/modules/juce_audio_utils/players/juce_SoundPlayer.cpp index 1623eba09c..29a270d637 100644 --- a/modules/juce_audio_utils/players/juce_SoundPlayer.cpp +++ b/modules/juce_audio_utils/players/juce_SoundPlayer.cpp @@ -24,7 +24,9 @@ ============================================================================== */ -//============================================================================== +namespace juce +{ + // This is an AudioTransportSource which will own it's assigned source struct AudioSourceOwningTransportSource : public AudioTransportSource { @@ -273,3 +275,5 @@ void SoundPlayer::audioDeviceError (const String& errorMessage) { player.audioDeviceError (errorMessage); } + +} // namespace juce diff --git a/modules/juce_audio_utils/players/juce_SoundPlayer.h b/modules/juce_audio_utils/players/juce_SoundPlayer.h index b436c6316e..535c936ae4 100644 --- a/modules/juce_audio_utils/players/juce_SoundPlayer.h +++ b/modules/juce_audio_utils/players/juce_SoundPlayer.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -130,3 +131,5 @@ private: //============================================================================== JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SoundPlayer) }; + +} // namespace juce diff --git a/modules/juce_blocks_basics/blocks/juce_Block.cpp b/modules/juce_blocks_basics/blocks/juce_Block.cpp index 6b4093899b..4336a92f90 100644 --- a/modules/juce_blocks_basics/blocks/juce_Block.cpp +++ b/modules/juce_blocks_basics/blocks/juce_Block.cpp @@ -20,6 +20,8 @@ ============================================================================== */ +namespace juce +{ static Block::UID getBlockUIDFromSerialNumber (const uint8* serial) noexcept { @@ -104,3 +106,5 @@ LEDRow::~LEDRow() {} //============================================================================== StatusLight::StatusLight (Block& b) : block (b) {} StatusLight::~StatusLight() {} + +} // namespace juce diff --git a/modules/juce_blocks_basics/blocks/juce_Block.h b/modules/juce_blocks_basics/blocks/juce_Block.h index 1332dc3828..b7460746b9 100644 --- a/modules/juce_blocks_basics/blocks/juce_Block.h +++ b/modules/juce_blocks_basics/blocks/juce_Block.h @@ -20,6 +20,8 @@ ============================================================================== */ +namespace juce +{ /** Represents an individual BLOCKS device. @@ -431,3 +433,5 @@ private: //============================================================================== JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Block) }; + +} // namespace juce diff --git a/modules/juce_blocks_basics/blocks/juce_BlockConfigManager.h b/modules/juce_blocks_basics/blocks/juce_BlockConfigManager.h index 4369372c8d..eb591576fb 100644 --- a/modules/juce_blocks_basics/blocks/juce_BlockConfigManager.h +++ b/modules/juce_blocks_basics/blocks/juce_BlockConfigManager.h @@ -28,7 +28,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ // This file provides interfaces for managing the internal configuration of Blocks // and synchronises with the connected Block @@ -347,3 +348,5 @@ private: TopologyIndex deviceIndex; PhysicalTopologySource::DeviceConnection* deviceConnection; }; + +} // namespace juce diff --git a/modules/juce_blocks_basics/blocks/juce_ControlButton.h b/modules/juce_blocks_basics/blocks/juce_ControlButton.h index 2117e2cb60..4925747a8c 100644 --- a/modules/juce_blocks_basics/blocks/juce_ControlButton.h +++ b/modules/juce_blocks_basics/blocks/juce_ControlButton.h @@ -20,6 +20,8 @@ ============================================================================== */ +namespace juce +{ /** Represents a button on a block device. @@ -132,3 +134,5 @@ protected: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ControlButton) }; + +} // namespace juce diff --git a/modules/juce_blocks_basics/blocks/juce_LEDGrid.h b/modules/juce_blocks_basics/blocks/juce_LEDGrid.h index 51eec3e32a..6340fb303a 100644 --- a/modules/juce_blocks_basics/blocks/juce_LEDGrid.h +++ b/modules/juce_blocks_basics/blocks/juce_LEDGrid.h @@ -20,6 +20,8 @@ ============================================================================== */ +namespace juce +{ /** A simple ARGB colour class for setting LEDs. @@ -94,3 +96,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LEDGrid) }; + +} // namespace juce diff --git a/modules/juce_blocks_basics/blocks/juce_LEDRow.h b/modules/juce_blocks_basics/blocks/juce_LEDRow.h index 244133fd36..e32083985e 100644 --- a/modules/juce_blocks_basics/blocks/juce_LEDRow.h +++ b/modules/juce_blocks_basics/blocks/juce_LEDRow.h @@ -20,6 +20,8 @@ ============================================================================== */ +namespace juce +{ /** Represents an LED strip on a device. @@ -56,3 +58,5 @@ public: private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LEDRow) }; + +} // namespace juce diff --git a/modules/juce_blocks_basics/blocks/juce_StatusLight.h b/modules/juce_blocks_basics/blocks/juce_StatusLight.h index d452d5b9b8..79d13ca54a 100644 --- a/modules/juce_blocks_basics/blocks/juce_StatusLight.h +++ b/modules/juce_blocks_basics/blocks/juce_StatusLight.h @@ -20,6 +20,8 @@ ============================================================================== */ +namespace juce +{ /** Represents a status LED on a device. @@ -45,3 +47,5 @@ public: private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (StatusLight) }; + +} // namespace juce diff --git a/modules/juce_blocks_basics/blocks/juce_TouchList.h b/modules/juce_blocks_basics/blocks/juce_TouchList.h index 84eb45845c..81a4a4680d 100644 --- a/modules/juce_blocks_basics/blocks/juce_TouchList.h +++ b/modules/juce_blocks_basics/blocks/juce_TouchList.h @@ -20,6 +20,8 @@ ============================================================================== */ +namespace juce +{ /** Utility class to hold a list of TouchSurface::Touch objects with different @@ -137,3 +139,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TouchList) }; + +} // namespace juce diff --git a/modules/juce_blocks_basics/blocks/juce_TouchSurface.h b/modules/juce_blocks_basics/blocks/juce_TouchSurface.h index 82d2a849d0..0a8d71e96f 100644 --- a/modules/juce_blocks_basics/blocks/juce_TouchSurface.h +++ b/modules/juce_blocks_basics/blocks/juce_TouchSurface.h @@ -20,6 +20,8 @@ ============================================================================== */ +namespace juce +{ /** Represents the touch surface of a BLOCKS device. @@ -129,3 +131,5 @@ protected: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TouchSurface) }; + +} // namespace juce diff --git a/modules/juce_blocks_basics/juce_blocks_basics.cpp b/modules/juce_blocks_basics/juce_blocks_basics.cpp index 140a88136a..27a5dd1b40 100644 --- a/modules/juce_blocks_basics/juce_blocks_basics.cpp +++ b/modules/juce_blocks_basics/juce_blocks_basics.cpp @@ -23,21 +23,15 @@ #include "juce_blocks_basics.h" -namespace juce -{ - namespace BlocksProtocol - { - #include "protocol/juce_BitPackingUtilities.h" - #include "protocol/juce_BlocksProtocolDefinitions.h" - #include "protocol/juce_HostPacketDecoder.h" - #include "protocol/juce_HostPacketBuilder.h" - #include "protocol/juce_BlockModels.h" - } - - #include "blocks/juce_BlockConfigManager.h" - #include "blocks/juce_Block.cpp" - #include "topology/juce_PhysicalTopologySource.cpp" - #include "topology/juce_RuleBasedTopologySource.cpp" - #include "visualisers/juce_DrumPadLEDProgram.cpp" - #include "visualisers/juce_BitmapLEDProgram.cpp" -} +#include "protocol/juce_BitPackingUtilities.h" +#include "protocol/juce_BlocksProtocolDefinitions.h" +#include "protocol/juce_HostPacketDecoder.h" +#include "protocol/juce_HostPacketBuilder.h" +#include "protocol/juce_BlockModels.h" + +#include "blocks/juce_BlockConfigManager.h" +#include "blocks/juce_Block.cpp" +#include "topology/juce_PhysicalTopologySource.cpp" +#include "topology/juce_RuleBasedTopologySource.cpp" +#include "visualisers/juce_DrumPadLEDProgram.cpp" +#include "visualisers/juce_BitmapLEDProgram.cpp" diff --git a/modules/juce_blocks_basics/juce_blocks_basics.h b/modules/juce_blocks_basics/juce_blocks_basics.h index 9a5587c213..700592fbc2 100644 --- a/modules/juce_blocks_basics/juce_blocks_basics.h +++ b/modules/juce_blocks_basics/juce_blocks_basics.h @@ -52,27 +52,31 @@ namespace juce { - class TouchSurface; - class LEDGrid; - class LEDRow; - class StatusLight; - class LightRing; - class ControlButton; - - #include "blocks/juce_Block.h" - #include "blocks/juce_TouchSurface.h" - #include "blocks/juce_LEDGrid.h" - #include "blocks/juce_LEDRow.h" - #include "blocks/juce_ControlButton.h" - #include "blocks/juce_TouchList.h" - #include "blocks/juce_StatusLight.h" - #include "topology/juce_Topology.h" - #include "topology/juce_TopologySource.h" - #include "topology/juce_PhysicalTopologySource.h" - #include "topology/juce_RuleBasedTopologySource.h" - #include "littlefoot/juce_LittleFootRunner.h" - #include "littlefoot/juce_LittleFootCompiler.h" - #include "littlefoot/juce_LittleFootRemoteHeap.h" - #include "visualisers/juce_DrumPadLEDProgram.h" - #include "visualisers/juce_BitmapLEDProgram.h" + class TouchSurface; + class LEDGrid; + class LEDRow; + class StatusLight; + class LightRing; + class ControlButton; +} + +#include "blocks/juce_Block.h" +#include "blocks/juce_TouchSurface.h" +#include "blocks/juce_LEDGrid.h" +#include "blocks/juce_LEDRow.h" +#include "blocks/juce_ControlButton.h" +#include "blocks/juce_TouchList.h" +#include "blocks/juce_StatusLight.h" +#include "topology/juce_Topology.h" +#include "topology/juce_TopologySource.h" +#include "topology/juce_PhysicalTopologySource.h" +#include "topology/juce_RuleBasedTopologySource.h" +#include "visualisers/juce_DrumPadLEDProgram.h" +#include "visualisers/juce_BitmapLEDProgram.h" + +namespace juce +{ + #include "littlefoot/juce_LittleFootRunner.h" + #include "littlefoot/juce_LittleFootCompiler.h" + #include "littlefoot/juce_LittleFootRemoteHeap.h" } diff --git a/modules/juce_blocks_basics/littlefoot/juce_LittleFootCompiler.h b/modules/juce_blocks_basics/littlefoot/juce_LittleFootCompiler.h index 09b79da4bf..56aea22488 100644 --- a/modules/juce_blocks_basics/littlefoot/juce_LittleFootCompiler.h +++ b/modules/juce_blocks_basics/littlefoot/juce_LittleFootCompiler.h @@ -28,8 +28,6 @@ namespace littlefoot { -using namespace juce; - /** This class compiles littlefoot source code into a littlefoot::Program object which can be executed by a littlefoot::Runner. diff --git a/modules/juce_blocks_basics/littlefoot/juce_LittleFootRemoteHeap.h b/modules/juce_blocks_basics/littlefoot/juce_LittleFootRemoteHeap.h index 143b05099c..40d07c103d 100644 --- a/modules/juce_blocks_basics/littlefoot/juce_LittleFootRemoteHeap.h +++ b/modules/juce_blocks_basics/littlefoot/juce_LittleFootRemoteHeap.h @@ -23,8 +23,6 @@ namespace littlefoot { -using namespace juce; - //============================================================================== /** This class manages the synchronisation of a remote block of heap memory used diff --git a/modules/juce_blocks_basics/protocol/juce_BitPackingUtilities.h b/modules/juce_blocks_basics/protocol/juce_BitPackingUtilities.h index 7acc4d9691..4d122d6486 100644 --- a/modules/juce_blocks_basics/protocol/juce_BitPackingUtilities.h +++ b/modules/juce_blocks_basics/protocol/juce_BitPackingUtilities.h @@ -20,6 +20,10 @@ ============================================================================== */ +namespace juce +{ +namespace BlocksProtocol +{ /** All sysex messages to or from a BLOCKS device begin with these header bytes. @@ -270,3 +274,6 @@ private: const uint8* data; int totalBits, bitsReadInCurrentByte = 0; }; + +} // namespace BlocksProtocol +} // namespace juce diff --git a/modules/juce_blocks_basics/protocol/juce_BlockModels.h b/modules/juce_blocks_basics/protocol/juce_BlockModels.h index e83b1458b3..e809c880d1 100644 --- a/modules/juce_blocks_basics/protocol/juce_BlockModels.h +++ b/modules/juce_blocks_basics/protocol/juce_BlockModels.h @@ -20,6 +20,10 @@ ============================================================================== */ +namespace juce +{ +namespace BlocksProtocol +{ // This file isn't part of the public API, it's where we encode the knowledge base // of all the different types of block we know about.. @@ -312,3 +316,6 @@ static const char* getButtonNameForFunction (ControlButton::ButtonFunction fn) n jassertfalse; return nullptr; } + +} // namespace BlocksProtocol +} // namespace juce diff --git a/modules/juce_blocks_basics/protocol/juce_BlocksProtocolDefinitions.h b/modules/juce_blocks_basics/protocol/juce_BlocksProtocolDefinitions.h index 519889d873..94910de1f1 100644 --- a/modules/juce_blocks_basics/protocol/juce_BlocksProtocolDefinitions.h +++ b/modules/juce_blocks_basics/protocol/juce_BlocksProtocolDefinitions.h @@ -20,6 +20,10 @@ ============================================================================== */ +namespace juce +{ +namespace BlocksProtocol +{ /** This value is incremented when the format of the API changes in a way which breaks compatibility. @@ -503,3 +507,6 @@ static constexpr const char* ledProgramLittleFootFunctions[] = "initControl/viiiiiiiii", nullptr }; + +} // namespace BlocksProtocol +} // namespace juce diff --git a/modules/juce_blocks_basics/protocol/juce_HostPacketBuilder.h b/modules/juce_blocks_basics/protocol/juce_HostPacketBuilder.h index 84f9bf4963..2a2841651e 100644 --- a/modules/juce_blocks_basics/protocol/juce_HostPacketBuilder.h +++ b/modules/juce_blocks_basics/protocol/juce_HostPacketBuilder.h @@ -20,6 +20,10 @@ ============================================================================== */ +namespace juce +{ +namespace BlocksProtocol +{ /** Helper class for constructing a packet for sending to a BLOCKS device @@ -314,3 +318,6 @@ private: data << MessageType ((uint32) type); } }; + +} // namespace BlocksProtocol +} // namespace juce diff --git a/modules/juce_blocks_basics/protocol/juce_HostPacketDecoder.h b/modules/juce_blocks_basics/protocol/juce_HostPacketDecoder.h index cd1b39c023..16142ae793 100644 --- a/modules/juce_blocks_basics/protocol/juce_HostPacketDecoder.h +++ b/modules/juce_blocks_basics/protocol/juce_HostPacketDecoder.h @@ -20,6 +20,10 @@ ============================================================================== */ +namespace juce +{ +namespace BlocksProtocol +{ /** Parses data packets from a BLOCKS device, and translates them into callbacks @@ -352,3 +356,6 @@ struct HostPacketDecoder return true; } }; + +} // namespace BlocksProtocol +} // namespace juce diff --git a/modules/juce_blocks_basics/topology/juce_PhysicalTopologySource.cpp b/modules/juce_blocks_basics/topology/juce_PhysicalTopologySource.cpp index ae88a60ee6..6099cc8530 100644 --- a/modules/juce_blocks_basics/topology/juce_PhysicalTopologySource.cpp +++ b/modules/juce_blocks_basics/topology/juce_PhysicalTopologySource.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + #define JUCE_ASSERT_MESSAGE_MANAGER_IS_LOCKED \ jassert (juce::MessageManager::getInstance()->currentThreadHasLockedMessageManager()); @@ -2353,3 +2356,5 @@ bool BlockDeviceConnection::operator!= (const BlockDeviceConnection& other) cons { return ! operator== (other); } + +} // namespace juce diff --git a/modules/juce_blocks_basics/topology/juce_PhysicalTopologySource.h b/modules/juce_blocks_basics/topology/juce_PhysicalTopologySource.h index e809175e0b..442e78e28a 100644 --- a/modules/juce_blocks_basics/topology/juce_PhysicalTopologySource.h +++ b/modules/juce_blocks_basics/topology/juce_PhysicalTopologySource.h @@ -20,6 +20,8 @@ ============================================================================== */ +namespace juce +{ /** This topology source manages the topology of the physical Blocks devices @@ -80,3 +82,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PhysicalTopologySource) }; + +} // namespace juce diff --git a/modules/juce_blocks_basics/topology/juce_RuleBasedTopologySource.cpp b/modules/juce_blocks_basics/topology/juce_RuleBasedTopologySource.cpp index 476223f841..33ff36c286 100644 --- a/modules/juce_blocks_basics/topology/juce_RuleBasedTopologySource.cpp +++ b/modules/juce_blocks_basics/topology/juce_RuleBasedTopologySource.cpp @@ -20,6 +20,8 @@ ============================================================================== */ +namespace juce +{ struct RuleBasedTopologySource::Internal : public TopologySource::Listener, private juce::AsyncUpdater @@ -100,3 +102,5 @@ BlockTopology RuleBasedTopologySource::getCurrentTopology() const { void RuleBasedTopologySource::clearRules() { internal->clearRules(); } void RuleBasedTopologySource::addRule (Rule* r) { internal->addRule (r); } + +} // namespace juce diff --git a/modules/juce_blocks_basics/topology/juce_RuleBasedTopologySource.h b/modules/juce_blocks_basics/topology/juce_RuleBasedTopologySource.h index b25292f87d..7b155a1d89 100644 --- a/modules/juce_blocks_basics/topology/juce_RuleBasedTopologySource.h +++ b/modules/juce_blocks_basics/topology/juce_RuleBasedTopologySource.h @@ -20,6 +20,8 @@ ============================================================================== */ +namespace juce +{ /** This topology source holds and applies a set of rules for transforming one device topology into another one that may involve virtual and/or @@ -74,3 +76,5 @@ private: struct Internal; juce::ScopedPointer internal; }; + +} // namespace juce diff --git a/modules/juce_blocks_basics/topology/juce_Topology.h b/modules/juce_blocks_basics/topology/juce_Topology.h index e132ca38c4..2c846a036f 100644 --- a/modules/juce_blocks_basics/topology/juce_Topology.h +++ b/modules/juce_blocks_basics/topology/juce_Topology.h @@ -20,6 +20,8 @@ ============================================================================== */ +namespace juce +{ /** Describes a phyiscal connection between two ports of two block devices. */ struct BlockDeviceConnection @@ -41,3 +43,5 @@ struct BlockTopology bool operator== (const BlockTopology&) const noexcept; bool operator!= (const BlockTopology&) const noexcept; }; + +} // namespace juce diff --git a/modules/juce_blocks_basics/topology/juce_TopologySource.h b/modules/juce_blocks_basics/topology/juce_TopologySource.h index f3f06a7476..f0b5bdbc6c 100644 --- a/modules/juce_blocks_basics/topology/juce_TopologySource.h +++ b/modules/juce_blocks_basics/topology/juce_TopologySource.h @@ -20,6 +20,8 @@ ============================================================================== */ +namespace juce +{ /** Base class for an entity that provides access to a blocks topology. */ class TopologySource @@ -49,3 +51,5 @@ protected: //========================================================================== juce::ListenerList listeners; }; + +} // namespace juce diff --git a/modules/juce_blocks_basics/visualisers/juce_BitmapLEDProgram.cpp b/modules/juce_blocks_basics/visualisers/juce_BitmapLEDProgram.cpp index fa2e89b244..e2df561f27 100644 --- a/modules/juce_blocks_basics/visualisers/juce_BitmapLEDProgram.cpp +++ b/modules/juce_blocks_basics/visualisers/juce_BitmapLEDProgram.cpp @@ -20,6 +20,8 @@ ============================================================================== */ +namespace juce +{ BitmapLEDProgram::BitmapLEDProgram (Block& b) : Program (b) {} @@ -81,3 +83,5 @@ juce::String BitmapLEDProgram::getLittleFootProgram() jassertfalse; return {}; } + +} // namespace juce diff --git a/modules/juce_blocks_basics/visualisers/juce_BitmapLEDProgram.h b/modules/juce_blocks_basics/visualisers/juce_BitmapLEDProgram.h index 113569d840..795c7eca7c 100644 --- a/modules/juce_blocks_basics/visualisers/juce_BitmapLEDProgram.h +++ b/modules/juce_blocks_basics/visualisers/juce_BitmapLEDProgram.h @@ -20,6 +20,8 @@ ============================================================================== */ +namespace juce +{ /** A simple Program to set the colours of individual LEDs. @@ -34,3 +36,5 @@ struct BitmapLEDProgram : public Block::Program private: juce::String getLittleFootProgram() override; }; + +} // namespace juce diff --git a/modules/juce_blocks_basics/visualisers/juce_DrumPadLEDProgram.cpp b/modules/juce_blocks_basics/visualisers/juce_DrumPadLEDProgram.cpp index 263561a066..cc559789c5 100644 --- a/modules/juce_blocks_basics/visualisers/juce_DrumPadLEDProgram.cpp +++ b/modules/juce_blocks_basics/visualisers/juce_DrumPadLEDProgram.cpp @@ -20,6 +20,8 @@ ============================================================================== */ +namespace juce +{ DrumPadGridProgram::DrumPadGridProgram (Block& b) : Program (b) {} @@ -870,3 +872,5 @@ juce::String DrumPadGridProgram::getLittleFootProgramPost25() const )littlefoot"; } + +} // namespace juce diff --git a/modules/juce_blocks_basics/visualisers/juce_DrumPadLEDProgram.h b/modules/juce_blocks_basics/visualisers/juce_DrumPadLEDProgram.h index a92e82e635..b45f235734 100644 --- a/modules/juce_blocks_basics/visualisers/juce_DrumPadLEDProgram.h +++ b/modules/juce_blocks_basics/visualisers/juce_DrumPadLEDProgram.h @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + /** */ struct DrumPadGridProgram : public Block::Program @@ -118,3 +121,5 @@ private: juce::String getLittleFootProgramPre25() const; juce::String getLittleFootProgramPost25() const; }; + +} // namespace juce diff --git a/modules/juce_box2d/juce_box2d.cpp b/modules/juce_box2d/juce_box2d.cpp index e3ab3e0ec4..5fa5497a7a 100644 --- a/modules/juce_box2d/juce_box2d.cpp +++ b/modules/juce_box2d/juce_box2d.cpp @@ -87,10 +87,7 @@ #include "box2d/Dynamics/Joints/b2WheelJoint.cpp" #include "box2d/Rope/b2Rope.cpp" -namespace juce -{ #include "utils/juce_Box2DRenderer.cpp" -} #if JUCE_CLANG #pragma clang diagnostic pop diff --git a/modules/juce_box2d/juce_box2d.h b/modules/juce_box2d/juce_box2d.h index 095c84f1b4..2eb94954aa 100644 --- a/modules/juce_box2d/juce_box2d.h +++ b/modules/juce_box2d/juce_box2d.h @@ -66,8 +66,5 @@ #endif #ifndef DOXYGEN // for some reason, Doxygen sees this as a re-definition of Box2DRenderer -namespace juce -{ - #include "utils/juce_Box2DRenderer.h" -} + #include "utils/juce_Box2DRenderer.h" #endif // DOXYGEN diff --git a/modules/juce_box2d/utils/juce_Box2DRenderer.cpp b/modules/juce_box2d/utils/juce_Box2DRenderer.cpp index c2dcb11bc5..0988f0f07b 100644 --- a/modules/juce_box2d/utils/juce_Box2DRenderer.cpp +++ b/modules/juce_box2d/utils/juce_Box2DRenderer.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + Box2DRenderer::Box2DRenderer() noexcept : graphics (nullptr) { SetFlags (e_shapeBit); @@ -105,3 +108,5 @@ void Box2DRenderer::DrawSegment (const b2Vec2& p1, const b2Vec2& p2, const b2Col void Box2DRenderer::DrawTransform (const b2Transform&) { } + +} // namespace juce diff --git a/modules/juce_box2d/utils/juce_Box2DRenderer.h b/modules/juce_box2d/utils/juce_Box2DRenderer.h index 063f26fba2..89d56db9a2 100644 --- a/modules/juce_box2d/utils/juce_Box2DRenderer.h +++ b/modules/juce_box2d/utils/juce_Box2DRenderer.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** A simple implementation of the b2Draw class, used to draw a Box2D world. @@ -73,3 +74,5 @@ protected: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Box2DRenderer) }; + +} // namespace juce diff --git a/modules/juce_core/containers/juce_AbstractFifo.cpp b/modules/juce_core/containers/juce_AbstractFifo.cpp index 03d61396b5..d33f7f85b1 100644 --- a/modules/juce_core/containers/juce_AbstractFifo.cpp +++ b/modules/juce_core/containers/juce_AbstractFifo.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + AbstractFifo::AbstractFifo (const int capacity) noexcept : bufferSize (capacity) { @@ -227,3 +230,5 @@ public: static AbstractFifoTests fifoUnitTests; #endif + +} // namespace juce diff --git a/modules/juce_core/containers/juce_AbstractFifo.h b/modules/juce_core/containers/juce_AbstractFifo.h index 5412a20202..0d41d6d9b9 100644 --- a/modules/juce_core/containers/juce_AbstractFifo.h +++ b/modules/juce_core/containers/juce_AbstractFifo.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -208,3 +208,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AbstractFifo) }; + +} // namespace juce diff --git a/modules/juce_core/containers/juce_Array.h b/modules/juce_core/containers/juce_Array.h index 11465ed4ee..8f7380b1ea 100644 --- a/modules/juce_core/containers/juce_Array.h +++ b/modules/juce_core/containers/juce_Array.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -1265,3 +1265,5 @@ private: addAssumingCapacityIsReady (otherElements...); } }; + +} // namespace juce diff --git a/modules/juce_core/containers/juce_ArrayAllocationBase.h b/modules/juce_core/containers/juce_ArrayAllocationBase.h index a4c3d89f1d..5ab3ce00f9 100644 --- a/modules/juce_core/containers/juce_ArrayAllocationBase.h +++ b/modules/juce_core/containers/juce_ArrayAllocationBase.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -124,3 +124,5 @@ public: private: JUCE_DECLARE_NON_COPYABLE (ArrayAllocationBase) }; + +} // namespace juce diff --git a/modules/juce_core/containers/juce_DynamicObject.cpp b/modules/juce_core/containers/juce_DynamicObject.cpp index 697205bfa8..4d299ac0cc 100644 --- a/modules/juce_core/containers/juce_DynamicObject.cpp +++ b/modules/juce_core/containers/juce_DynamicObject.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + DynamicObject::DynamicObject() { } @@ -125,3 +128,5 @@ void DynamicObject::writeAsJSON (OutputStream& out, const int indentLevel, const out << '}'; } + +} // namespace juce diff --git a/modules/juce_core/containers/juce_DynamicObject.h b/modules/juce_core/containers/juce_DynamicObject.h index 20c4e7608b..83ee6ccf0e 100644 --- a/modules/juce_core/containers/juce_DynamicObject.h +++ b/modules/juce_core/containers/juce_DynamicObject.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -126,3 +126,5 @@ private: JUCE_LEAK_DETECTOR (DynamicObject) }; + +} // namespace juce diff --git a/modules/juce_core/containers/juce_ElementComparator.h b/modules/juce_core/containers/juce_ElementComparator.h index 3f5881c1d1..aa30b194a5 100644 --- a/modules/juce_core/containers/juce_ElementComparator.h +++ b/modules/juce_core/containers/juce_ElementComparator.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ #ifndef DOXYGEN @@ -183,3 +184,5 @@ public: return (first < second) ? -1 : ((second < first) ? 1 : 0); } }; + +} // namespace juce diff --git a/modules/juce_core/containers/juce_HashMap.h b/modules/juce_core/containers/juce_HashMap.h index 019e5b41d5..ab04728d7d 100644 --- a/modules/juce_core/containers/juce_HashMap.h +++ b/modules/juce_core/containers/juce_HashMap.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -496,3 +496,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (HashMap) }; + +} // namespace juce diff --git a/modules/juce_core/containers/juce_HashMap_test.cpp b/modules/juce_core/containers/juce_HashMap_test.cpp index 428bdc8071..76dcd87e0a 100644 --- a/modules/juce_core/containers/juce_HashMap_test.cpp +++ b/modules/juce_core/containers/juce_HashMap_test.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + struct HashMapTest : public UnitTest { HashMapTest() : UnitTest ("HashMap", "Containers") {} @@ -269,3 +272,5 @@ template <> String HashMapTest::RandomKeys::generateRandomKey (Random& r } static HashMapTest hashMapTest; + +} // namespace juce diff --git a/modules/juce_core/containers/juce_LinkedListPointer.h b/modules/juce_core/containers/juce_LinkedListPointer.h index d8ddc7ed05..00994bc958 100644 --- a/modules/juce_core/containers/juce_LinkedListPointer.h +++ b/modules/juce_core/containers/juce_LinkedListPointer.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -357,3 +357,5 @@ private: JUCE_DECLARE_NON_COPYABLE (LinkedListPointer) }; + +} // namespace juce diff --git a/modules/juce_core/containers/juce_ListenerList.cpp b/modules/juce_core/containers/juce_ListenerList.cpp index f0885171b0..972122e0a0 100644 --- a/modules/juce_core/containers/juce_ListenerList.cpp +++ b/modules/juce_core/containers/juce_ListenerList.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_UNIT_TESTS struct ListenerBase @@ -182,3 +185,5 @@ public: static ListenerListTests listenerListTests; #endif + +} // namespace juce diff --git a/modules/juce_core/containers/juce_ListenerList.h b/modules/juce_core/containers/juce_ListenerList.h index 36ca27e3c9..7986b74ecd 100644 --- a/modules/juce_core/containers/juce_ListenerList.h +++ b/modules/juce_core/containers/juce_ListenerList.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -540,3 +540,5 @@ private: #undef LL_TEMPLATE #undef LL_PARAM }; + +} // namespace juce diff --git a/modules/juce_core/containers/juce_NamedValueSet.cpp b/modules/juce_core/containers/juce_NamedValueSet.cpp index b33ea1da9e..45bfff11d4 100644 --- a/modules/juce_core/containers/juce_NamedValueSet.cpp +++ b/modules/juce_core/containers/juce_NamedValueSet.cpp @@ -20,7 +20,9 @@ ============================================================================== */ -//============================================================================== +namespace juce +{ + NamedValueSet::NamedValueSet() noexcept { } @@ -241,3 +243,5 @@ void NamedValueSet::copyToXmlAttributes (XmlElement& xml) const } } } + +} // namespace juce diff --git a/modules/juce_core/containers/juce_NamedValueSet.h b/modules/juce_core/containers/juce_NamedValueSet.h index 0916052585..4e6ea7ab43 100644 --- a/modules/juce_core/containers/juce_NamedValueSet.h +++ b/modules/juce_core/containers/juce_NamedValueSet.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** Holds a set of named var objects. @@ -171,3 +171,5 @@ private: //============================================================================== Array values; }; + +} // namespace juce diff --git a/modules/juce_core/containers/juce_OwnedArray.h b/modules/juce_core/containers/juce_OwnedArray.h index 4edc190683..ccfacb0436 100644 --- a/modules/juce_core/containers/juce_OwnedArray.h +++ b/modules/juce_core/containers/juce_OwnedArray.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** An array designed for holding objects. @@ -892,3 +892,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OwnedArray) }; + +} // namespace juce diff --git a/modules/juce_core/containers/juce_PropertySet.cpp b/modules/juce_core/containers/juce_PropertySet.cpp index ce28d140c6..b1938de478 100644 --- a/modules/juce_core/containers/juce_PropertySet.cpp +++ b/modules/juce_core/containers/juce_PropertySet.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + PropertySet::PropertySet (const bool ignoreCaseOfKeyNames) : properties (ignoreCaseOfKeyNames), fallbackProperties (nullptr), @@ -211,3 +214,5 @@ void PropertySet::restoreFromXml (const XmlElement& xml) void PropertySet::propertyChanged() { } + +} // namespace juce diff --git a/modules/juce_core/containers/juce_PropertySet.h b/modules/juce_core/containers/juce_PropertySet.h index b8e934fce2..26a2cad525 100644 --- a/modules/juce_core/containers/juce_PropertySet.h +++ b/modules/juce_core/containers/juce_PropertySet.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -199,3 +199,5 @@ private: JUCE_LEAK_DETECTOR (PropertySet) }; + +} // namespace juce diff --git a/modules/juce_core/containers/juce_ReferenceCountedArray.h b/modules/juce_core/containers/juce_ReferenceCountedArray.h index 7c10c9c690..aaee953955 100644 --- a/modules/juce_core/containers/juce_ReferenceCountedArray.h +++ b/modules/juce_core/containers/juce_ReferenceCountedArray.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -909,3 +909,5 @@ private: ContainerDeletePolicy::destroy (o); } }; + +} // namespace juce diff --git a/modules/juce_core/containers/juce_ScopedValueSetter.h b/modules/juce_core/containers/juce_ScopedValueSetter.h index eeb3426509..f5e03345a8 100644 --- a/modules/juce_core/containers/juce_ScopedValueSetter.h +++ b/modules/juce_core/containers/juce_ScopedValueSetter.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -88,3 +88,5 @@ private: JUCE_DECLARE_NON_COPYABLE (ScopedValueSetter) }; + +} // namespace juce diff --git a/modules/juce_core/containers/juce_SortedSet.h b/modules/juce_core/containers/juce_SortedSet.h index 3007f43f46..192de75082 100644 --- a/modules/juce_core/containers/juce_SortedSet.h +++ b/modules/juce_core/containers/juce_SortedSet.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ #if JUCE_MSVC #pragma warning (push) @@ -481,3 +482,5 @@ private: #if JUCE_MSVC #pragma warning (pop) #endif + +} // namespace juce diff --git a/modules/juce_core/containers/juce_SparseSet.h b/modules/juce_core/containers/juce_SparseSet.h index 1b4e478e73..37efeb4f78 100644 --- a/modules/juce_core/containers/juce_SparseSet.h +++ b/modules/juce_core/containers/juce_SparseSet.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -285,3 +285,5 @@ private: values.removeRange (--i, 2); } }; + +} // namespace juce diff --git a/modules/juce_core/containers/juce_Variant.cpp b/modules/juce_core/containers/juce_Variant.cpp index 2d79e22bd8..7c517bb886 100644 --- a/modules/juce_core/containers/juce_Variant.cpp +++ b/modules/juce_core/containers/juce_Variant.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + enum VariantStreamMarkers { varMarker_Int = 1, @@ -785,3 +788,5 @@ var var::readFromStream (InputStream& input) var::NativeFunctionArgs::NativeFunctionArgs (const var& t, const var* args, int numArgs) noexcept : thisObject (t), arguments (args), numArguments (numArgs) {} + +} // namespace juce diff --git a/modules/juce_core/containers/juce_Variant.h b/modules/juce_core/containers/juce_Variant.h index d227a6a046..6cb65043aa 100644 --- a/modules/juce_core/containers/juce_Variant.h +++ b/modules/juce_core/containers/juce_Variant.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -334,3 +334,5 @@ struct VariantConverter static String fromVar (const var& v) { return v.toString(); } static var toVar (const String& s) { return s; } }; + +} // namespace juce diff --git a/modules/juce_core/files/juce_DirectoryIterator.cpp b/modules/juce_core/files/juce_DirectoryIterator.cpp index c32ae7b519..a0f8aaa38e 100644 --- a/modules/juce_core/files/juce_DirectoryIterator.cpp +++ b/modules/juce_core/files/juce_DirectoryIterator.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + DirectoryIterator::DirectoryIterator (const File& directory, bool recursive, const String& pattern, const int type) : wildCards (parseWildcards (pattern)), @@ -158,3 +161,5 @@ float DirectoryIterator::getEstimatedProgress() const return jlimit (0.0f, 1.0f, detailedIndex / totalNumFiles); } + +} // namespace juce diff --git a/modules/juce_core/files/juce_DirectoryIterator.h b/modules/juce_core/files/juce_DirectoryIterator.h index 83e579bcd9..a9b576f249 100644 --- a/modules/juce_core/files/juce_DirectoryIterator.h +++ b/modules/juce_core/files/juce_DirectoryIterator.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -148,3 +148,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DirectoryIterator) }; + +} // namespace juce diff --git a/modules/juce_core/files/juce_File.cpp b/modules/juce_core/files/juce_File.cpp index c5bd5b8be6..ef96be662c 100644 --- a/modules/juce_core/files/juce_File.cpp +++ b/modules/juce_core/files/juce_File.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + File::File (const String& fullPathName) : fullPath (parseAbsolutePath (fullPathName)) { @@ -1205,3 +1208,5 @@ public: static FileTests fileUnitTests; #endif + +} // namespace juce diff --git a/modules/juce_core/files/juce_File.h b/modules/juce_core/files/juce_File.h index de3a7d9e9f..36b58f3f35 100644 --- a/modules/juce_core/files/juce_File.h +++ b/modules/juce_core/files/juce_File.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -1043,3 +1043,5 @@ private: bool setFileReadOnlyInternal (bool) const; bool setFileExecutableInternal (bool) const; }; + +} // namespace juce diff --git a/modules/juce_core/files/juce_FileFilter.cpp b/modules/juce_core/files/juce_FileFilter.cpp index 3fe61708a4..2d0cb624a1 100644 --- a/modules/juce_core/files/juce_FileFilter.cpp +++ b/modules/juce_core/files/juce_FileFilter.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + FileFilter::FileFilter (const String& filterDescription) : description (filterDescription) { @@ -33,3 +36,5 @@ const String& FileFilter::getDescription() const noexcept { return description; } + +} // namespace juce diff --git a/modules/juce_core/files/juce_FileFilter.h b/modules/juce_core/files/juce_FileFilter.h index d40da458c5..e1e241c7f9 100644 --- a/modules/juce_core/files/juce_FileFilter.h +++ b/modules/juce_core/files/juce_FileFilter.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -65,3 +65,5 @@ protected: //============================================================================== String description; }; + +} // namespace juce diff --git a/modules/juce_core/files/juce_FileInputStream.cpp b/modules/juce_core/files/juce_FileInputStream.cpp index f136cf0907..638abf9831 100644 --- a/modules/juce_core/files/juce_FileInputStream.cpp +++ b/modules/juce_core/files/juce_FileInputStream.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + int64 juce_fileSetPosition (void* handle, int64 pos); @@ -76,3 +79,5 @@ bool FileInputStream::setPosition (int64 pos) return currentPosition == pos; } + +} // namespace juce diff --git a/modules/juce_core/files/juce_FileInputStream.h b/modules/juce_core/files/juce_FileInputStream.h index 8354b20d59..9fd84b0251 100644 --- a/modules/juce_core/files/juce_FileInputStream.h +++ b/modules/juce_core/files/juce_FileInputStream.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -84,3 +84,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FileInputStream) }; + +} // namespace juce diff --git a/modules/juce_core/files/juce_FileOutputStream.cpp b/modules/juce_core/files/juce_FileOutputStream.cpp index 31d013b113..495104380d 100644 --- a/modules/juce_core/files/juce_FileOutputStream.cpp +++ b/modules/juce_core/files/juce_FileOutputStream.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + int64 juce_fileSetPosition (void* handle, int64 pos); //============================================================================== @@ -126,3 +129,5 @@ bool FileOutputStream::writeRepeatedByte (uint8 byte, size_t numBytes) return OutputStream::writeRepeatedByte (byte, numBytes); } + +} // namespace juce diff --git a/modules/juce_core/files/juce_FileOutputStream.h b/modules/juce_core/files/juce_FileOutputStream.h index 75b14bc49a..3e1100ce76 100644 --- a/modules/juce_core/files/juce_FileOutputStream.h +++ b/modules/juce_core/files/juce_FileOutputStream.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -109,3 +109,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FileOutputStream) }; + +} // namespace juce diff --git a/modules/juce_core/files/juce_FileSearchPath.cpp b/modules/juce_core/files/juce_FileSearchPath.cpp index 8219de13a3..baa2539f6f 100644 --- a/modules/juce_core/files/juce_FileSearchPath.cpp +++ b/modules/juce_core/files/juce_FileSearchPath.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + FileSearchPath::FileSearchPath() {} FileSearchPath::~FileSearchPath() {} @@ -165,3 +168,5 @@ bool FileSearchPath::isFileInPath (const File& fileToCheck, return false; } + +} // namespace juce diff --git a/modules/juce_core/files/juce_FileSearchPath.h b/modules/juce_core/files/juce_FileSearchPath.h index 94cde68c93..91011c093a 100644 --- a/modules/juce_core/files/juce_FileSearchPath.h +++ b/modules/juce_core/files/juce_FileSearchPath.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -157,3 +157,5 @@ private: JUCE_LEAK_DETECTOR (FileSearchPath) }; + +} // namespace juce diff --git a/modules/juce_core/files/juce_MemoryMappedFile.h b/modules/juce_core/files/juce_MemoryMappedFile.h index cd8a4b3ca6..1afc083122 100644 --- a/modules/juce_core/files/juce_MemoryMappedFile.h +++ b/modules/juce_core/files/juce_MemoryMappedFile.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -109,3 +109,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MemoryMappedFile) }; + +} // namespace juce diff --git a/modules/juce_core/files/juce_TemporaryFile.cpp b/modules/juce_core/files/juce_TemporaryFile.cpp index a3c17ef63e..7010677920 100644 --- a/modules/juce_core/files/juce_TemporaryFile.cpp +++ b/modules/juce_core/files/juce_TemporaryFile.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + static File createTempFile (const File& parentDirectory, String name, const String& suffix, const int optionFlags) { @@ -109,3 +112,5 @@ bool TemporaryFile::deleteTemporaryFile() const return false; } + +} // namespace juce diff --git a/modules/juce_core/files/juce_TemporaryFile.h b/modules/juce_core/files/juce_TemporaryFile.h index 8663f0cde9..a781a101b3 100644 --- a/modules/juce_core/files/juce_TemporaryFile.h +++ b/modules/juce_core/files/juce_TemporaryFile.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -158,3 +158,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TemporaryFile) }; + +} // namespace juce diff --git a/modules/juce_core/files/juce_WildcardFileFilter.cpp b/modules/juce_core/files/juce_WildcardFileFilter.cpp index 82ffe9645e..8db43f34e7 100644 --- a/modules/juce_core/files/juce_WildcardFileFilter.cpp +++ b/modules/juce_core/files/juce_WildcardFileFilter.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + static void parseWildcard (const String& pattern, StringArray& result) { result.addTokens (pattern.toLowerCase(), ";,", "\"'"); @@ -68,3 +71,5 @@ bool WildcardFileFilter::isDirectorySuitable (const File& file) const { return matchWildcard (file, directoryWildcards); } + +} // namespace juce diff --git a/modules/juce_core/files/juce_WildcardFileFilter.h b/modules/juce_core/files/juce_WildcardFileFilter.h index 5492bdaaa4..b49c498988 100644 --- a/modules/juce_core/files/juce_WildcardFileFilter.h +++ b/modules/juce_core/files/juce_WildcardFileFilter.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -70,3 +70,5 @@ private: JUCE_LEAK_DETECTOR (WildcardFileFilter) }; + +} // namespace juce diff --git a/modules/juce_core/javascript/juce_JSON.cpp b/modules/juce_core/javascript/juce_JSON.cpp index 749d1067c2..494da5a83d 100644 --- a/modules/juce_core/javascript/juce_JSON.cpp +++ b/modules/juce_core/javascript/juce_JSON.cpp @@ -20,9 +20,11 @@ ============================================================================== */ -class JSONParser +namespace juce +{ + +struct JSONParser { -public: static Result parseObjectOrArray (String::CharPointerType t, var& result) { t = t.findEndOfWhitespace(); @@ -319,9 +321,8 @@ private: }; //============================================================================== -class JSONFormatter +struct JSONFormatter { -public: static void write (OutputStream& out, const var& v, const int indentLevel, const bool allOnOneLine, int maximumDecimalPlaces) @@ -648,3 +649,5 @@ public: static JSONTests JSONUnitTests; #endif + +} // namespace juce diff --git a/modules/juce_core/javascript/juce_JSON.h b/modules/juce_core/javascript/juce_JSON.h index 1cbe1a1d62..c185442be6 100644 --- a/modules/juce_core/javascript/juce_JSON.h +++ b/modules/juce_core/javascript/juce_JSON.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -128,3 +128,5 @@ private: //============================================================================== JSON() JUCE_DELETED_FUNCTION; // This class can't be instantiated - just use its static methods. }; + +} // namespace juce diff --git a/modules/juce_core/javascript/juce_Javascript.cpp b/modules/juce_core/javascript/juce_Javascript.cpp index 72b059de27..9ef8305160 100644 --- a/modules/juce_core/javascript/juce_Javascript.cpp +++ b/modules/juce_core/javascript/juce_Javascript.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + #define JUCE_JS_OPERATORS(X) \ X(semicolon, ";") X(dot, ".") X(comma, ",") \ X(openParen, "(") X(closeParen, ")") X(openBrace, "{") X(closeBrace, "}") \ @@ -1891,3 +1894,5 @@ const NamedValueSet& JavascriptEngine::getRootObjectProperties() const noexcept #if JUCE_MSVC #pragma warning (pop) #endif + +} // namespace juce diff --git a/modules/juce_core/javascript/juce_Javascript.h b/modules/juce_core/javascript/juce_Javascript.h index 93a55a405f..1a95998a5b 100644 --- a/modules/juce_core/javascript/juce_Javascript.h +++ b/modules/juce_core/javascript/juce_Javascript.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -116,3 +116,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (JavascriptEngine) }; + +} // namespace juce diff --git a/modules/juce_core/juce_core.cpp b/modules/juce_core/juce_core.cpp index 7d10dfa25e..df5d73287b 100644 --- a/modules/juce_core/juce_core.cpp +++ b/modules/juce_core/juce_core.cpp @@ -32,6 +32,7 @@ #define JUCE_CORE_INCLUDE_OBJC_HELPERS 1 #define JUCE_CORE_INCLUDE_COM_SMART_PTR 1 #define JUCE_CORE_INCLUDE_NATIVE_HEADERS 1 +#define JUCE_CORE_INCLUDE_JNI_HELPERS 1 #include "juce_core.h" @@ -114,9 +115,6 @@ #endif //============================================================================== -namespace juce -{ - #include "containers/juce_AbstractFifo.cpp" #include "containers/juce_NamedValueSet.cpp" #include "containers/juce_ListenerList.cpp" @@ -179,10 +177,6 @@ namespace juce #include "files/juce_WildcardFileFilter.cpp" //============================================================================== -#if JUCE_ANDROID -#include "native/juce_android_JNIHelpers.h" -#endif - #if ! JUCE_WINDOWS #include "native/juce_posix_SharedCode.h" #include "native/juce_posix_NamedPipe.cpp" @@ -238,6 +232,8 @@ namespace juce #endif //============================================================================== +namespace juce +{ /* As the very long class names here try to explain, the purpose of this code is to cause a linker error if not all of your compile units are consistent in the options that they @@ -253,5 +249,4 @@ namespace juce this_will_fail_to_link_if_some_of_your_compile_units_are_built_in_release_mode ::this_will_fail_to_link_if_some_of_your_compile_units_are_built_in_release_mode() noexcept {} #endif - } diff --git a/modules/juce_core/juce_core.h b/modules/juce_core/juce_core.h index c6aead166c..f1bbc4f029 100644 --- a/modules/juce_core/juce_core.h +++ b/modules/juce_core/juce_core.h @@ -175,20 +175,19 @@ namespace juce { - -class StringRef; -class MemoryBlock; -class File; -class InputStream; -class OutputStream; -class DynamicObject; -class FileInputStream; -class FileOutputStream; -class XmlElement; -class JSONFormatter; - -extern JUCE_API bool JUCE_CALLTYPE juce_isRunningUnderDebugger() noexcept; -extern JUCE_API void JUCE_CALLTYPE logAssertion (const char* file, int line) noexcept; + class StringRef; + class MemoryBlock; + class File; + class InputStream; + class OutputStream; + class DynamicObject; + class FileInputStream; + class FileOutputStream; + class XmlElement; + + extern JUCE_API bool JUCE_CALLTYPE juce_isRunningUnderDebugger() noexcept; + extern JUCE_API void JUCE_CALLTYPE logAssertion (const char* file, int line) noexcept; +} #include "memory/juce_Memory.h" #include "maths/juce_MathsFunctions.h" @@ -322,8 +321,9 @@ extern JUCE_API void JUCE_CALLTYPE logAssertion (const char* file, int line) noe #include "native/juce_android_JNIHelpers.h" #endif - #ifndef DOXYGEN +namespace juce +{ /* As the very long class names here try to explain, the purpose of this code is to cause a linker error if not all of your compile units are consistent in the options that they @@ -341,9 +341,8 @@ extern JUCE_API void JUCE_CALLTYPE logAssertion (const char* file, int line) noe { this_will_fail_to_link_if_some_of_your_compile_units_are_built_in_release_mode() noexcept; }; static this_will_fail_to_link_if_some_of_your_compile_units_are_built_in_release_mode compileUnitMismatchSentinel; #endif -#endif - } +#endif #if JUCE_MSVC #pragma warning (pop) diff --git a/modules/juce_core/logging/juce_FileLogger.cpp b/modules/juce_core/logging/juce_FileLogger.cpp index 9a92d383a8..7ec9dba6df 100644 --- a/modules/juce_core/logging/juce_FileLogger.cpp +++ b/modules/juce_core/logging/juce_FileLogger.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + FileLogger::FileLogger (const File& file, const String& welcomeMessage, const int64 maxInitialFileSizeBytes) @@ -126,3 +129,5 @@ FileLogger* FileLogger::createDateStampedLogger (const String& logFileSubDirecto .getNonexistentSibling(), welcomeMessage, 0); } + +} // namespace juce diff --git a/modules/juce_core/logging/juce_FileLogger.h b/modules/juce_core/logging/juce_FileLogger.h index c9846f81d8..ac29683ca8 100644 --- a/modules/juce_core/logging/juce_FileLogger.h +++ b/modules/juce_core/logging/juce_FileLogger.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -127,3 +127,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FileLogger) }; + +} // namespace juce diff --git a/modules/juce_core/logging/juce_Logger.cpp b/modules/juce_core/logging/juce_Logger.cpp index b69d69dc6f..3cb0d89631 100644 --- a/modules/juce_core/logging/juce_Logger.cpp +++ b/modules/juce_core/logging/juce_Logger.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + Logger::Logger() {} Logger::~Logger() @@ -55,3 +58,5 @@ void JUCE_API JUCE_CALLTYPE logAssertion (const char* const filename, const int #endif } #endif + +} // namespace juce diff --git a/modules/juce_core/logging/juce_Logger.h b/modules/juce_core/logging/juce_Logger.h index 45b5949b8c..bb38c565bd 100644 --- a/modules/juce_core/logging/juce_Logger.h +++ b/modules/juce_core/logging/juce_Logger.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -85,3 +85,5 @@ protected: private: static Logger* currentLogger; }; + +} // namespace juce diff --git a/modules/juce_core/maths/juce_BigInteger.cpp b/modules/juce_core/maths/juce_BigInteger.cpp index 14a9354394..78634ed2ff 100644 --- a/modules/juce_core/maths/juce_BigInteger.cpp +++ b/modules/juce_core/maths/juce_BigInteger.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + namespace { inline uint32 bitToMask (const int bit) noexcept { return (uint32) 1 << (bit & 31); } @@ -1370,3 +1373,5 @@ public: static BigIntegerTests bigIntegerTests; #endif + +} // namespace juce diff --git a/modules/juce_core/maths/juce_BigInteger.h b/modules/juce_core/maths/juce_BigInteger.h index 01a0965e3d..54726e7fe4 100644 --- a/modules/juce_core/maths/juce_BigInteger.h +++ b/modules/juce_core/maths/juce_BigInteger.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -342,3 +342,5 @@ OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const BigInteger& // For backwards compatibility, BitArray is defined as an alias for BigInteger. typedef BigInteger BitArray; #endif + +} // namespace juce diff --git a/modules/juce_core/maths/juce_Expression.cpp b/modules/juce_core/maths/juce_Expression.cpp index 639d85a1df..afab1ae9d6 100644 --- a/modules/juce_core/maths/juce_Expression.cpp +++ b/modules/juce_core/maths/juce_Expression.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + class Expression::Term : public SingleThreadedReferenceCountedObject { public: @@ -1167,3 +1170,5 @@ String Expression::Scope::getScopeUID() const { return {}; } + +} // namespace juce diff --git a/modules/juce_core/maths/juce_Expression.h b/modules/juce_core/maths/juce_Expression.h index 189a4f03d9..a3a4af7a4e 100644 --- a/modules/juce_core/maths/juce_Expression.h +++ b/modules/juce_core/maths/juce_Expression.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -249,3 +249,5 @@ private: explicit Expression (Term*); }; + +} // namespace juce diff --git a/modules/juce_core/maths/juce_MathsFunctions.h b/modules/juce_core/maths/juce_MathsFunctions.h index 7361ea71f0..7e6b348f8e 100644 --- a/modules/juce_core/maths/juce_MathsFunctions.h +++ b/modules/juce_core/maths/juce_MathsFunctions.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /* @@ -661,5 +662,4 @@ namespace TypeHelpers template <> struct UnsignedTypeWithSize<8> { typedef uint64 type; }; } - -//============================================================================== +} // namespace juce diff --git a/modules/juce_core/maths/juce_NormalisableRange.h b/modules/juce_core/maths/juce_NormalisableRange.h index 3f3794e151..cf5b3e7a11 100644 --- a/modules/juce_core/maths/juce_NormalisableRange.h +++ b/modules/juce_core/maths/juce_NormalisableRange.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -266,3 +266,5 @@ private: convertTo0To1Function = nullptr, snapToLegalValueFunction = nullptr; }; + +} // namespace juce diff --git a/modules/juce_core/maths/juce_Random.cpp b/modules/juce_core/maths/juce_Random.cpp index 9fa81369e4..219e1b40c8 100644 --- a/modules/juce_core/maths/juce_Random.cpp +++ b/modules/juce_core/maths/juce_Random.cpp @@ -20,7 +20,10 @@ ============================================================================== */ -Random::Random (const int64 seedValue) noexcept : seed (seedValue) +namespace juce +{ + +Random::Random (int64 seedValue) noexcept : seed (seedValue) { } @@ -181,3 +184,5 @@ public: static RandomTests randomTests; #endif + +} // namespace juce diff --git a/modules/juce_core/maths/juce_Random.h b/modules/juce_core/maths/juce_Random.h index fa97413f3b..f3d7d490cf 100644 --- a/modules/juce_core/maths/juce_Random.h +++ b/modules/juce_core/maths/juce_Random.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -131,3 +131,5 @@ private: JUCE_LEAK_DETECTOR (Random) }; + +} // namespace juce diff --git a/modules/juce_core/maths/juce_Range.h b/modules/juce_core/maths/juce_Range.h index bdb388530f..bbdfa765f6 100644 --- a/modules/juce_core/maths/juce_Range.h +++ b/modules/juce_core/maths/juce_Range.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** A general-purpose range object, that simply represents any linear range with @@ -301,3 +301,5 @@ private: //============================================================================== ValueType start, end; }; + +} // namespace juce diff --git a/modules/juce_core/maths/juce_StatisticsAccumulator.h b/modules/juce_core/maths/juce_StatisticsAccumulator.h index 31be08e4d3..4d1b61f4ba 100644 --- a/modules/juce_core/maths/juce_StatisticsAccumulator.h +++ b/modules/juce_core/maths/juce_StatisticsAccumulator.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -133,3 +133,5 @@ private: KahanSum sum, sumSquares; FloatType minimum, maximum; }; + +} // namespace juce diff --git a/modules/juce_core/memory/juce_Atomic.h b/modules/juce_core/memory/juce_Atomic.h index 65408b4c01..353ca2a0d5 100644 --- a/modules/juce_core/memory/juce_Atomic.h +++ b/modules/juce_core/memory/juce_Atomic.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ #ifndef DOXYGEN namespace AtomicHelpers @@ -472,3 +473,5 @@ #endif #endif + +} // namespace juce diff --git a/modules/juce_core/memory/juce_ByteOrder.h b/modules/juce_core/memory/juce_ByteOrder.h index 49c79c181a..f2e53d5cb4 100644 --- a/modules/juce_core/memory/juce_ByteOrder.h +++ b/modules/juce_core/memory/juce_ByteOrder.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** Contains static methods for converting the byte order between different @@ -233,3 +233,5 @@ inline int ByteOrder::littleEndian24Bit (const void* const bytes) noexcept inline int ByteOrder::bigEndian24Bit (const void* const bytes) noexcept { return (int) ((((unsigned int) static_cast (bytes)[0]) << 16) | (((unsigned int) static_cast (bytes)[1]) << 8) | ((unsigned int) static_cast (bytes)[2])); } inline void ByteOrder::littleEndian24BitToChars (const int value, void* const destBytes) noexcept { static_cast (destBytes)[0] = (uint8) value; static_cast (destBytes)[1] = (uint8) (value >> 8); static_cast (destBytes)[2] = (uint8) (value >> 16); } inline void ByteOrder::bigEndian24BitToChars (const int value, void* const destBytes) noexcept { static_cast (destBytes)[0] = (uint8) (value >> 16); static_cast (destBytes)[1] = (uint8) (value >> 8); static_cast (destBytes)[2] = (uint8) value; } + +} // namespace juce diff --git a/modules/juce_core/memory/juce_ContainerDeletePolicy.h b/modules/juce_core/memory/juce_ContainerDeletePolicy.h index 156feafa5c..26d1497382 100644 --- a/modules/juce_core/memory/juce_ContainerDeletePolicy.h +++ b/modules/juce_core/memory/juce_ContainerDeletePolicy.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -51,3 +52,5 @@ struct ContainerDeletePolicy delete object; } }; + +} // namespace juce diff --git a/modules/juce_core/memory/juce_HeapBlock.h b/modules/juce_core/memory/juce_HeapBlock.h index 5bb5aa9657..a469d58905 100644 --- a/modules/juce_core/memory/juce_HeapBlock.h +++ b/modules/juce_core/memory/juce_HeapBlock.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ #if ! (defined (DOXYGEN) || JUCE_EXCEPTIONS_DISABLED) namespace HeapBlockHelper @@ -307,3 +308,5 @@ private: JUCE_PREVENT_HEAP_ALLOCATION // Creating a 'new HeapBlock' would be missing the point! #endif }; + +} // namespace juce diff --git a/modules/juce_core/memory/juce_LeakedObjectDetector.h b/modules/juce_core/memory/juce_LeakedObjectDetector.h index 293ab18daf..d48be309eb 100644 --- a/modules/juce_core/memory/juce_LeakedObjectDetector.h +++ b/modules/juce_core/memory/juce_LeakedObjectDetector.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -134,3 +134,5 @@ private: #define JUCE_LEAK_DETECTOR(OwnerClass) #endif #endif + +} // namespace juce diff --git a/modules/juce_core/memory/juce_Memory.h b/modules/juce_core/memory/juce_Memory.h index ab9d833082..83b81117a9 100644 --- a/modules/juce_core/memory/juce_Memory.h +++ b/modules/juce_core/memory/juce_Memory.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** Fills a block of memory with zeros. */ @@ -72,7 +73,6 @@ inline Type readUnaligned (const void* srcPtr) noexcept { Type value; memcpy (&value, srcPtr, sizeof (Type)); - return value; } @@ -80,7 +80,7 @@ inline Type readUnaligned (const void* srcPtr) noexcept template inline void writeUnaligned (void* dstPtr, Type value) noexcept { - memcpy (dstPtr, &value, sizeof(Type)); + memcpy (dstPtr, &value, sizeof (Type)); } //============================================================================== @@ -140,3 +140,5 @@ inline void writeUnaligned (void* dstPtr, Type value) noexcept #ifndef juce_UseDebuggingNewOperator #define juce_UseDebuggingNewOperator #endif + +} // namespace juce diff --git a/modules/juce_core/memory/juce_MemoryBlock.cpp b/modules/juce_core/memory/juce_MemoryBlock.cpp index 85d3e20d91..8bf8b76672 100644 --- a/modules/juce_core/memory/juce_MemoryBlock.cpp +++ b/modules/juce_core/memory/juce_MemoryBlock.cpp @@ -20,8 +20,10 @@ ============================================================================== */ -MemoryBlock::MemoryBlock() noexcept - : size (0) +namespace juce +{ + +MemoryBlock::MemoryBlock() noexcept : size (0) { } @@ -405,3 +407,5 @@ bool MemoryBlock::fromBase64Encoding (StringRef s) } } } + +} // namespace juce diff --git a/modules/juce_core/memory/juce_MemoryBlock.h b/modules/juce_core/memory/juce_MemoryBlock.h index ad70739a17..888449a4be 100644 --- a/modules/juce_core/memory/juce_MemoryBlock.h +++ b/modules/juce_core/memory/juce_MemoryBlock.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -256,3 +256,5 @@ private: JUCE_LEAK_DETECTOR (MemoryBlock) }; + +} // namespace juce diff --git a/modules/juce_core/memory/juce_OptionalScopedPointer.h b/modules/juce_core/memory/juce_OptionalScopedPointer.h index 6d6ad66c3e..898c95ca56 100644 --- a/modules/juce_core/memory/juce_OptionalScopedPointer.h +++ b/modules/juce_core/memory/juce_OptionalScopedPointer.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -180,3 +180,5 @@ private: // myPointer.setOwned (myScopedPointer.release()) void setOwned (const ScopedPointer&) JUCE_DELETED_FUNCTION; }; + +} // namespace juce diff --git a/modules/juce_core/memory/juce_ReferenceCountedObject.h b/modules/juce_core/memory/juce_ReferenceCountedObject.h index ba4b893c61..052e136dc3 100644 --- a/modules/juce_core/memory/juce_ReferenceCountedObject.h +++ b/modules/juce_core/memory/juce_ReferenceCountedObject.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -407,3 +407,5 @@ bool operator!= (ReferenceCountedObjectClass* object1, const ReferenceCountedObj { return object1 != object2.get(); } + +} // namespace juce diff --git a/modules/juce_core/memory/juce_ScopedPointer.h b/modules/juce_core/memory/juce_ScopedPointer.h index d0c5cee701..8c7499ec8a 100644 --- a/modules/juce_core/memory/juce_ScopedPointer.h +++ b/modules/juce_core/memory/juce_ScopedPointer.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -249,3 +250,5 @@ template void deleteAndZero (ScopedPointer&) { static_assert (sizeof (Type) == 12345, "Attempt to call deleteAndZero() on a ScopedPointer"); } #endif + +} // namespace juce diff --git a/modules/juce_core/memory/juce_SharedResourcePointer.h b/modules/juce_core/memory/juce_SharedResourcePointer.h index 181f93fc6f..89de47a64b 100644 --- a/modules/juce_core/memory/juce_SharedResourcePointer.h +++ b/modules/juce_core/memory/juce_SharedResourcePointer.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -158,3 +158,5 @@ private: JUCE_LEAK_DETECTOR (SharedResourcePointer) }; + +} // namespace juce diff --git a/modules/juce_core/memory/juce_Singleton.h b/modules/juce_core/memory/juce_Singleton.h index 9bcaa34eb5..e9567e4615 100644 --- a/modules/juce_core/memory/juce_Singleton.h +++ b/modules/juce_core/memory/juce_Singleton.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -279,3 +279,5 @@ #define juce_ImplementSingleton_SingleThreaded(classname) \ \ classname* classname::_singletonInstance = nullptr; + +} // namespace juce diff --git a/modules/juce_core/memory/juce_WeakReference.h b/modules/juce_core/memory/juce_WeakReference.h index 1751cecc72..c743fc6c9b 100644 --- a/modules/juce_core/memory/juce_WeakReference.h +++ b/modules/juce_core/memory/juce_WeakReference.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -201,3 +201,5 @@ private: return (o != nullptr) ? o->masterReference.getSharedPointer (o) : nullptr; } }; + +} // namespace juce diff --git a/modules/juce_core/misc/juce_Result.cpp b/modules/juce_core/misc/juce_Result.cpp index 678af8747c..f94e0f2688 100644 --- a/modules/juce_core/misc/juce_Result.cpp +++ b/modules/juce_core/misc/juce_Result.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + Result::Result() noexcept {} Result::Result (const String& message) noexcept @@ -73,3 +76,5 @@ bool Result::wasOk() const noexcept { return errorMessage.isEmpty(); } Result::operator bool() const noexcept { return errorMessage.isEmpty(); } bool Result::failed() const noexcept { return errorMessage.isNotEmpty(); } bool Result::operator!() const noexcept { return errorMessage.isNotEmpty(); } + +} // namespace juce diff --git a/modules/juce_core/misc/juce_Result.h b/modules/juce_core/misc/juce_Result.h index 0eda20c38c..5f08bfc4d6 100644 --- a/modules/juce_core/misc/juce_Result.h +++ b/modules/juce_core/misc/juce_Result.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -110,3 +110,5 @@ private: operator int() const; operator void*() const; }; + +} // namespace juce diff --git a/modules/juce_core/misc/juce_RuntimePermissions.cpp b/modules/juce_core/misc/juce_RuntimePermissions.cpp index e15a071935..bf7306b554 100644 --- a/modules/juce_core/misc/juce_RuntimePermissions.cpp +++ b/modules/juce_core/misc/juce_RuntimePermissions.cpp @@ -20,23 +20,17 @@ ============================================================================== */ +namespace juce +{ + #if ! JUCE_ANDROID // We currently don't request runtime permissions on any other platform // than Android, so this file contains a dummy implementation for those. // This may change in the future. -void RuntimePermissions::request (PermissionID /*permission*/, Callback callback) -{ - callback (true); -} - -bool RuntimePermissions::isRequired (PermissionID /*permission*/) -{ - return false; -} - -bool RuntimePermissions::isGranted (PermissionID /*permission*/) -{ - return true; -} +void RuntimePermissions::request (PermissionID, Callback callback) { callback (true); } +bool RuntimePermissions::isRequired (PermissionID) { return false; } +bool RuntimePermissions::isGranted (PermissionID) { return true; } #endif + +} // namespace juce diff --git a/modules/juce_core/misc/juce_RuntimePermissions.h b/modules/juce_core/misc/juce_RuntimePermissions.h index bb170eea33..4de84c678f 100644 --- a/modules/juce_core/misc/juce_RuntimePermissions.h +++ b/modules/juce_core/misc/juce_RuntimePermissions.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -121,3 +122,5 @@ public: */ static bool isGranted (PermissionID permission); }; + +} // namespace juce diff --git a/modules/juce_core/misc/juce_StdFunctionCompat.cpp b/modules/juce_core/misc/juce_StdFunctionCompat.cpp index ec56e2255e..93bcf5c602 100644 --- a/modules/juce_core/misc/juce_StdFunctionCompat.cpp +++ b/modules/juce_core/misc/juce_StdFunctionCompat.cpp @@ -28,6 +28,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_UNIT_TESTS namespace FunctionTestsHelpers @@ -252,3 +255,5 @@ public: static FunctionTests functionTests; #endif + +} // namespace juce diff --git a/modules/juce_core/misc/juce_StdFunctionCompat.h b/modules/juce_core/misc/juce_StdFunctionCompat.h index f1b262b760..3d5381a461 100644 --- a/modules/juce_core/misc/juce_StdFunctionCompat.h +++ b/modules/juce_core/misc/juce_StdFunctionCompat.h @@ -28,8 +28,6 @@ ============================================================================== */ -#pragma once - namespace std { /** diff --git a/modules/juce_core/misc/juce_Uuid.cpp b/modules/juce_core/misc/juce_Uuid.cpp index 03f911cbf2..807031d02b 100644 --- a/modules/juce_core/misc/juce_Uuid.cpp +++ b/modules/juce_core/misc/juce_Uuid.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + Uuid::Uuid() { Random r; @@ -130,3 +133,5 @@ uint16 Uuid::getTimeHighAndVersion() const noexcept { return ByteOrder::bi uint8 Uuid::getClockSeqAndReserved() const noexcept { return uuid[8]; } uint8 Uuid::getClockSeqLow() const noexcept { return uuid[9]; } uint64 Uuid::getNode() const noexcept { return (((uint64) ByteOrder::bigEndianShort (uuid + 10)) << 32) + ByteOrder::bigEndianInt (uuid + 12); } + +} // namespace juce diff --git a/modules/juce_core/misc/juce_Uuid.h b/modules/juce_core/misc/juce_Uuid.h index cab55d8dc7..5eee6d67cc 100644 --- a/modules/juce_core/misc/juce_Uuid.h +++ b/modules/juce_core/misc/juce_Uuid.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -128,3 +128,5 @@ private: JUCE_LEAK_DETECTOR (Uuid) }; + +} // namespace juce diff --git a/modules/juce_core/misc/juce_WindowsRegistry.h b/modules/juce_core/misc/juce_WindowsRegistry.h index 239849cc74..1c49ac32ae 100644 --- a/modules/juce_core/misc/juce_WindowsRegistry.h +++ b/modules/juce_core/misc/juce_WindowsRegistry.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ #if JUCE_WINDOWS || DOXYGEN @@ -131,3 +132,5 @@ private: }; #endif + +} // namespace juce diff --git a/modules/juce_core/native/juce_android_Files.cpp b/modules/juce_core/native/juce_android_Files.cpp index 41f8ec5f66..5c0de20908 100644 --- a/modules/juce_core/native/juce_android_Files.cpp +++ b/modules/juce_core/native/juce_android_Files.cpp @@ -20,7 +20,9 @@ ============================================================================== */ -//============================================================================== +namespace juce +{ + #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ METHOD (constructor, "", "(Landroid/content/Context;Landroid/media/MediaScannerConnection$MediaScannerConnectionClient;)V") \ METHOD (connect, "connect", "()V") \ @@ -190,3 +192,5 @@ void FileOutputStream::flushInternal() new SingleMediaScanner (file.getFullPathName()); } } + +} // namespace juce diff --git a/modules/juce_core/native/juce_android_JNIHelpers.h b/modules/juce_core/native/juce_android_JNIHelpers.h index 1b5b100ea8..ceb8dc3948 100644 --- a/modules/juce_core/native/juce_android_JNIHelpers.h +++ b/modules/juce_core/native/juce_android_JNIHelpers.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ #if ! (defined (JUCE_ANDROID_ACTIVITY_CLASSNAME) && defined (JUCE_ANDROID_ACTIVITY_CLASSPATH)) #error "The JUCE_ANDROID_ACTIVITY_CLASSNAME and JUCE_ANDROID_ACTIVITY_CLASSPATH macros must be set!" @@ -429,3 +430,5 @@ LocalRef CreateJavaInterface (AndroidInterfaceImplementer* implementer, const StringArray& interfaceNames); LocalRef CreateJavaInterface (AndroidInterfaceImplementer* implementer, const String& interfaceName); + +} // namespace juce diff --git a/modules/juce_core/native/juce_android_Misc.cpp b/modules/juce_core/native/juce_android_Misc.cpp index 4a0f8189f7..8ad39bed56 100644 --- a/modules/juce_core/native/juce_android_Misc.cpp +++ b/modules/juce_core/native/juce_android_Misc.cpp @@ -20,7 +20,12 @@ ============================================================================== */ +namespace juce +{ + void Logger::outputDebugString (const String& text) { __android_log_print (ANDROID_LOG_INFO, "JUCE", "%s", text.toUTF8().getAddress()); } + +} // namespace juce diff --git a/modules/juce_core/native/juce_android_Network.cpp b/modules/juce_core/native/juce_android_Network.cpp index 4189766e4d..136ce47de3 100644 --- a/modules/juce_core/native/juce_android_Network.cpp +++ b/modules/juce_core/native/juce_android_Network.cpp @@ -20,7 +20,9 @@ ============================================================================== */ -//============================================================================== +namespace juce +{ + #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ METHOD (constructor, "", "()V") \ METHOD (toString, "toString", "()Ljava/lang/String;") \ @@ -298,3 +300,5 @@ void IPAddress::findAllAddresses (Array& result, bool /*includeIPv6*/ ::close (sock); } } + +} // namespace juce diff --git a/modules/juce_core/native/juce_android_RuntimePermissions.cpp b/modules/juce_core/native/juce_android_RuntimePermissions.cpp index 155cffc746..6158271d64 100644 --- a/modules/juce_core/native/juce_android_RuntimePermissions.cpp +++ b/modules/juce_core/native/juce_android_RuntimePermissions.cpp @@ -20,27 +20,27 @@ ============================================================================== */ -namespace +namespace juce { - void handleAndroidCallback (bool permissionWasGranted, RuntimePermissions::Callback* callbackPtr) + +static void handleAndroidCallback (bool permissionWasGranted, RuntimePermissions::Callback* callbackPtr) +{ + if (callbackPtr == nullptr) { - if (callbackPtr == nullptr) - { - // got a nullptr passed in from java! this should never happen... - jassertfalse; - return; - } + // got a nullptr passed in from java! this should never happen... + jassertfalse; + return; + } - std::unique_ptr uptr (callbackPtr); + std::unique_ptr uptr (callbackPtr); - if (RuntimePermissions::Callback callbackObj = *uptr) - callbackObj (permissionWasGranted); - } + if (RuntimePermissions::Callback callbackObj = *uptr) + callbackObj (permissionWasGranted); } JUCE_JNI_CALLBACK (JUCE_ANDROID_ACTIVITY_CLASSNAME, androidRuntimePermissionsCallback, - void, (JNIEnv* env, jobject /*javaObjectHandle*/, jboolean permissionsGranted, jlong callbackPtr)) + void, (JNIEnv* env, jobject, jboolean permissionsGranted, jlong callbackPtr)) { setEnv (env); handleAndroidCallback (permissionsGranted != 0, @@ -84,3 +84,5 @@ bool RuntimePermissions::isGranted (PermissionID permission) { return android.activity.callBooleanMethod (JuceAppActivity.isPermissionGranted, permission); } + +} // namespace juce diff --git a/modules/juce_core/native/juce_android_SystemStats.cpp b/modules/juce_core/native/juce_android_SystemStats.cpp index 762ce02f48..00d0c44c64 100644 --- a/modules/juce_core/native/juce_android_SystemStats.cpp +++ b/modules/juce_core/native/juce_android_SystemStats.cpp @@ -20,7 +20,9 @@ ============================================================================== */ -//============================================================================== +namespace juce +{ + #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ STATICMETHOD (newProxyInstance, "newProxyInstance", "(Ljava/lang/ClassLoader;[Ljava/lang/Class;Ljava/lang/reflect/InvocationHandler;)Ljava/lang/Object;") \ @@ -514,3 +516,5 @@ bool Time::setSystemTimeToThisTime() const jassertfalse; return false; } + +} // namespace juce diff --git a/modules/juce_core/native/juce_android_Threads.cpp b/modules/juce_core/native/juce_android_Threads.cpp index 7a526e4503..be8780d232 100644 --- a/modules/juce_core/native/juce_android_Threads.cpp +++ b/modules/juce_core/native/juce_android_Threads.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + /* Note that a lot of methods that you'd expect to find in this file actually live in juce_posix_SharedCode.h! @@ -70,3 +73,5 @@ JUCE_API bool JUCE_CALLTYPE juce_isRunningUnderDebugger() noexcept JUCE_API void JUCE_CALLTYPE Process::raisePrivilege() {} JUCE_API void JUCE_CALLTYPE Process::lowerPrivilege() {} + +} // namespace juce diff --git a/modules/juce_core/native/juce_curl_Network.cpp b/modules/juce_core/native/juce_curl_Network.cpp index 9c14f69848..8781712c18 100644 --- a/modules/juce_core/native/juce_curl_Network.cpp +++ b/modules/juce_core/native/juce_curl_Network.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + class WebInputStream::Pimpl { public: @@ -552,3 +555,5 @@ URL::DownloadTask* URL::downloadToFile (const File& targetLocation, String extra { return URL::DownloadTask::createFallbackDownloader (*this, targetLocation, extraHeaders, listener, shouldUsePost); } + +} // namespace juce diff --git a/modules/juce_core/native/juce_linux_CommonFile.cpp b/modules/juce_core/native/juce_linux_CommonFile.cpp index 1166bd7b7a..c22f64f779 100644 --- a/modules/juce_core/native/juce_linux_CommonFile.cpp +++ b/modules/juce_core/native/juce_linux_CommonFile.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + bool File::copyInternal (const File& dest) const { FileInputStream in (*this); @@ -145,3 +148,5 @@ bool DirectoryIterator::NativeIterator::next (String& filenameFound, { return pimpl->next (filenameFound, isDir, isHidden, fileSize, modTime, creationTime, isReadOnly); } + +} // namespace juce diff --git a/modules/juce_core/native/juce_linux_Files.cpp b/modules/juce_core/native/juce_linux_Files.cpp index 1867cb770d..5e34d6a717 100644 --- a/modules/juce_core/native/juce_linux_Files.cpp +++ b/modules/juce_core/native/juce_linux_Files.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + enum { U_ISOFS_SUPER_MAGIC = 0x9660, // linux/iso_fs.h @@ -229,3 +232,5 @@ void File::revealToUser() const else if (getParentDirectory().exists()) getParentDirectory().startAsProcess(); } + +} // namespace juce diff --git a/modules/juce_core/native/juce_linux_Network.cpp b/modules/juce_core/native/juce_linux_Network.cpp index c2965a323e..2ca8d51200 100644 --- a/modules/juce_core/native/juce_linux_Network.cpp +++ b/modules/juce_core/native/juce_linux_Network.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + void MACAddress::findAllAddresses (Array& result) { const int s = socket (AF_INET, SOCK_DGRAM, 0); @@ -578,3 +581,5 @@ URL::DownloadTask* URL::downloadToFile (const File& targetLocation, String extra return URL::DownloadTask::createFallbackDownloader (*this, targetLocation, extraHeaders, listener, shouldUsePost); } #endif + +} // namespace juce diff --git a/modules/juce_core/native/juce_linux_SystemStats.cpp b/modules/juce_core/native/juce_linux_SystemStats.cpp index 4b8f4bdfb9..40f19187fc 100644 --- a/modules/juce_core/native/juce_linux_SystemStats.cpp +++ b/modules/juce_core/native/juce_linux_SystemStats.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + void Logger::outputDebugString (const String& text) { std::cerr << text << std::endl; @@ -199,3 +202,5 @@ JUCE_API bool JUCE_CALLTYPE juce_isRunningUnderDebugger() noexcept .getIntValue() > 0; #endif } + +} // namespace juce diff --git a/modules/juce_core/native/juce_linux_Threads.cpp b/modules/juce_core/native/juce_linux_Threads.cpp index d293a76e03..144fa05d95 100644 --- a/modules/juce_core/native/juce_linux_Threads.cpp +++ b/modules/juce_core/native/juce_linux_Threads.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + /* Note that a lot of methods that you'd expect to find in this file actually live in juce_posix_SharedCode.h! @@ -55,3 +58,5 @@ static bool swapUserAndEffectiveUser() JUCE_API void JUCE_CALLTYPE Process::raisePrivilege() { if (geteuid() != 0 && getuid() == 0) swapUserAndEffectiveUser(); } JUCE_API void JUCE_CALLTYPE Process::lowerPrivilege() { if (geteuid() == 0 && getuid() != 0) swapUserAndEffectiveUser(); } + +} // namespace juce diff --git a/modules/juce_core/native/juce_mac_Files.mm b/modules/juce_core/native/juce_mac_Files.mm index 85ca9a39b3..845cec0a6c 100644 --- a/modules/juce_core/native/juce_mac_Files.mm +++ b/modules/juce_core/native/juce_mac_Files.mm @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + /* Note that a lot of methods that you'd expect to find in this file actually live in juce_posix_SharedCode.h! @@ -488,3 +491,5 @@ void File::addToDock() const } } #endif + +} // namespace juce diff --git a/modules/juce_core/native/juce_mac_Network.mm b/modules/juce_core/native/juce_mac_Network.mm index 6410a8b223..f182a42b52 100644 --- a/modules/juce_core/native/juce_mac_Network.mm +++ b/modules/juce_core/native/juce_mac_Network.mm @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + void MACAddress::findAllAddresses (Array& result) { ifaddrs* addrs = nullptr; @@ -1119,3 +1122,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Pimpl) }; + +} // namespace juce diff --git a/modules/juce_core/native/juce_mac_Strings.mm b/modules/juce_core/native/juce_mac_Strings.mm index e8996ba5e0..b8a479ead8 100644 --- a/modules/juce_core/native/juce_mac_Strings.mm +++ b/modules/juce_core/native/juce_mac_Strings.mm @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + String String::fromCFString (CFStringRef cfString) { if (cfString == 0) @@ -98,3 +101,5 @@ String String::convertToPrecomposedUnicode() const return result; #endif } + +} // namespace juce diff --git a/modules/juce_core/native/juce_mac_SystemStats.mm b/modules/juce_core/native/juce_mac_SystemStats.mm index a3f97d208f..81f62192ec 100644 --- a/modules/juce_core/native/juce_mac_SystemStats.mm +++ b/modules/juce_core/native/juce_mac_SystemStats.mm @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + ScopedAutoReleasePool::ScopedAutoReleasePool() { pool = [[NSAutoreleasePool alloc] init]; @@ -313,3 +316,5 @@ int SystemStats::getPageSize() { return (int) NSPageSize(); } + +} // namespace juce diff --git a/modules/juce_core/native/juce_mac_Threads.mm b/modules/juce_core/native/juce_mac_Threads.mm index a02403e178..8ac6c0ed52 100644 --- a/modules/juce_core/native/juce_mac_Threads.mm +++ b/modules/juce_core/native/juce_mac_Threads.mm @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + /* Note that a lot of methods that you'd expect to find in this file actually live in juce_posix_SharedCode.h! @@ -82,3 +85,5 @@ JUCE_API bool JUCE_CALLTYPE juce_isRunningUnderDebugger() noexcept sysctl (m, 4, &info, &sz, 0, 0); return (info.kp_proc.p_flag & P_TRACED) != 0; } + +} // namespace juce diff --git a/modules/juce_core/native/juce_osx_ObjCHelpers.h b/modules/juce_core/native/juce_osx_ObjCHelpers.h index 760803edfc..b335287cbe 100644 --- a/modules/juce_core/native/juce_osx_ObjCHelpers.h +++ b/modules/juce_core/native/juce_osx_ObjCHelpers.h @@ -20,92 +20,89 @@ ============================================================================== */ -#pragma once - - /* This file contains a few helper functions that are used internally but which need to be kept away from the public headers because they use obj-C symbols. */ -namespace +namespace juce { - //============================================================================== - static inline String nsStringToJuce (NSString* s) - { - return CharPointer_UTF8 ([s UTF8String]); - } - - static inline NSString* juceStringToNS (const String& s) - { - return [NSString stringWithUTF8String: s.toUTF8()]; - } - static inline NSString* nsStringLiteral (const char* const s) noexcept - { - return [NSString stringWithUTF8String: s]; - } +//============================================================================== +static inline String nsStringToJuce (NSString* s) +{ + return CharPointer_UTF8 ([s UTF8String]); +} - static inline NSString* nsEmptyString() noexcept - { - return [NSString string]; - } +static inline NSString* juceStringToNS (const String& s) +{ + return [NSString stringWithUTF8String: s.toUTF8()]; +} - static inline NSURL* createNSURLFromFile (const String& f) - { - return [NSURL fileURLWithPath: juceStringToNS (f)]; - } +static inline NSString* nsStringLiteral (const char* const s) noexcept +{ + return [NSString stringWithUTF8String: s]; +} - static inline NSURL* createNSURLFromFile (const File& f) - { - return createNSURLFromFile (f.getFullPathName()); - } +static inline NSString* nsEmptyString() noexcept +{ + return [NSString string]; +} - static inline NSArray* createNSArrayFromStringArray (const StringArray& strings) - { - auto* array = [[NSMutableArray alloc] init]; +static inline NSURL* createNSURLFromFile (const String& f) +{ + return [NSURL fileURLWithPath: juceStringToNS (f)]; +} - for (auto string: strings) - [array addObject:juceStringToNS (string)]; +static inline NSURL* createNSURLFromFile (const File& f) +{ + return createNSURLFromFile (f.getFullPathName()); +} - return [array autorelease]; - } +static inline NSArray* createNSArrayFromStringArray (const StringArray& strings) +{ + auto* array = [[NSMutableArray alloc] init]; - #if JUCE_MAC - template - static NSRect makeNSRect (const RectangleType& r) noexcept - { - return NSMakeRect (static_cast (r.getX()), - static_cast (r.getY()), - static_cast (r.getWidth()), - static_cast (r.getHeight())); - } - #endif - #if JUCE_MAC || JUCE_IOS - #if JUCE_COMPILER_SUPPORTS_VARIADIC_TEMPLATES - - // This is necessary as on iOS builds, some arguments may be passed on registers - // depending on the argument type. The re-cast objc_msgSendSuper to a function - // take the same arguments as the target method. - template - static inline ReturnValue ObjCMsgSendSuper (struct objc_super* s, SEL sel, Params... params) - { - typedef ReturnValue (*SuperFn)(struct objc_super*, SEL, Params...); - SuperFn fn = reinterpret_cast (objc_msgSendSuper); - return fn (s, sel, params...); - } + for (auto string: strings) + [array addObject:juceStringToNS (string)]; - #endif + return [array autorelease]; +} - // These hacks are a workaround for newer Xcode builds which by default prevent calls to these objc functions.. - typedef id (*MsgSendSuperFn) (struct objc_super*, SEL, ...); - static inline MsgSendSuperFn getMsgSendSuperFn() noexcept { return (MsgSendSuperFn) (void*) objc_msgSendSuper; } +#if JUCE_MAC +template +static NSRect makeNSRect (const RectangleType& r) noexcept +{ + return NSMakeRect (static_cast (r.getX()), + static_cast (r.getY()), + static_cast (r.getWidth()), + static_cast (r.getHeight())); +} +#endif +#if JUCE_MAC || JUCE_IOS +#if JUCE_COMPILER_SUPPORTS_VARIADIC_TEMPLATES - #if ! JUCE_IOS - typedef double (*MsgSendFPRetFn) (id, SEL op, ...); - static inline MsgSendFPRetFn getMsgSendFPRetFn() noexcept { return (MsgSendFPRetFn) (void*) objc_msgSend_fpret; } - #endif - #endif +// This is necessary as on iOS builds, some arguments may be passed on registers +// depending on the argument type. The re-cast objc_msgSendSuper to a function +// take the same arguments as the target method. +template +static inline ReturnValue ObjCMsgSendSuper (struct objc_super* s, SEL sel, Params... params) +{ + typedef ReturnValue (*SuperFn)(struct objc_super*, SEL, Params...); + SuperFn fn = reinterpret_cast (objc_msgSendSuper); + return fn (s, sel, params...); } +#endif + +// These hacks are a workaround for newer Xcode builds which by default prevent calls to these objc functions.. +typedef id (*MsgSendSuperFn) (struct objc_super*, SEL, ...); +static inline MsgSendSuperFn getMsgSendSuperFn() noexcept { return (MsgSendSuperFn) (void*) objc_msgSendSuper; } + +#if ! JUCE_IOS +typedef double (*MsgSendFPRetFn) (id, SEL op, ...); +static inline MsgSendFPRetFn getMsgSendFPRetFn() noexcept { return (MsgSendFPRetFn) (void*) objc_msgSend_fpret; } +#endif +#endif + //============================================================================== template struct NSObjectRetainer @@ -236,3 +233,5 @@ private: }; #endif + +} // namespace juce diff --git a/modules/juce_core/native/juce_posix_NamedPipe.cpp b/modules/juce_core/native/juce_posix_NamedPipe.cpp index 80bfa2e703..be948ffd4f 100644 --- a/modules/juce_core/native/juce_posix_NamedPipe.cpp +++ b/modules/juce_core/native/juce_posix_NamedPipe.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + class NamedPipe::Pimpl { public: @@ -226,3 +229,5 @@ int NamedPipe::write (const void* sourceBuffer, int numBytesToWrite, int timeOut ScopedReadLock sl (lock); return pimpl != nullptr ? pimpl->write (static_cast (sourceBuffer), numBytesToWrite, timeOutMilliseconds) : -1; } + +} // namespace juce diff --git a/modules/juce_core/native/juce_posix_SharedCode.h b/modules/juce_core/native/juce_posix_SharedCode.h index 2e6d75547b..dc81366ad9 100644 --- a/modules/juce_core/native/juce_posix_SharedCode.h +++ b/modules/juce_core/native/juce_posix_SharedCode.h @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + CriticalSection::CriticalSection() noexcept { pthread_mutexattr_t atts; @@ -1497,3 +1500,5 @@ private: JUCE_DECLARE_NON_COPYABLE (Pimpl) }; + +} // namespace juce diff --git a/modules/juce_core/native/juce_win32_ComSmartPtr.h b/modules/juce_core/native/juce_win32_ComSmartPtr.h index 09bfd5b7b5..0a6511c4c8 100644 --- a/modules/juce_core/native/juce_win32_ComSmartPtr.h +++ b/modules/juce_core/native/juce_win32_ComSmartPtr.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ #if JUCE_MINGW || (! (defined (_MSC_VER) || defined (__uuidof))) #ifdef __uuidof @@ -189,3 +190,5 @@ public: return ComBaseClassHelperBase::QueryInterface (refId, result); } }; + +} // namespace juce diff --git a/modules/juce_core/native/juce_win32_Files.cpp b/modules/juce_core/native/juce_win32_Files.cpp index 07641d558f..6534ba6a6a 100644 --- a/modules/juce_core/native/juce_win32_Files.cpp +++ b/modules/juce_core/native/juce_win32_Files.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + #ifndef INVALID_FILE_ATTRIBUTES #define INVALID_FILE_ATTRIBUTES ((DWORD) -1) #endif @@ -1071,3 +1074,5 @@ int NamedPipe::write (const void* sourceBuffer, int numBytesToWrite, int timeOut ScopedReadLock sl (lock); return pimpl != nullptr ? pimpl->write (sourceBuffer, numBytesToWrite, timeOutMilliseconds) : -1; } + +} // namespace juce diff --git a/modules/juce_core/native/juce_win32_Network.cpp b/modules/juce_core/native/juce_win32_Network.cpp index 42f17d9db2..21da41aba4 100644 --- a/modules/juce_core/native/juce_win32_Network.cpp +++ b/modules/juce_core/native/juce_win32_Network.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + #ifndef INTERNET_FLAG_NEED_FILE #define INTERNET_FLAG_NEED_FILE 0x00000010 #endif @@ -655,3 +658,5 @@ URL::DownloadTask* URL::downloadToFile (const File& targetLocation, String extra { return URL::DownloadTask::createFallbackDownloader (*this, targetLocation, extraHeaders, listener, shouldUsePost); } + +} // namespace juce diff --git a/modules/juce_core/native/juce_win32_Registry.cpp b/modules/juce_core/native/juce_win32_Registry.cpp index 91b2c12570..e1b5f5b814 100644 --- a/modules/juce_core/native/juce_win32_Registry.cpp +++ b/modules/juce_core/native/juce_win32_Registry.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + struct RegistryKeyWrapper { RegistryKeyWrapper (String name, bool createForWriting, DWORD wow64Flags) @@ -244,3 +247,5 @@ bool JUCE_CALLTYPE WindowsRegistry::registerFileAssociation (const String& fileE String WindowsRegistry::getValueWow64 (const String& p, const String& defVal) { return getValue (p, defVal, WoW64_64bit); } bool WindowsRegistry::valueExistsWow64 (const String& p) { return valueExists (p, WoW64_64bit); } bool WindowsRegistry::keyExistsWow64 (const String& p) { return keyExists (p, WoW64_64bit); } + +} // namespace juce diff --git a/modules/juce_core/native/juce_win32_SystemStats.cpp b/modules/juce_core/native/juce_win32_SystemStats.cpp index b2ff9e9450..3f28dded45 100644 --- a/modules/juce_core/native/juce_win32_SystemStats.cpp +++ b/modules/juce_core/native/juce_win32_SystemStats.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + #if ! JUCE_MINGW #pragma intrinsic (__cpuid) #pragma intrinsic (__rdtsc) @@ -479,3 +482,5 @@ String SystemStats::getDisplayLanguage() return mainLang; } + +} // namespace juce diff --git a/modules/juce_core/native/juce_win32_Threads.cpp b/modules/juce_core/native/juce_win32_Threads.cpp index 68d891f6d9..62c7b76643 100644 --- a/modules/juce_core/native/juce_win32_Threads.cpp +++ b/modules/juce_core/native/juce_win32_Threads.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + HWND juce_messageWindowHandle = 0; // (this is used by other parts of the codebase) void* getUser32Function (const char* functionName) @@ -529,7 +532,7 @@ bool ChildProcess::start (const StringArray& args, int streamFlags) //============================================================================== struct HighResolutionTimer::Pimpl { - Pimpl (HighResolutionTimer& t) noexcept : owner (t), periodMs (0) + Pimpl (HighResolutionTimer& t) noexcept : owner (t) { } @@ -563,7 +566,7 @@ struct HighResolutionTimer::Pimpl } HighResolutionTimer& owner; - int periodMs; + int periodMs = 0; private: unsigned int timerID; @@ -577,3 +580,5 @@ private: JUCE_DECLARE_NON_COPYABLE (Pimpl) }; + +} // namespace juce diff --git a/modules/juce_core/network/juce_IPAddress.cpp b/modules/juce_core/network/juce_IPAddress.cpp index 92c68bab66..2b38499faa 100644 --- a/modules/juce_core/network/juce_IPAddress.cpp +++ b/modules/juce_core/network/juce_IPAddress.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + IPAddress::IPAddress (bool IPv6) noexcept : isIPv6 (IPv6) { for (int i = 0; i < 16; ++i) @@ -296,3 +299,5 @@ void IPAddress::findAllAddresses (Array& result, bool includeIPv6) freeifaddrs (ifaddr); } #endif + +} // namespace juce diff --git a/modules/juce_core/network/juce_IPAddress.h b/modules/juce_core/network/juce_IPAddress.h index a450ff7d18..ac29e0c41a 100644 --- a/modules/juce_core/network/juce_IPAddress.h +++ b/modules/juce_core/network/juce_IPAddress.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -108,3 +108,5 @@ private: address[i] = 0; } }; + +} // namespace juce diff --git a/modules/juce_core/network/juce_MACAddress.cpp b/modules/juce_core/network/juce_MACAddress.cpp index 62b0e24eac..a2c7e1fb55 100644 --- a/modules/juce_core/network/juce_MACAddress.cpp +++ b/modules/juce_core/network/juce_MACAddress.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + MACAddress::MACAddress() noexcept { zeromem (address, sizeof (address)); @@ -86,3 +89,5 @@ bool MACAddress::isNull() const noexcept { return bool MACAddress::operator== (const MACAddress& other) const noexcept { return memcmp (address, other.address, sizeof (address)) == 0; } bool MACAddress::operator!= (const MACAddress& other) const noexcept { return ! operator== (other); } + +} // namespace juce diff --git a/modules/juce_core/network/juce_MACAddress.h b/modules/juce_core/network/juce_MACAddress.h index 7a709b01cb..45a5a1a04a 100644 --- a/modules/juce_core/network/juce_MACAddress.h +++ b/modules/juce_core/network/juce_MACAddress.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -79,3 +79,5 @@ public: private: uint8 address[6]; }; + +} // namespace juce diff --git a/modules/juce_core/network/juce_NamedPipe.cpp b/modules/juce_core/network/juce_NamedPipe.cpp index 434fdb6063..8d493488f0 100644 --- a/modules/juce_core/network/juce_NamedPipe.cpp +++ b/modules/juce_core/network/juce_NamedPipe.cpp @@ -20,9 +20,10 @@ ============================================================================== */ -NamedPipe::NamedPipe() +namespace juce { -} + +NamedPipe::NamedPipe() {} NamedPipe::~NamedPipe() { @@ -58,3 +59,5 @@ String NamedPipe::getName() const } // other methods for this class are implemented in the platform-specific files + +} // namespace juce diff --git a/modules/juce_core/network/juce_NamedPipe.h b/modules/juce_core/network/juce_NamedPipe.h index af09f49000..8ae0482086 100644 --- a/modules/juce_core/network/juce_NamedPipe.h +++ b/modules/juce_core/network/juce_NamedPipe.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -94,3 +94,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (NamedPipe) }; + +} // namespace juce diff --git a/modules/juce_core/network/juce_Socket.cpp b/modules/juce_core/network/juce_Socket.cpp index 64288abcea..f850bad50f 100644 --- a/modules/juce_core/network/juce_Socket.cpp +++ b/modules/juce_core/network/juce_Socket.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_MSVC #pragma warning (push) #pragma warning (disable : 4127 4389 4018) @@ -770,3 +773,5 @@ bool DatagramSocket::setEnablePortReuse (bool enabled) #if JUCE_MSVC #pragma warning (pop) #endif + +} // namespace juce diff --git a/modules/juce_core/network/juce_Socket.h b/modules/juce_core/network/juce_Socket.h index 8c586f9f38..6a6b7b5982 100644 --- a/modules/juce_core/network/juce_Socket.h +++ b/modules/juce_core/network/juce_Socket.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -349,3 +349,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DatagramSocket) }; + +} // namespace juce diff --git a/modules/juce_core/network/juce_URL.cpp b/modules/juce_core/network/juce_URL.cpp index 9505dd89b6..402aa62989 100644 --- a/modules/juce_core/network/juce_URL.cpp +++ b/modules/juce_core/network/juce_URL.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + struct FallbackDownloadTask : public URL::DownloadTask, public Thread { @@ -661,3 +664,5 @@ bool URL::launchInDefaultBrowser() const return Process::openDocument (u, String()); } + +} // namespace juce diff --git a/modules/juce_core/network/juce_URL.h b/modules/juce_core/network/juce_URL.h index b2a3f592c8..fa2169ddf8 100644 --- a/modules/juce_core/network/juce_URL.h +++ b/modules/juce_core/network/juce_URL.h @@ -20,9 +20,11 @@ ============================================================================== */ -#pragma once +namespace juce +{ class WebInputStream; + //============================================================================== /** Represents a URL and has a bunch of useful functions to manipulate it. @@ -516,3 +518,5 @@ private: JUCE_LEAK_DETECTOR (URL) }; + +} // namespace juce diff --git a/modules/juce_core/network/juce_WebInputStream.cpp b/modules/juce_core/network/juce_WebInputStream.cpp index 4a7aafc1f9..c82b396a8f 100644 --- a/modules/juce_core/network/juce_WebInputStream.cpp +++ b/modules/juce_core/network/juce_WebInputStream.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + WebInputStream::WebInputStream (const URL& url, const bool usePost) : pimpl (new Pimpl (*this, url, usePost)), hasCalledConnect (false) {} @@ -79,3 +82,5 @@ void WebInputStream::createHeadersAndPostData (const URL& aURL, String& headers, { aURL.createHeadersAndPostData (headers, data); } + +} // namespace juce diff --git a/modules/juce_core/network/juce_WebInputStream.h b/modules/juce_core/network/juce_WebInputStream.h index 5d013ea4a4..fe6da1cfbd 100644 --- a/modules/juce_core/network/juce_WebInputStream.h +++ b/modules/juce_core/network/juce_WebInputStream.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -208,3 +209,5 @@ class JUCE_API WebInputStream : public InputStream JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (WebInputStream) }; + +} // namespace juce diff --git a/modules/juce_core/streams/juce_BufferedInputStream.cpp b/modules/juce_core/streams/juce_BufferedInputStream.cpp index b17c526915..8af122a694 100644 --- a/modules/juce_core/streams/juce_BufferedInputStream.cpp +++ b/modules/juce_core/streams/juce_BufferedInputStream.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + static inline int calcBufferStreamBufferSize (int requestedSize, InputStream* source) noexcept { // You need to supply a real stream when creating a BufferedInputStream @@ -180,3 +183,5 @@ String BufferedInputStream::readString() return InputStream::readString(); } + +} // namespace juce diff --git a/modules/juce_core/streams/juce_BufferedInputStream.h b/modules/juce_core/streams/juce_BufferedInputStream.h index 5a51053858..8719b66c5b 100644 --- a/modules/juce_core/streams/juce_BufferedInputStream.h +++ b/modules/juce_core/streams/juce_BufferedInputStream.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** Wraps another input stream, and reads from it using an intermediate buffer @@ -84,3 +84,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (BufferedInputStream) }; + +} // namespace juce diff --git a/modules/juce_core/streams/juce_FileInputSource.cpp b/modules/juce_core/streams/juce_FileInputSource.cpp index ab777793ea..feb4081a8d 100644 --- a/modules/juce_core/streams/juce_FileInputSource.cpp +++ b/modules/juce_core/streams/juce_FileInputSource.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + FileInputSource::FileInputSource (const File& f, bool useFileTimeInHash) : file (f), useFileTimeInHashGeneration (useFileTimeInHash) { @@ -48,3 +51,5 @@ int64 FileInputSource::hashCode() const return h; } + +} // namespace juce diff --git a/modules/juce_core/streams/juce_FileInputSource.h b/modules/juce_core/streams/juce_FileInputSource.h index 00f8bee369..d5f5942132 100644 --- a/modules/juce_core/streams/juce_FileInputSource.h +++ b/modules/juce_core/streams/juce_FileInputSource.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -54,3 +54,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FileInputSource) }; + +} diff --git a/modules/juce_core/streams/juce_InputSource.h b/modules/juce_core/streams/juce_InputSource.h index 14f3d96b49..925cdf30f6 100644 --- a/modules/juce_core/streams/juce_InputSource.h +++ b/modules/juce_core/streams/juce_InputSource.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -66,3 +66,5 @@ private: //============================================================================== JUCE_LEAK_DETECTOR (InputSource) }; + +} // namespace juce diff --git a/modules/juce_core/streams/juce_InputStream.cpp b/modules/juce_core/streams/juce_InputStream.cpp index eb6bc57a7e..a27f5cfc1d 100644 --- a/modules/juce_core/streams/juce_InputStream.cpp +++ b/modules/juce_core/streams/juce_InputStream.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + int64 InputStream::getNumBytesRemaining() { int64 len = getTotalLength(); @@ -227,3 +230,5 @@ void InputStream::skipNextBytes (int64 numBytesToSkip) numBytesToSkip -= read (temp, (int) jmin (numBytesToSkip, (int64) skipBufferSize)); } } + +} // namespace juce diff --git a/modules/juce_core/streams/juce_InputStream.h b/modules/juce_core/streams/juce_InputStream.h index 3db0e9d71c..398615ad85 100644 --- a/modules/juce_core/streams/juce_InputStream.h +++ b/modules/juce_core/streams/juce_InputStream.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** The base class for streams that read data. @@ -255,3 +255,5 @@ protected: private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (InputStream) }; + +} // namespace juce diff --git a/modules/juce_core/streams/juce_MemoryInputStream.cpp b/modules/juce_core/streams/juce_MemoryInputStream.cpp index 3dfb1237c6..041b24ec8c 100644 --- a/modules/juce_core/streams/juce_MemoryInputStream.cpp +++ b/modules/juce_core/streams/juce_MemoryInputStream.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + MemoryInputStream::MemoryInputStream (const void* const sourceData, const size_t sourceDataSize, const bool keepInternalCopy) @@ -156,3 +159,5 @@ public: static MemoryStreamTests memoryInputStreamUnitTests; #endif + +} // namespace juce diff --git a/modules/juce_core/streams/juce_MemoryInputStream.h b/modules/juce_core/streams/juce_MemoryInputStream.h index 3bfa985ac6..86373ca657 100644 --- a/modules/juce_core/streams/juce_MemoryInputStream.h +++ b/modules/juce_core/streams/juce_MemoryInputStream.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -86,3 +86,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MemoryInputStream) }; + +} // namespace juce diff --git a/modules/juce_core/streams/juce_MemoryOutputStream.cpp b/modules/juce_core/streams/juce_MemoryOutputStream.cpp index 57226cb2ae..1b27e05dec 100644 --- a/modules/juce_core/streams/juce_MemoryOutputStream.cpp +++ b/modules/juce_core/streams/juce_MemoryOutputStream.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + MemoryOutputStream::MemoryOutputStream (const size_t initialSize) : blockToUse (&internalBlock), externalData (nullptr), position (0), size (0), availableSize (0) @@ -206,3 +209,5 @@ OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const MemoryOutput return stream; } + +} // namespace juce diff --git a/modules/juce_core/streams/juce_MemoryOutputStream.h b/modules/juce_core/streams/juce_MemoryOutputStream.h index 794d78f86c..6f89c940ce 100644 --- a/modules/juce_core/streams/juce_MemoryOutputStream.h +++ b/modules/juce_core/streams/juce_MemoryOutputStream.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -127,3 +127,5 @@ private: /** Copies all the data that has been written to a MemoryOutputStream into another stream. */ OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const MemoryOutputStream& streamToRead); + +} // namespace juce diff --git a/modules/juce_core/streams/juce_OutputStream.cpp b/modules/juce_core/streams/juce_OutputStream.cpp index a87e5b2fcc..499f532cf7 100644 --- a/modules/juce_core/streams/juce_OutputStream.cpp +++ b/modules/juce_core/streams/juce_OutputStream.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_DEBUG struct DanglingStreamChecker @@ -343,3 +346,5 @@ JUCE_API OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const New { return stream << stream.getNewLineString(); } + +} // namespace juce diff --git a/modules/juce_core/streams/juce_OutputStream.h b/modules/juce_core/streams/juce_OutputStream.h index 2b53107aa5..1ab0a0ce77 100644 --- a/modules/juce_core/streams/juce_OutputStream.h +++ b/modules/juce_core/streams/juce_OutputStream.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -265,3 +265,5 @@ JUCE_API OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, InputStre @see OutputStream::setNewLineString */ JUCE_API OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const NewLine&); + +} // namespace juce diff --git a/modules/juce_core/streams/juce_SubregionStream.cpp b/modules/juce_core/streams/juce_SubregionStream.cpp index 5e74c28945..c7b67900cb 100644 --- a/modules/juce_core/streams/juce_SubregionStream.cpp +++ b/modules/juce_core/streams/juce_SubregionStream.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + SubregionStream::SubregionStream (InputStream* const sourceStream, const int64 start, const int64 length, const bool deleteSourceWhenDestroyed) @@ -74,3 +77,5 @@ bool SubregionStream::isExhausted() return source->isExhausted(); } + +} // namespace juce diff --git a/modules/juce_core/streams/juce_SubregionStream.h b/modules/juce_core/streams/juce_SubregionStream.h index 624d6b8a7f..998a2ccdb1 100644 --- a/modules/juce_core/streams/juce_SubregionStream.h +++ b/modules/juce_core/streams/juce_SubregionStream.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** Wraps another input stream, and reads from a specific part of it. @@ -77,3 +77,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SubregionStream) }; + +} // namespace juce diff --git a/modules/juce_core/system/juce_PlatformDefs.h b/modules/juce_core/system/juce_PlatformDefs.h index d29b492371..32b9323596 100644 --- a/modules/juce_core/system/juce_PlatformDefs.h +++ b/modules/juce_core/system/juce_PlatformDefs.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /* This file defines miscellaneous macros for debugging, assertions, etc. @@ -81,7 +82,7 @@ #if JUCE_CLANG && defined (__has_feature) && ! defined (JUCE_ANALYZER_NORETURN) #if __has_feature (attribute_analyzer_noreturn) inline void __attribute__((analyzer_noreturn)) juce_assert_noreturn() {} - #define JUCE_ANALYZER_NORETURN juce_assert_noreturn(); + #define JUCE_ANALYZER_NORETURN juce::juce_assert_noreturn(); #endif #endif @@ -293,3 +294,5 @@ #else #define JUCE_NO_ASSOCIATIVE_MATH_OPTIMISATIONS #endif + +} // namespace juce diff --git a/modules/juce_core/system/juce_SystemStats.cpp b/modules/juce_core/system/juce_SystemStats.cpp index 7e05277429..c073331b97 100644 --- a/modules/juce_core/system/juce_SystemStats.cpp +++ b/modules/juce_core/system/juce_SystemStats.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + String SystemStats::getJUCEVersion() { // Some basic tests, to keep an eye on things and make sure these types work ok @@ -230,3 +233,5 @@ bool SystemStats::isRunningInAppExtensionSandbox() noexcept return false; #endif } + +} // namespace juce diff --git a/modules/juce_core/system/juce_SystemStats.h b/modules/juce_core/system/juce_SystemStats.h index 4bf4e0e13e..89d3854e33 100644 --- a/modules/juce_core/system/juce_SystemStats.h +++ b/modules/juce_core/system/juce_SystemStats.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -217,3 +217,5 @@ private: JUCE_DECLARE_NON_COPYABLE (SystemStats) }; + +} // namespace juce diff --git a/modules/juce_core/text/juce_Base64.cpp b/modules/juce_core/text/juce_Base64.cpp index bda7c3b669..14bcdeb795 100644 --- a/modules/juce_core/text/juce_Base64.cpp +++ b/modules/juce_core/text/juce_Base64.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + bool Base64::convertToBase64 (OutputStream& base64Result, const void* sourceData, size_t sourceDataSize) { static const char lookup[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; @@ -157,3 +160,5 @@ public: static Base64Tests base64Tests; #endif + +} // namespace juce diff --git a/modules/juce_core/text/juce_Base64.h b/modules/juce_core/text/juce_Base64.h index 169c0e2ebb..c7eafa2212 100644 --- a/modules/juce_core/text/juce_Base64.h +++ b/modules/juce_core/text/juce_Base64.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ /** Contains some static methods for converting between binary and the @@ -47,3 +47,5 @@ struct JUCE_API Base64 /** Converts a string's UTF-8 representation to a base-64 string. */ static String toBase64 (const String& textToEncode); }; + +} // namespace juce diff --git a/modules/juce_core/text/juce_CharPointer_ASCII.h b/modules/juce_core/text/juce_CharPointer_ASCII.h index 0c9ed44ac7..2e6b2b808b 100644 --- a/modules/juce_core/text/juce_CharPointer_ASCII.h +++ b/modules/juce_core/text/juce_CharPointer_ASCII.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -374,3 +374,5 @@ public: private: CharType* data; }; + +} // namespace juce diff --git a/modules/juce_core/text/juce_CharPointer_UTF16.h b/modules/juce_core/text/juce_CharPointer_UTF16.h index 7d45f95208..2176482de0 100644 --- a/modules/juce_core/text/juce_CharPointer_UTF16.h +++ b/modules/juce_core/text/juce_CharPointer_UTF16.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -516,3 +516,5 @@ private: return n; } }; + +} // namespace juce diff --git a/modules/juce_core/text/juce_CharPointer_UTF32.h b/modules/juce_core/text/juce_CharPointer_UTF32.h index 5367fbec84..41a9a7c251 100644 --- a/modules/juce_core/text/juce_CharPointer_UTF32.h +++ b/modules/juce_core/text/juce_CharPointer_UTF32.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -369,3 +369,5 @@ public: private: CharType* data; }; + +} // namespace juce diff --git a/modules/juce_core/text/juce_CharPointer_UTF8.h b/modules/juce_core/text/juce_CharPointer_UTF8.h index 639b5c2d1e..0d3c5d6634 100644 --- a/modules/juce_core/text/juce_CharPointer_UTF8.h +++ b/modules/juce_core/text/juce_CharPointer_UTF8.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -560,3 +561,5 @@ public: private: CharType* data; }; + +} // namespace juce diff --git a/modules/juce_core/text/juce_CharacterFunctions.cpp b/modules/juce_core/text/juce_CharacterFunctions.cpp index cd81957d95..9c10e8c38f 100644 --- a/modules/juce_core/text/juce_CharacterFunctions.cpp +++ b/modules/juce_core/text/juce_CharacterFunctions.cpp @@ -20,7 +20,9 @@ ============================================================================== */ -//============================================================================== +namespace juce +{ + #if JUCE_MSVC #pragma warning (push) #pragma warning (disable: 4514 4996) @@ -280,3 +282,5 @@ public: static CharacterFunctionsTests characterFunctionsTests; #endif + +} // namespace juce diff --git a/modules/juce_core/text/juce_CharacterFunctions.h b/modules/juce_core/text/juce_CharacterFunctions.h index 759080b283..27894bd8f5 100644 --- a/modules/juce_core/text/juce_CharacterFunctions.h +++ b/modules/juce_core/text/juce_CharacterFunctions.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== #if JUCE_WINDOWS && ! DOXYGEN @@ -631,3 +631,5 @@ public: private: static double mulexp10 (double value, int exponent) noexcept; }; + +} // namespace juce diff --git a/modules/juce_core/text/juce_Identifier.cpp b/modules/juce_core/text/juce_Identifier.cpp index 513b921e5c..3ca2b45ff7 100644 --- a/modules/juce_core/text/juce_Identifier.cpp +++ b/modules/juce_core/text/juce_Identifier.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + Identifier::Identifier() noexcept {} Identifier::~Identifier() noexcept {} @@ -67,3 +70,5 @@ bool Identifier::isValidIdentifier (const String& possibleIdentifier) noexcept return possibleIdentifier.isNotEmpty() && possibleIdentifier.containsOnly ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-:#@$%"); } + +} // namespace juce diff --git a/modules/juce_core/text/juce_Identifier.h b/modules/juce_core/text/juce_Identifier.h index 1d960e586f..4c6d9bcd23 100644 --- a/modules/juce_core/text/juce_Identifier.h +++ b/modules/juce_core/text/juce_Identifier.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -126,3 +126,5 @@ public: private: String name; }; + +} // namespace juce diff --git a/modules/juce_core/text/juce_LocalisedStrings.cpp b/modules/juce_core/text/juce_LocalisedStrings.cpp index 58533de91d..c5d091f640 100644 --- a/modules/juce_core/text/juce_LocalisedStrings.cpp +++ b/modules/juce_core/text/juce_LocalisedStrings.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + LocalisedStrings::LocalisedStrings (const String& fileContents, bool ignoreCase) { loadFromText (fileContents, ignoreCase); @@ -201,3 +204,5 @@ JUCE_API String translate (const String& text, const String& resultIfNotFound) return resultIfNotFound; } + +} // namespace juce diff --git a/modules/juce_core/text/juce_LocalisedStrings.h b/modules/juce_core/text/juce_LocalisedStrings.h index 71b6423fde..0cee6b3ad0 100644 --- a/modules/juce_core/text/juce_LocalisedStrings.h +++ b/modules/juce_core/text/juce_LocalisedStrings.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -235,3 +235,5 @@ JUCE_API String translate (CharPointer_UTF8 stringLiteral); @see LocalisedStrings */ JUCE_API String translate (const String& stringLiteral, const String& resultIfNotFound); + +} // namespace juce diff --git a/modules/juce_core/text/juce_NewLine.h b/modules/juce_core/text/juce_NewLine.h index 885618a7a7..164f4b1c3f 100644 --- a/modules/juce_core/text/juce_NewLine.h +++ b/modules/juce_core/text/juce_NewLine.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** This class is used for represent a new-line character sequence. @@ -76,3 +76,5 @@ inline String& operator+= (String& s1, const NewLine&) { return s1 += NewLi inline String operator+ (const NewLine&, const NewLine&) { return String (NewLine::getDefault()) + NewLine::getDefault(); } inline String operator+ (String s1, const NewLine&) { return s1 += NewLine::getDefault(); } inline String operator+ (const NewLine&, const char* s2) { return String (NewLine::getDefault()) + s2; } + +} // namespace juce diff --git a/modules/juce_core/text/juce_String.cpp b/modules/juce_core/text/juce_String.cpp index 5f2ac413de..7de15744e0 100644 --- a/modules/juce_core/text/juce_String.cpp +++ b/modules/juce_core/text/juce_String.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_MSVC #pragma warning (push) #pragma warning (disable: 4514 4996) @@ -2709,3 +2712,5 @@ public: static StringTests stringUnitTests; #endif + +} // namespace juce diff --git a/modules/juce_core/text/juce_String.h b/modules/juce_core/text/juce_String.h index 8b5bf10e61..642c10dd15 100644 --- a/modules/juce_core/text/juce_String.h +++ b/modules/juce_core/text/juce_String.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -1411,10 +1411,9 @@ JUCE_API OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const Str /** Writes a string to an OutputStream as UTF8. */ JUCE_API OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, StringRef stringToWrite); - -#if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS // just used to avoid compiling this under compilers that lack libc++ } // namespace juce +#if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS // just used to avoid compiling this under compilers that lack libc++ namespace std { template <> struct hash @@ -1422,6 +1421,4 @@ namespace std size_t operator() (const juce::String& s) const noexcept { return s.hash(); } }; } - -namespace juce { #endif diff --git a/modules/juce_core/text/juce_StringArray.cpp b/modules/juce_core/text/juce_StringArray.cpp index 2ce830f71d..a22b31c7b0 100644 --- a/modules/juce_core/text/juce_StringArray.cpp +++ b/modules/juce_core/text/juce_StringArray.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + StringArray::StringArray() noexcept { } @@ -492,3 +495,5 @@ void StringArray::minimiseStorageOverheads() { strings.minimiseStorageOverheads(); } + +} // namespace juce diff --git a/modules/juce_core/text/juce_StringArray.h b/modules/juce_core/text/juce_StringArray.h index a49c65f6b8..49d8662753 100644 --- a/modules/juce_core/text/juce_StringArray.h +++ b/modules/juce_core/text/juce_StringArray.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -423,3 +423,5 @@ public: private: JUCE_LEAK_DETECTOR (StringArray) }; + +} // namespace juce diff --git a/modules/juce_core/text/juce_StringPairArray.cpp b/modules/juce_core/text/juce_StringPairArray.cpp index 5ae706fbc2..202fd44f8c 100644 --- a/modules/juce_core/text/juce_StringPairArray.cpp +++ b/modules/juce_core/text/juce_StringPairArray.cpp @@ -20,8 +20,10 @@ ============================================================================== */ -StringPairArray::StringPairArray (const bool ignoreCase_) - : ignoreCase (ignoreCase_) +namespace juce +{ + +StringPairArray::StringPairArray (bool shouldIgnoreCase) : ignoreCase (shouldIgnoreCase) { } @@ -139,3 +141,5 @@ void StringPairArray::minimiseStorageOverheads() keys.minimiseStorageOverheads(); values.minimiseStorageOverheads(); } + +} // namespace juce diff --git a/modules/juce_core/text/juce_StringPairArray.h b/modules/juce_core/text/juce_StringPairArray.h index 7d9f3afef5..8bf8b61543 100644 --- a/modules/juce_core/text/juce_StringPairArray.h +++ b/modules/juce_core/text/juce_StringPairArray.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -145,3 +145,5 @@ private: JUCE_LEAK_DETECTOR (StringPairArray) }; + +} // namespace juce diff --git a/modules/juce_core/text/juce_StringPool.cpp b/modules/juce_core/text/juce_StringPool.cpp index 65bde3535f..a9a1121032 100644 --- a/modules/juce_core/text/juce_StringPool.cpp +++ b/modules/juce_core/text/juce_StringPool.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + static const int minNumberOfStringsForGarbageCollection = 300; static const uint32 garbageCollectionInterval = 30000; @@ -158,3 +161,5 @@ StringPool& StringPool::getGlobalPool() noexcept static StringPool pool; return pool; } + +} // namespace juce diff --git a/modules/juce_core/text/juce_StringPool.h b/modules/juce_core/text/juce_StringPool.h index 26240ca036..0f81bbbca3 100644 --- a/modules/juce_core/text/juce_StringPool.h +++ b/modules/juce_core/text/juce_StringPool.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -84,3 +84,5 @@ private: JUCE_DECLARE_NON_COPYABLE (StringPool) }; + +} // namespace juce diff --git a/modules/juce_core/text/juce_StringRef.h b/modules/juce_core/text/juce_StringRef.h index 77919b63bc..308474d10c 100644 --- a/modules/juce_core/text/juce_StringRef.h +++ b/modules/juce_core/text/juce_StringRef.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -128,3 +129,5 @@ inline String operator+ (String s1, StringRef s2) { return s1 += Strin inline String operator+ (StringRef s1, const String& s2) { return String (s1.text) + s2; } inline String operator+ (const char* s1, StringRef s2) { return String (s1) + String (s2.text); } inline String operator+ (StringRef s1, const char* s2) { return String (s1.text) + String (s2); } + +} // namespace juce diff --git a/modules/juce_core/text/juce_TextDiff.cpp b/modules/juce_core/text/juce_TextDiff.cpp index 35b13f7a48..f3e6b21daf 100644 --- a/modules/juce_core/text/juce_TextDiff.cpp +++ b/modules/juce_core/text/juce_TextDiff.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + struct TextDiffHelpers { enum { minLengthToMatch = 3, @@ -276,3 +279,5 @@ public: static DiffTests diffTests; #endif + +} // namespace juce diff --git a/modules/juce_core/text/juce_TextDiff.h b/modules/juce_core/text/juce_TextDiff.h index a0b9c29bad..05910ff0cd 100644 --- a/modules/juce_core/text/juce_TextDiff.h +++ b/modules/juce_core/text/juce_TextDiff.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ /** Calculates and applies a sequence of changes to convert one text string into @@ -68,3 +68,5 @@ public: */ Array changes; }; + +} // namespace juce diff --git a/modules/juce_core/threads/juce_ChildProcess.cpp b/modules/juce_core/threads/juce_ChildProcess.cpp index 5648c5d673..0a74d7bf50 100644 --- a/modules/juce_core/threads/juce_ChildProcess.cpp +++ b/modules/juce_core/threads/juce_ChildProcess.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + ChildProcess::ChildProcess() {} ChildProcess::~ChildProcess() {} @@ -45,7 +48,7 @@ uint32 ChildProcess::getExitCode() const bool ChildProcess::waitForProcessToFinish (const int timeoutMs) const { - const uint32 timeoutTime = Time::getMillisecondCounter() + (uint32) timeoutMs; + auto timeoutTime = Time::getMillisecondCounter() + (uint32) timeoutMs; do { @@ -105,3 +108,5 @@ public: static ChildProcessTests childProcessUnitTests; #endif + +} // namespace juce diff --git a/modules/juce_core/threads/juce_ChildProcess.h b/modules/juce_core/threads/juce_ChildProcess.h index b2bd0e1b63..98250f3613 100644 --- a/modules/juce_core/threads/juce_ChildProcess.h +++ b/modules/juce_core/threads/juce_ChildProcess.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -107,3 +107,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ChildProcess) }; + +} // namespace juce diff --git a/modules/juce_core/threads/juce_CriticalSection.h b/modules/juce_core/threads/juce_CriticalSection.h index 60a2409232..b382acdc75 100644 --- a/modules/juce_core/threads/juce_CriticalSection.h +++ b/modules/juce_core/threads/juce_CriticalSection.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -254,3 +254,5 @@ typedef CriticalSection::ScopedUnlockType ScopedUnlock; @see CriticalSection::tryEnter, ScopedLock, ScopedUnlock, ScopedReadLock */ typedef CriticalSection::ScopedTryLockType ScopedTryLock; + +} // namespace juce diff --git a/modules/juce_core/threads/juce_DynamicLibrary.h b/modules/juce_core/threads/juce_DynamicLibrary.h index 0d07839997..a4a273769b 100644 --- a/modules/juce_core/threads/juce_DynamicLibrary.h +++ b/modules/juce_core/threads/juce_DynamicLibrary.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ /** Handles the opening and closing of DLLs. @@ -35,14 +36,14 @@ public: /** Creates an unopened DynamicLibrary object. Call open() to actually open one. */ - DynamicLibrary() noexcept : handle (nullptr) {} + DynamicLibrary() noexcept {} /** */ - DynamicLibrary (const String& name) : handle (nullptr) { open (name); } + DynamicLibrary (const String& name) { open (name); } /** Move constructor */ - DynamicLibrary (DynamicLibrary&& other) noexcept : handle (nullptr) + DynamicLibrary (DynamicLibrary&& other) noexcept { std::swap (handle, other.handle); } @@ -75,7 +76,9 @@ public: void* getNativeHandle() const noexcept { return handle; } private: - void* handle; + void* handle = nullptr; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DynamicLibrary) }; + +} // namespace juce diff --git a/modules/juce_core/threads/juce_HighResolutionTimer.cpp b/modules/juce_core/threads/juce_HighResolutionTimer.cpp index 9e7550d7f9..91f9eac784 100644 --- a/modules/juce_core/threads/juce_HighResolutionTimer.cpp +++ b/modules/juce_core/threads/juce_HighResolutionTimer.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + HighResolutionTimer::HighResolutionTimer() { pimpl = new Pimpl (*this); } HighResolutionTimer::~HighResolutionTimer() { stopTimer(); } @@ -28,3 +31,5 @@ void HighResolutionTimer::stopTimer() { pimpl->stop(); } bool HighResolutionTimer::isTimerRunning() const noexcept { return pimpl->periodMs != 0; } int HighResolutionTimer::getTimerInterval() const noexcept { return pimpl->periodMs; } + +} // namespace juce diff --git a/modules/juce_core/threads/juce_HighResolutionTimer.h b/modules/juce_core/threads/juce_HighResolutionTimer.h index d90f59737e..4c846093cb 100644 --- a/modules/juce_core/threads/juce_HighResolutionTimer.h +++ b/modules/juce_core/threads/juce_HighResolutionTimer.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ /** A high-resolution periodic timer. @@ -97,3 +98,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (HighResolutionTimer) }; + +} // namespace juce diff --git a/modules/juce_core/threads/juce_InterProcessLock.h b/modules/juce_core/threads/juce_InterProcessLock.h index effcf26e9b..3bec0275d7 100644 --- a/modules/juce_core/threads/juce_InterProcessLock.h +++ b/modules/juce_core/threads/juce_InterProcessLock.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -116,3 +116,5 @@ private: JUCE_DECLARE_NON_COPYABLE (InterProcessLock) }; + +} // namespace juce diff --git a/modules/juce_core/threads/juce_Process.h b/modules/juce_core/threads/juce_Process.h index 656f88acb3..1804b89452 100644 --- a/modules/juce_core/threads/juce_Process.h +++ b/modules/juce_core/threads/juce_Process.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** Represents the current executable's process. @@ -150,3 +150,5 @@ private: Process(); JUCE_DECLARE_NON_COPYABLE (Process) }; + +} // namespace juce diff --git a/modules/juce_core/threads/juce_ReadWriteLock.cpp b/modules/juce_core/threads/juce_ReadWriteLock.cpp index 7a7efe4391..27347d5f40 100644 --- a/modules/juce_core/threads/juce_ReadWriteLock.cpp +++ b/modules/juce_core/threads/juce_ReadWriteLock.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + ReadWriteLock::ReadWriteLock() noexcept : numWaitingWriters (0), numWriters (0), @@ -142,3 +145,5 @@ void ReadWriteLock::exitWrite() const noexcept waitEvent.signal(); } } + +} // namespace juce diff --git a/modules/juce_core/threads/juce_ReadWriteLock.h b/modules/juce_core/threads/juce_ReadWriteLock.h index cb5e4cdddf..4d3f6e5172 100644 --- a/modules/juce_core/threads/juce_ReadWriteLock.h +++ b/modules/juce_core/threads/juce_ReadWriteLock.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -140,3 +140,5 @@ private: JUCE_DECLARE_NON_COPYABLE (ReadWriteLock) }; + +} // namespace juce diff --git a/modules/juce_core/threads/juce_ScopedLock.h b/modules/juce_core/threads/juce_ScopedLock.h index c1b5795be1..886f555e9e 100644 --- a/modules/juce_core/threads/juce_ScopedLock.h +++ b/modules/juce_core/threads/juce_ScopedLock.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -225,3 +225,5 @@ private: JUCE_DECLARE_NON_COPYABLE (GenericScopedTryLock) }; + +} // namespace juce diff --git a/modules/juce_core/threads/juce_ScopedReadLock.h b/modules/juce_core/threads/juce_ScopedReadLock.h index c459c29d02..fa5fe1ab04 100644 --- a/modules/juce_core/threads/juce_ScopedReadLock.h +++ b/modules/juce_core/threads/juce_ScopedReadLock.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -78,3 +78,5 @@ private: JUCE_DECLARE_NON_COPYABLE (ScopedReadLock) }; + +} // namespace juce diff --git a/modules/juce_core/threads/juce_ScopedWriteLock.h b/modules/juce_core/threads/juce_ScopedWriteLock.h index 52539fb7bb..7a9e8e53ef 100644 --- a/modules/juce_core/threads/juce_ScopedWriteLock.h +++ b/modules/juce_core/threads/juce_ScopedWriteLock.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -78,3 +78,5 @@ private: JUCE_DECLARE_NON_COPYABLE (ScopedWriteLock) }; + +} diff --git a/modules/juce_core/threads/juce_SpinLock.h b/modules/juce_core/threads/juce_SpinLock.h index 5454006adb..f79a6e5afd 100644 --- a/modules/juce_core/threads/juce_SpinLock.h +++ b/modules/juce_core/threads/juce_SpinLock.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -79,3 +79,5 @@ private: JUCE_DECLARE_NON_COPYABLE (SpinLock) }; + +} // namespace juce diff --git a/modules/juce_core/threads/juce_Thread.cpp b/modules/juce_core/threads/juce_Thread.cpp index fa2b26a12d..8195ce7f49 100644 --- a/modules/juce_core/threads/juce_Thread.cpp +++ b/modules/juce_core/threads/juce_Thread.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + Thread::Thread (const String& name, size_t stackSize) : threadName (name), threadStackSize (stackSize) { @@ -503,3 +506,5 @@ private: ThreadLocalValueUnitTest threadLocalValueUnitTest; #endif + +} // namespace juce diff --git a/modules/juce_core/threads/juce_Thread.h b/modules/juce_core/threads/juce_Thread.h index e5d1a49230..e4baa969d6 100644 --- a/modules/juce_core/threads/juce_Thread.h +++ b/modules/juce_core/threads/juce_Thread.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -330,3 +330,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Thread) }; + +} // namespace juce diff --git a/modules/juce_core/threads/juce_ThreadLocalValue.h b/modules/juce_core/threads/juce_ThreadLocalValue.h index 2b6d4fe028..ca2630976d 100644 --- a/modules/juce_core/threads/juce_ThreadLocalValue.h +++ b/modules/juce_core/threads/juce_ThreadLocalValue.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -143,3 +144,5 @@ private: JUCE_DECLARE_NON_COPYABLE (ThreadLocalValue) }; + +} // namespace juce diff --git a/modules/juce_core/threads/juce_ThreadPool.cpp b/modules/juce_core/threads/juce_ThreadPool.cpp index f12300155f..4cee61dabf 100644 --- a/modules/juce_core/threads/juce_ThreadPool.cpp +++ b/modules/juce_core/threads/juce_ThreadPool.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + class ThreadPool::ThreadPoolThread : public Thread { public: @@ -419,3 +422,5 @@ void ThreadPool::addToDeleteList (OwnedArray& deletionList, Threa if (job->shouldBeDeleted) deletionList.add (job); } + +} // namespace juce diff --git a/modules/juce_core/threads/juce_ThreadPool.h b/modules/juce_core/threads/juce_ThreadPool.h index 6dda3ed939..9ead49c864 100644 --- a/modules/juce_core/threads/juce_ThreadPool.h +++ b/modules/juce_core/threads/juce_ThreadPool.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ class ThreadPool; class ThreadPoolThread; @@ -328,3 +329,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ThreadPool) }; + +} // namespace juce diff --git a/modules/juce_core/threads/juce_TimeSliceThread.cpp b/modules/juce_core/threads/juce_TimeSliceThread.cpp index 94ecca528f..d5c4c227e5 100644 --- a/modules/juce_core/threads/juce_TimeSliceThread.cpp +++ b/modules/juce_core/threads/juce_TimeSliceThread.cpp @@ -20,9 +20,10 @@ ============================================================================== */ -TimeSliceThread::TimeSliceThread (const String& name) - : Thread (name), - clientBeingCalled (nullptr) +namespace juce +{ + +TimeSliceThread::TimeSliceThread (const String& name) : Thread (name) { } @@ -179,3 +180,5 @@ void TimeSliceThread::run() wait (timeToWait); } } + +} // namespace juce diff --git a/modules/juce_core/threads/juce_TimeSliceThread.h b/modules/juce_core/threads/juce_TimeSliceThread.h index 7a3ad7791e..53648b69c5 100644 --- a/modules/juce_core/threads/juce_TimeSliceThread.h +++ b/modules/juce_core/threads/juce_TimeSliceThread.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ class TimeSliceThread; @@ -135,9 +136,11 @@ public: private: CriticalSection callbackLock, listLock; Array clients; - TimeSliceClient* clientBeingCalled; + TimeSliceClient* clientBeingCalled = nullptr; TimeSliceClient* getNextClient (int index) const; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TimeSliceThread) }; + +} // namespace juce diff --git a/modules/juce_core/threads/juce_WaitableEvent.h b/modules/juce_core/threads/juce_WaitableEvent.h index 55900a268d..e13ec398d9 100644 --- a/modules/juce_core/threads/juce_WaitableEvent.h +++ b/modules/juce_core/threads/juce_WaitableEvent.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -106,3 +106,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (WaitableEvent) }; + +} // namespace juce diff --git a/modules/juce_core/time/juce_PerformanceCounter.cpp b/modules/juce_core/time/juce_PerformanceCounter.cpp index 6c3c3bbdd6..4650e16f17 100644 --- a/modules/juce_core/time/juce_PerformanceCounter.cpp +++ b/modules/juce_core/time/juce_PerformanceCounter.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + static void appendToFile (const File& f, const String& s) { if (f.getFullPathName().isNotEmpty()) @@ -124,3 +127,5 @@ PerformanceCounter::Statistics PerformanceCounter::getStatisticsAndReset() return s; } + +} // namespace juce diff --git a/modules/juce_core/time/juce_PerformanceCounter.h b/modules/juce_core/time/juce_PerformanceCounter.h index 7108b0f874..506a490442 100644 --- a/modules/juce_core/time/juce_PerformanceCounter.h +++ b/modules/juce_core/time/juce_PerformanceCounter.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** A timer for measuring performance of code and dumping the results to a file. @@ -157,3 +157,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ScopedTimeMeasurement) }; + +} // namespace juce diff --git a/modules/juce_core/time/juce_RelativeTime.cpp b/modules/juce_core/time/juce_RelativeTime.cpp index 013a1fc26f..3dc2fd4da9 100644 --- a/modules/juce_core/time/juce_RelativeTime.cpp +++ b/modules/juce_core/time/juce_RelativeTime.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + RelativeTime::RelativeTime (const double secs) noexcept : numSeconds (secs) {} RelativeTime::RelativeTime (const RelativeTime& other) noexcept : numSeconds (other.numSeconds) {} RelativeTime::~RelativeTime() noexcept {} @@ -131,3 +134,5 @@ String RelativeTime::getDescription (const String& returnValueForZeroTime) const return result.trimEnd(); } + +} // namespace juce diff --git a/modules/juce_core/time/juce_RelativeTime.h b/modules/juce_core/time/juce_RelativeTime.h index 9700d9aa29..7ccbce2cd1 100644 --- a/modules/juce_core/time/juce_RelativeTime.h +++ b/modules/juce_core/time/juce_RelativeTime.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** A relative measure of time. @@ -171,3 +171,5 @@ JUCE_API bool JUCE_CALLTYPE operator<= (RelativeTime t1, RelativeTime t2) noexce JUCE_API RelativeTime JUCE_CALLTYPE operator+ (RelativeTime t1, RelativeTime t2) noexcept; /** Subtracts two RelativeTimes. */ JUCE_API RelativeTime JUCE_CALLTYPE operator- (RelativeTime t1, RelativeTime t2) noexcept; + +} // namespace juce diff --git a/modules/juce_core/time/juce_Time.cpp b/modules/juce_core/time/juce_Time.cpp index 2e78b58edb..dfa54dfa77 100644 --- a/modules/juce_core/time/juce_Time.cpp +++ b/modules/juce_core/time/juce_Time.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + namespace TimeHelpers { static std::tm millisToLocal (int64 millis) noexcept @@ -679,3 +682,5 @@ public: static TimeTests timeTests; #endif + +} // namespace juce diff --git a/modules/juce_core/time/juce_Time.h b/modules/juce_core/time/juce_Time.h index c38321b5a0..2ff37375b5 100644 --- a/modules/juce_core/time/juce_Time.h +++ b/modules/juce_core/time/juce_Time.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -403,3 +403,5 @@ JUCE_API bool operator<= (Time time1, Time time2) noexcept; JUCE_API bool operator> (Time time1, Time time2) noexcept; /** Compares two Time objects. */ JUCE_API bool operator>= (Time time1, Time time2) noexcept; + +} // namespace juce diff --git a/modules/juce_core/unit_tests/juce_UnitTest.cpp b/modules/juce_core/unit_tests/juce_UnitTest.cpp index 2ed41b9813..9e9150ee63 100644 --- a/modules/juce_core/unit_tests/juce_UnitTest.cpp +++ b/modules/juce_core/unit_tests/juce_UnitTest.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + UnitTest::UnitTest (const String& nm, const String& ctg) : name (nm), category (ctg), runner (nullptr) { @@ -286,3 +289,5 @@ void UnitTestRunner::addFail (const String& failureMessage) if (assertOnFailure) { jassertfalse; } } + +} // namespace juce diff --git a/modules/juce_core/unit_tests/juce_UnitTest.h b/modules/juce_core/unit_tests/juce_UnitTest.h index 68c4459818..9a9580b836 100644 --- a/modules/juce_core/unit_tests/juce_UnitTest.h +++ b/modules/juce_core/unit_tests/juce_UnitTest.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ class UnitTestRunner; @@ -431,3 +432,5 @@ private: JUCE_DECLARE_NON_COPYABLE (UnitTestRunner) }; + +} // namespace juce diff --git a/modules/juce_core/xml/juce_XmlDocument.cpp b/modules/juce_core/xml/juce_XmlDocument.cpp index e522a45a83..b3268dfc7c 100644 --- a/modules/juce_core/xml/juce_XmlDocument.cpp +++ b/modules/juce_core/xml/juce_XmlDocument.cpp @@ -20,23 +20,16 @@ ============================================================================== */ +namespace juce +{ + XmlDocument::XmlDocument (const String& documentText) - : originalText (documentText), - input (nullptr), - outOfData (false), - errorOccurred (false), - needToLoadDTD (false), - ignoreEmptyTextElements (true) + : originalText (documentText) { } XmlDocument::XmlDocument (const File& file) - : input (nullptr), - outOfData (false), - errorOccurred (false), - needToLoadDTD (false), - ignoreEmptyTextElements (true), - inputSource (new FileInputSource (file)) + : inputSource (new FileInputSource (file)) { } @@ -883,3 +876,5 @@ String XmlDocument::getParameterEntity (const String& entity) return entity; } + +} diff --git a/modules/juce_core/xml/juce_XmlDocument.h b/modules/juce_core/xml/juce_XmlDocument.h index 6d0bd62174..e09bd63584 100644 --- a/modules/juce_core/xml/juce_XmlDocument.h +++ b/modules/juce_core/xml/juce_XmlDocument.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -143,12 +143,11 @@ public: //============================================================================== private: String originalText; - String::CharPointerType input; - bool outOfData, errorOccurred; - + String::CharPointerType input { nullptr }; + bool outOfData = false, errorOccurred = false; String lastError, dtdText; StringArray tokenisedDTD; - bool needToLoadDTD, ignoreEmptyTextElements; + bool needToLoadDTD = false, ignoreEmptyTextElements = true; ScopedPointer inputSource; XmlElement* parseDocumentElement (String::CharPointerType, bool outer); @@ -169,3 +168,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (XmlDocument) }; + +} // namespace juce diff --git a/modules/juce_core/xml/juce_XmlElement.cpp b/modules/juce_core/xml/juce_XmlElement.cpp index 04e81b6da2..b04e307282 100644 --- a/modules/juce_core/xml/juce_XmlElement.cpp +++ b/modules/juce_core/xml/juce_XmlElement.cpp @@ -20,38 +20,38 @@ ============================================================================== */ -namespace +namespace juce { - inline bool isValidXmlNameStartCharacter (const juce_wchar character) noexcept - { - return character == ':' - || character == '_' - || (character >= 'a' && character <= 'z') - || (character >= 'A' && character <= 'Z') - || (character >= 0xc0 && character <= 0xd6) - || (character >= 0xd8 && character <= 0xf6) - || (character >= 0xf8 && character <= 0x2ff) - || (character >= 0x370 && character <= 0x37d) - || (character >= 0x37f && character <= 0x1fff) - || (character >= 0x200c && character <= 0x200d) - || (character >= 0x2070 && character <= 0x218f) - || (character >= 0x2c00 && character <= 0x2fef) - || (character >= 0x3001 && character <= 0xd7ff) - || (character >= 0xf900 && character <= 0xfdcf) - || (character >= 0xfdf0 && character <= 0xfffd) - || (character >= 0x10000 && character <= 0xeffff); - } - inline bool isValidXmlNameBodyCharacter (const juce_wchar character) noexcept - { - return isValidXmlNameStartCharacter (character) - || character == '-' - || character == '.' - || character == 0xb7 - || (character >= '0' && character <= '9') - || (character >= 0x300 && character <= 0x036f) - || (character >= 0x203f && character <= 0x2040); - } +inline static bool isValidXmlNameStartCharacter (juce_wchar character) noexcept +{ + return character == ':' + || character == '_' + || (character >= 'a' && character <= 'z') + || (character >= 'A' && character <= 'Z') + || (character >= 0xc0 && character <= 0xd6) + || (character >= 0xd8 && character <= 0xf6) + || (character >= 0xf8 && character <= 0x2ff) + || (character >= 0x370 && character <= 0x37d) + || (character >= 0x37f && character <= 0x1fff) + || (character >= 0x200c && character <= 0x200d) + || (character >= 0x2070 && character <= 0x218f) + || (character >= 0x2c00 && character <= 0x2fef) + || (character >= 0x3001 && character <= 0xd7ff) + || (character >= 0xf900 && character <= 0xfdcf) + || (character >= 0xfdf0 && character <= 0xfffd) + || (character >= 0x10000 && character <= 0xeffff); +} + +inline static bool isValidXmlNameBodyCharacter (juce_wchar character) noexcept +{ + return isValidXmlNameStartCharacter (character) + || character == '-' + || character == '.' + || character == 0xb7 + || (character >= '0' && character <= '9') + || (character >= 0x300 && character <= 0x036f) + || (character >= 0x203f && character <= 0x2040); } XmlElement::XmlAttributeNode::XmlAttributeNode (const XmlAttributeNode& other) noexcept @@ -928,3 +928,5 @@ void XmlElement::deleteAllTextElements() noexcept child = next; } } + +} // namespace juce diff --git a/modules/juce_core/xml/juce_XmlElement.h b/modules/juce_core/xml/juce_XmlElement.h index 5c1b90fe34..33f86744ec 100644 --- a/modules/juce_core/xml/juce_XmlElement.h +++ b/modules/juce_core/xml/juce_XmlElement.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** A handy macro to make it easy to iterate all the child elements in an XmlElement. @@ -762,3 +762,5 @@ private: JUCE_LEAK_DETECTOR (XmlElement) }; + +} // namespace juce diff --git a/modules/juce_core/zip/juce_GZIPCompressorOutputStream.cpp b/modules/juce_core/zip/juce_GZIPCompressorOutputStream.cpp index d8c46bc009..df64f23d2c 100644 --- a/modules/juce_core/zip/juce_GZIPCompressorOutputStream.cpp +++ b/modules/juce_core/zip/juce_GZIPCompressorOutputStream.cpp @@ -20,14 +20,14 @@ ============================================================================== */ +namespace juce +{ + class GZIPCompressorOutputStream::GZIPCompressorHelper { public: GZIPCompressorHelper (const int compressionLevel, const int windowBits) - : compLevel ((compressionLevel < 0 || compressionLevel > 9) ? -1 : compressionLevel), - isFirstDeflate (true), - streamIsValid (false), - finished (false) + : compLevel ((compressionLevel < 0 || compressionLevel > 9) ? -1 : compressionLevel) { using namespace zlibNamespace; zerostruct (stream); @@ -70,7 +70,7 @@ private: zlibNamespace::z_stream stream; const int compLevel; - bool isFirstDeflate, streamIsValid, finished; + bool isFirstDeflate = true, streamIsValid = false, finished = false; zlibNamespace::Bytef buffer[32768]; bool doNextBlock (const uint8*& data, size_t& dataSize, OutputStream& out, const int flushMode) @@ -155,9 +155,8 @@ bool GZIPCompressorOutputStream::setPosition (int64 /*newPosition*/) //============================================================================== #if JUCE_UNIT_TESTS -class GZIPTests : public UnitTest +struct GZIPTests : public UnitTest { -public: GZIPTests() : UnitTest ("GZIP", "Compression") {} void runTest() override @@ -205,3 +204,5 @@ public: static GZIPTests gzipTests; #endif + +} // namespace juce diff --git a/modules/juce_core/zip/juce_GZIPCompressorOutputStream.h b/modules/juce_core/zip/juce_GZIPCompressorOutputStream.h index ff14f9fcc2..25a28101a6 100644 --- a/modules/juce_core/zip/juce_GZIPCompressorOutputStream.h +++ b/modules/juce_core/zip/juce_GZIPCompressorOutputStream.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -90,3 +90,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (GZIPCompressorOutputStream) }; + +} // namespace juce diff --git a/modules/juce_core/zip/juce_GZIPDecompressorInputStream.cpp b/modules/juce_core/zip/juce_GZIPDecompressorInputStream.cpp index 35e7a15042..0bae4d39d6 100644 --- a/modules/juce_core/zip/juce_GZIPDecompressorInputStream.cpp +++ b/modules/juce_core/zip/juce_GZIPDecompressorInputStream.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_MSVC #pragma warning (push) #pragma warning (disable: 4309 4305 4365) @@ -97,12 +100,6 @@ class GZIPDecompressorInputStream::GZIPDecompressHelper { public: GZIPDecompressHelper (Format f) - : finished (true), - needsDictionary (false), - error (true), - streamIsValid (false), - data (nullptr), - dataSize (0) { using namespace zlibNamespace; zerostruct (stream); @@ -112,9 +109,8 @@ public: ~GZIPDecompressHelper() { - using namespace zlibNamespace; if (streamIsValid) - inflateEnd (&stream); + zlibNamespace::inflateEnd (&stream); } bool needsInput() const noexcept { return dataSize <= 0; } @@ -128,6 +124,7 @@ public: int doNextBlock (uint8* const dest, const unsigned int destSize) { using namespace zlibNamespace; + if (streamIsValid && data != nullptr && ! finished) { stream.next_in = data; @@ -176,14 +173,14 @@ public: return MAX_WBITS; } - bool finished, needsDictionary, error, streamIsValid; + bool finished = true, needsDictionary = false, error = true, streamIsValid = false; enum { gzipDecompBufferSize = 32768 }; private: zlibNamespace::z_stream stream; - uint8* data; - size_t dataSize; + uint8* data = nullptr; + size_t dataSize = 0; JUCE_DECLARE_NON_COPYABLE (GZIPDecompressHelper) }; @@ -303,3 +300,5 @@ bool GZIPDecompressorInputStream::setPosition (int64 newPos) skipNextBytes (newPos - currentPos); return true; } + +} // namespace juce diff --git a/modules/juce_core/zip/juce_GZIPDecompressorInputStream.h b/modules/juce_core/zip/juce_GZIPDecompressorInputStream.h index be0e287310..a7edadc04d 100644 --- a/modules/juce_core/zip/juce_GZIPDecompressorInputStream.h +++ b/modules/juce_core/zip/juce_GZIPDecompressorInputStream.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -98,3 +98,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (GZIPDecompressorInputStream) }; + +} // namespace juce diff --git a/modules/juce_core/zip/juce_ZipFile.cpp b/modules/juce_core/zip/juce_ZipFile.cpp index 87e461f14f..78badf8165 100644 --- a/modules/juce_core/zip/juce_ZipFile.cpp +++ b/modules/juce_core/zip/juce_ZipFile.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + class ZipFile::ZipEntryHolder { public: @@ -603,3 +606,5 @@ bool ZipFile::Builder::writeToStream (OutputStream& target, double* const progre return true; } + +} // namespace juce diff --git a/modules/juce_core/zip/juce_ZipFile.h b/modules/juce_core/zip/juce_ZipFile.h index ca83230577..4e1c75bf11 100644 --- a/modules/juce_core/zip/juce_ZipFile.h +++ b/modules/juce_core/zip/juce_ZipFile.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -254,3 +254,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ZipFile) }; + +} // namespace juce diff --git a/modules/juce_cryptography/encryption/juce_BlowFish.cpp b/modules/juce_cryptography/encryption/juce_BlowFish.cpp index 7d2f7358f4..ca1b3f3741 100644 --- a/modules/juce_cryptography/encryption/juce_BlowFish.cpp +++ b/modules/juce_cryptography/encryption/juce_BlowFish.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + BlowFish::BlowFish (const void* const keyData, const int keyBytes) { jassert (keyData != nullptr); @@ -466,3 +469,5 @@ public: static BlowFishTests blowFishUnitTests; #endif + +} // namespace juce diff --git a/modules/juce_cryptography/encryption/juce_BlowFish.h b/modules/juce_cryptography/encryption/juce_BlowFish.h index dfa50dd88d..cdabc1ac68 100644 --- a/modules/juce_cryptography/encryption/juce_BlowFish.h +++ b/modules/juce_cryptography/encryption/juce_BlowFish.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -107,3 +107,5 @@ private: JUCE_LEAK_DETECTOR (BlowFish) }; + +} // namespace juce diff --git a/modules/juce_cryptography/encryption/juce_Primes.cpp b/modules/juce_cryptography/encryption/juce_Primes.cpp index 16c9ec2232..217f98156f 100644 --- a/modules/juce_cryptography/encryption/juce_Primes.cpp +++ b/modules/juce_cryptography/encryption/juce_Primes.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace PrimesHelpers { static void createSmallSieve (const int numBits, BigInteger& result) @@ -238,3 +241,5 @@ bool Primes::isProbablyPrime (const BigInteger& number, const int certainty) return passesMillerRabin (number, certainty); } } + +} // namespace juce diff --git a/modules/juce_cryptography/encryption/juce_Primes.h b/modules/juce_cryptography/encryption/juce_Primes.h index 904c92d073..7adcddb0cb 100644 --- a/modules/juce_cryptography/encryption/juce_Primes.h +++ b/modules/juce_cryptography/encryption/juce_Primes.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -69,3 +69,5 @@ private: JUCE_DECLARE_NON_COPYABLE (Primes) }; + +} // namespace juce diff --git a/modules/juce_cryptography/encryption/juce_RSAKey.cpp b/modules/juce_cryptography/encryption/juce_RSAKey.cpp index 6536cd64fe..7e7735a7d1 100644 --- a/modules/juce_cryptography/encryption/juce_RSAKey.cpp +++ b/modules/juce_cryptography/encryption/juce_RSAKey.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + RSAKey::RSAKey() { } @@ -135,3 +138,5 @@ void RSAKey::createKeyPair (RSAKey& publicKey, RSAKey& privateKey, privateKey.part1 = d; privateKey.part2 = n; } + +} // namespace juce diff --git a/modules/juce_cryptography/encryption/juce_RSAKey.h b/modules/juce_cryptography/encryption/juce_RSAKey.h index 6927175e93..334513ea0f 100644 --- a/modules/juce_cryptography/encryption/juce_RSAKey.h +++ b/modules/juce_cryptography/encryption/juce_RSAKey.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -170,3 +170,5 @@ private: JUCE_LEAK_DETECTOR (RSAKey) }; + +} // namespace juce diff --git a/modules/juce_cryptography/hashing/juce_MD5.cpp b/modules/juce_cryptography/hashing/juce_MD5.cpp index c4f7f86393..d139393b00 100644 --- a/modules/juce_cryptography/hashing/juce_MD5.cpp +++ b/modules/juce_cryptography/hashing/juce_MD5.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class MD5Generator { public: @@ -336,3 +339,5 @@ public: static MD5Tests MD5UnitTests; #endif + +} // namespace juce diff --git a/modules/juce_cryptography/hashing/juce_MD5.h b/modules/juce_cryptography/hashing/juce_MD5.h index 0eed61e8cb..ffd22f8f47 100644 --- a/modules/juce_cryptography/hashing/juce_MD5.h +++ b/modules/juce_cryptography/hashing/juce_MD5.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -115,3 +115,5 @@ private: JUCE_LEAK_DETECTOR (MD5) }; + +} // namespace juce diff --git a/modules/juce_cryptography/hashing/juce_SHA256.cpp b/modules/juce_cryptography/hashing/juce_SHA256.cpp index 4173e4c644..8504eaa8fc 100644 --- a/modules/juce_cryptography/hashing/juce_SHA256.cpp +++ b/modules/juce_cryptography/hashing/juce_SHA256.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class SHA256Processor { public: @@ -275,3 +278,5 @@ public: static SHA256Tests sha256UnitTests; #endif + +} // namespace juce diff --git a/modules/juce_cryptography/hashing/juce_SHA256.h b/modules/juce_cryptography/hashing/juce_SHA256.h index 5c30cae3c2..de56d5e9c1 100644 --- a/modules/juce_cryptography/hashing/juce_SHA256.h +++ b/modules/juce_cryptography/hashing/juce_SHA256.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -103,3 +103,5 @@ private: JUCE_LEAK_DETECTOR (SHA256) }; + +} // namespace juce diff --git a/modules/juce_cryptography/hashing/juce_Whirlpool.cpp b/modules/juce_cryptography/hashing/juce_Whirlpool.cpp index de4474fbbd..0078ceda4c 100644 --- a/modules/juce_cryptography/hashing/juce_Whirlpool.cpp +++ b/modules/juce_cryptography/hashing/juce_Whirlpool.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + struct WhirlpoolProcessor { WhirlpoolProcessor() noexcept : bufferBits (0), bufferPos (0) @@ -661,3 +664,5 @@ public: static WhirlpoolTests whirlpoolUnitTests; #endif + +} // namespace juce diff --git a/modules/juce_cryptography/hashing/juce_Whirlpool.h b/modules/juce_cryptography/hashing/juce_Whirlpool.h index a6912d557c..b04622fbaa 100644 --- a/modules/juce_cryptography/hashing/juce_Whirlpool.h +++ b/modules/juce_cryptography/hashing/juce_Whirlpool.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -109,3 +109,5 @@ private: JUCE_LEAK_DETECTOR (Whirlpool) }; + +} // namespace juce diff --git a/modules/juce_cryptography/juce_cryptography.cpp b/modules/juce_cryptography/juce_cryptography.cpp index 931013b442..e9cf86f33c 100644 --- a/modules/juce_cryptography/juce_cryptography.cpp +++ b/modules/juce_cryptography/juce_cryptography.cpp @@ -35,14 +35,9 @@ #include "juce_cryptography.h" -namespace juce -{ - #include "encryption/juce_BlowFish.cpp" #include "encryption/juce_Primes.cpp" #include "encryption/juce_RSAKey.cpp" #include "hashing/juce_MD5.cpp" #include "hashing/juce_SHA256.cpp" #include "hashing/juce_Whirlpool.cpp" - -} diff --git a/modules/juce_cryptography/juce_cryptography.h b/modules/juce_cryptography/juce_cryptography.h index 269777f772..07b5494658 100644 --- a/modules/juce_cryptography/juce_cryptography.h +++ b/modules/juce_cryptography/juce_cryptography.h @@ -54,14 +54,9 @@ //============================================================================== #include -namespace juce -{ - #include "encryption/juce_BlowFish.h" #include "encryption/juce_Primes.h" #include "encryption/juce_RSAKey.h" #include "hashing/juce_MD5.h" #include "hashing/juce_SHA256.h" #include "hashing/juce_Whirlpool.h" - -} diff --git a/modules/juce_data_structures/app_properties/juce_ApplicationProperties.cpp b/modules/juce_data_structures/app_properties/juce_ApplicationProperties.cpp index e120a1469d..eca113fb41 100644 --- a/modules/juce_data_structures/app_properties/juce_ApplicationProperties.cpp +++ b/modules/juce_data_structures/app_properties/juce_ApplicationProperties.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ApplicationProperties::ApplicationProperties() : commonSettingsAreReadOnly (0) { @@ -102,3 +105,5 @@ void ApplicationProperties::closeFiles() userProps = nullptr; commonProps = nullptr; } + +} // namespace juce diff --git a/modules/juce_data_structures/app_properties/juce_ApplicationProperties.h b/modules/juce_data_structures/app_properties/juce_ApplicationProperties.h index b65e5854d7..faa3817c43 100644 --- a/modules/juce_data_structures/app_properties/juce_ApplicationProperties.h +++ b/modules/juce_data_structures/app_properties/juce_ApplicationProperties.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -128,3 +128,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ApplicationProperties) }; + +} // namespace juce diff --git a/modules/juce_data_structures/app_properties/juce_PropertiesFile.cpp b/modules/juce_data_structures/app_properties/juce_PropertiesFile.cpp index 666710f865..d964fb9cdd 100644 --- a/modules/juce_data_structures/app_properties/juce_PropertiesFile.cpp +++ b/modules/juce_data_structures/app_properties/juce_PropertiesFile.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace PropertyFileConstants { JUCE_CONSTEXPR static const int magicNumber = (int) ByteOrder::littleEndianInt ('P', 'R', 'O', 'P'); @@ -356,3 +359,5 @@ void PropertiesFile::propertyChanged() else if (options.millisecondsBeforeSaving == 0) saveIfNeeded(); } + +} // namespace juce diff --git a/modules/juce_data_structures/app_properties/juce_PropertiesFile.h b/modules/juce_data_structures/app_properties/juce_PropertiesFile.h index bc29a13659..2848c5bb2c 100644 --- a/modules/juce_data_structures/app_properties/juce_PropertiesFile.h +++ b/modules/juce_data_structures/app_properties/juce_PropertiesFile.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** Wrapper on a file that stores a list of key/value data pairs. @@ -248,3 +248,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PropertiesFile) }; + +} // namespace juce diff --git a/modules/juce_data_structures/juce_data_structures.cpp b/modules/juce_data_structures/juce_data_structures.cpp index 7b3a3c497c..5913ca47f5 100644 --- a/modules/juce_data_structures/juce_data_structures.cpp +++ b/modules/juce_data_structures/juce_data_structures.cpp @@ -35,9 +35,6 @@ #include "juce_data_structures.h" -namespace juce -{ - #include "values/juce_Value.cpp" #include "values/juce_ValueTree.cpp" #include "values/juce_ValueTreeSynchroniser.cpp" @@ -45,5 +42,3 @@ namespace juce #include "undomanager/juce_UndoManager.cpp" #include "app_properties/juce_ApplicationProperties.cpp" #include "app_properties/juce_PropertiesFile.cpp" - -} diff --git a/modules/juce_data_structures/juce_data_structures.h b/modules/juce_data_structures/juce_data_structures.h index 0692f4682a..183df62279 100644 --- a/modules/juce_data_structures/juce_data_structures.h +++ b/modules/juce_data_structures/juce_data_structures.h @@ -54,9 +54,6 @@ //============================================================================== #include -namespace juce -{ - #include "undomanager/juce_UndoableAction.h" #include "undomanager/juce_UndoManager.h" #include "values/juce_Value.h" @@ -65,5 +62,3 @@ namespace juce #include "values/juce_CachedValue.h" #include "app_properties/juce_PropertiesFile.h" #include "app_properties/juce_ApplicationProperties.h" - -} diff --git a/modules/juce_data_structures/undomanager/juce_UndoManager.cpp b/modules/juce_data_structures/undomanager/juce_UndoManager.cpp index 5c0fb525f8..a5a705a32e 100644 --- a/modules/juce_data_structures/undomanager/juce_UndoManager.cpp +++ b/modules/juce_data_structures/undomanager/juce_UndoManager.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + struct UndoManager::ActionSet { ActionSet (const String& transactionName) @@ -345,3 +348,5 @@ int UndoManager::getNumActionsInCurrentTransaction() const return 0; } + +} // namespace juce diff --git a/modules/juce_data_structures/undomanager/juce_UndoManager.h b/modules/juce_data_structures/undomanager/juce_UndoManager.h index 1cca8518a1..75f3d0f30d 100644 --- a/modules/juce_data_structures/undomanager/juce_UndoManager.h +++ b/modules/juce_data_structures/undomanager/juce_UndoManager.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -242,3 +242,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (UndoManager) }; + +} // namespace juce diff --git a/modules/juce_data_structures/undomanager/juce_UndoableAction.h b/modules/juce_data_structures/undomanager/juce_UndoableAction.h index b5447210e5..9b418cd4ff 100644 --- a/modules/juce_data_structures/undomanager/juce_UndoableAction.h +++ b/modules/juce_data_structures/undomanager/juce_UndoableAction.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -95,3 +95,5 @@ public: */ virtual UndoableAction* createCoalescedAction (UndoableAction* nextAction) { ignoreUnused (nextAction); return nullptr; } }; + +} // namespace juce diff --git a/modules/juce_data_structures/values/juce_CachedValue.cpp b/modules/juce_data_structures/values/juce_CachedValue.cpp index b8ecbcc34d..ace2c41de7 100644 --- a/modules/juce_data_structures/values/juce_CachedValue.cpp +++ b/modules/juce_data_structures/values/juce_CachedValue.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_UNIT_TESTS class CachedValueTests : public UnitTest @@ -152,3 +155,5 @@ public: static CachedValueTests cachedValueTests; #endif + +} // namespace juce diff --git a/modules/juce_data_structures/values/juce_CachedValue.h b/modules/juce_data_structures/values/juce_CachedValue.h index f2725b6a8e..7a807df300 100644 --- a/modules/juce_data_structures/values/juce_CachedValue.h +++ b/modules/juce_data_structures/values/juce_CachedValue.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -308,3 +308,5 @@ inline void CachedValue::valueTreePropertyChanged (ValueTree& changedTree, if (changedProperty == targetProperty && targetTree == changedTree) forceUpdateOfCachedValue(); } + +} // namespace juce diff --git a/modules/juce_data_structures/values/juce_Value.cpp b/modules/juce_data_structures/values/juce_Value.cpp index 19e678871c..b09530fed6 100644 --- a/modules/juce_data_structures/values/juce_Value.cpp +++ b/modules/juce_data_structures/values/juce_Value.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + Value::ValueSource::ValueSource() { } @@ -235,3 +238,5 @@ OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const Value& value { return stream << value.toString(); } + +} // namespace juce diff --git a/modules/juce_data_structures/values/juce_Value.h b/modules/juce_data_structures/values/juce_Value.h index d470a9da73..e1216da45c 100644 --- a/modules/juce_data_structures/values/juce_Value.h +++ b/modules/juce_data_structures/values/juce_Value.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -239,3 +239,5 @@ OutputStream& JUCE_CALLTYPE operator<< (OutputStream&, const Value&); /** This typedef is just for compatibility with old code - newer code should use the Value::Listener class directly. */ typedef Value::Listener ValueListener; + +} // namespace juce diff --git a/modules/juce_data_structures/values/juce_ValueTree.cpp b/modules/juce_data_structures/values/juce_ValueTree.cpp index afe068d16d..b1e596e354 100644 --- a/modules/juce_data_structures/values/juce_ValueTree.cpp +++ b/modules/juce_data_structures/values/juce_ValueTree.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class ValueTree::SharedObject : public ReferenceCountedObject { public: @@ -1144,3 +1147,5 @@ public: static ValueTreeTests valueTreeTests; #endif + +} // namespace juce diff --git a/modules/juce_data_structures/values/juce_ValueTree.h b/modules/juce_data_structures/values/juce_ValueTree.h index 7c3e3eccfc..d0a66f0cff 100644 --- a/modules/juce_data_structures/values/juce_ValueTree.h +++ b/modules/juce_data_structures/values/juce_ValueTree.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -574,3 +574,5 @@ private: explicit ValueTree (SharedObject*) noexcept; }; + +} // namespace juce diff --git a/modules/juce_data_structures/values/juce_ValueTreeSynchroniser.cpp b/modules/juce_data_structures/values/juce_ValueTreeSynchroniser.cpp index d29b692b4c..7e49e712fb 100644 --- a/modules/juce_data_structures/values/juce_ValueTreeSynchroniser.cpp +++ b/modules/juce_data_structures/values/juce_ValueTreeSynchroniser.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace ValueTreeSynchroniserHelpers { enum ChangeType @@ -235,3 +238,5 @@ bool ValueTreeSynchroniser::applyChange (ValueTree& root, const void* data, size return false; } + +} // namespace juce diff --git a/modules/juce_data_structures/values/juce_ValueTreeSynchroniser.h b/modules/juce_data_structures/values/juce_ValueTreeSynchroniser.h index 0867a56e95..42c3823602 100644 --- a/modules/juce_data_structures/values/juce_ValueTreeSynchroniser.h +++ b/modules/juce_data_structures/values/juce_ValueTreeSynchroniser.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -93,3 +93,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ValueTreeSynchroniser) }; + +} // namespace juce diff --git a/modules/juce_dsp/containers/juce_AudioBlock.h b/modules/juce_dsp/containers/juce_AudioBlock.h index cd4ccd2daa..b8a40f23af 100644 --- a/modules/juce_dsp/containers/juce_AudioBlock.h +++ b/modules/juce_dsp/containers/juce_AudioBlock.h @@ -24,6 +24,11 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ + #ifndef DOXYGEN namespace SampleTypeHelpers // Internal classes needed for handling sample type classes { @@ -539,3 +544,6 @@ private: ChannelCountType numChannels = 0; size_t startSample = 0, numSamples = 0; }; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/containers/juce_SIMDRegister.h b/modules/juce_dsp/containers/juce_SIMDRegister.h index 1eb4964a73..42840ee39b 100644 --- a/modules/juce_dsp/containers/juce_SIMDRegister.h +++ b/modules/juce_dsp/containers/juce_SIMDRegister.h @@ -24,6 +24,11 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ + #ifndef DOXYGEN // This class is needed internally. template @@ -395,13 +400,12 @@ struct CmplxSIMDOps > } #endif -//============================================================================== -// Extend some common used global functions to SIMDRegister types -} // close namespace dsp +} // namespace dsp +// Extend some common used global functions to SIMDRegister types template inline dsp::SIMDRegister JUCE_VECTOR_CALLTYPE jmin (dsp::SIMDRegister a, dsp::SIMDRegister b) { return dsp::SIMDRegister::min (a, b); } template inline dsp::SIMDRegister JUCE_VECTOR_CALLTYPE jmax (dsp::SIMDRegister a, dsp::SIMDRegister b) { return dsp::SIMDRegister::max (a, b); } -namespace dsp { +} // namespace juce diff --git a/modules/juce_dsp/containers/juce_SIMDRegister_test.cpp b/modules/juce_dsp/containers/juce_SIMDRegister_test.cpp index 38e0df9724..49bd48eaee 100644 --- a/modules/juce_dsp/containers/juce_SIMDRegister_test.cpp +++ b/modules/juce_dsp/containers/juce_SIMDRegister_test.cpp @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ namespace SIMDRegister_test_internal { @@ -667,3 +671,6 @@ public: }; static SIMDRegisterUnitTests SIMDRegisterUnitTests; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/filter_design/juce_FilterDesign.cpp b/modules/juce_dsp/filter_design/juce_FilterDesign.cpp index 38e296e51e..f961fcabaa 100644 --- a/modules/juce_dsp/filter_design/juce_FilterDesign.cpp +++ b/modules/juce_dsp/filter_design/juce_FilterDesign.cpp @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ template typename FIR::Coefficients::Ptr @@ -616,3 +620,6 @@ typename FilterDesign::IIRPolyphaseAllpassStructure template struct FilterDesign; template struct FilterDesign; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/filter_design/juce_FilterDesign.h b/modules/juce_dsp/filter_design/juce_FilterDesign.h index abc19aff2c..5ab6aa9d36 100644 --- a/modules/juce_dsp/filter_design/juce_FilterDesign.h +++ b/modules/juce_dsp/filter_design/juce_FilterDesign.h @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ /** This class provides a set of functions which generates FIR::Coefficients @@ -257,3 +261,6 @@ private: FloatType stopbandAttenuationdB); FilterDesign() = delete; }; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/frequency/juce_Convolution.cpp b/modules/juce_dsp/frequency/juce_Convolution.cpp index 8dd3f21b2e..e09dc73df9 100644 --- a/modules/juce_dsp/frequency/juce_Convolution.cpp +++ b/modules/juce_dsp/frequency/juce_Convolution.cpp @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ /** This class is the convolution engine itself, processing only one channel at a time of input signal. @@ -1141,3 +1145,6 @@ void Convolution::processSamples (const AudioBlock& input, AudioBlock (size)); } + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/frequency/juce_FFT.h b/modules/juce_dsp/frequency/juce_FFT.h index 6b0ece8955..7879684d7c 100644 --- a/modules/juce_dsp/frequency/juce_FFT.h +++ b/modules/juce_dsp/frequency/juce_FFT.h @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ /** Performs a fast fourier transform. @@ -111,3 +115,6 @@ private: //============================================================================== JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FFT) }; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/frequency/juce_FFT_test.cpp b/modules/juce_dsp/frequency/juce_FFT_test.cpp index 056560dc97..0bf3b1c156 100644 --- a/modules/juce_dsp/frequency/juce_FFT_test.cpp +++ b/modules/juce_dsp/frequency/juce_FFT_test.cpp @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ struct FFTUnitTest : public UnitTest { @@ -204,3 +208,6 @@ struct FFTUnitTest : public UnitTest }; static FFTUnitTest fftUnitTest; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/frequency/juce_Windowing.cpp b/modules/juce_dsp/frequency/juce_Windowing.cpp index bf3fa0531f..0c563d54a4 100644 --- a/modules/juce_dsp/frequency/juce_Windowing.cpp +++ b/modules/juce_dsp/frequency/juce_Windowing.cpp @@ -24,6 +24,11 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ + template static inline FloatType ncos (size_t order, size_t i, size_t size) noexcept { @@ -184,3 +189,6 @@ const char* WindowingFunction::getWindowingMethodName (WindowingMetho template struct WindowingFunction; template struct WindowingFunction; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/frequency/juce_Windowing.h b/modules/juce_dsp/frequency/juce_Windowing.h index 09aa720867..81c9ea247c 100644 --- a/modules/juce_dsp/frequency/juce_Windowing.h +++ b/modules/juce_dsp/frequency/juce_Windowing.h @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ /** A class which provides multiple windowing functions useful for filter design @@ -71,3 +75,6 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (WindowingFunction) }; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/juce_dsp.cpp b/modules/juce_dsp/juce_dsp.cpp index fd9dea4cc1..1545ee54c5 100644 --- a/modules/juce_dsp/juce_dsp.cpp +++ b/modules/juce_dsp/juce_dsp.cpp @@ -49,42 +49,36 @@ #include #endif -namespace juce -{ - namespace dsp - { - #include "processors/juce_FIRFilter.cpp" - #include "processors/juce_IIRFilter.cpp" - #include "processors/juce_Oversampling.cpp" - #include "maths/juce_SpecialFunctions.cpp" - #include "maths/juce_Matrix.cpp" - #include "maths/juce_LookupTable.cpp" - #include "frequency/juce_FFT.cpp" - #include "frequency/juce_Convolution.cpp" - #include "frequency/juce_Windowing.cpp" - #include "filter_design/juce_FilterDesign.cpp" +#include "processors/juce_FIRFilter.cpp" +#include "processors/juce_IIRFilter.cpp" +#include "processors/juce_Oversampling.cpp" +#include "maths/juce_SpecialFunctions.cpp" +#include "maths/juce_Matrix.cpp" +#include "maths/juce_LookupTable.cpp" +#include "frequency/juce_FFT.cpp" +#include "frequency/juce_Convolution.cpp" +#include "frequency/juce_Windowing.cpp" +#include "filter_design/juce_FilterDesign.cpp" - #if JUCE_USE_SIMD - #if defined(__i386__) || defined(__amd64__) || defined(_M_X64) || defined(_X86_) || defined(_M_IX86) - #ifdef __AVX2__ - #include "native/juce_avx_SIMDNativeOps.cpp" - #else - #include "native/juce_sse_SIMDNativeOps.cpp" - #endif - #elif defined(__arm__) || defined(_M_ARM) || defined (__arm64__) || defined (__aarch64__) - #include "native/juce_neon_SIMDNativeOps.cpp" - #else - #error "SIMD register support not implemented for this platform" - #endif - #endif +#if JUCE_USE_SIMD +#if defined(__i386__) || defined(__amd64__) || defined(_M_X64) || defined(_X86_) || defined(_M_IX86) + #ifdef __AVX2__ + #include "native/juce_avx_SIMDNativeOps.cpp" + #else + #include "native/juce_sse_SIMDNativeOps.cpp" + #endif +#elif defined(__arm__) || defined(_M_ARM) || defined (__arm64__) || defined (__aarch64__) + #include "native/juce_neon_SIMDNativeOps.cpp" +#else + #error "SIMD register support not implemented for this platform" +#endif +#endif - #if JUCE_UNIT_TESTS - #include "maths/juce_Matrix_test.cpp" - #if JUCE_USE_SIMD - #include "containers/juce_SIMDRegister_test.cpp" - #endif - #include "frequency/juce_FFT_test.cpp" - #include "processors/juce_FIRFilter_test.cpp" - #endif - } -} +#if JUCE_UNIT_TESTS +#include "maths/juce_Matrix_test.cpp" +#if JUCE_USE_SIMD +#include "containers/juce_SIMDRegister_test.cpp" +#endif +#include "frequency/juce_FFT_test.cpp" +#include "processors/juce_FIRFilter_test.cpp" +#endif diff --git a/modules/juce_dsp/juce_dsp.h b/modules/juce_dsp/juce_dsp.h index d0c803b128..4566489153 100644 --- a/modules/juce_dsp/juce_dsp.h +++ b/modules/juce_dsp/juce_dsp.h @@ -167,12 +167,13 @@ #endif //============================================================================== +#undef Complex // apparently some C libraries actually define these symbols (!) +#undef Factor + namespace juce { namespace dsp { - #undef Complex // apparently some C libraries actually define these symbols (!) - #undef Factor template using Complex = ::std::complex; @@ -190,48 +191,48 @@ namespace juce inline void snapToZero (long double& x) noexcept { JUCE_SNAP_TO_ZERO (x); } #endif } - - //============================================================================== - #if JUCE_USE_SIMD - #include "native/juce_fallback_SIMDNativeOps.h" - - // include the correct native file for this build target CPU - #if defined(__i386__) || defined(__amd64__) || defined(_M_X64) || defined(_X86_) || defined(_M_IX86) - #ifdef __AVX2__ - #include "native/juce_avx_SIMDNativeOps.h" - #else - #include "native/juce_sse_SIMDNativeOps.h" - #endif - #elif defined(__arm__) || defined(_M_ARM) || defined (__arm64__) || defined (__aarch64__) - #include "native/juce_neon_SIMDNativeOps.h" - #else - #error "SIMD register support not implemented for this platform" - #endif - - #include "containers/juce_SIMDRegister.h" - #endif - - #include "maths/juce_SpecialFunctions.h" - #include "maths/juce_Matrix.h" - #include "maths/juce_Polynomial.h" - #include "maths/juce_FastMathApproximations.h" - #include "maths/juce_LookupTable.h" - #include "containers/juce_AudioBlock.h" - #include "processors/juce_ProcessContext.h" - #include "processors/juce_ProcessorWrapper.h" - #include "processors/juce_ProcessorChain.h" - #include "processors/juce_ProcessorDuplicator.h" - #include "processors/juce_Bias.h" - #include "processors/juce_Gain.h" - #include "processors/juce_WaveShaper.h" - #include "processors/juce_IIRFilter.h" - #include "processors/juce_FIRFilter.h" - #include "processors/juce_Oscillator.h" - #include "processors/juce_StateVariableFilter.h" - #include "processors/juce_Oversampling.h" - #include "frequency/juce_FFT.h" - #include "frequency/juce_Convolution.h" - #include "frequency/juce_Windowing.h" - #include "filter_design/juce_FilterDesign.h" } } + +//============================================================================== +#if JUCE_USE_SIMD + #include "native/juce_fallback_SIMDNativeOps.h" + + // include the correct native file for this build target CPU + #if defined(__i386__) || defined(__amd64__) || defined(_M_X64) || defined(_X86_) || defined(_M_IX86) + #ifdef __AVX2__ + #include "native/juce_avx_SIMDNativeOps.h" + #else + #include "native/juce_sse_SIMDNativeOps.h" + #endif + #elif defined(__arm__) || defined(_M_ARM) || defined (__arm64__) || defined (__aarch64__) + #include "native/juce_neon_SIMDNativeOps.h" + #else + #error "SIMD register support not implemented for this platform" + #endif + + #include "containers/juce_SIMDRegister.h" +#endif + +#include "maths/juce_SpecialFunctions.h" +#include "maths/juce_Matrix.h" +#include "maths/juce_Polynomial.h" +#include "maths/juce_FastMathApproximations.h" +#include "maths/juce_LookupTable.h" +#include "containers/juce_AudioBlock.h" +#include "processors/juce_ProcessContext.h" +#include "processors/juce_ProcessorWrapper.h" +#include "processors/juce_ProcessorChain.h" +#include "processors/juce_ProcessorDuplicator.h" +#include "processors/juce_Bias.h" +#include "processors/juce_Gain.h" +#include "processors/juce_WaveShaper.h" +#include "processors/juce_IIRFilter.h" +#include "processors/juce_FIRFilter.h" +#include "processors/juce_Oscillator.h" +#include "processors/juce_StateVariableFilter.h" +#include "processors/juce_Oversampling.h" +#include "frequency/juce_FFT.h" +#include "frequency/juce_Convolution.h" +#include "frequency/juce_Windowing.h" +#include "filter_design/juce_FilterDesign.h" diff --git a/modules/juce_dsp/maths/juce_FastMathApproximations.h b/modules/juce_dsp/maths/juce_FastMathApproximations.h index 0b59afea8c..3be0473c23 100644 --- a/modules/juce_dsp/maths/juce_FastMathApproximations.h +++ b/modules/juce_dsp/maths/juce_FastMathApproximations.h @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ /** This class contains various fast mathematical function approximations. @@ -254,3 +258,6 @@ struct FastMathApproximations values[i] = FastMathApproximations::logNPlusOne (values[i]); } }; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/maths/juce_LookupTable.cpp b/modules/juce_dsp/maths/juce_LookupTable.cpp index 8d0a6e0bf7..21fe2563bb 100644 --- a/modules/juce_dsp/maths/juce_LookupTable.cpp +++ b/modules/juce_dsp/maths/juce_LookupTable.cpp @@ -24,6 +24,11 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ + template LookupTable::LookupTable() { @@ -147,3 +152,6 @@ template class LookupTable; template class LookupTableTransform; template class LookupTableTransform; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/maths/juce_LookupTable.h b/modules/juce_dsp/maths/juce_LookupTable.h index f6dba351db..a4d4061f69 100644 --- a/modules/juce_dsp/maths/juce_LookupTable.h +++ b/modules/juce_dsp/maths/juce_LookupTable.h @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ /** Class for efficiently approximating expensive arithmetic operations. @@ -319,3 +323,6 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LookupTableTransform) }; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/maths/juce_Matrix.cpp b/modules/juce_dsp/maths/juce_Matrix.cpp index 19fa3a57a2..d91859ad09 100644 --- a/modules/juce_dsp/maths/juce_Matrix.cpp +++ b/modules/juce_dsp/maths/juce_Matrix.cpp @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ template Matrix Matrix::identity (size_t size) @@ -309,3 +313,6 @@ String Matrix::toString() const template class Matrix; template class Matrix; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/maths/juce_Matrix.h b/modules/juce_dsp/maths/juce_Matrix.h index 756b573970..1d49594741 100644 --- a/modules/juce_dsp/maths/juce_Matrix.h +++ b/modules/juce_dsp/maths/juce_Matrix.h @@ -24,6 +24,11 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ + /** General matrix and vectors class, meant for classic math manipulation such as additions, multiplications, and linear systems of equations solving. @@ -243,3 +248,6 @@ private: //============================================================================== JUCE_LEAK_DETECTOR (Matrix) }; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/maths/juce_Matrix_test.cpp b/modules/juce_dsp/maths/juce_Matrix_test.cpp index e81bfa4d7f..e9f3357f63 100644 --- a/modules/juce_dsp/maths/juce_Matrix_test.cpp +++ b/modules/juce_dsp/maths/juce_Matrix_test.cpp @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ struct LinearAlgebraUnitTest : public UnitTest { @@ -163,3 +167,6 @@ struct LinearAlgebraUnitTest : public UnitTest }; static LinearAlgebraUnitTest linearAlgebraUnitTest; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/maths/juce_Polynomial.h b/modules/juce_dsp/maths/juce_Polynomial.h index 6a4d0e2c2a..4099436615 100644 --- a/modules/juce_dsp/maths/juce_Polynomial.h +++ b/modules/juce_dsp/maths/juce_Polynomial.h @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ /** A class representing a polynomial @@ -160,3 +164,6 @@ private: JUCE_LEAK_DETECTOR (Polynomial) }; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/maths/juce_SpecialFunctions.cpp b/modules/juce_dsp/maths/juce_SpecialFunctions.cpp index 6874ef020a..55da31118b 100644 --- a/modules/juce_dsp/maths/juce_SpecialFunctions.cpp +++ b/modules/juce_dsp/maths/juce_SpecialFunctions.cpp @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ double SpecialFunctions::besselI0 (double x) noexcept { @@ -133,3 +137,6 @@ Complex SpecialFunctions::asne (Complex w, double k) noexcept return 2.0 / double_Pi * std::asin (last); } + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/maths/juce_SpecialFunctions.h b/modules/juce_dsp/maths/juce_SpecialFunctions.h index 834416d969..275aac21e5 100644 --- a/modules/juce_dsp/maths/juce_SpecialFunctions.h +++ b/modules/juce_dsp/maths/juce_SpecialFunctions.h @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ /** Contains miscellaneous filter design and windowing functions. @@ -57,3 +61,6 @@ struct SpecialFunctions */ static Complex asne (Complex w, double k) noexcept; }; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/native/juce_avx_SIMDNativeOps.cpp b/modules/juce_dsp/native/juce_avx_SIMDNativeOps.cpp index 3780fd5375..25d47499d0 100644 --- a/modules/juce_dsp/native/juce_avx_SIMDNativeOps.cpp +++ b/modules/juce_dsp/native/juce_avx_SIMDNativeOps.cpp @@ -24,31 +24,36 @@ ============================================================================== */ +namespace juce +{ + namespace dsp + { + DEFINE_AVX_SIMD_CONST (int32_t, float, kAllBitsSet) = { -1, -1, -1, -1, -1, -1, -1, -1 }; + DEFINE_AVX_SIMD_CONST (int32_t, float, kEvenHighBit) = { static_cast(0x80000000), 0, static_cast(0x80000000), 0, static_cast(0x80000000), 0, static_cast(0x80000000), 0 }; + DEFINE_AVX_SIMD_CONST (float, float, kOne) = { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f }; -DEFINE_AVX_SIMD_CONST (int32_t, float, kAllBitsSet) = { -1, -1, -1, -1, -1, -1, -1, -1 }; -DEFINE_AVX_SIMD_CONST (int32_t, float, kEvenHighBit) = { static_cast(0x80000000), 0, static_cast(0x80000000), 0, static_cast(0x80000000), 0, static_cast(0x80000000), 0 }; -DEFINE_AVX_SIMD_CONST (float, float, kOne) = { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f }; + DEFINE_AVX_SIMD_CONST (int64_t, double, kAllBitsSet) = { -1, -1, -1, -1 }; + DEFINE_AVX_SIMD_CONST (int64_t, double, kEvenHighBit) = { static_cast (0x8000000000000000), 0, static_cast (0x8000000000000000), 0 }; + DEFINE_AVX_SIMD_CONST (double, double, kOne) = { 1.0, 1.0, 1.0, 1.0 }; -DEFINE_AVX_SIMD_CONST (int64_t, double, kAllBitsSet) = { -1, -1, -1, -1 }; -DEFINE_AVX_SIMD_CONST (int64_t, double, kEvenHighBit) = { static_cast (0x8000000000000000), 0, static_cast (0x8000000000000000), 0 }; -DEFINE_AVX_SIMD_CONST (double, double, kOne) = { 1.0, 1.0, 1.0, 1.0 }; + DEFINE_AVX_SIMD_CONST (int8_t, int8_t, kAllBitsSet) = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; -DEFINE_AVX_SIMD_CONST (int8_t, int8_t, kAllBitsSet) = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; + DEFINE_AVX_SIMD_CONST (uint8_t, uint8_t, kAllBitsSet) = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; + DEFINE_AVX_SIMD_CONST (uint8_t, uint8_t, kHighBit) = { 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }; -DEFINE_AVX_SIMD_CONST (uint8_t, uint8_t, kAllBitsSet) = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; -DEFINE_AVX_SIMD_CONST (uint8_t, uint8_t, kHighBit) = { 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }; + DEFINE_AVX_SIMD_CONST (int16_t, int16_t, kAllBitsSet) = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; -DEFINE_AVX_SIMD_CONST (int16_t, int16_t, kAllBitsSet) = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; + DEFINE_AVX_SIMD_CONST (uint16_t, uint16_t, kAllBitsSet) = { 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff }; + DEFINE_AVX_SIMD_CONST (uint16_t, uint16_t, kHighBit) = { 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000 }; -DEFINE_AVX_SIMD_CONST (uint16_t, uint16_t, kAllBitsSet) = { 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff }; -DEFINE_AVX_SIMD_CONST (uint16_t, uint16_t, kHighBit) = { 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000 }; + DEFINE_AVX_SIMD_CONST (int32_t, int32_t, kAllBitsSet) = { -1, -1, -1, -1, -1, -1, -1, -1 }; -DEFINE_AVX_SIMD_CONST (int32_t, int32_t, kAllBitsSet) = { -1, -1, -1, -1, -1, -1, -1, -1 }; + DEFINE_AVX_SIMD_CONST (uint32_t, uint32_t, kAllBitsSet) = { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }; + DEFINE_AVX_SIMD_CONST (uint32_t, uint32_t, kHighBit) = { 0x80000000, 0x80000000, 0x80000000, 0x80000000, 0x80000000, 0x80000000, 0x80000000, 0x80000000 }; -DEFINE_AVX_SIMD_CONST (uint32_t, uint32_t, kAllBitsSet) = { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }; -DEFINE_AVX_SIMD_CONST (uint32_t, uint32_t, kHighBit) = { 0x80000000, 0x80000000, 0x80000000, 0x80000000, 0x80000000, 0x80000000, 0x80000000, 0x80000000 }; + DEFINE_AVX_SIMD_CONST (int64_t, int64_t, kAllBitsSet) = { -1LL, -1LL, -1LL, -1LL }; -DEFINE_AVX_SIMD_CONST (int64_t, int64_t, kAllBitsSet) = { -1LL, -1LL, -1LL, -1LL }; - -DEFINE_AVX_SIMD_CONST (uint64_t, uint64_t, kAllBitsSet) = { 0xffffffffffffffffULL, 0xffffffffffffffffULL, 0xffffffffffffffffULL, 0xffffffffffffffffULL }; -DEFINE_AVX_SIMD_CONST (uint64_t, uint64_t, kHighBit) = { 0x8000000000000000ULL, 0x8000000000000000ULL, 0x8000000000000000ULL, 0x8000000000000000ULL }; + DEFINE_AVX_SIMD_CONST (uint64_t, uint64_t, kAllBitsSet) = { 0xffffffffffffffffULL, 0xffffffffffffffffULL, 0xffffffffffffffffULL, 0xffffffffffffffffULL }; + DEFINE_AVX_SIMD_CONST (uint64_t, uint64_t, kHighBit) = { 0x8000000000000000ULL, 0x8000000000000000ULL, 0x8000000000000000ULL, 0x8000000000000000ULL }; + } +} diff --git a/modules/juce_dsp/native/juce_avx_SIMDNativeOps.h b/modules/juce_dsp/native/juce_avx_SIMDNativeOps.h index c3f6506e95..c5894209f7 100644 --- a/modules/juce_dsp/native/juce_avx_SIMDNativeOps.h +++ b/modules/juce_dsp/native/juce_avx_SIMDNativeOps.h @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ #ifndef DOXYGEN @@ -558,3 +562,6 @@ struct SIMDNativeOps }; #endif + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/native/juce_fallback_SIMDNativeOps.h b/modules/juce_dsp/native/juce_fallback_SIMDNativeOps.h index 78c11ddf61..4701beb981 100644 --- a/modules/juce_dsp/native/juce_fallback_SIMDNativeOps.h +++ b/modules/juce_dsp/native/juce_fallback_SIMDNativeOps.h @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ /** A template specialisation to find corresponding mask type for primitives. */ namespace SIMDInternal @@ -211,3 +215,6 @@ struct SIMDFallbackOps return retval; } }; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/native/juce_neon_SIMDNativeOps.cpp b/modules/juce_dsp/native/juce_neon_SIMDNativeOps.cpp index d52f7505bd..8193545391 100644 --- a/modules/juce_dsp/native/juce_neon_SIMDNativeOps.cpp +++ b/modules/juce_dsp/native/juce_neon_SIMDNativeOps.cpp @@ -24,16 +24,21 @@ ============================================================================== */ - -DEFINE_NEON_SIMD_CONST (int32_t, float, kAllBitsSet) = { -1, -1, -1, -1 }; -DEFINE_NEON_SIMD_CONST (int32_t, float, kEvenHighBit) = { static_cast(0x80000000), 0, static_cast(0x80000000), 0 }; -DEFINE_NEON_SIMD_CONST (float, float, kOne) = { 1.0f, 1.0f, 1.0f, 1.0f }; - -DEFINE_NEON_SIMD_CONST (int8_t, int8_t, kAllBitsSet) = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; -DEFINE_NEON_SIMD_CONST (uint8_t, uint8_t, kAllBitsSet) = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; -DEFINE_NEON_SIMD_CONST (int16_t, int16_t, kAllBitsSet) = { -1, -1, -1, -1, -1, -1, -1, -1 }; -DEFINE_NEON_SIMD_CONST (uint16_t, uint16_t, kAllBitsSet) = { 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff }; -DEFINE_NEON_SIMD_CONST (int32_t, int32_t, kAllBitsSet) = { -1, -1, -1, -1 }; -DEFINE_NEON_SIMD_CONST (uint32_t, uint32_t, kAllBitsSet) = { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }; -DEFINE_NEON_SIMD_CONST (int64_t, int64_t, kAllBitsSet) = { -1, -1 }; -DEFINE_NEON_SIMD_CONST (uint64_t, uint64_t, kAllBitsSet) = { 0xffffffffffffffff, 0xffffffffffffffff }; +namespace juce +{ + namespace dsp + { + DEFINE_NEON_SIMD_CONST (int32_t, float, kAllBitsSet) = { -1, -1, -1, -1 }; + DEFINE_NEON_SIMD_CONST (int32_t, float, kEvenHighBit) = { static_cast(0x80000000), 0, static_cast(0x80000000), 0 }; + DEFINE_NEON_SIMD_CONST (float, float, kOne) = { 1.0f, 1.0f, 1.0f, 1.0f }; + + DEFINE_NEON_SIMD_CONST (int8_t, int8_t, kAllBitsSet) = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; + DEFINE_NEON_SIMD_CONST (uint8_t, uint8_t, kAllBitsSet) = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; + DEFINE_NEON_SIMD_CONST (int16_t, int16_t, kAllBitsSet) = { -1, -1, -1, -1, -1, -1, -1, -1 }; + DEFINE_NEON_SIMD_CONST (uint16_t, uint16_t, kAllBitsSet) = { 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff }; + DEFINE_NEON_SIMD_CONST (int32_t, int32_t, kAllBitsSet) = { -1, -1, -1, -1 }; + DEFINE_NEON_SIMD_CONST (uint32_t, uint32_t, kAllBitsSet) = { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }; + DEFINE_NEON_SIMD_CONST (int64_t, int64_t, kAllBitsSet) = { -1, -1 }; + DEFINE_NEON_SIMD_CONST (uint64_t, uint64_t, kAllBitsSet) = { 0xffffffffffffffff, 0xffffffffffffffff }; + } +} diff --git a/modules/juce_dsp/native/juce_neon_SIMDNativeOps.h b/modules/juce_dsp/native/juce_neon_SIMDNativeOps.h index de8bc9d602..55a23e107b 100644 --- a/modules/juce_dsp/native/juce_neon_SIMDNativeOps.h +++ b/modules/juce_dsp/native/juce_neon_SIMDNativeOps.h @@ -24,6 +24,11 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ + #ifndef DOXYGEN #ifdef _MSC_VER @@ -384,3 +389,6 @@ struct SIMDNativeOps }; #endif + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/native/juce_sse_SIMDNativeOps.cpp b/modules/juce_dsp/native/juce_sse_SIMDNativeOps.cpp index c3af98e6e0..e12923121e 100644 --- a/modules/juce_dsp/native/juce_sse_SIMDNativeOps.cpp +++ b/modules/juce_dsp/native/juce_sse_SIMDNativeOps.cpp @@ -24,31 +24,36 @@ ============================================================================== */ +namespace juce +{ + namespace dsp + { + DEFINE_SSE_SIMD_CONST (int32_t, float, kAllBitsSet) = { -1, -1, -1, -1 }; + DEFINE_SSE_SIMD_CONST (int32_t, float, kEvenHighBit) = { static_cast(0x80000000), 0, static_cast(0x80000000), 0 }; + DEFINE_SSE_SIMD_CONST (float, float, kOne) = { 1.0f, 1.0f, 1.0f, 1.0f }; -DEFINE_SSE_SIMD_CONST (int32_t, float, kAllBitsSet) = { -1, -1, -1, -1 }; -DEFINE_SSE_SIMD_CONST (int32_t, float, kEvenHighBit) = { static_cast(0x80000000), 0, static_cast(0x80000000), 0 }; -DEFINE_SSE_SIMD_CONST (float, float, kOne) = { 1.0f, 1.0f, 1.0f, 1.0f }; + DEFINE_SSE_SIMD_CONST (int64_t, double, kAllBitsSet) = { -1LL, -1LL }; + DEFINE_SSE_SIMD_CONST (int64_t, double, kEvenHighBit) = { static_cast(0x8000000000000000), 0 }; + DEFINE_SSE_SIMD_CONST (double, double, kOne) = { 1.0, 1.0 }; -DEFINE_SSE_SIMD_CONST (int64_t, double, kAllBitsSet) = { -1LL, -1LL }; -DEFINE_SSE_SIMD_CONST (int64_t, double, kEvenHighBit) = { static_cast(0x8000000000000000), 0 }; -DEFINE_SSE_SIMD_CONST (double, double, kOne) = { 1.0, 1.0 }; + DEFINE_SSE_SIMD_CONST (int8_t, int8_t, kAllBitsSet) = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; -DEFINE_SSE_SIMD_CONST (int8_t, int8_t, kAllBitsSet) = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; + DEFINE_SSE_SIMD_CONST (uint8_t, uint8_t, kAllBitsSet) = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; + DEFINE_SSE_SIMD_CONST (uint8_t, uint8_t, kHighBit) = { 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }; -DEFINE_SSE_SIMD_CONST (uint8_t, uint8_t, kAllBitsSet) = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; -DEFINE_SSE_SIMD_CONST (uint8_t, uint8_t, kHighBit) = { 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }; + DEFINE_SSE_SIMD_CONST (int16_t, int16_t, kAllBitsSet) = { -1, -1, -1, -1, -1, -1, -1, -1 }; -DEFINE_SSE_SIMD_CONST (int16_t, int16_t, kAllBitsSet) = { -1, -1, -1, -1, -1, -1, -1, -1 }; + DEFINE_SSE_SIMD_CONST (uint16_t, uint16_t, kAllBitsSet) = { 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff }; + DEFINE_SSE_SIMD_CONST (uint16_t, uint16_t, kHighBit) = { 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000 }; -DEFINE_SSE_SIMD_CONST (uint16_t, uint16_t, kAllBitsSet) = { 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff }; -DEFINE_SSE_SIMD_CONST (uint16_t, uint16_t, kHighBit) = { 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000 }; + DEFINE_SSE_SIMD_CONST (int32_t, int32_t, kAllBitsSet) = { -1, -1, -1, -1 }; -DEFINE_SSE_SIMD_CONST (int32_t, int32_t, kAllBitsSet) = { -1, -1, -1, -1 }; + DEFINE_SSE_SIMD_CONST (uint32_t, uint32_t, kAllBitsSet) = { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }; + DEFINE_SSE_SIMD_CONST (uint32_t, uint32_t, kHighBit) = { 0x80000000, 0x80000000, 0x80000000, 0x80000000 }; -DEFINE_SSE_SIMD_CONST (uint32_t, uint32_t, kAllBitsSet) = { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }; -DEFINE_SSE_SIMD_CONST (uint32_t, uint32_t, kHighBit) = { 0x80000000, 0x80000000, 0x80000000, 0x80000000 }; + DEFINE_SSE_SIMD_CONST (int64_t, int64_t, kAllBitsSet) = { -1, -1 }; -DEFINE_SSE_SIMD_CONST (int64_t, int64_t, kAllBitsSet) = { -1, -1 }; - -DEFINE_SSE_SIMD_CONST (uint64_t, uint64_t, kAllBitsSet) = { 0xffffffffffffffff, 0xffffffffffffffff }; -DEFINE_SSE_SIMD_CONST (uint64_t, uint64_t, kHighBit) = { 0x8000000000000000, 0x8000000000000000 }; + DEFINE_SSE_SIMD_CONST (uint64_t, uint64_t, kAllBitsSet) = { 0xffffffffffffffff, 0xffffffffffffffff }; + DEFINE_SSE_SIMD_CONST (uint64_t, uint64_t, kHighBit) = { 0x8000000000000000, 0x8000000000000000 }; + } +} diff --git a/modules/juce_dsp/native/juce_sse_SIMDNativeOps.h b/modules/juce_dsp/native/juce_sse_SIMDNativeOps.h index 847403334e..3b2c741fbd 100644 --- a/modules/juce_dsp/native/juce_sse_SIMDNativeOps.h +++ b/modules/juce_dsp/native/juce_sse_SIMDNativeOps.h @@ -24,6 +24,11 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ + #ifndef DOXYGEN #ifdef _MSC_VER @@ -738,3 +743,6 @@ struct SIMDNativeOps }; #endif + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/processors/juce_Bias.h b/modules/juce_dsp/processors/juce_Bias.h index 7913965126..1937af9573 100644 --- a/modules/juce_dsp/processors/juce_Bias.h +++ b/modules/juce_dsp/processors/juce_Bias.h @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ /** Adds a DC offset (voltage bias) to the audio samples. @@ -137,3 +141,6 @@ private: bias.reset (sampleRate, rampDurationSeconds); } }; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/processors/juce_FIRFilter.cpp b/modules/juce_dsp/processors/juce_FIRFilter.cpp index c0008b2bbe..abcf5d27a9 100644 --- a/modules/juce_dsp/processors/juce_FIRFilter.cpp +++ b/modules/juce_dsp/processors/juce_FIRFilter.cpp @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ template double FIR::Coefficients::Coefficients::getMagnitudeForFrequency (double frequency, double theSampleRate) const noexcept @@ -153,3 +157,6 @@ void FIR::Coefficients::Coefficients::normalise() noexcept //============================================================================== template struct FIR::Coefficients; template struct FIR::Coefficients; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/processors/juce_FIRFilter.h b/modules/juce_dsp/processors/juce_FIRFilter.h index 902ff437df..08912dbfb1 100644 --- a/modules/juce_dsp/processors/juce_FIRFilter.h +++ b/modules/juce_dsp/processors/juce_FIRFilter.h @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ /** Classes for FIR filter processing. @@ -274,3 +278,6 @@ namespace FIR Array coefficients; }; } + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/processors/juce_FIRFilter_test.cpp b/modules/juce_dsp/processors/juce_FIRFilter_test.cpp index b1fc1ddfc9..437611ceac 100644 --- a/modules/juce_dsp/processors/juce_FIRFilter_test.cpp +++ b/modules/juce_dsp/processors/juce_FIRFilter_test.cpp @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ class FIRFilterTest : public UnitTest { @@ -201,3 +205,6 @@ public: }; static FIRFilterTest firFilterUnitTest; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/processors/juce_Gain.h b/modules/juce_dsp/processors/juce_Gain.h index cfa2b1dcf8..e8e206f333 100644 --- a/modules/juce_dsp/processors/juce_Gain.h +++ b/modules/juce_dsp/processors/juce_Gain.h @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ /** Applies a gain to audio samples as single samples or AudioBlocks. @@ -126,3 +130,6 @@ private: LinearSmoothedValue gain; double sampleRate = 0, rampDurationSeconds = 0; }; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/processors/juce_IIRFilter.cpp b/modules/juce_dsp/processors/juce_IIRFilter.cpp index beb7664e68..bebcf701a5 100644 --- a/modules/juce_dsp/processors/juce_IIRFilter.cpp +++ b/modules/juce_dsp/processors/juce_IIRFilter.cpp @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ template IIR::Coefficients::Coefficients() @@ -482,3 +486,6 @@ void IIR::Coefficients::getPhaseForFrequencyArray (double* frequenc template struct IIR::Coefficients; template struct IIR::Coefficients; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/processors/juce_IIRFilter.h b/modules/juce_dsp/processors/juce_IIRFilter.h index 2c5e5980fd..63a311b940 100644 --- a/modules/juce_dsp/processors/juce_IIRFilter.h +++ b/modules/juce_dsp/processors/juce_IIRFilter.h @@ -24,10 +24,13 @@ ============================================================================== */ - /** Classes for IIR filter processing. */ +namespace juce +{ +namespace dsp +{ namespace IIR { template @@ -276,5 +279,8 @@ namespace IIR static constexpr NumericType inverseRootTwo = static_cast (0.70710678118654752440L); }; - #include "juce_IIRFilter_Impl.h" -} +} // namespace IIR +} // namespace dsp +} // namespace juce + +#include "juce_IIRFilter_Impl.h" diff --git a/modules/juce_dsp/processors/juce_IIRFilter_Impl.h b/modules/juce_dsp/processors/juce_IIRFilter_Impl.h index c096f5d114..5ef75be08c 100644 --- a/modules/juce_dsp/processors/juce_IIRFilter_Impl.h +++ b/modules/juce_dsp/processors/juce_IIRFilter_Impl.h @@ -24,6 +24,13 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ +namespace IIR +{ + #ifndef DOXYGEN //============================================================================== @@ -214,3 +221,7 @@ void Filter::check() } #endif + +} // namespace IIR +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/processors/juce_Oscillator.h b/modules/juce_dsp/processors/juce_Oscillator.h index 9230658951..03f64f4ba8 100644 --- a/modules/juce_dsp/processors/juce_Oscillator.h +++ b/modules/juce_dsp/processors/juce_Oscillator.h @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ /** Generates a signal based on a user-supplied function. @@ -153,3 +157,6 @@ private: LinearSmoothedValue frequency {static_cast (440.0)}; NumericType sampleRate = 48000.0, pos = 0.0; }; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/processors/juce_Oversampling.cpp b/modules/juce_dsp/processors/juce_Oversampling.cpp index a6349966ac..c039f484b3 100644 --- a/modules/juce_dsp/processors/juce_Oversampling.cpp +++ b/modules/juce_dsp/processors/juce_Oversampling.cpp @@ -24,8 +24,11 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ -//=============================================================================== /** Abstract class for the provided oversampling engines used internally in the Oversampling class. */ @@ -710,3 +713,6 @@ void Oversampling::processSamplesDown (dsp::AudioBlock & template class Oversampling; template class Oversampling; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/processors/juce_Oversampling.h b/modules/juce_dsp/processors/juce_Oversampling.h index 8b6da27c0c..159f0a5dce 100644 --- a/modules/juce_dsp/processors/juce_Oversampling.h +++ b/modules/juce_dsp/processors/juce_Oversampling.h @@ -24,6 +24,11 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ + template class OversamplingEngine; @@ -136,3 +141,6 @@ private: //=============================================================================== JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Oversampling) }; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/processors/juce_ProcessContext.h b/modules/juce_dsp/processors/juce_ProcessContext.h index 8c41f7c686..3016ccdccb 100644 --- a/modules/juce_dsp/processors/juce_ProcessContext.h +++ b/modules/juce_dsp/processors/juce_ProcessContext.h @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ /** This structure is passed into a DSP algorithm's prepare() method, and contains @@ -153,3 +157,6 @@ private: const AudioBlockType& inputBlock; AudioBlockType& outputBlock; }; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/processors/juce_ProcessorChain.h b/modules/juce_dsp/processors/juce_ProcessorChain.h index fa16f60d35..004380176d 100644 --- a/modules/juce_dsp/processors/juce_ProcessorChain.h +++ b/modules/juce_dsp/processors/juce_ProcessorChain.h @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ #ifndef DOXYGEN namespace ProcessorHelpers // Internal helper classes used in building the ProcessorChain @@ -112,3 +116,6 @@ namespace ProcessorHelpers // Internal helper classes used in building the Proc */ template using ProcessorChain = ProcessorHelpers::Chain; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/processors/juce_ProcessorDuplicator.h b/modules/juce_dsp/processors/juce_ProcessorDuplicator.h index f66f6a082f..cd561bb388 100644 --- a/modules/juce_dsp/processors/juce_ProcessorDuplicator.h +++ b/modules/juce_dsp/processors/juce_ProcessorDuplicator.h @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ /** Converts a mono processor class into a multi-channel version by duplicating it @@ -88,3 +92,6 @@ private: juce::OwnedArray processors; }; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/processors/juce_ProcessorWrapper.h b/modules/juce_dsp/processors/juce_ProcessorWrapper.h index 2e9fe98dd5..9df2b2090d 100644 --- a/modules/juce_dsp/processors/juce_ProcessorWrapper.h +++ b/modules/juce_dsp/processors/juce_ProcessorWrapper.h @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ /** Acts as a polymorphic base class for processors. @@ -69,3 +73,6 @@ struct ProcessorWrapper : public ProcessorBase ProcessorType processor; }; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/processors/juce_StateVariableFilter.h b/modules/juce_dsp/processors/juce_StateVariableFilter.h index 437f6995cf..a35bc3dfb2 100644 --- a/modules/juce_dsp/processors/juce_StateVariableFilter.h +++ b/modules/juce_dsp/processors/juce_StateVariableFilter.h @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ /** An IIR filter that can perform low, band and high-pass filtering on an audio @@ -201,3 +205,6 @@ namespace StateVariableFilter NumericType h = static_cast (1.0 / (1.0 + R2 * g + g * g)); }; } + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/processors/juce_WaveShaper.h b/modules/juce_dsp/processors/juce_WaveShaper.h index 7dd5aeb387..1681901165 100644 --- a/modules/juce_dsp/processors/juce_WaveShaper.h +++ b/modules/juce_dsp/processors/juce_WaveShaper.h @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ /** Applies waveshaping to audio samples as single samples or AudioBlocks. @@ -63,3 +67,6 @@ struct WaveShaper //============================================================================== template static WaveShaper, Functor> CreateWaveShaper (Functor functionToUse) { return {functionToUse}; } + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_events/broadcasters/juce_ActionBroadcaster.cpp b/modules/juce_events/broadcasters/juce_ActionBroadcaster.cpp index 76253f347c..2b4613e82c 100644 --- a/modules/juce_events/broadcasters/juce_ActionBroadcaster.cpp +++ b/modules/juce_events/broadcasters/juce_ActionBroadcaster.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + class ActionBroadcaster::ActionMessage : public MessageManager::MessageBase { public: @@ -87,3 +90,5 @@ void ActionBroadcaster::sendActionMessage (const String& message) const for (int i = actionListeners.size(); --i >= 0;) (new ActionMessage (this, message, actionListeners.getUnchecked(i)))->post(); } + +} // namespace juce diff --git a/modules/juce_events/broadcasters/juce_ActionBroadcaster.h b/modules/juce_events/broadcasters/juce_ActionBroadcaster.h index 8a2d559011..3267d86139 100644 --- a/modules/juce_events/broadcasters/juce_ActionBroadcaster.h +++ b/modules/juce_events/broadcasters/juce_ActionBroadcaster.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** Manages a list of ActionListeners, and can send them messages. @@ -75,3 +75,5 @@ private: JUCE_DECLARE_NON_COPYABLE (ActionBroadcaster) }; + +} // namespace juce diff --git a/modules/juce_events/broadcasters/juce_ActionListener.h b/modules/juce_events/broadcasters/juce_ActionListener.h index 0571eaf05f..c16449f7df 100644 --- a/modules/juce_events/broadcasters/juce_ActionListener.h +++ b/modules/juce_events/broadcasters/juce_ActionListener.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -42,3 +42,5 @@ public: */ virtual void actionListenerCallback (const String& message) = 0; }; + +} // namespace juce diff --git a/modules/juce_events/broadcasters/juce_AsyncUpdater.cpp b/modules/juce_events/broadcasters/juce_AsyncUpdater.cpp index 15659057f5..8d9a20e5a9 100644 --- a/modules/juce_events/broadcasters/juce_AsyncUpdater.cpp +++ b/modules/juce_events/broadcasters/juce_AsyncUpdater.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + class AsyncUpdater::AsyncUpdaterMessage : public CallbackMessage { public: @@ -86,3 +89,5 @@ bool AsyncUpdater::isUpdatePending() const noexcept { return activeMessage->shouldDeliver.value != 0; } + +} // namespace juce diff --git a/modules/juce_events/broadcasters/juce_AsyncUpdater.h b/modules/juce_events/broadcasters/juce_AsyncUpdater.h index 3b61f21088..7a94a63d63 100644 --- a/modules/juce_events/broadcasters/juce_AsyncUpdater.h +++ b/modules/juce_events/broadcasters/juce_AsyncUpdater.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -104,3 +104,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AsyncUpdater) }; + +} // namespace juce diff --git a/modules/juce_events/broadcasters/juce_ChangeBroadcaster.cpp b/modules/juce_events/broadcasters/juce_ChangeBroadcaster.cpp index c7b4cbfae8..a816c3d8ff 100644 --- a/modules/juce_events/broadcasters/juce_ChangeBroadcaster.cpp +++ b/modules/juce_events/broadcasters/juce_ChangeBroadcaster.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + ChangeBroadcaster::ChangeBroadcaster() noexcept { broadcastCallback.owner = this; @@ -92,3 +95,5 @@ void ChangeBroadcaster::ChangeBroadcasterCallback::handleAsyncUpdate() jassert (owner != nullptr); owner->callListeners(); } + +} // namespace juce diff --git a/modules/juce_events/broadcasters/juce_ChangeBroadcaster.h b/modules/juce_events/broadcasters/juce_ChangeBroadcaster.h index 7750e1278c..beef4e85a0 100644 --- a/modules/juce_events/broadcasters/juce_ChangeBroadcaster.h +++ b/modules/juce_events/broadcasters/juce_ChangeBroadcaster.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -97,3 +97,5 @@ private: JUCE_DECLARE_NON_COPYABLE (ChangeBroadcaster) }; + +} // namespace juce diff --git a/modules/juce_events/broadcasters/juce_ChangeListener.h b/modules/juce_events/broadcasters/juce_ChangeListener.h index 37aabd0d60..aacaf223cd 100644 --- a/modules/juce_events/broadcasters/juce_ChangeListener.h +++ b/modules/juce_events/broadcasters/juce_ChangeListener.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ class ChangeBroadcaster; @@ -56,3 +57,5 @@ public: private: virtual int changeListenerCallback (void*) { return 0; } #endif }; + +} // namespace juce diff --git a/modules/juce_events/interprocess/juce_ConnectedChildProcess.cpp b/modules/juce_events/interprocess/juce_ConnectedChildProcess.cpp index a0e69161ba..9e7070e4d0 100644 --- a/modules/juce_events/interprocess/juce_ConnectedChildProcess.cpp +++ b/modules/juce_events/interprocess/juce_ConnectedChildProcess.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + enum { magicMastSlaveConnectionHeader = 0x712baf04 }; static const char* startMessage = "__ipc_st"; @@ -260,3 +263,5 @@ bool ChildProcessSlave::initialiseFromCommandLine (const String& commandLine, return connection != nullptr; } + +} // namespace juce diff --git a/modules/juce_events/interprocess/juce_ConnectedChildProcess.h b/modules/juce_events/interprocess/juce_ConnectedChildProcess.h index d1eaadc29d..8f6cc8cc1e 100644 --- a/modules/juce_events/interprocess/juce_ConnectedChildProcess.h +++ b/modules/juce_events/interprocess/juce_ConnectedChildProcess.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -184,3 +185,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ChildProcessMaster) }; + +} // namespace juce diff --git a/modules/juce_events/interprocess/juce_InterprocessConnection.cpp b/modules/juce_events/interprocess/juce_InterprocessConnection.cpp index 353beeaac2..6f98aed632 100644 --- a/modules/juce_events/interprocess/juce_InterprocessConnection.cpp +++ b/modules/juce_events/interprocess/juce_InterprocessConnection.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + struct InterprocessConnection::ConnectionThread : public Thread { ConnectionThread (InterprocessConnection& c) : Thread ("JUCE IPC"), owner (c) {} @@ -361,3 +364,5 @@ void InterprocessConnection::runThread() break; } } + +} // namespace juce diff --git a/modules/juce_events/interprocess/juce_InterprocessConnection.h b/modules/juce_events/interprocess/juce_InterprocessConnection.h index 6f9048bc7c..83cd910f31 100644 --- a/modules/juce_events/interprocess/juce_InterprocessConnection.h +++ b/modules/juce_events/interprocess/juce_InterprocessConnection.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ class InterprocessConnectionServer; class MemoryBlock; @@ -203,3 +204,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (InterprocessConnection) }; + +} // namespace juce diff --git a/modules/juce_events/interprocess/juce_InterprocessConnectionServer.cpp b/modules/juce_events/interprocess/juce_InterprocessConnectionServer.cpp index 196d90978e..6c9022bd46 100644 --- a/modules/juce_events/interprocess/juce_InterprocessConnectionServer.cpp +++ b/modules/juce_events/interprocess/juce_InterprocessConnectionServer.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + InterprocessConnectionServer::InterprocessConnectionServer() : Thread ("Juce IPC server") { @@ -74,3 +77,5 @@ void InterprocessConnectionServer::run() newConnection->initialiseWithSocket (clientSocket.release()); } } + +} // namespace juce diff --git a/modules/juce_events/interprocess/juce_InterprocessConnectionServer.h b/modules/juce_events/interprocess/juce_InterprocessConnectionServer.h index f731a379a2..552dd1c180 100644 --- a/modules/juce_events/interprocess/juce_InterprocessConnectionServer.h +++ b/modules/juce_events/interprocess/juce_InterprocessConnectionServer.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -100,3 +100,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (InterprocessConnectionServer) }; + +} // namespace juce diff --git a/modules/juce_events/juce_events.cpp b/modules/juce_events/juce_events.cpp index 50d8fdd69a..bee0e3dff2 100644 --- a/modules/juce_events/juce_events.cpp +++ b/modules/juce_events/juce_events.cpp @@ -54,9 +54,6 @@ #endif //============================================================================== -namespace juce -{ - #include "messages/juce_ApplicationBase.cpp" #include "messages/juce_DeletedAtShutdown.cpp" #include "messages/juce_MessageListener.cpp" @@ -103,5 +100,3 @@ namespace juce #include "native/juce_android_Messaging.cpp" #endif - -} diff --git a/modules/juce_events/juce_events.h b/modules/juce_events/juce_events.h index a09ece17d3..b451c40d6f 100644 --- a/modules/juce_events/juce_events.h +++ b/modules/juce_events/juce_events.h @@ -62,9 +62,6 @@ #include #endif -namespace juce -{ - #include "messages/juce_MessageManager.h" #include "messages/juce_Message.h" #include "messages/juce_MessageListener.h" @@ -89,7 +86,6 @@ namespace juce #include "native/juce_linux_EventLoop.h" #endif - #if JUCE_WINDOWS #if JUCE_EVENTS_INCLUDE_WIN32_MESSAGE_WINDOW #include "native/juce_win32_HiddenMessageWindow.h" @@ -98,5 +94,3 @@ namespace juce #include "native/juce_win32_WinRTWrapper.h" #endif #endif - -} diff --git a/modules/juce_events/messages/juce_ApplicationBase.cpp b/modules/juce_events/messages/juce_ApplicationBase.cpp index be929bee3e..cbd549f8b0 100644 --- a/modules/juce_events/messages/juce_ApplicationBase.cpp +++ b/modules/juce_events/messages/juce_ApplicationBase.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + JUCEApplicationBase::CreateInstanceFunction JUCEApplicationBase::createInstance = 0; JUCEApplicationBase* JUCEApplicationBase::appInstance = nullptr; @@ -326,3 +329,5 @@ int JUCEApplicationBase::shutdownApp() multipleInstanceHandler = nullptr; return getApplicationReturnValue(); } + +} // namespace juce diff --git a/modules/juce_events/messages/juce_ApplicationBase.h b/modules/juce_events/messages/juce_ApplicationBase.h index c9ffc5f0b9..88950fd7c0 100644 --- a/modules/juce_events/messages/juce_ApplicationBase.h +++ b/modules/juce_events/messages/juce_ApplicationBase.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -308,3 +308,5 @@ private: #define JUCE_TRY #define JUCE_CATCH_EXCEPTION #endif + +} // namespace juce diff --git a/modules/juce_events/messages/juce_CallbackMessage.h b/modules/juce_events/messages/juce_CallbackMessage.h index 249b204c01..303c1b438a 100644 --- a/modules/juce_events/messages/juce_CallbackMessage.h +++ b/modules/juce_events/messages/juce_CallbackMessage.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -68,3 +68,5 @@ private: // messages still in the system event queue. These aren't harmful, but can cause annoying assertions. JUCE_DECLARE_NON_COPYABLE (CallbackMessage) }; + +} // namespace juce diff --git a/modules/juce_events/messages/juce_DeletedAtShutdown.cpp b/modules/juce_events/messages/juce_DeletedAtShutdown.cpp index 897632a28b..feede821f1 100644 --- a/modules/juce_events/messages/juce_DeletedAtShutdown.cpp +++ b/modules/juce_events/messages/juce_DeletedAtShutdown.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + static SpinLock deletedAtShutdownLock; // use a spin lock because it can be statically initialised static Array& getDeletedAtShutdownObjects() @@ -87,3 +90,5 @@ void DeletedAtShutdown::deleteAll() #if JUCE_MSVC #pragma warning (pop) #endif + +} // namespace juce diff --git a/modules/juce_events/messages/juce_DeletedAtShutdown.h b/modules/juce_events/messages/juce_DeletedAtShutdown.h index a0284f80dd..9b28a49eda 100644 --- a/modules/juce_events/messages/juce_DeletedAtShutdown.h +++ b/modules/juce_events/messages/juce_DeletedAtShutdown.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -59,3 +59,5 @@ public: private: JUCE_DECLARE_NON_COPYABLE (DeletedAtShutdown) }; + +} // namespace juce diff --git a/modules/juce_events/messages/juce_Initialisation.h b/modules/juce_events/messages/juce_Initialisation.h index e911807bd1..db2988a709 100644 --- a/modules/juce_events/messages/juce_Initialisation.h +++ b/modules/juce_events/messages/juce_Initialisation.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** Initialises Juce's GUI classes. @@ -196,3 +196,5 @@ public: #endif #endif #endif + +} // namespace juce diff --git a/modules/juce_events/messages/juce_Message.h b/modules/juce_events/messages/juce_Message.h index 52033be77a..c0abb238ce 100644 --- a/modules/juce_events/messages/juce_Message.h +++ b/modules/juce_events/messages/juce_Message.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ class MessageListener; @@ -57,3 +58,5 @@ private: // messages still in the system event queue. These aren't harmful, but can cause annoying assertions. JUCE_DECLARE_NON_COPYABLE (Message) }; + +} // namespace juce diff --git a/modules/juce_events/messages/juce_MessageListener.cpp b/modules/juce_events/messages/juce_MessageListener.cpp index 671cbe27d0..e1e8dcf637 100644 --- a/modules/juce_events/messages/juce_MessageListener.cpp +++ b/modules/juce_events/messages/juce_MessageListener.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + Message::Message() noexcept {} Message::~Message() {} @@ -45,3 +48,5 @@ void MessageListener::postMessage (Message* const message) const message->recipient = const_cast (this); message->post(); } + +} // namespace juce diff --git a/modules/juce_events/messages/juce_MessageListener.h b/modules/juce_events/messages/juce_MessageListener.h index 9e787864eb..8c8fe9bd50 100644 --- a/modules/juce_events/messages/juce_MessageListener.h +++ b/modules/juce_events/messages/juce_MessageListener.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -64,3 +64,5 @@ private: WeakReference::Master masterReference; friend class WeakReference; }; + +} // namespace juce diff --git a/modules/juce_events/messages/juce_MessageManager.cpp b/modules/juce_events/messages/juce_MessageManager.cpp index 2d9fb60d7b..563852e54a 100644 --- a/modules/juce_events/messages/juce_MessageManager.cpp +++ b/modules/juce_events/messages/juce_MessageManager.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + MessageManager::MessageManager() noexcept : messageThreadId (Thread::getCurrentThreadId()) { @@ -380,3 +383,5 @@ static int numScopedInitInstances = 0; ScopedJuceInitialiser_GUI::ScopedJuceInitialiser_GUI() { if (numScopedInitInstances++ == 0) initialiseJuce_GUI(); } ScopedJuceInitialiser_GUI::~ScopedJuceInitialiser_GUI() { if (--numScopedInitInstances == 0) shutdownJuce_GUI(); } + +} // namespace juce diff --git a/modules/juce_events/messages/juce_MessageManager.h b/modules/juce_events/messages/juce_MessageManager.h index e0734f8e3d..e4cb3fc4fd 100644 --- a/modules/juce_events/messages/juce_MessageManager.h +++ b/modules/juce_events/messages/juce_MessageManager.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ class MessageManagerLock; class ThreadPoolJob; @@ -376,3 +377,5 @@ private: JUCE_DECLARE_NON_COPYABLE (MessageManagerLock) }; + +} // namespace juce diff --git a/modules/juce_events/messages/juce_MountedVolumeListChangeDetector.h b/modules/juce_events/messages/juce_MountedVolumeListChangeDetector.h index 37d181e01c..ccc00b11b9 100644 --- a/modules/juce_events/messages/juce_MountedVolumeListChangeDetector.h +++ b/modules/juce_events/messages/juce_MountedVolumeListChangeDetector.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ #if JUCE_MAC || JUCE_WINDOWS || defined (DOXYGEN) @@ -52,3 +53,5 @@ private: }; #endif + +} // namespace juce diff --git a/modules/juce_events/messages/juce_NotificationType.h b/modules/juce_events/messages/juce_NotificationType.h index 1ad3f35dbe..168ac5c681 100644 --- a/modules/juce_events/messages/juce_NotificationType.h +++ b/modules/juce_events/messages/juce_NotificationType.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -34,3 +35,5 @@ enum NotificationType sendNotificationSync, /**< Requests a synchronous notification. */ sendNotificationAsync, /**< Requests an asynchronous notification. */ }; + +} // namespace juce diff --git a/modules/juce_events/native/juce_android_Messaging.cpp b/modules/juce_events/native/juce_android_Messaging.cpp index 922704ddd7..9cb4dfbfce 100644 --- a/modules/juce_events/native/juce_android_Messaging.cpp +++ b/modules/juce_events/native/juce_android_Messaging.cpp @@ -20,7 +20,9 @@ ============================================================================== */ -//============================================================================== +namespace juce +{ + #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ METHOD (constructor, "", "()V") \ METHOD (post, "post", "(Ljava/lang/Runnable;)Z") \ @@ -141,3 +143,5 @@ void MessageManager::stopDispatchLoop() (new QuitCallback())->post(); quitMessagePosted = true; } + +} // namespace juce diff --git a/modules/juce_events/native/juce_ios_MessageManager.mm b/modules/juce_events/native/juce_ios_MessageManager.mm index cf5ce1b5ae..47aed5f498 100644 --- a/modules/juce_events/native/juce_ios_MessageManager.mm +++ b/modules/juce_events/native/juce_ios_MessageManager.mm @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + void MessageManager::runDispatchLoop() { jassert (isThisTheMessageThread()); // must only be called by the message thread @@ -96,3 +99,5 @@ void MessageManager::broadcastMessage (const String&) { // N/A on current iOS } + +} // namespace juce diff --git a/modules/juce_events/native/juce_linux_EventLoop.h b/modules/juce_events/native/juce_linux_EventLoop.h index 46df2bdfd4..ce99bd7ff0 100644 --- a/modules/juce_events/native/juce_linux_EventLoop.h +++ b/modules/juce_events/native/juce_linux_EventLoop.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ namespace LinuxEventLoop { @@ -50,3 +51,5 @@ namespace LinuxEventLoop void setWindowSystemFdInternal (int fd, CallbackFunctionBase* readCallback) noexcept; } + +} // namespace juce diff --git a/modules/juce_events/native/juce_linux_Messaging.cpp b/modules/juce_events/native/juce_linux_Messaging.cpp index 0a88349755..35cf97aef2 100644 --- a/modules/juce_events/native/juce_linux_Messaging.cpp +++ b/modules/juce_events/native/juce_linux_Messaging.cpp @@ -22,22 +22,23 @@ #include -enum FdType { +enum FdType +{ INTERNAL_QUEUE_FD, WINDOW_SYSTEM_FD, FD_COUNT, }; +namespace juce +{ + //============================================================================== class InternalMessageQueue { public: InternalMessageQueue() - : fdCount (1), - loopCount (0), - bytesInSocket (0) { - int ret = ::socketpair (AF_LOCAL, SOCK_STREAM, 0, fd); + auto ret = ::socketpair (AF_LOCAL, SOCK_STREAM, 0, fd); ignoreUnused (ret); jassert (ret == 0); auto internalQueueCb = [this] (int _fd) @@ -115,11 +116,10 @@ public: { const int i = loopCount++; loopCount %= fdCount; + if (readCallback[i] != nullptr && readCallback[i]->active) - { if ((*readCallback[i]) (pfds[i].fd)) return true; - } } return false; @@ -140,9 +140,9 @@ private: int fd[2]; pollfd pfds[FD_COUNT]; ScopedPointer readCallback[FD_COUNT]; - int fdCount; - int loopCount; - int bytesInSocket; + int fdCount = 1; + int loopCount = 0; + int bytesInSocket = 0; int getWriteHandle() const noexcept { return fd[0]; } int getReadHandle() const noexcept { return fd[1]; } @@ -196,12 +196,10 @@ namespace LinuxErrorHandling void MessageManager::doPlatformSpecificInitialisation() { if (JUCEApplicationBase::isStandaloneApp()) - { LinuxErrorHandling::installKeyboardBreakHandler(); - } // Create the internal message queue - InternalMessageQueue* queue = InternalMessageQueue::getInstance(); + auto* queue = InternalMessageQueue::getInstance(); ignoreUnused (queue); } @@ -212,7 +210,7 @@ void MessageManager::doPlatformSpecificShutdown() bool MessageManager::postMessageToSystemQueue (MessageManager::MessageBase* const message) { - if (InternalMessageQueue* queue = InternalMessageQueue::getInstanceWithoutCreating()) + if (auto* queue = InternalMessageQueue::getInstanceWithoutCreating()) { queue->postMessage (message); return true; @@ -221,9 +219,9 @@ bool MessageManager::postMessageToSystemQueue (MessageManager::MessageBase* cons return false; } -void MessageManager::broadcastMessage (const String& /* value */) +void MessageManager::broadcastMessage (const String&) { - /* TODO */ + // TODO } // this function expects that it will NEVER be called simultaneously for two concurrent threads @@ -234,12 +232,12 @@ bool MessageManager::dispatchNextMessageOnSystemQueue (bool returnIfNoPendingMes if (LinuxErrorHandling::keyboardBreakOccurred) JUCEApplicationBase::getInstance()->quit(); - if (InternalMessageQueue* queue = InternalMessageQueue::getInstanceWithoutCreating()) + if (auto* queue = InternalMessageQueue::getInstanceWithoutCreating()) { if (queue->dispatchNextEvent()) break; - else if (returnIfNoPendingMessages) + if (returnIfNoPendingMessages) return false; // wait for 2000ms for next events if necessary @@ -251,16 +249,17 @@ bool MessageManager::dispatchNextMessageOnSystemQueue (bool returnIfNoPendingMes } //============================================================================== - - void LinuxEventLoop::setWindowSystemFdInternal (int fd, LinuxEventLoop::CallbackFunctionBase* readCallback) noexcept { - if (InternalMessageQueue* queue = InternalMessageQueue::getInstanceWithoutCreating()) + if (auto* queue = InternalMessageQueue::getInstanceWithoutCreating()) queue->setWindowSystemFd (fd, readCallback); } void LinuxEventLoop::removeWindowSystemFd() noexcept { - if (InternalMessageQueue* queue = InternalMessageQueue::getInstanceWithoutCreating()) + if (auto* queue = InternalMessageQueue::getInstanceWithoutCreating()) queue->removeWindowSystemFd(); } + + +} // namespace juce diff --git a/modules/juce_events/native/juce_mac_MessageManager.mm b/modules/juce_events/native/juce_mac_MessageManager.mm index 95e9a59dcc..27456e63a9 100644 --- a/modules/juce_events/native/juce_mac_MessageManager.mm +++ b/modules/juce_events/native/juce_mac_MessageManager.mm @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + typedef void (*AppFocusChangeCallback)(); AppFocusChangeCallback appFocusChangeCallback = nullptr; @@ -423,3 +426,5 @@ private: MountedVolumeListChangeDetector::MountedVolumeListChangeDetector() { pimpl = new Pimpl (*this); } MountedVolumeListChangeDetector::~MountedVolumeListChangeDetector() {} #endif + +} // namespace juce diff --git a/modules/juce_events/native/juce_osx_MessageQueue.h b/modules/juce_events/native/juce_osx_MessageQueue.h index 9a23c15c42..32f24fde79 100644 --- a/modules/juce_events/native/juce_osx_MessageQueue.h +++ b/modules/juce_events/native/juce_osx_MessageQueue.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /* An internal message pump class used in OSX and iOS. */ @@ -100,3 +101,5 @@ private: static_cast (info)->runLoopCallback(); } }; + +} // namespace juce diff --git a/modules/juce_events/native/juce_win32_HiddenMessageWindow.h b/modules/juce_events/native/juce_win32_HiddenMessageWindow.h index 80328fb202..9135d99bd6 100644 --- a/modules/juce_events/native/juce_win32_HiddenMessageWindow.h +++ b/modules/juce_events/native/juce_win32_HiddenMessageWindow.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== class HiddenMessageWindow @@ -80,7 +81,7 @@ public: private: static LONG_PTR getImprobableWindowNumber() noexcept { - static LONG_PTR number = (LONG_PTR) Random::getSystemRandom().nextInt64(); + static auto number = (LONG_PTR) Random().nextInt64(); return number; } }; @@ -130,3 +131,5 @@ private: systemDeviceChanged(); } }; + +} // namespace juce diff --git a/modules/juce_events/native/juce_win32_Messaging.cpp b/modules/juce_events/native/juce_win32_Messaging.cpp index f55e5401a9..458f489b17 100644 --- a/modules/juce_events/native/juce_win32_Messaging.cpp +++ b/modules/juce_events/native/juce_win32_Messaging.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + extern HWND juce_messageWindowHandle; typedef bool (*CheckEventBlockedByModalComps) (const MSG&); @@ -225,3 +228,5 @@ struct MountedVolumeListChangeDetector::Pimpl : private DeviceChangeDetector MountedVolumeListChangeDetector::MountedVolumeListChangeDetector() { pimpl = new Pimpl (*this); } MountedVolumeListChangeDetector::~MountedVolumeListChangeDetector() {} + +} // namespace juce diff --git a/modules/juce_events/native/juce_win32_WinRTWrapper.cpp b/modules/juce_events/native/juce_win32_WinRTWrapper.cpp index 39cb99cae7..e8d848da42 100644 --- a/modules/juce_events/native/juce_win32_WinRTWrapper.cpp +++ b/modules/juce_events/native/juce_win32_WinRTWrapper.cpp @@ -20,4 +20,7 @@ ============================================================================== */ -juce_ImplementSingleton (WinRTWrapper) +namespace juce +{ + juce_ImplementSingleton (WinRTWrapper) +} diff --git a/modules/juce_events/native/juce_win32_WinRTWrapper.h b/modules/juce_events/native/juce_win32_WinRTWrapper.h index 8f2503daaf..4a48e04285 100644 --- a/modules/juce_events/native/juce_win32_WinRTWrapper.h +++ b/modules/juce_events/native/juce_win32_WinRTWrapper.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ class WinRTWrapper : public DeletedAtShutdown { @@ -63,13 +64,9 @@ public: String hStringToString (HSTRING hstr) { - const wchar_t* str = nullptr; if (isInitialised()) - { - str = getHStringRawBuffer (hstr, nullptr); - if (str != nullptr) + if (const wchar_t* str = getHStringRawBuffer (hstr, nullptr)) return String (str); - } return {}; } @@ -130,3 +127,5 @@ private: WindowsGetStringRawBufferFuncPtr getHStringRawBuffer = nullptr; RoGetActivationFactoryFuncPtr roGetActivationFactory = nullptr; }; + +} // namespace juce diff --git a/modules/juce_events/timers/juce_MultiTimer.cpp b/modules/juce_events/timers/juce_MultiTimer.cpp index e9ace0a9d5..3f73eb3d7b 100644 --- a/modules/juce_events/timers/juce_MultiTimer.cpp +++ b/modules/juce_events/timers/juce_MultiTimer.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + struct MultiTimerCallback : public Timer { MultiTimerCallback (const int tid, MultiTimer& mt) noexcept @@ -101,3 +104,5 @@ int MultiTimer::getTimerInterval (const int timerID) const noexcept return 0; } + +} // namespace juce diff --git a/modules/juce_events/timers/juce_MultiTimer.h b/modules/juce_events/timers/juce_MultiTimer.h index 87848458d5..8921b68443 100644 --- a/modules/juce_events/timers/juce_MultiTimer.h +++ b/modules/juce_events/timers/juce_MultiTimer.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -119,3 +119,5 @@ private: Timer* getCallback (int) const noexcept; MultiTimer& operator= (const MultiTimer&); }; + +} // namespace juce diff --git a/modules/juce_events/timers/juce_Timer.cpp b/modules/juce_events/timers/juce_Timer.cpp index da2ea738ee..ae6e48fb5e 100644 --- a/modules/juce_events/timers/juce_Timer.cpp +++ b/modules/juce_events/timers/juce_Timer.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + class Timer::TimerThread : private Thread, private DeletedAtShutdown, private AsyncUpdater @@ -364,3 +367,5 @@ void JUCE_CALLTYPE Timer::callAfterDelay (int milliseconds, std::function @@ -692,3 +695,5 @@ Graphics::ScopedSaveState::~ScopedSaveState() { context.restoreState(); } + +} // namespace juce diff --git a/modules/juce_graphics/contexts/juce_GraphicsContext.h b/modules/juce_graphics/contexts/juce_GraphicsContext.h index 1e2e40053b..8351003c0d 100644 --- a/modules/juce_graphics/contexts/juce_GraphicsContext.h +++ b/modules/juce_graphics/contexts/juce_GraphicsContext.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -742,3 +742,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Graphics) }; + +} // namespace juce diff --git a/modules/juce_graphics/contexts/juce_LowLevelGraphicsContext.h b/modules/juce_graphics/contexts/juce_LowLevelGraphicsContext.h index 92ca194393..a9828e3051 100644 --- a/modules/juce_graphics/contexts/juce_LowLevelGraphicsContext.h +++ b/modules/juce_graphics/contexts/juce_LowLevelGraphicsContext.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -97,3 +97,5 @@ public: virtual void drawGlyph (int glyphNumber, const AffineTransform&) = 0; virtual bool drawTextLayout (const AttributedString&, const Rectangle&) { return false; } }; + +} // namespace juce diff --git a/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.cpp b/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.cpp index a9900f03a0..868ccf7355 100644 --- a/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.cpp +++ b/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + // this will throw an assertion if you try to draw something that's not // possible in postscript #define WARN_ABOUT_NON_POSTSCRIPT_OPERATIONS 0 @@ -533,3 +536,5 @@ void LowLevelGraphicsPostScriptRenderer::drawGlyph (int glyphNumber, const Affin font.getTypeface()->getOutlineForGlyph (glyphNumber, p); fillPath (p, AffineTransform::scale (font.getHeight() * font.getHorizontalScale(), font.getHeight()).followedBy (transform)); } + +} // namespace juce diff --git a/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.h b/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.h index 463df4dba7..889702bca3 100644 --- a/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.h +++ b/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -116,3 +116,5 @@ protected: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LowLevelGraphicsPostScriptRenderer) }; + +} // namespace juce diff --git a/modules/juce_graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp b/modules/juce_graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp index c884113714..a32e907710 100644 --- a/modules/juce_graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp +++ b/modules/juce_graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + LowLevelGraphicsSoftwareRenderer::LowLevelGraphicsSoftwareRenderer (const Image& image) : RenderingHelpers::StackBasedLowLevelGraphicsContext (new RenderingHelpers::SoftwareRendererSavedState (image, image.getBounds())) @@ -38,3 +41,5 @@ LowLevelGraphicsSoftwareRenderer::LowLevelGraphicsSoftwareRenderer (const Image& } LowLevelGraphicsSoftwareRenderer::~LowLevelGraphicsSoftwareRenderer() {} + +} // namespace juce diff --git a/modules/juce_graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.h b/modules/juce_graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.h index 648970f91a..06ecca5e0a 100644 --- a/modules/juce_graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.h +++ b/modules/juce_graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -52,3 +52,5 @@ public: private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LowLevelGraphicsSoftwareRenderer) }; + +} // namespace juce diff --git a/modules/juce_graphics/effects/juce_DropShadowEffect.cpp b/modules/juce_graphics/effects/juce_DropShadowEffect.cpp index 5e68ac0dfe..6557c9dd85 100644 --- a/modules/juce_graphics/effects/juce_DropShadowEffect.cpp +++ b/modules/juce_graphics/effects/juce_DropShadowEffect.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + static inline void blurDataTriplets (uint8* d, int num, const int delta) noexcept { uint32 last = d[0]; @@ -182,3 +185,5 @@ void DropShadowEffect::applyEffect (Image& image, Graphics& g, float scaleFactor g.setOpacity (alpha); g.drawImageAt (image, 0, 0); } + +} // namespace juce diff --git a/modules/juce_graphics/effects/juce_DropShadowEffect.h b/modules/juce_graphics/effects/juce_DropShadowEffect.h index 9fefe9a365..3de0f97a62 100644 --- a/modules/juce_graphics/effects/juce_DropShadowEffect.h +++ b/modules/juce_graphics/effects/juce_DropShadowEffect.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -106,3 +106,5 @@ private: JUCE_LEAK_DETECTOR (DropShadowEffect) }; + +} // namespace juce diff --git a/modules/juce_graphics/effects/juce_GlowEffect.cpp b/modules/juce_graphics/effects/juce_GlowEffect.cpp index e3af9ed032..4e1ee32c59 100644 --- a/modules/juce_graphics/effects/juce_GlowEffect.cpp +++ b/modules/juce_graphics/effects/juce_GlowEffect.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + GlowEffect::GlowEffect() {} GlowEffect::~GlowEffect() {} @@ -51,3 +54,5 @@ void GlowEffect::applyEffect (Image& image, Graphics& g, float scaleFactor, floa g.setOpacity (alpha); g.drawImageAt (image, offset.x, offset.y, false); } + +} // namespace juce diff --git a/modules/juce_graphics/effects/juce_GlowEffect.h b/modules/juce_graphics/effects/juce_GlowEffect.h index 2489516825..428ebad709 100644 --- a/modules/juce_graphics/effects/juce_GlowEffect.h +++ b/modules/juce_graphics/effects/juce_GlowEffect.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -71,3 +71,5 @@ private: JUCE_LEAK_DETECTOR (GlowEffect) }; + +} // namespace juce diff --git a/modules/juce_graphics/effects/juce_ImageEffectFilter.h b/modules/juce_graphics/effects/juce_ImageEffectFilter.h index 3d5d11afdd..e06222d92c 100644 --- a/modules/juce_graphics/effects/juce_ImageEffectFilter.h +++ b/modules/juce_graphics/effects/juce_ImageEffectFilter.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -66,3 +66,5 @@ public: virtual ~ImageEffectFilter() {} }; + +} // namespace juce diff --git a/modules/juce_graphics/fonts/juce_AttributedString.cpp b/modules/juce_graphics/fonts/juce_AttributedString.cpp index 944a9be920..000223d966 100644 --- a/modules/juce_graphics/fonts/juce_AttributedString.cpp +++ b/modules/juce_graphics/fonts/juce_AttributedString.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace { int getLength (const Array& atts) noexcept @@ -349,3 +352,5 @@ void AttributedString::draw (Graphics& g, const Rectangle& area) const } } } + +} // namespace juce diff --git a/modules/juce_graphics/fonts/juce_AttributedString.h b/modules/juce_graphics/fonts/juce_AttributedString.h index 98d15a99fb..f0cac6a062 100644 --- a/modules/juce_graphics/fonts/juce_AttributedString.h +++ b/modules/juce_graphics/fonts/juce_AttributedString.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -203,3 +203,5 @@ private: JUCE_LEAK_DETECTOR (AttributedString) }; + +} // namespace juce diff --git a/modules/juce_graphics/fonts/juce_CustomTypeface.cpp b/modules/juce_graphics/fonts/juce_CustomTypeface.cpp index 26d5d9506b..acc1456aa6 100644 --- a/modules/juce_graphics/fonts/juce_CustomTypeface.cpp +++ b/modules/juce_graphics/fonts/juce_CustomTypeface.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class CustomTypeface::GlyphInfo { public: @@ -406,3 +409,5 @@ EdgeTable* CustomTypeface::getEdgeTableForGlyph (int glyphNumber, const AffineTr return nullptr; } + +} // namespace juce diff --git a/modules/juce_graphics/fonts/juce_CustomTypeface.h b/modules/juce_graphics/fonts/juce_CustomTypeface.h index 0de1862f9f..36dda6d5cd 100644 --- a/modules/juce_graphics/fonts/juce_CustomTypeface.h +++ b/modules/juce_graphics/fonts/juce_CustomTypeface.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -161,3 +161,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CustomTypeface) }; + +} // namespace juce diff --git a/modules/juce_graphics/fonts/juce_Font.cpp b/modules/juce_graphics/fonts/juce_Font.cpp index 8d43600250..40e7f1bdea 100644 --- a/modules/juce_graphics/fonts/juce_Font.cpp +++ b/modules/juce_graphics/fonts/juce_Font.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace FontValues { static float limitFontHeight (const float height) noexcept @@ -715,3 +718,5 @@ Font Font::fromString (const String& fontDescription) return Font (name, style, height); } + +} // namespace juce diff --git a/modules/juce_graphics/fonts/juce_Font.h b/modules/juce_graphics/fonts/juce_Font.h index 27fb61a976..cacea2d219 100644 --- a/modules/juce_graphics/fonts/juce_Font.h +++ b/modules/juce_graphics/fonts/juce_Font.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -474,3 +474,5 @@ private: JUCE_LEAK_DETECTOR (Font) }; + +} // namespace juce diff --git a/modules/juce_graphics/fonts/juce_GlyphArrangement.cpp b/modules/juce_graphics/fonts/juce_GlyphArrangement.cpp index adf8d7e03d..f0d05460c5 100644 --- a/modules/juce_graphics/fonts/juce_GlyphArrangement.cpp +++ b/modules/juce_graphics/fonts/juce_GlyphArrangement.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + PositionedGlyph::PositionedGlyph() noexcept : character (0), glyph (0), x (0), y (0), w (0), whitespace (false) { @@ -813,3 +816,5 @@ int GlyphArrangement::findGlyphIndexAt (const float x, const float y) const return -1; } + +} // namespace juce diff --git a/modules/juce_graphics/fonts/juce_GlyphArrangement.h b/modules/juce_graphics/fonts/juce_GlyphArrangement.h index 42bcde4ef2..711e6a06fd 100644 --- a/modules/juce_graphics/fonts/juce_GlyphArrangement.h +++ b/modules/juce_graphics/fonts/juce_GlyphArrangement.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -323,3 +323,5 @@ private: JUCE_LEAK_DETECTOR (GlyphArrangement) }; + +} // namespace juce diff --git a/modules/juce_graphics/fonts/juce_TextLayout.cpp b/modules/juce_graphics/fonts/juce_TextLayout.cpp index 895316607a..5987bb19a6 100644 --- a/modules/juce_graphics/fonts/juce_TextLayout.cpp +++ b/modules/juce_graphics/fonts/juce_TextLayout.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + TextLayout::Glyph::Glyph (const int glyph, Point anch, float w) noexcept : glyphCode (glyph), anchor (anch), width (w) { @@ -583,3 +586,5 @@ void TextLayout::recalculateSize() height = 0; } } + +} // namespace juce diff --git a/modules/juce_graphics/fonts/juce_TextLayout.h b/modules/juce_graphics/fonts/juce_TextLayout.h index 5a1510e654..d5b2016276 100644 --- a/modules/juce_graphics/fonts/juce_TextLayout.h +++ b/modules/juce_graphics/fonts/juce_TextLayout.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -191,3 +191,5 @@ private: JUCE_LEAK_DETECTOR (TextLayout) }; + +} // namespace juce diff --git a/modules/juce_graphics/fonts/juce_Typeface.cpp b/modules/juce_graphics/fonts/juce_Typeface.cpp index 1ce9a78fdf..d712e2d810 100644 --- a/modules/juce_graphics/fonts/juce_Typeface.cpp +++ b/modules/juce_graphics/fonts/juce_Typeface.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + struct FontStyleHelpers { static const char* getStyleName (const bool bold, @@ -260,3 +263,5 @@ void Typeface::applyVerticalHintingTransform (float fontSize, Path& path) return hintingParams->applyVerticalHintingTransform (fontSize, path); } } + +} // namespace juce diff --git a/modules/juce_graphics/fonts/juce_Typeface.h b/modules/juce_graphics/fonts/juce_Typeface.h index 3669fc16ac..82a2eb8f6d 100644 --- a/modules/juce_graphics/fonts/juce_Typeface.h +++ b/modules/juce_graphics/fonts/juce_Typeface.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -157,3 +157,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Typeface) }; + +} // namespace juce diff --git a/modules/juce_graphics/geometry/juce_AffineTransform.cpp b/modules/juce_graphics/geometry/juce_AffineTransform.cpp index b111ed5b1c..59115696db 100644 --- a/modules/juce_graphics/geometry/juce_AffineTransform.cpp +++ b/modules/juce_graphics/geometry/juce_AffineTransform.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + AffineTransform::AffineTransform() noexcept : mat00 (1.0f), mat01 (0), mat02 (0), mat10 (0), mat11 (1.0f), mat12 (0) @@ -262,3 +265,5 @@ float AffineTransform::getScaleFactor() const noexcept { return (std::abs (mat00) + std::abs (mat11)) / 2.0f; } + +} // namespace juce diff --git a/modules/juce_graphics/geometry/juce_AffineTransform.h b/modules/juce_graphics/geometry/juce_AffineTransform.h index 24fcf51568..a11561bafd 100644 --- a/modules/juce_graphics/geometry/juce_AffineTransform.h +++ b/modules/juce_graphics/geometry/juce_AffineTransform.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -275,3 +275,5 @@ public: float mat00, mat01, mat02; float mat10, mat11, mat12; }; + +} // namespace juce diff --git a/modules/juce_graphics/geometry/juce_BorderSize.h b/modules/juce_graphics/geometry/juce_BorderSize.h index 7dbfb8ce57..8678c2eb44 100644 --- a/modules/juce_graphics/geometry/juce_BorderSize.h +++ b/modules/juce_graphics/geometry/juce_BorderSize.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -149,3 +149,5 @@ private: //============================================================================== ValueType top, left, bottom, right; }; + +} // namespace juce diff --git a/modules/juce_graphics/geometry/juce_EdgeTable.cpp b/modules/juce_graphics/geometry/juce_EdgeTable.cpp index ea35e47521..141613c844 100644 --- a/modules/juce_graphics/geometry/juce_EdgeTable.cpp +++ b/modules/juce_graphics/geometry/juce_EdgeTable.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + const int juce_edgeTableDefaultEdgesPerLine = 32; //============================================================================== @@ -831,3 +834,5 @@ bool EdgeTable::isEmpty() noexcept return bounds.getHeight() == 0; } + +} // namespace juce diff --git a/modules/juce_graphics/geometry/juce_EdgeTable.h b/modules/juce_graphics/geometry/juce_EdgeTable.h index f32e61e127..76c318ed1d 100644 --- a/modules/juce_graphics/geometry/juce_EdgeTable.h +++ b/modules/juce_graphics/geometry/juce_EdgeTable.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -216,3 +216,5 @@ private: JUCE_LEAK_DETECTOR (EdgeTable) }; + +} // namespace juce diff --git a/modules/juce_graphics/geometry/juce_Line.h b/modules/juce_graphics/geometry/juce_Line.h index 7143fe3082..d8db97a4e6 100644 --- a/modules/juce_graphics/geometry/juce_Line.h +++ b/modules/juce_graphics/geometry/juce_Line.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -424,3 +424,5 @@ private: return isZeroToOne (along2); } }; + +} // namespace juce diff --git a/modules/juce_graphics/geometry/juce_Path.cpp b/modules/juce_graphics/geometry/juce_Path.cpp index 38b0d53cc0..849d4a0835 100644 --- a/modules/juce_graphics/geometry/juce_Path.cpp +++ b/modules/juce_graphics/geometry/juce_Path.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + // tests that some coordinates aren't NaNs #define JUCE_CHECK_COORDS_ARE_VALID(x, y) \ jassert (x == x && y == y); @@ -1631,3 +1634,5 @@ bool Path::Iterator::next() noexcept } #undef JUCE_CHECK_COORDS_ARE_VALID + +} // namespace juce diff --git a/modules/juce_graphics/geometry/juce_Path.h b/modules/juce_graphics/geometry/juce_Path.h index 03dc768949..1a4962ac6d 100644 --- a/modules/juce_graphics/geometry/juce_Path.h +++ b/modules/juce_graphics/geometry/juce_Path.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -829,3 +829,5 @@ private: JUCE_LEAK_DETECTOR (Path) }; + +} // namespace juce diff --git a/modules/juce_graphics/geometry/juce_PathIterator.cpp b/modules/juce_graphics/geometry/juce_PathIterator.cpp index d56cd436a1..ca239d4f95 100644 --- a/modules/juce_graphics/geometry/juce_PathIterator.cpp +++ b/modules/juce_graphics/geometry/juce_PathIterator.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_MSVC && JUCE_DEBUG #pragma optimize ("t", on) #endif @@ -279,3 +282,5 @@ bool PathFlatteningIterator::next() #if JUCE_MSVC && JUCE_DEBUG #pragma optimize ("", on) // resets optimisations to the project defaults #endif + +} // namespace juce diff --git a/modules/juce_graphics/geometry/juce_PathIterator.h b/modules/juce_graphics/geometry/juce_PathIterator.h index 96c70a8525..d37b5407d6 100644 --- a/modules/juce_graphics/geometry/juce_PathIterator.h +++ b/modules/juce_graphics/geometry/juce_PathIterator.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -106,3 +106,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PathFlatteningIterator) }; + +} // namespace juce diff --git a/modules/juce_graphics/geometry/juce_PathStrokeType.cpp b/modules/juce_graphics/geometry/juce_PathStrokeType.cpp index dbab9c7bbe..8069a696d2 100644 --- a/modules/juce_graphics/geometry/juce_PathStrokeType.cpp +++ b/modules/juce_graphics/geometry/juce_PathStrokeType.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + PathStrokeType::PathStrokeType (float strokeThickness) noexcept : thickness (strokeThickness), jointStyle (mitered), endStyle (butt) { @@ -738,3 +741,5 @@ void PathStrokeType::createStrokeWithArrowheads (Path& destPath, PathStrokeHelpers::createStroke (thickness, jointStyle, endStyle, destPath, sourcePath, transform, extraAccuracy, &head); } + +} // namespace juce diff --git a/modules/juce_graphics/geometry/juce_PathStrokeType.h b/modules/juce_graphics/geometry/juce_PathStrokeType.h index de804b1436..c84412dd98 100644 --- a/modules/juce_graphics/geometry/juce_PathStrokeType.h +++ b/modules/juce_graphics/geometry/juce_PathStrokeType.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -201,3 +201,5 @@ private: JUCE_LEAK_DETECTOR (PathStrokeType) }; + +} // namespace juce diff --git a/modules/juce_graphics/geometry/juce_Point.h b/modules/juce_graphics/geometry/juce_Point.h index 69915c31a5..2b66ae8475 100644 --- a/modules/juce_graphics/geometry/juce_Point.h +++ b/modules/juce_graphics/geometry/juce_Point.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -239,3 +239,5 @@ public: /** Multiplies the point's coordinates by a scalar value. */ template Point operator* (ValueType value, Point p) noexcept { return p * value; } + +} // namespace juce diff --git a/modules/juce_graphics/geometry/juce_Rectangle.h b/modules/juce_graphics/geometry/juce_Rectangle.h index dca99f300f..eb5d937be3 100644 --- a/modules/juce_graphics/geometry/juce_Rectangle.h +++ b/modules/juce_graphics/geometry/juce_Rectangle.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -977,3 +977,5 @@ private: static int ceilAsInt (float n) noexcept { return n < (float) std::numeric_limits::max() ? (int) std::ceil (n) : std::numeric_limits::max(); } static int ceilAsInt (double n) noexcept { return n < (double) std::numeric_limits::max() ? (int) std::ceil (n) : std::numeric_limits::max(); } }; + +} // namespace juce diff --git a/modules/juce_graphics/geometry/juce_RectangleList.h b/modules/juce_graphics/geometry/juce_RectangleList.h index e611fcb8fe..55512fda1d 100644 --- a/modules/juce_graphics/geometry/juce_RectangleList.h +++ b/modules/juce_graphics/geometry/juce_RectangleList.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -649,3 +649,5 @@ private: //============================================================================== Array rects; }; + +} // namespace juce diff --git a/modules/juce_graphics/image_formats/juce_GIFLoader.cpp b/modules/juce_graphics/image_formats/juce_GIFLoader.cpp index 5d8c205e16..80a101e644 100644 --- a/modules/juce_graphics/image_formats/juce_GIFLoader.cpp +++ b/modules/juce_graphics/image_formats/juce_GIFLoader.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #if (JUCE_MAC || JUCE_IOS) && USE_COREGRAPHICS_RENDERING && JUCE_USE_COREIMAGE_LOADER Image juce_loadWithCoreImage (InputStream& input); #else @@ -444,3 +447,5 @@ bool GIFImageFormat::writeImageToStream (const Image& /*sourceImage*/, OutputStr jassertfalse; // writing isn't implemented for GIFs! return false; } + +} // namespace juce diff --git a/modules/juce_graphics/image_formats/juce_JPEGLoader.cpp b/modules/juce_graphics/image_formats/juce_JPEGLoader.cpp index ff5c1629d6..793d10ba64 100644 --- a/modules/juce_graphics/image_formats/juce_JPEGLoader.cpp +++ b/modules/juce_graphics/image_formats/juce_JPEGLoader.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_MSVC #pragma warning (push) #pragma warning (disable: 4365) @@ -449,3 +452,5 @@ bool JPEGImageFormat::writeImageToStream (const Image& image, OutputStream& out) return true; } + +} // namespace juce diff --git a/modules/juce_graphics/image_formats/juce_PNGLoader.cpp b/modules/juce_graphics/image_formats/juce_PNGLoader.cpp index dbf35059eb..ee06273171 100644 --- a/modules/juce_graphics/image_formats/juce_PNGLoader.cpp +++ b/modules/juce_graphics/image_formats/juce_PNGLoader.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_MSVC #pragma warning (push) #pragma warning (disable: 4390 4611 4365 4267) @@ -598,3 +601,5 @@ bool PNGImageFormat::writeImageToStream (const Image& image, OutputStream& out) return true; } + +} // namespace juce diff --git a/modules/juce_graphics/images/juce_Image.cpp b/modules/juce_graphics/images/juce_Image.cpp index 7028b65e91..1b206f5a22 100644 --- a/modules/juce_graphics/images/juce_Image.cpp +++ b/modules/juce_graphics/images/juce_Image.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ImagePixelData::ImagePixelData (const Image::PixelFormat format, const int w, const int h) : pixelFormat (format), width (w), height (h) { @@ -673,3 +676,5 @@ void Image::moveImageSection (int dx, int dy, } } } + +} // namespace juce diff --git a/modules/juce_graphics/images/juce_Image.h b/modules/juce_graphics/images/juce_Image.h index a2c436d251..eefaa98d1f 100644 --- a/modules/juce_graphics/images/juce_Image.h +++ b/modules/juce_graphics/images/juce_Image.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ class ImageType; class ImagePixelData; @@ -542,3 +543,5 @@ public: ImagePixelData::Ptr create (Image::PixelFormat, int width, int height, bool clearImage) const override; int getTypeID() const override; }; + +} // namespace juce diff --git a/modules/juce_graphics/images/juce_ImageCache.cpp b/modules/juce_graphics/images/juce_ImageCache.cpp index 50c3203f4b..e565f5e5e6 100644 --- a/modules/juce_graphics/images/juce_ImageCache.cpp +++ b/modules/juce_graphics/images/juce_ImageCache.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + struct ImageCache::Pimpl : private Timer, private DeletedAtShutdown { @@ -163,3 +166,5 @@ void ImageCache::releaseUnusedImages() { Pimpl::getInstance()->releaseUnusedImages(); } + +} // namespace juce diff --git a/modules/juce_graphics/images/juce_ImageCache.h b/modules/juce_graphics/images/juce_ImageCache.h index fa5b5710c7..753ce750de 100644 --- a/modules/juce_graphics/images/juce_ImageCache.h +++ b/modules/juce_graphics/images/juce_ImageCache.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -122,3 +122,5 @@ private: JUCE_DECLARE_NON_COPYABLE (ImageCache) }; + +} // namespace juce diff --git a/modules/juce_graphics/images/juce_ImageConvolutionKernel.cpp b/modules/juce_graphics/images/juce_ImageConvolutionKernel.cpp index a56cab1ebe..e7408c2f0c 100644 --- a/modules/juce_graphics/images/juce_ImageConvolutionKernel.cpp +++ b/modules/juce_graphics/images/juce_ImageConvolutionKernel.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ImageConvolutionKernel::ImageConvolutionKernel (const int size_) : values ((size_t) (size_ * size_)), size (size_) @@ -290,3 +293,5 @@ void ImageConvolutionKernel::applyToImage (Image& destImage, } } } + +} // namespace juce diff --git a/modules/juce_graphics/images/juce_ImageConvolutionKernel.h b/modules/juce_graphics/images/juce_ImageConvolutionKernel.h index cc399d9653..c3495a2684 100644 --- a/modules/juce_graphics/images/juce_ImageConvolutionKernel.h +++ b/modules/juce_graphics/images/juce_ImageConvolutionKernel.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -107,3 +107,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ImageConvolutionKernel) }; + +} // namespace juce diff --git a/modules/juce_graphics/images/juce_ImageFileFormat.cpp b/modules/juce_graphics/images/juce_ImageFileFormat.cpp index 669a39be47..12ad6afb2e 100644 --- a/modules/juce_graphics/images/juce_ImageFileFormat.cpp +++ b/modules/juce_graphics/images/juce_ImageFileFormat.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + struct DefaultImageFormats { static ImageFileFormat** get() @@ -105,3 +108,5 @@ Image ImageFileFormat::loadFrom (const void* rawData, const size_t numBytes) return Image(); } + +} // namespace juce diff --git a/modules/juce_graphics/images/juce_ImageFileFormat.h b/modules/juce_graphics/images/juce_ImageFileFormat.h index e558906af7..ec7138836a 100644 --- a/modules/juce_graphics/images/juce_ImageFileFormat.h +++ b/modules/juce_graphics/images/juce_ImageFileFormat.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -212,3 +212,5 @@ public: Image decodeImage (InputStream&) override; bool writeImageToStream (const Image&, OutputStream&) override; }; + +} // namespace juce diff --git a/modules/juce_graphics/juce_graphics.cpp b/modules/juce_graphics/juce_graphics.cpp index 6884981880..373c9f4e4d 100644 --- a/modules/juce_graphics/juce_graphics.cpp +++ b/modules/juce_graphics/juce_graphics.cpp @@ -106,9 +106,6 @@ #endif //============================================================================== -namespace juce -{ - #include "colour/juce_Colour.cpp" #include "colour/juce_ColourGradient.cpp" #include "colour/juce_Colours.cpp" @@ -167,7 +164,6 @@ namespace juce #include "native/juce_android_IconHelpers.cpp" #endif -} //============================================================================== #if JUCE_USE_FREETYPE && JUCE_USE_FREETYPE_AMALGAMATED diff --git a/modules/juce_graphics/juce_graphics.h b/modules/juce_graphics/juce_graphics.h index c823b10f10..29b19b1370 100644 --- a/modules/juce_graphics/juce_graphics.h +++ b/modules/juce_graphics/juce_graphics.h @@ -92,14 +92,14 @@ //============================================================================== namespace juce { - -class Image; -class AffineTransform; -class Path; -class Font; -class Graphics; -class FillType; -class LowLevelGraphicsContext; + class Image; + class AffineTransform; + class Path; + class Font; + class Graphics; + class FillType; + class LowLevelGraphicsContext; +} #include "geometry/juce_AffineTransform.h" #include "geometry/juce_Point.h" @@ -145,5 +145,3 @@ class LowLevelGraphicsContext; #if JUCE_DIRECT2D && JUCE_WINDOWS #include "native/juce_win32_Direct2DGraphicsContext.h" #endif - -} diff --git a/modules/juce_graphics/native/juce_RenderingHelpers.h b/modules/juce_graphics/native/juce_RenderingHelpers.h index 67b9b561c0..e552758b2c 100644 --- a/modules/juce_graphics/native/juce_RenderingHelpers.h +++ b/modules/juce_graphics/native/juce_RenderingHelpers.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ #if JUCE_MSVC #pragma warning (push) @@ -2685,3 +2686,5 @@ protected: #if JUCE_MSVC #pragma warning (pop) #endif + +} // namespace juce diff --git a/modules/juce_graphics/native/juce_android_Fonts.cpp b/modules/juce_graphics/native/juce_android_Fonts.cpp index 5bfe92da6f..a5ffa6b7d8 100644 --- a/modules/juce_graphics/native/juce_android_Fonts.cpp +++ b/modules/juce_graphics/native/juce_android_Fonts.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + struct DefaultFontNames { DefaultFontNames() @@ -402,3 +405,5 @@ bool TextLayout::createNativeLayout (const AttributedString&) } #endif + +} // namespace juce diff --git a/modules/juce_graphics/native/juce_android_GraphicsContext.cpp b/modules/juce_graphics/native/juce_android_GraphicsContext.cpp index 2f36d872e5..77dabe2e3f 100644 --- a/modules/juce_graphics/native/juce_android_GraphicsContext.cpp +++ b/modules/juce_graphics/native/juce_android_GraphicsContext.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace GraphicsHelpers { jobject createPaint (Graphics::ResamplingQuality quality) @@ -60,3 +63,5 @@ ImagePixelData::Ptr NativeImageType::create (Image::PixelFormat format, int widt { return SoftwareImageType().create (format, width, height, clearImage); } + +} // namespace juce diff --git a/modules/juce_graphics/native/juce_android_IconHelpers.cpp b/modules/juce_graphics/native/juce_android_IconHelpers.cpp index 287005422c..3a11f8e344 100644 --- a/modules/juce_graphics/native/juce_android_IconHelpers.cpp +++ b/modules/juce_graphics/native/juce_android_IconHelpers.cpp @@ -24,7 +24,7 @@ ============================================================================== */ -Image JUCE_API getIconFromApplication (const String&, const int) +namespace juce { - return Image(); + Image JUCE_API getIconFromApplication (const String&, int) { return {}; } } diff --git a/modules/juce_graphics/native/juce_freetype_Fonts.cpp b/modules/juce_graphics/native/juce_freetype_Fonts.cpp index 1f01b77c96..a813ec61b1 100644 --- a/modules/juce_graphics/native/juce_freetype_Fonts.cpp +++ b/modules/juce_graphics/native/juce_freetype_Fonts.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + struct FTLibWrapper : public ReferenceCountedObject { FTLibWrapper() : library (0) @@ -455,3 +458,5 @@ private: JUCE_DECLARE_NON_COPYABLE (FreeTypeTypeface) }; + +} // namespace juce diff --git a/modules/juce_graphics/native/juce_linux_Fonts.cpp b/modules/juce_graphics/native/juce_linux_Fonts.cpp index 24b98669e6..06cd9401a6 100644 --- a/modules/juce_graphics/native/juce_linux_Fonts.cpp +++ b/modules/juce_graphics/native/juce_linux_Fonts.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + static XmlElement* findFontsConfFile() { static const char* pathsToSearch[] = { "/etc/fonts/fonts.conf", @@ -190,3 +193,5 @@ Typeface::Ptr Font::getDefaultTypefaceForFont (const Font& font) f.setTypefaceName (defaultNames.getRealFontName (font.getTypefaceName())); return Typeface::createSystemTypefaceFor (f); } + +} // namespace juce diff --git a/modules/juce_graphics/native/juce_linux_IconHelpers.cpp b/modules/juce_graphics/native/juce_linux_IconHelpers.cpp index 287005422c..3a11f8e344 100644 --- a/modules/juce_graphics/native/juce_linux_IconHelpers.cpp +++ b/modules/juce_graphics/native/juce_linux_IconHelpers.cpp @@ -24,7 +24,7 @@ ============================================================================== */ -Image JUCE_API getIconFromApplication (const String&, const int) +namespace juce { - return Image(); + Image JUCE_API getIconFromApplication (const String&, int) { return {}; } } diff --git a/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.h b/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.h index 4b81cf1002..5db0407439 100644 --- a/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.h +++ b/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== class CoreGraphicsContext : public LowLevelGraphicsContext @@ -110,3 +111,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CoreGraphicsContext) }; + +} // namespace juce diff --git a/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm b/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm index fa97d97a58..63e7f89259 100644 --- a/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm +++ b/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm @@ -24,9 +24,9 @@ ============================================================================== */ -#include "juce_mac_CoreGraphicsContext.h" +namespace juce +{ -//============================================================================== class CoreGraphicsImage : public ImagePixelData { public: @@ -919,3 +919,5 @@ Image juce_createImageFromUIImage (UIImage* img) return retval; } #endif + +} diff --git a/modules/juce_graphics/native/juce_mac_CoreGraphicsHelpers.h b/modules/juce_graphics/native/juce_mac_CoreGraphicsHelpers.h index f60b158a1f..6d04d73ea7 100644 --- a/modules/juce_graphics/native/juce_mac_CoreGraphicsHelpers.h +++ b/modules/juce_graphics/native/juce_mac_CoreGraphicsHelpers.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== namespace @@ -59,5 +59,7 @@ extern CGImageRef juce_createCoreGraphicsImage (const Image&, CGColorSpaceRef, b extern CGContextRef juce_getImageContext (const Image&); #if JUCE_IOS -extern Image juce_createImageFromUIImage (UIImage*); + extern Image juce_createImageFromUIImage (UIImage*); #endif + +} // namespace juce diff --git a/modules/juce_graphics/native/juce_mac_Fonts.mm b/modules/juce_graphics/native/juce_mac_Fonts.mm index 61c9cf8c2f..19b3b38f3f 100644 --- a/modules/juce_graphics/native/juce_mac_Fonts.mm +++ b/modules/juce_graphics/native/juce_mac_Fonts.mm @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #ifndef JUCE_CORETEXT_AVAILABLE #define JUCE_CORETEXT_AVAILABLE 1 #endif @@ -1245,3 +1248,5 @@ bool TextLayout::createNativeLayout (const AttributedString& text) ignoreUnused (text); return false; } + +} // namespace juce diff --git a/modules/juce_graphics/native/juce_mac_IconHelpers.cpp b/modules/juce_graphics/native/juce_mac_IconHelpers.cpp index 0f3b740b06..03aa559c5e 100644 --- a/modules/juce_graphics/native/juce_mac_IconHelpers.cpp +++ b/modules/juce_graphics/native/juce_mac_IconHelpers.cpp @@ -24,9 +24,13 @@ ============================================================================== */ +namespace juce +{ + Image getIconFromIcnsFile (const File& icnsFile, const int size) { FileInputStream stream (icnsFile); + if (! stream.openedOk()) return {}; @@ -44,6 +48,7 @@ Image getIconFromIcnsFile (const File& icnsFile, const int size) return {}; const auto dataSize = juce::ByteOrder::bigEndianInt (headerSection); + if (dataSize <= 0) return {}; @@ -66,6 +71,7 @@ Image getIconFromIcnsFile (const File& icnsFile, const int size) break; const auto sectionSize = ByteOrder::bigEndianInt (headerSection); + if (sectionSize <= 0) break; @@ -81,6 +87,7 @@ Image getIconFromIcnsFile (const File& icnsFile, const int size) const auto lastImageIndex = images.size() - 1; const auto lastWidth = images.getReference (lastImageIndex).getWidth(); + if (lastWidth > maxWidth) { maxWidthIndex = lastImageIndex; @@ -122,16 +129,22 @@ Image JUCE_API getIconFromApplication (const String& applicationPath, const int hostIcon = getIconFromIcnsFile (icnsFile, size); CFRelease (iconPath); } + CFRelease (iconURL); } } } + CFRelease (appBundle); } + CFRelease (url); } + CFRelease (pathCFString); } return hostIcon; } + +} // namespace juce diff --git a/modules/juce_graphics/native/juce_win32_Direct2DGraphicsContext.cpp b/modules/juce_graphics/native/juce_win32_Direct2DGraphicsContext.cpp index 40f848e58d..b9f7d592ff 100644 --- a/modules/juce_graphics/native/juce_win32_Direct2DGraphicsContext.cpp +++ b/modules/juce_graphics/native/juce_win32_Direct2DGraphicsContext.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + template D2D1_RECT_F rectangleToRectF (const Rectangle& r) { @@ -823,3 +826,5 @@ bool Direct2DLowLevelGraphicsContext::drawTextLayout (const AttributedString& te pimpl->renderingTarget->SetTransform (D2D1::IdentityMatrix()); return true; } + +} // namespace juce diff --git a/modules/juce_graphics/native/juce_win32_Direct2DGraphicsContext.h b/modules/juce_graphics/native/juce_win32_Direct2DGraphicsContext.h index 2c923a76ed..fb8714dbf1 100644 --- a/modules/juce_graphics/native/juce_win32_Direct2DGraphicsContext.h +++ b/modules/juce_graphics/native/juce_win32_Direct2DGraphicsContext.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ #ifndef _WINDEF_ class HWND__; // Forward or never @@ -101,3 +102,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Direct2DLowLevelGraphicsContext) }; + +} // namespace juce diff --git a/modules/juce_graphics/native/juce_win32_DirectWriteTypeLayout.cpp b/modules/juce_graphics/native/juce_win32_DirectWriteTypeLayout.cpp index 739fc539ae..d007ebb6bc 100644 --- a/modules/juce_graphics/native/juce_win32_DirectWriteTypeLayout.cpp +++ b/modules/juce_graphics/native/juce_win32_DirectWriteTypeLayout.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_USE_DIRECTWRITE namespace DirectWriteTypeLayout { @@ -453,3 +456,5 @@ bool TextLayout::createNativeLayout (const AttributedString& text) return false; } + +} // namespace juce diff --git a/modules/juce_graphics/native/juce_win32_DirectWriteTypeface.cpp b/modules/juce_graphics/native/juce_win32_DirectWriteTypeface.cpp index fb30ddb42d..2643d1a169 100644 --- a/modules/juce_graphics/native/juce_win32_DirectWriteTypeface.cpp +++ b/modules/juce_graphics/native/juce_win32_DirectWriteTypeface.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_USE_DIRECTWRITE namespace { @@ -320,3 +323,5 @@ private: }; #endif + +} // namespace juce diff --git a/modules/juce_graphics/native/juce_win32_Fonts.cpp b/modules/juce_graphics/native/juce_win32_Fonts.cpp index d8198341cd..b6159c3f94 100644 --- a/modules/juce_graphics/native/juce_win32_Fonts.cpp +++ b/modules/juce_graphics/native/juce_win32_Fonts.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + /* This is some quick-and-dirty code to extract the typeface name from a lump of TTF file data. It's needed because although win32 will happily load a TTF file from in-memory data, it won't tell you the name of the damned font that it just loaded.. and in order to actually use the font, @@ -644,3 +647,5 @@ void Typeface::scanFolderForFonts (const File&) { jassertfalse; // not implemented on this platform } + +} // namespace juce diff --git a/modules/juce_graphics/native/juce_win32_IconHelpers.cpp b/modules/juce_graphics/native/juce_win32_IconHelpers.cpp index 287005422c..3a11f8e344 100644 --- a/modules/juce_graphics/native/juce_win32_IconHelpers.cpp +++ b/modules/juce_graphics/native/juce_win32_IconHelpers.cpp @@ -24,7 +24,7 @@ ============================================================================== */ -Image JUCE_API getIconFromApplication (const String&, const int) +namespace juce { - return Image(); + Image JUCE_API getIconFromApplication (const String&, int) { return {}; } } diff --git a/modules/juce_graphics/placement/juce_Justification.h b/modules/juce_graphics/placement/juce_Justification.h index a70ea25184..8c8fb8362b 100644 --- a/modules/juce_graphics/placement/juce_Justification.h +++ b/modules/juce_graphics/placement/juce_Justification.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -186,3 +186,5 @@ private: //============================================================================== int flags; }; + +} // namespace juce diff --git a/modules/juce_graphics/placement/juce_RectanglePlacement.cpp b/modules/juce_graphics/placement/juce_RectanglePlacement.cpp index 1d1143636e..6f718c0948 100644 --- a/modules/juce_graphics/placement/juce_RectanglePlacement.cpp +++ b/modules/juce_graphics/placement/juce_RectanglePlacement.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + RectanglePlacement::RectanglePlacement (const RectanglePlacement& other) noexcept : flags (other.flags) { @@ -127,3 +130,5 @@ AffineTransform RectanglePlacement::getTransformToFit (const Rectangle& s .scaled (scaleX, scaleY) .translated (newX, newY); } + +} // namespace juce diff --git a/modules/juce_graphics/placement/juce_RectanglePlacement.h b/modules/juce_graphics/placement/juce_RectanglePlacement.h index 1d6aefd748..84eec1db0f 100644 --- a/modules/juce_graphics/placement/juce_RectanglePlacement.h +++ b/modules/juce_graphics/placement/juce_RectanglePlacement.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -169,3 +169,5 @@ private: //============================================================================== int flags; }; + +} // namespace juce diff --git a/modules/juce_gui_basics/application/juce_Application.cpp b/modules/juce_gui_basics/application/juce_Application.cpp index a365031d2e..efa5242bbd 100644 --- a/modules/juce_gui_basics/application/juce_Application.cpp +++ b/modules/juce_gui_basics/application/juce_Application.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + JUCEApplication::JUCEApplication() {} JUCEApplication::~JUCEApplication() {} @@ -98,3 +101,5 @@ bool JUCEApplication::initialiseApp() return false; } + +} // namespace juce diff --git a/modules/juce_gui_basics/application/juce_Application.h b/modules/juce_gui_basics/application/juce_Application.h index 9ade8bbe9d..423f8ce5c6 100644 --- a/modules/juce_gui_basics/application/juce_Application.h +++ b/modules/juce_gui_basics/application/juce_Application.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -188,3 +188,5 @@ private: JUCE_DECLARE_NON_COPYABLE (JUCEApplication) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/buttons/juce_ArrowButton.cpp b/modules/juce_gui_basics/buttons/juce_ArrowButton.cpp index 4076462db9..fa76bc1d3d 100644 --- a/modules/juce_gui_basics/buttons/juce_ArrowButton.cpp +++ b/modules/juce_gui_basics/buttons/juce_ArrowButton.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ArrowButton::ArrowButton (const String& name, float arrowDirectionInRadians, Colour arrowColour) : Button (name), colour (arrowColour) { @@ -45,3 +48,5 @@ void ArrowButton::paintButton (Graphics& g, bool /*isMouseOverButton*/, bool isB g.setColour (colour); g.fillPath (p); } + +} // namespace juce diff --git a/modules/juce_gui_basics/buttons/juce_ArrowButton.h b/modules/juce_gui_basics/buttons/juce_ArrowButton.h index c05a0c5f65..8ff4d7f476 100644 --- a/modules/juce_gui_basics/buttons/juce_ArrowButton.h +++ b/modules/juce_gui_basics/buttons/juce_ArrowButton.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -60,3 +60,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ArrowButton) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/buttons/juce_Button.cpp b/modules/juce_gui_basics/buttons/juce_Button.cpp index 9ece5dd0c6..e82b83897d 100644 --- a/modules/juce_gui_basics/buttons/juce_Button.cpp +++ b/modules/juce_gui_basics/buttons/juce_Button.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class Button::CallbackHelper : public Timer, public ApplicationCommandManagerListener, public Value::Listener, @@ -692,3 +695,5 @@ void Button::repeatTimerCallback() callbackHelper->stopTimer(); } } + +} // namespace juce diff --git a/modules/juce_gui_basics/buttons/juce_Button.h b/modules/juce_gui_basics/buttons/juce_Button.h index 9ba29f157c..79de48cc27 100644 --- a/modules/juce_gui_basics/buttons/juce_Button.h +++ b/modules/juce_gui_basics/buttons/juce_Button.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -518,3 +518,5 @@ private: /** This typedef is just for compatibility with old code and VC6 - newer code should use Button::Listener instead. */ typedef Button::Listener ButtonListener; #endif + +} // namespace juce diff --git a/modules/juce_gui_basics/buttons/juce_DrawableButton.cpp b/modules/juce_gui_basics/buttons/juce_DrawableButton.cpp index 3fa94c0c85..f4b01ef3ef 100644 --- a/modules/juce_gui_basics/buttons/juce_DrawableButton.cpp +++ b/modules/juce_gui_basics/buttons/juce_DrawableButton.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + DrawableButton::DrawableButton (const String& name, const DrawableButton::ButtonStyle buttonStyle) : Button (name), style (buttonStyle) { @@ -219,3 +222,5 @@ Drawable* DrawableButton::getDownImage() const noexcept return getOverImage(); } + +} // namespace juce diff --git a/modules/juce_gui_basics/buttons/juce_DrawableButton.h b/modules/juce_gui_basics/buttons/juce_DrawableButton.h index 44124c2b58..8e261373c9 100644 --- a/modules/juce_gui_basics/buttons/juce_DrawableButton.h +++ b/modules/juce_gui_basics/buttons/juce_DrawableButton.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -187,3 +187,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DrawableButton) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/buttons/juce_HyperlinkButton.cpp b/modules/juce_gui_basics/buttons/juce_HyperlinkButton.cpp index 5d76c4310a..acafad1ac8 100644 --- a/modules/juce_gui_basics/buttons/juce_HyperlinkButton.cpp +++ b/modules/juce_gui_basics/buttons/juce_HyperlinkButton.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + HyperlinkButton::HyperlinkButton (const String& linkText, const URL& linkURL) : Button (linkText), @@ -109,3 +112,5 @@ void HyperlinkButton::paintButton (Graphics& g, justification.getOnlyHorizontalFlags() | Justification::verticallyCentred, true); } + +} // namespace juce diff --git a/modules/juce_gui_basics/buttons/juce_HyperlinkButton.h b/modules/juce_gui_basics/buttons/juce_HyperlinkButton.h index 746dd4e284..1b67e17d08 100644 --- a/modules/juce_gui_basics/buttons/juce_HyperlinkButton.h +++ b/modules/juce_gui_basics/buttons/juce_HyperlinkButton.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -111,3 +111,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (HyperlinkButton) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/buttons/juce_ImageButton.cpp b/modules/juce_gui_basics/buttons/juce_ImageButton.cpp index 7bd3fb5f17..e89f5736d5 100644 --- a/modules/juce_gui_basics/buttons/juce_ImageButton.cpp +++ b/modules/juce_gui_basics/buttons/juce_ImageButton.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ImageButton::ImageButton (const String& text_) : Button (text_), scaleImageToFit (true), @@ -192,3 +195,5 @@ bool ImageButton::hitTest (int x, int y) && alphaThreshold < im.getPixelAt (((x - imageBounds.getX()) * im.getWidth()) / imageBounds.getWidth(), ((y - imageBounds.getY()) * im.getHeight()) / imageBounds.getHeight()).getAlpha()); } + +} // namespace juce diff --git a/modules/juce_gui_basics/buttons/juce_ImageButton.h b/modules/juce_gui_basics/buttons/juce_ImageButton.h index d24de290ce..c867973d7c 100644 --- a/modules/juce_gui_basics/buttons/juce_ImageButton.h +++ b/modules/juce_gui_basics/buttons/juce_ImageButton.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -156,3 +156,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ImageButton) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/buttons/juce_ShapeButton.cpp b/modules/juce_gui_basics/buttons/juce_ShapeButton.cpp index 733b1a41e6..3e7f91a59d 100644 --- a/modules/juce_gui_basics/buttons/juce_ShapeButton.cpp +++ b/modules/juce_gui_basics/buttons/juce_ShapeButton.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ShapeButton::ShapeButton (const String& t, Colour n, Colour o, Colour d) : Button (t), normalColour (n), overColour (o), downColour (d), @@ -129,3 +132,5 @@ void ShapeButton::paintButton (Graphics& g, bool isMouseOverButton, bool isButto g.strokePath (shape, PathStrokeType (outlineWidth), trans); } } + +} // namespace juce diff --git a/modules/juce_gui_basics/buttons/juce_ShapeButton.h b/modules/juce_gui_basics/buttons/juce_ShapeButton.h index 60372a3bf0..193d886fd4 100644 --- a/modules/juce_gui_basics/buttons/juce_ShapeButton.h +++ b/modules/juce_gui_basics/buttons/juce_ShapeButton.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -121,3 +121,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ShapeButton) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/buttons/juce_TextButton.cpp b/modules/juce_gui_basics/buttons/juce_TextButton.cpp index 59e80696de..d7d4fb46cd 100644 --- a/modules/juce_gui_basics/buttons/juce_TextButton.cpp +++ b/modules/juce_gui_basics/buttons/juce_TextButton.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + TextButton::TextButton() : Button (String()) { } @@ -71,3 +74,5 @@ int TextButton::getBestWidthForHeight (int buttonHeight) { return getLookAndFeel().getTextButtonWidthToFitText (*this, buttonHeight); } + +} // namespace juce diff --git a/modules/juce_gui_basics/buttons/juce_TextButton.h b/modules/juce_gui_basics/buttons/juce_TextButton.h index b5f6d346ba..1631af52cb 100644 --- a/modules/juce_gui_basics/buttons/juce_TextButton.h +++ b/modules/juce_gui_basics/buttons/juce_TextButton.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -109,3 +109,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TextButton) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/buttons/juce_ToggleButton.cpp b/modules/juce_gui_basics/buttons/juce_ToggleButton.cpp index a9a3c84f99..a43e45d1e7 100644 --- a/modules/juce_gui_basics/buttons/juce_ToggleButton.cpp +++ b/modules/juce_gui_basics/buttons/juce_ToggleButton.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ToggleButton::ToggleButton() : Button (String()) { @@ -54,3 +57,5 @@ void ToggleButton::colourChanged() { repaint(); } + +} // namespace juce diff --git a/modules/juce_gui_basics/buttons/juce_ToggleButton.h b/modules/juce_gui_basics/buttons/juce_ToggleButton.h index 500946ec61..afe3dcf2aa 100644 --- a/modules/juce_gui_basics/buttons/juce_ToggleButton.h +++ b/modules/juce_gui_basics/buttons/juce_ToggleButton.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -85,3 +85,5 @@ protected: private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ToggleButton) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/buttons/juce_ToolbarButton.cpp b/modules/juce_gui_basics/buttons/juce_ToolbarButton.cpp index e09bd913ac..d4f60ac8c0 100644 --- a/modules/juce_gui_basics/buttons/juce_ToolbarButton.cpp +++ b/modules/juce_gui_basics/buttons/juce_ToolbarButton.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ToolbarButton::ToolbarButton (const int iid, const String& buttonText, Drawable* const normalIm, Drawable* const toggledOnIm) : ToolbarItemComponent (iid, buttonText, true), @@ -107,3 +110,5 @@ void ToolbarButton::buttonStateChanged() { setCurrentImage (getImageToUse()); } + +} // namespace juce diff --git a/modules/juce_gui_basics/buttons/juce_ToolbarButton.h b/modules/juce_gui_basics/buttons/juce_ToolbarButton.h index 20a4322bc6..ce2190e038 100644 --- a/modules/juce_gui_basics/buttons/juce_ToolbarButton.h +++ b/modules/juce_gui_basics/buttons/juce_ToolbarButton.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -93,3 +93,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ToolbarButton) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/commands/juce_ApplicationCommandID.h b/modules/juce_gui_basics/commands/juce_ApplicationCommandID.h index 65c3e4b705..cae26668d5 100644 --- a/modules/juce_gui_basics/commands/juce_ApplicationCommandID.h +++ b/modules/juce_gui_basics/commands/juce_ApplicationCommandID.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** A type used to hold the unique ID for an application command. @@ -87,3 +87,5 @@ namespace StandardApplicationCommandIDs redo = 0x1009 }; } + +} // namespace juce diff --git a/modules/juce_gui_basics/commands/juce_ApplicationCommandInfo.cpp b/modules/juce_gui_basics/commands/juce_ApplicationCommandInfo.cpp index 388113d6c6..6599fdd9f5 100644 --- a/modules/juce_gui_basics/commands/juce_ApplicationCommandInfo.cpp +++ b/modules/juce_gui_basics/commands/juce_ApplicationCommandInfo.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ApplicationCommandInfo::ApplicationCommandInfo (const CommandID cid) noexcept : commandID (cid), flags (0) { @@ -60,3 +63,5 @@ void ApplicationCommandInfo::addDefaultKeypress (const int keyCode, ModifierKeys { defaultKeypresses.add (KeyPress (keyCode, modifiers, 0)); } + +} // namespace juce diff --git a/modules/juce_gui_basics/commands/juce_ApplicationCommandInfo.h b/modules/juce_gui_basics/commands/juce_ApplicationCommandInfo.h index c6cb9927ee..63358df6a5 100644 --- a/modules/juce_gui_basics/commands/juce_ApplicationCommandInfo.h +++ b/modules/juce_gui_basics/commands/juce_ApplicationCommandInfo.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -185,3 +185,5 @@ struct JUCE_API ApplicationCommandInfo */ int flags; }; + +} // namespace juce diff --git a/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.cpp b/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.cpp index 7379a9b48b..acd785a369 100644 --- a/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.cpp +++ b/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ApplicationCommandManager::ApplicationCommandManager() : firstTarget (nullptr) { @@ -312,3 +315,5 @@ void ApplicationCommandManager::globalFocusChanged (Component*) { commandStatusChanged(); } + +} // namespace juce diff --git a/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.h b/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.h index 9baf3da991..396002134b 100644 --- a/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.h +++ b/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -348,3 +348,5 @@ public: */ virtual void applicationCommandListChanged() = 0; }; + +} // namespace juce diff --git a/modules/juce_gui_basics/commands/juce_ApplicationCommandTarget.cpp b/modules/juce_gui_basics/commands/juce_ApplicationCommandTarget.cpp index fa25e12444..17cd9a0a56 100644 --- a/modules/juce_gui_basics/commands/juce_ApplicationCommandTarget.cpp +++ b/modules/juce_gui_basics/commands/juce_ApplicationCommandTarget.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class ApplicationCommandTarget::CommandMessage : public MessageManager::MessageBase { public: @@ -186,3 +189,5 @@ ApplicationCommandTarget::InvocationInfo::InvocationInfo (const CommandID comman millisecsSinceKeyPressed (0) { } + +} // namespace juce diff --git a/modules/juce_gui_basics/commands/juce_ApplicationCommandTarget.h b/modules/juce_gui_basics/commands/juce_ApplicationCommandTarget.h index f37414180f..bec7308406 100644 --- a/modules/juce_gui_basics/commands/juce_ApplicationCommandTarget.h +++ b/modules/juce_gui_basics/commands/juce_ApplicationCommandTarget.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -241,3 +241,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ApplicationCommandTarget) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/commands/juce_KeyPressMappingSet.cpp b/modules/juce_gui_basics/commands/juce_KeyPressMappingSet.cpp index 2293d58351..0a0232843b 100644 --- a/modules/juce_gui_basics/commands/juce_KeyPressMappingSet.cpp +++ b/modules/juce_gui_basics/commands/juce_KeyPressMappingSet.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + KeyPressMappingSet::KeyPressMappingSet (ApplicationCommandManager& cm) : commandManager (cm) { @@ -412,3 +415,5 @@ void KeyPressMappingSet::globalFocusChanged (Component* focusedComponent) if (focusedComponent != nullptr) focusedComponent->keyStateChanged (false); } + +} // namespace juce diff --git a/modules/juce_gui_basics/commands/juce_KeyPressMappingSet.h b/modules/juce_gui_basics/commands/juce_KeyPressMappingSet.h index 75e3ca5f3f..d850739bfa 100644 --- a/modules/juce_gui_basics/commands/juce_KeyPressMappingSet.h +++ b/modules/juce_gui_basics/commands/juce_KeyPressMappingSet.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -241,3 +241,5 @@ private: KeyPressMappingSet& operator= (const KeyPressMappingSet&); JUCE_LEAK_DETECTOR (KeyPressMappingSet) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/components/juce_CachedComponentImage.h b/modules/juce_gui_basics/components/juce_CachedComponentImage.h index fda4f550ee..7e2b5485d7 100644 --- a/modules/juce_gui_basics/components/juce_CachedComponentImage.h +++ b/modules/juce_gui_basics/components/juce_CachedComponentImage.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -67,3 +67,5 @@ public: */ virtual void releaseResources() = 0; }; + +} // namespace juce diff --git a/modules/juce_gui_basics/components/juce_Component.cpp b/modules/juce_gui_basics/components/juce_Component.cpp index cdd9d634fc..d69a2bbf73 100644 --- a/modules/juce_gui_basics/components/juce_Component.cpp +++ b/modules/juce_gui_basics/components/juce_Component.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + Component* Component::currentlyFocusedComponent = nullptr; @@ -3039,3 +3042,5 @@ bool Component::BailOutChecker::shouldBailOut() const noexcept { return safePointer == nullptr; } + +} // namespace juce diff --git a/modules/juce_gui_basics/components/juce_Component.h b/modules/juce_gui_basics/components/juce_Component.h index 961609dee2..9c9c55a566 100644 --- a/modules/juce_gui_basics/components/juce_Component.h +++ b/modules/juce_gui_basics/components/juce_Component.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -2372,3 +2372,5 @@ protected: virtual ComponentPeer* createNewPeer (int styleFlags, void* nativeWindowToAttachTo); #endif }; + +} // namespace juce diff --git a/modules/juce_gui_basics/components/juce_ComponentListener.cpp b/modules/juce_gui_basics/components/juce_ComponentListener.cpp index 0c45b3f300..4f27a5109b 100644 --- a/modules/juce_gui_basics/components/juce_ComponentListener.cpp +++ b/modules/juce_gui_basics/components/juce_ComponentListener.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + void ComponentListener::componentMovedOrResized (Component&, bool, bool) {} void ComponentListener::componentBroughtToFront (Component&) {} void ComponentListener::componentVisibilityChanged (Component&) {} @@ -31,3 +34,5 @@ void ComponentListener::componentChildrenChanged (Component&) {} void ComponentListener::componentParentHierarchyChanged (Component&) {} void ComponentListener::componentNameChanged (Component&) {} void ComponentListener::componentBeingDeleted (Component&) {} + +} // namespace juce diff --git a/modules/juce_gui_basics/components/juce_ComponentListener.h b/modules/juce_gui_basics/components/juce_ComponentListener.h index 9c24fb1b59..cc657b83a3 100644 --- a/modules/juce_gui_basics/components/juce_ComponentListener.h +++ b/modules/juce_gui_basics/components/juce_ComponentListener.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -107,3 +107,5 @@ public: */ virtual void componentBeingDeleted (Component& component); }; + +} // namespace juce diff --git a/modules/juce_gui_basics/components/juce_Desktop.cpp b/modules/juce_gui_basics/components/juce_Desktop.cpp index 9317213fe2..edaf72f98b 100644 --- a/modules/juce_gui_basics/components/juce_Desktop.cpp +++ b/modules/juce_gui_basics/components/juce_Desktop.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + Desktop::Desktop() : mouseSources (new MouseInputSource::SourceList()), mouseClickCounter (0), mouseWheelCounter (0), @@ -425,3 +428,5 @@ void Desktop::setGlobalScaleFactor (float newScaleFactor) noexcept displays->refresh(); } } + +} // namespace juce diff --git a/modules/juce_gui_basics/components/juce_Desktop.h b/modules/juce_gui_basics/components/juce_Desktop.h index 502ca0fd97..a7486bfc7b 100644 --- a/modules/juce_gui_basics/components/juce_Desktop.h +++ b/modules/juce_gui_basics/components/juce_Desktop.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -470,3 +470,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Desktop) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/components/juce_ModalComponentManager.cpp b/modules/juce_gui_basics/components/juce_ModalComponentManager.cpp index d0cbb13f5b..b08f24014b 100644 --- a/modules/juce_gui_basics/components/juce_ModalComponentManager.cpp +++ b/modules/juce_gui_basics/components/juce_ModalComponentManager.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class ModalComponentManager::ModalItem : public ComponentMovementWatcher { public: @@ -311,3 +314,5 @@ ModalComponentManager::Callback* ModalCallbackFunction::create (std::function(), Point (100.0f, 0.0f), Point (0.0f, 100.0f)) { @@ -327,3 +330,5 @@ Path DrawableComposite::getOutlineAsPath() const p.applyTransform (getTransform()); return p; } + +} // namespace juce diff --git a/modules/juce_gui_basics/drawables/juce_DrawableComposite.h b/modules/juce_gui_basics/drawables/juce_DrawableComposite.h index 00217e4f9c..b98bb62375 100644 --- a/modules/juce_gui_basics/drawables/juce_DrawableComposite.h +++ b/modules/juce_gui_basics/drawables/juce_DrawableComposite.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -159,3 +159,5 @@ private: DrawableComposite& operator= (const DrawableComposite&); JUCE_LEAK_DETECTOR (DrawableComposite) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/drawables/juce_DrawableImage.cpp b/modules/juce_gui_basics/drawables/juce_DrawableImage.cpp index c8f1770955..c7675afce2 100644 --- a/modules/juce_gui_basics/drawables/juce_DrawableImage.cpp +++ b/modules/juce_gui_basics/drawables/juce_DrawableImage.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + DrawableImage::DrawableImage() : opacity (1.0f), overlayColour (0x00000000) @@ -295,3 +298,5 @@ Path DrawableImage::getOutlineAsPath() const { return {}; // not applicable for images } + +} // namespace juce diff --git a/modules/juce_gui_basics/drawables/juce_DrawableImage.h b/modules/juce_gui_basics/drawables/juce_DrawableImage.h index 818012e444..d1277174ab 100644 --- a/modules/juce_gui_basics/drawables/juce_DrawableImage.h +++ b/modules/juce_gui_basics/drawables/juce_DrawableImage.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -136,3 +136,5 @@ private: DrawableImage& operator= (const DrawableImage&); JUCE_LEAK_DETECTOR (DrawableImage) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/drawables/juce_DrawablePath.cpp b/modules/juce_gui_basics/drawables/juce_DrawablePath.cpp index 975a053851..a581e980f4 100644 --- a/modules/juce_gui_basics/drawables/juce_DrawablePath.cpp +++ b/modules/juce_gui_basics/drawables/juce_DrawablePath.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + DrawablePath::DrawablePath() { } @@ -570,3 +573,5 @@ ValueTree DrawablePath::createValueTree (ComponentBuilder::ImageProvider* imageP return tree; } + +} // namespace juce diff --git a/modules/juce_gui_basics/drawables/juce_DrawablePath.h b/modules/juce_gui_basics/drawables/juce_DrawablePath.h index 1dd33f7aee..66254d44c0 100644 --- a/modules/juce_gui_basics/drawables/juce_DrawablePath.h +++ b/modules/juce_gui_basics/drawables/juce_DrawablePath.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -141,3 +141,5 @@ private: DrawablePath& operator= (const DrawablePath&); JUCE_LEAK_DETECTOR (DrawablePath) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/drawables/juce_DrawableRectangle.cpp b/modules/juce_gui_basics/drawables/juce_DrawableRectangle.cpp index 4bd0c70ecf..52a24ecd92 100644 --- a/modules/juce_gui_basics/drawables/juce_DrawableRectangle.cpp +++ b/modules/juce_gui_basics/drawables/juce_DrawableRectangle.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + DrawableRectangle::DrawableRectangle() { } @@ -183,3 +186,5 @@ ValueTree DrawableRectangle::createValueTree (ComponentBuilder::ImageProvider* i return tree; } + +} // namespace juce diff --git a/modules/juce_gui_basics/drawables/juce_DrawableRectangle.h b/modules/juce_gui_basics/drawables/juce_DrawableRectangle.h index f34e77b794..fbb3f77ccb 100644 --- a/modules/juce_gui_basics/drawables/juce_DrawableRectangle.h +++ b/modules/juce_gui_basics/drawables/juce_DrawableRectangle.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -99,3 +99,5 @@ private: DrawableRectangle& operator= (const DrawableRectangle&); JUCE_LEAK_DETECTOR (DrawableRectangle) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/drawables/juce_DrawableShape.cpp b/modules/juce_gui_basics/drawables/juce_DrawableShape.cpp index 9c23c44a7c..e93130a71a 100644 --- a/modules/juce_gui_basics/drawables/juce_DrawableShape.cpp +++ b/modules/juce_gui_basics/drawables/juce_DrawableShape.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + DrawableShape::DrawableShape() : strokeType (0.0f), mainFill (Colours::black), @@ -496,3 +499,5 @@ Path DrawableShape::getOutlineAsPath() const outline.applyTransform (getTransform()); return outline; } + +} // namespace juce diff --git a/modules/juce_gui_basics/drawables/juce_DrawableShape.h b/modules/juce_gui_basics/drawables/juce_DrawableShape.h index 2cb7e3712a..10a89dd1d9 100644 --- a/modules/juce_gui_basics/drawables/juce_DrawableShape.h +++ b/modules/juce_gui_basics/drawables/juce_DrawableShape.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -187,3 +187,5 @@ private: DrawableShape& operator= (const DrawableShape&); }; + +} // namespace juce diff --git a/modules/juce_gui_basics/drawables/juce_DrawableText.cpp b/modules/juce_gui_basics/drawables/juce_DrawableText.cpp index 3bfddce9d7..de6d7c2a2c 100644 --- a/modules/juce_gui_basics/drawables/juce_DrawableText.cpp +++ b/modules/juce_gui_basics/drawables/juce_DrawableText.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + DrawableText::DrawableText() : colour (Colours::black), justification (Justification::centredLeft) @@ -372,3 +375,5 @@ Path DrawableText::getOutlineAsPath() const return pathOfAllGlyphs; } + +} // namespace juce diff --git a/modules/juce_gui_basics/drawables/juce_DrawableText.h b/modules/juce_gui_basics/drawables/juce_DrawableText.h index 1033b0b665..637659ed8d 100644 --- a/modules/juce_gui_basics/drawables/juce_DrawableText.h +++ b/modules/juce_gui_basics/drawables/juce_DrawableText.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -155,3 +155,5 @@ private: DrawableText& operator= (const DrawableText&); JUCE_LEAK_DETECTOR (DrawableText) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/drawables/juce_SVGParser.cpp b/modules/juce_gui_basics/drawables/juce_SVGParser.cpp index 3f71281009..a2aaef12da 100644 --- a/modules/juce_gui_basics/drawables/juce_SVGParser.cpp +++ b/modules/juce_gui_basics/drawables/juce_SVGParser.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class SVGState { public: @@ -1728,3 +1731,5 @@ Path Drawable::parseSVGPath (const String& svgPath) state.parsePathString (p, svgPath); return p; } + +} // namespace juce diff --git a/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsDisplayComponent.cpp b/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsDisplayComponent.cpp index 5e9268fe94..b83d356253 100644 --- a/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsDisplayComponent.cpp +++ b/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsDisplayComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + DirectoryContentsDisplayComponent::DirectoryContentsDisplayComponent (DirectoryContentsList& l) : directoryContentsList (l) { @@ -64,3 +67,5 @@ void DirectoryContentsDisplayComponent::sendDoubleClickMessage (const File& file listeners.callChecked (checker, &FileBrowserListener::fileDoubleClicked, file); } } + +} // namespace juce diff --git a/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsDisplayComponent.h b/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsDisplayComponent.h index 77279ed5a2..d01427f682 100644 --- a/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsDisplayComponent.h +++ b/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsDisplayComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -110,3 +110,5 @@ protected: private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DirectoryContentsDisplayComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp b/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp index 27a32cfa37..7db6e282ce 100644 --- a/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp +++ b/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + DirectoryContentsList::DirectoryContentsList (const FileFilter* f, TimeSliceThread& t) : fileFilter (f), thread (t), fileTypeFlags (File::ignoreHiddenFiles | File::findFiles), @@ -258,3 +261,5 @@ bool DirectoryContentsList::addFile (const File& file, const bool isDir, return false; } + +} // namespace juce diff --git a/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.h b/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.h index 33e062ff7a..50877c395b 100644 --- a/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.h +++ b/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -219,3 +219,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DirectoryContentsList) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp b/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp index c7030fb88f..eb367095ba 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp +++ b/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + FileBrowserComponent::FileBrowserComponent (int flags_, const File& initialFileOrDirectory, const FileFilter* fileFilter_, @@ -606,3 +609,5 @@ void FileBrowserComponent::timerCallback() refresh(); } } + +} // namespace juce diff --git a/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.h b/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.h index eb26c52556..148adeaebc 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.h +++ b/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -285,3 +285,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FileBrowserComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/filebrowser/juce_FileBrowserListener.h b/modules/juce_gui_basics/filebrowser/juce_FileBrowserListener.h index fe7776bcaf..45506a19d4 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileBrowserListener.h +++ b/modules/juce_gui_basics/filebrowser/juce_FileBrowserListener.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -53,3 +53,5 @@ public: /** Callback when the browser's root folder changes. */ virtual void browserRootChanged (const File& newRoot) = 0; }; + +} // namespace juce diff --git a/modules/juce_gui_basics/filebrowser/juce_FileChooser.cpp b/modules/juce_gui_basics/filebrowser/juce_FileChooser.cpp index 0e3995c757..024bafead1 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileChooser.cpp +++ b/modules/juce_gui_basics/filebrowser/juce_FileChooser.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + FileChooser::FileChooser (const String& chooserBoxTitle, const File& currentFileOrDirectory, const String& fileFilters, @@ -150,3 +153,5 @@ File FileChooser::getResult() const //============================================================================== FilePreviewComponent::FilePreviewComponent() {} FilePreviewComponent::~FilePreviewComponent() {} + +} // namespace juce diff --git a/modules/juce_gui_basics/filebrowser/juce_FileChooser.h b/modules/juce_gui_basics/filebrowser/juce_FileChooser.h index 82a31abb56..4584acc659 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileChooser.h +++ b/modules/juce_gui_basics/filebrowser/juce_FileChooser.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -201,3 +201,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FileChooser) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.cpp b/modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.cpp index 642860daf3..22de557db7 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.cpp +++ b/modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class FileChooserDialogBox::ContentComponent : public Component { public: @@ -269,3 +272,5 @@ void FileChooserDialogBox::createNewFolderConfirmed (const String& nameFromDialo content->chooserComponent.refresh(); } } + +} // namespace juce diff --git a/modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.h b/modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.h index feb82bdeaa..0ccd01df29 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.h +++ b/modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -153,3 +153,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FileChooserDialogBox) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/filebrowser/juce_FileListComponent.cpp b/modules/juce_gui_basics/filebrowser/juce_FileListComponent.cpp index 4e201007c4..65fc283103 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileListComponent.cpp +++ b/modules/juce_gui_basics/filebrowser/juce_FileListComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + Image juce_createIconForFile (const File& file); @@ -255,3 +258,5 @@ void FileListComponent::returnKeyPressed (int currentSelectedRow) { sendDoubleClickMessage (directoryContentsList.getFile (currentSelectedRow)); } + +} // namespace juce diff --git a/modules/juce_gui_basics/filebrowser/juce_FileListComponent.h b/modules/juce_gui_basics/filebrowser/juce_FileListComponent.h index 3dbf93efc7..770e666c20 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileListComponent.h +++ b/modules/juce_gui_basics/filebrowser/juce_FileListComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -89,3 +89,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FileListComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/filebrowser/juce_FilePreviewComponent.h b/modules/juce_gui_basics/filebrowser/juce_FilePreviewComponent.h index 74e99c6e2c..4781531371 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FilePreviewComponent.h +++ b/modules/juce_gui_basics/filebrowser/juce_FilePreviewComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -61,3 +61,5 @@ private: //============================================================================== JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FilePreviewComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/filebrowser/juce_FileSearchPathListComponent.cpp b/modules/juce_gui_basics/filebrowser/juce_FileSearchPathListComponent.cpp index 0bee475fc3..e74e7f769c 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileSearchPathListComponent.cpp +++ b/modules/juce_gui_basics/filebrowser/juce_FileSearchPathListComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + FileSearchPathListComponent::FileSearchPathListComponent() : addButton ("+"), removeButton ("-"), @@ -266,3 +269,5 @@ void FileSearchPathListComponent::buttonClicked (Button* button) changed(); } + +} // namespace juce diff --git a/modules/juce_gui_basics/filebrowser/juce_FileSearchPathListComponent.h b/modules/juce_gui_basics/filebrowser/juce_FileSearchPathListComponent.h index 5119d96782..07c285378f 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileSearchPathListComponent.h +++ b/modules/juce_gui_basics/filebrowser/juce_FileSearchPathListComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -112,3 +112,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FileSearchPathListComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.cpp b/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.cpp index 15bc43a44a..febfba3685 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.cpp +++ b/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + Image juce_createIconForFile (const File&); //============================================================================== @@ -321,3 +324,5 @@ void FileTreeComponent::setItemHeight (int newHeight) root->treeHasChanged(); } } + +} // namespace juce diff --git a/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.h b/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.h index 46d2b21097..1a9a6cf2f3 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.h +++ b/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -100,3 +100,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FileTreeComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/filebrowser/juce_FilenameComponent.cpp b/modules/juce_gui_basics/filebrowser/juce_FilenameComponent.cpp index fee3d6c964..11b718fd31 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FilenameComponent.cpp +++ b/modules/juce_gui_basics/filebrowser/juce_FilenameComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + FilenameComponent::FilenameComponent (const String& name, const File& currentFile, const bool canEditFilename, @@ -268,3 +271,5 @@ void FilenameComponent::handleAsyncUpdate() Component::BailOutChecker checker (this); listeners.callChecked (checker, &FilenameComponentListener::filenameComponentChanged, this); } + +} // namespace juce diff --git a/modules/juce_gui_basics/filebrowser/juce_FilenameComponent.h b/modules/juce_gui_basics/filebrowser/juce_FilenameComponent.h index d3768f738f..72706db6d3 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FilenameComponent.h +++ b/modules/juce_gui_basics/filebrowser/juce_FilenameComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -229,3 +229,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FilenameComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/filebrowser/juce_ImagePreviewComponent.cpp b/modules/juce_gui_basics/filebrowser/juce_ImagePreviewComponent.cpp index c1d3e699d9..0de138337c 100644 --- a/modules/juce_gui_basics/filebrowser/juce_ImagePreviewComponent.cpp +++ b/modules/juce_gui_basics/filebrowser/juce_ImagePreviewComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ImagePreviewComponent::ImagePreviewComponent() { } @@ -114,3 +117,5 @@ void ImagePreviewComponent::paint (Graphics& g) Justification::centredTop, numLines); } } + +} // namespace juce diff --git a/modules/juce_gui_basics/filebrowser/juce_ImagePreviewComponent.h b/modules/juce_gui_basics/filebrowser/juce_ImagePreviewComponent.h index 0af35fefd0..df96266468 100644 --- a/modules/juce_gui_basics/filebrowser/juce_ImagePreviewComponent.h +++ b/modules/juce_gui_basics/filebrowser/juce_ImagePreviewComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -62,3 +62,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ImagePreviewComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/juce_gui_basics.cpp b/modules/juce_gui_basics/juce_gui_basics.cpp index 828632769c..9787ca6622 100644 --- a/modules/juce_gui_basics/juce_gui_basics.cpp +++ b/modules/juce_gui_basics/juce_gui_basics.cpp @@ -132,16 +132,16 @@ #include //============================================================================== -namespace juce -{ - #define ASSERT_MESSAGE_MANAGER_IS_LOCKED \ jassert (MessageManager::getInstance()->currentThreadHasLockedMessageManager()); #define ASSERT_MESSAGE_MANAGER_IS_LOCKED_OR_OFFSCREEN \ jassert (MessageManager::getInstance()->currentThreadHasLockedMessageManager() || getPeer() == nullptr); -extern bool juce_areThereAnyAlwaysOnTopWindows(); +namespace juce +{ + extern bool juce_areThereAnyAlwaysOnTopWindows(); +} #include "components/juce_Component.cpp" #include "components/juce_ComponentListener.cpp" @@ -311,5 +311,3 @@ extern bool juce_areThereAnyAlwaysOnTopWindows(); #include "native/juce_android_FileChooser.cpp" #endif - -} diff --git a/modules/juce_gui_basics/juce_gui_basics.h b/modules/juce_gui_basics/juce_gui_basics.h index 2597c67028..5ddb188b3e 100644 --- a/modules/juce_gui_basics/juce_gui_basics.h +++ b/modules/juce_gui_basics/juce_gui_basics.h @@ -112,55 +112,55 @@ //============================================================================== namespace juce { - -class Component; -class LookAndFeel; -class MouseInputSource; -class MouseInputSourceInternal; -class ComponentPeer; -class MarkerList; -class RelativeRectangle; -class MouseEvent; -struct MouseWheelDetails; -struct PenDetails; -class ToggleButton; -class TextButton; -class AlertWindow; -class TextLayout; -class ScrollBar; -class ComboBox; -class Button; -class FilenameComponent; -class DocumentWindow; -class ResizableWindow; -class GroupComponent; -class MenuBarComponent; -class DropShadower; -class GlyphArrangement; -class PropertyComponent; -class TableHeaderComponent; -class Toolbar; -class ToolbarItemComponent; -class PopupMenu; -class ProgressBar; -class FileBrowserComponent; -class DirectoryContentsDisplayComponent; -class FilePreviewComponent; -class ImageButton; -class CallOutBox; -class Drawable; -class DrawablePath; -class DrawableComposite; -class CaretComponent; -class BubbleComponent; -class KeyPressMappingSet; -class ApplicationCommandManagerListener; -class DrawableButton; - -#if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS - class FlexBox; - class Grid; -#endif + class Component; + class LookAndFeel; + class MouseInputSource; + class MouseInputSourceInternal; + class ComponentPeer; + class MarkerList; + class RelativeRectangle; + class MouseEvent; + struct MouseWheelDetails; + struct PenDetails; + class ToggleButton; + class TextButton; + class AlertWindow; + class TextLayout; + class ScrollBar; + class ComboBox; + class Button; + class FilenameComponent; + class DocumentWindow; + class ResizableWindow; + class GroupComponent; + class MenuBarComponent; + class DropShadower; + class GlyphArrangement; + class PropertyComponent; + class TableHeaderComponent; + class Toolbar; + class ToolbarItemComponent; + class PopupMenu; + class ProgressBar; + class FileBrowserComponent; + class DirectoryContentsDisplayComponent; + class FilePreviewComponent; + class ImageButton; + class CallOutBox; + class Drawable; + class DrawablePath; + class DrawableComposite; + class CaretComponent; + class BubbleComponent; + class KeyPressMappingSet; + class ApplicationCommandManagerListener; + class DrawableButton; + + #if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS + class FlexBox; + class Grid; + #endif +} #include "mouse/juce_MouseCursor.h" #include "mouse/juce_MouseListener.h" @@ -297,19 +297,11 @@ class DrawableButton; // these classes are C++11-only #if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS -#include "layout/juce_FlexItem.h" -#include "layout/juce_FlexBox.h" -#endif - -#if JUCE_HAS_CONSTEXPR -#include "layout/juce_GridItem.h" -#include "layout/juce_Grid.h" - -constexpr Grid::Px operator"" _px (long double px) { return Grid::Px { px }; } -constexpr Grid::Px operator"" _px (unsigned long long px) { return Grid::Px { px }; } - -constexpr Grid::Fr operator"" _fr (unsigned long long fr) { return Grid::Fr { fr }; } + #include "layout/juce_FlexItem.h" + #include "layout/juce_FlexBox.h" + #if JUCE_HAS_CONSTEXPR + #include "layout/juce_GridItem.h" + #include "layout/juce_Grid.h" + #endif #endif - -} diff --git a/modules/juce_gui_basics/keyboard/juce_CaretComponent.cpp b/modules/juce_gui_basics/keyboard/juce_CaretComponent.cpp index fce9c35bc3..c1e0d1e931 100644 --- a/modules/juce_gui_basics/keyboard/juce_CaretComponent.cpp +++ b/modules/juce_gui_basics/keyboard/juce_CaretComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + CaretComponent::CaretComponent (Component* const keyFocusOwner) : owner (keyFocusOwner) { @@ -58,3 +61,5 @@ bool CaretComponent::shouldBeShown() const return owner == nullptr || (owner->hasKeyboardFocus (false) && ! owner->isCurrentlyBlockedByAnotherModalComponent()); } + +} // namespace juce diff --git a/modules/juce_gui_basics/keyboard/juce_CaretComponent.h b/modules/juce_gui_basics/keyboard/juce_CaretComponent.h index acee48a28e..b21cc7b5c3 100644 --- a/modules/juce_gui_basics/keyboard/juce_CaretComponent.h +++ b/modules/juce_gui_basics/keyboard/juce_CaretComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -76,3 +76,5 @@ private: JUCE_DECLARE_NON_COPYABLE (CaretComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/keyboard/juce_KeyListener.cpp b/modules/juce_gui_basics/keyboard/juce_KeyListener.cpp index 38e9de545e..43c5bdb7a9 100644 --- a/modules/juce_gui_basics/keyboard/juce_KeyListener.cpp +++ b/modules/juce_gui_basics/keyboard/juce_KeyListener.cpp @@ -24,7 +24,12 @@ ============================================================================== */ +namespace juce +{ + bool KeyListener::keyStateChanged (const bool, Component*) { return false; } + +} // namespace juce diff --git a/modules/juce_gui_basics/keyboard/juce_KeyListener.h b/modules/juce_gui_basics/keyboard/juce_KeyListener.h index 1dc7b10cbd..f3cc762102 100644 --- a/modules/juce_gui_basics/keyboard/juce_KeyListener.h +++ b/modules/juce_gui_basics/keyboard/juce_KeyListener.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -72,3 +72,5 @@ public: */ virtual bool keyStateChanged (bool isKeyDown, Component* originatingComponent); }; + +} // namespace juce diff --git a/modules/juce_gui_basics/keyboard/juce_KeyPress.cpp b/modules/juce_gui_basics/keyboard/juce_KeyPress.cpp index 502a6a47f8..eec2a85bc9 100644 --- a/modules/juce_gui_basics/keyboard/juce_KeyPress.cpp +++ b/modules/juce_gui_basics/keyboard/juce_KeyPress.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + KeyPress::KeyPress() noexcept : keyCode (0), textCharacter (0) { @@ -302,3 +305,5 @@ String KeyPress::getTextDescriptionWithIcons() const return getTextDescription(); #endif } + +} // namespace juce diff --git a/modules/juce_gui_basics/keyboard/juce_KeyPress.h b/modules/juce_gui_basics/keyboard/juce_KeyPress.h index 7e4c20bb5e..5f0300485d 100644 --- a/modules/juce_gui_basics/keyboard/juce_KeyPress.h +++ b/modules/juce_gui_basics/keyboard/juce_KeyPress.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -269,3 +269,5 @@ private: JUCE_LEAK_DETECTOR (KeyPress) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/keyboard/juce_KeyboardFocusTraverser.cpp b/modules/juce_gui_basics/keyboard/juce_KeyboardFocusTraverser.cpp index 13afbd4027..7ca108be03 100644 --- a/modules/juce_gui_basics/keyboard/juce_KeyboardFocusTraverser.cpp +++ b/modules/juce_gui_basics/keyboard/juce_KeyboardFocusTraverser.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace KeyboardFocusHelpers { // This will sort a set of components, so that they are ordered in terms of @@ -127,3 +130,5 @@ Component* KeyboardFocusTraverser::getDefaultComponent (Component* parentCompone return comps.getFirst(); } + +} // namespace juce diff --git a/modules/juce_gui_basics/keyboard/juce_KeyboardFocusTraverser.h b/modules/juce_gui_basics/keyboard/juce_KeyboardFocusTraverser.h index 856677cc7e..c6d88f0c48 100644 --- a/modules/juce_gui_basics/keyboard/juce_KeyboardFocusTraverser.h +++ b/modules/juce_gui_basics/keyboard/juce_KeyboardFocusTraverser.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -85,3 +85,5 @@ public: */ virtual Component* getDefaultComponent (Component* parentComponent); }; + +} // namespace juce diff --git a/modules/juce_gui_basics/keyboard/juce_ModifierKeys.cpp b/modules/juce_gui_basics/keyboard/juce_ModifierKeys.cpp index 7fbb587429..5133ed23c6 100644 --- a/modules/juce_gui_basics/keyboard/juce_ModifierKeys.cpp +++ b/modules/juce_gui_basics/keyboard/juce_ModifierKeys.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ModifierKeys::ModifierKeys() noexcept : flags (0) {} ModifierKeys::ModifierKeys (int rawFlags) noexcept : flags (rawFlags) {} ModifierKeys::ModifierKeys (const ModifierKeys& other) noexcept : flags (other.flags) {} @@ -51,3 +54,5 @@ int ModifierKeys::getNumMouseButtonsDown() const noexcept return num; } + +} // namespace juce diff --git a/modules/juce_gui_basics/keyboard/juce_ModifierKeys.h b/modules/juce_gui_basics/keyboard/juce_ModifierKeys.h index 3337b9adb4..61c02604b3 100644 --- a/modules/juce_gui_basics/keyboard/juce_ModifierKeys.h +++ b/modules/juce_gui_basics/keyboard/juce_ModifierKeys.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -219,3 +219,5 @@ private: static ModifierKeys currentModifiers; static void updateCurrentModifiers() noexcept; }; + +} // namespace juce diff --git a/modules/juce_gui_basics/keyboard/juce_SystemClipboard.h b/modules/juce_gui_basics/keyboard/juce_SystemClipboard.h index dbe6bdabd2..b00135dbaf 100644 --- a/modules/juce_gui_basics/keyboard/juce_SystemClipboard.h +++ b/modules/juce_gui_basics/keyboard/juce_SystemClipboard.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -44,3 +44,5 @@ public: */ static String getTextFromClipboard(); }; + +} // namespace juce diff --git a/modules/juce_gui_basics/keyboard/juce_TextEditorKeyMapper.h b/modules/juce_gui_basics/keyboard/juce_TextEditorKeyMapper.h index e8fd74f96f..05594ac45d 100644 --- a/modules/juce_gui_basics/keyboard/juce_TextEditorKeyMapper.h +++ b/modules/juce_gui_basics/keyboard/juce_TextEditorKeyMapper.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** This class is used to invoke a range of text-editor navigation methods on @@ -118,3 +118,5 @@ struct TextEditorKeyMapper return false; } }; + +} // namespace juce diff --git a/modules/juce_gui_basics/keyboard/juce_TextInputTarget.h b/modules/juce_gui_basics/keyboard/juce_TextInputTarget.h index e63a84a613..9d198be134 100644 --- a/modules/juce_gui_basics/keyboard/juce_TextInputTarget.h +++ b/modules/juce_gui_basics/keyboard/juce_TextInputTarget.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -91,3 +91,5 @@ public: */ virtual VirtualKeyboardType getKeyboardType() { return textKeyboard; } }; + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_AnimatedPosition.h b/modules/juce_gui_basics/layout/juce_AnimatedPosition.h index 7f75916fd1..7b4b320f4e 100644 --- a/modules/juce_gui_basics/layout/juce_AnimatedPosition.h +++ b/modules/juce_gui_basics/layout/juce_AnimatedPosition.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -205,3 +205,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AnimatedPosition) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_AnimatedPositionBehaviours.h b/modules/juce_gui_basics/layout/juce_AnimatedPositionBehaviours.h index 481e2be7ee..3be77da9be 100644 --- a/modules/juce_gui_basics/layout/juce_AnimatedPositionBehaviours.h +++ b/modules/juce_gui_basics/layout/juce_AnimatedPositionBehaviours.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** Contains classes for different types of physics behaviours - these classes @@ -153,3 +153,5 @@ namespace AnimatedPositionBehaviours double targetSnapPosition; }; } + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp b/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp index d322f4ae91..936660d221 100644 --- a/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp +++ b/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class ComponentAnimator::AnimationTask { public: @@ -345,3 +348,5 @@ void ComponentAnimator::timerCallback() if (tasks.size() == 0) stopTimer(); } + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_ComponentAnimator.h b/modules/juce_gui_basics/layout/juce_ComponentAnimator.h index 5a9441b7c6..85fdb1e775 100644 --- a/modules/juce_gui_basics/layout/juce_ComponentAnimator.h +++ b/modules/juce_gui_basics/layout/juce_ComponentAnimator.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -157,3 +157,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ComponentAnimator) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_ComponentBoundsConstrainer.cpp b/modules/juce_gui_basics/layout/juce_ComponentBoundsConstrainer.cpp index b34240c575..158cbe61f2 100644 --- a/modules/juce_gui_basics/layout/juce_ComponentBoundsConstrainer.cpp +++ b/modules/juce_gui_basics/layout/juce_ComponentBoundsConstrainer.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ComponentBoundsConstrainer::ComponentBoundsConstrainer() noexcept {} ComponentBoundsConstrainer::~ComponentBoundsConstrainer() {} @@ -290,3 +293,5 @@ void ComponentBoundsConstrainer::checkBounds (Rectangle& bounds, jassert (! bounds.isEmpty()); } + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_ComponentBoundsConstrainer.h b/modules/juce_gui_basics/layout/juce_ComponentBoundsConstrainer.h index e9d0a94937..16b8a44269 100644 --- a/modules/juce_gui_basics/layout/juce_ComponentBoundsConstrainer.h +++ b/modules/juce_gui_basics/layout/juce_ComponentBoundsConstrainer.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -192,3 +192,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ComponentBoundsConstrainer) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_ComponentBuilder.cpp b/modules/juce_gui_basics/layout/juce_ComponentBuilder.cpp index bd5b6c52db..f735f35efa 100644 --- a/modules/juce_gui_basics/layout/juce_ComponentBuilder.cpp +++ b/modules/juce_gui_basics/layout/juce_ComponentBuilder.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace ComponentBuilderHelpers { static String getStateId (const ValueTree& state) @@ -281,3 +284,5 @@ void ComponentBuilder::updateChildComponents (Component& parent, const ValueTree componentsInOrder.getUnchecked(i)->toBehind (componentsInOrder.getUnchecked (i + 1)); } } + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_ComponentBuilder.h b/modules/juce_gui_basics/layout/juce_ComponentBuilder.h index fc389b68a7..8d8d7debfd 100644 --- a/modules/juce_gui_basics/layout/juce_ComponentBuilder.h +++ b/modules/juce_gui_basics/layout/juce_ComponentBuilder.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -242,3 +242,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ComponentBuilder) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_ComponentMovementWatcher.cpp b/modules/juce_gui_basics/layout/juce_ComponentMovementWatcher.cpp index c42f004b32..6e5cfe94e3 100644 --- a/modules/juce_gui_basics/layout/juce_ComponentMovementWatcher.cpp +++ b/modules/juce_gui_basics/layout/juce_ComponentMovementWatcher.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ComponentMovementWatcher::ComponentMovementWatcher (Component* const comp) : component (comp), lastPeerID (0), @@ -139,3 +142,5 @@ void ComponentMovementWatcher::unregister() registeredParentComps.clear(); } + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_ComponentMovementWatcher.h b/modules/juce_gui_basics/layout/juce_ComponentMovementWatcher.h index 0a1c55bd9f..583ae4e32f 100644 --- a/modules/juce_gui_basics/layout/juce_ComponentMovementWatcher.h +++ b/modules/juce_gui_basics/layout/juce_ComponentMovementWatcher.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** An object that watches for any movement of a component or any of its parent components. @@ -91,3 +91,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ComponentMovementWatcher) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_ConcertinaPanel.cpp b/modules/juce_gui_basics/layout/juce_ConcertinaPanel.cpp index 175699812e..f5dad1d1b1 100644 --- a/modules/juce_gui_basics/layout/juce_ConcertinaPanel.cpp +++ b/modules/juce_gui_basics/layout/juce_ConcertinaPanel.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + struct ConcertinaPanel::PanelSizes { struct Panel @@ -451,3 +454,5 @@ void ConcertinaPanel::panelHeaderDoubleClicked (Component* component) if (! expandPanelFully (component, true)) setPanelSize (component, 0, true); } + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_ConcertinaPanel.h b/modules/juce_gui_basics/layout/juce_ConcertinaPanel.h index 4670fd2ed6..aea9dbff62 100644 --- a/modules/juce_gui_basics/layout/juce_ConcertinaPanel.h +++ b/modules/juce_gui_basics/layout/juce_ConcertinaPanel.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -141,3 +141,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ConcertinaPanel) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_FlexBox.cpp b/modules/juce_gui_basics/layout/juce_FlexBox.cpp index fb042d3727..d647b15a3c 100644 --- a/modules/juce_gui_basics/layout/juce_FlexBox.cpp +++ b/modules/juce_gui_basics/layout/juce_FlexBox.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + struct FlexBoxLayoutCalculation { using Coord = double; @@ -851,3 +854,5 @@ FlexItem FlexItem::withHeight (float newHeight) const noexcept { auto fi = FlexItem FlexItem::withMargin (Margin m) const noexcept { auto fi = *this; fi.margin = m; return fi; } FlexItem FlexItem::withOrder (int newOrder) const noexcept { auto fi = *this; fi.order = newOrder; return fi; } FlexItem FlexItem::withAlignSelf (AlignSelf a) const noexcept { auto fi = *this; fi.alignSelf = a; return fi; } + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_FlexBox.h b/modules/juce_gui_basics/layout/juce_FlexBox.h index 35b26e9fdf..b2c3e0929d 100644 --- a/modules/juce_gui_basics/layout/juce_FlexBox.h +++ b/modules/juce_gui_basics/layout/juce_FlexBox.h @@ -24,6 +24,8 @@ ============================================================================== */ +namespace juce +{ /** Represents a FlexBox container, which contains and manages the layout of a set @@ -102,3 +104,5 @@ public: private: JUCE_LEAK_DETECTOR (FlexBox) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_FlexItem.h b/modules/juce_gui_basics/layout/juce_FlexItem.h index 3565c98990..b52c3b6f48 100644 --- a/modules/juce_gui_basics/layout/juce_FlexItem.h +++ b/modules/juce_gui_basics/layout/juce_FlexItem.h @@ -24,6 +24,8 @@ ============================================================================== */ +namespace juce +{ /** Describes the properties of an item inside a FlexBox container. @@ -161,3 +163,5 @@ public: /** Returns a copy of this object with a new alignSelf value. */ FlexItem withAlignSelf (AlignSelf newAlignSelf) const noexcept; }; + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_Grid.cpp b/modules/juce_gui_basics/layout/juce_Grid.cpp index f3c97ec303..74338d1d3a 100644 --- a/modules/juce_gui_basics/layout/juce_Grid.cpp +++ b/modules/juce_gui_basics/layout/juce_Grid.cpp @@ -24,6 +24,8 @@ ============================================================================== */ +namespace juce +{ struct Grid::SizeCalculation { @@ -1023,3 +1025,5 @@ void Grid::performLayout (juce::Rectangle targetArea) c->setBounds (item->currentBounds.toNearestInt()); } } + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_Grid.h b/modules/juce_gui_basics/layout/juce_Grid.h index 21d8cdbd42..bf8d8fd7d4 100644 --- a/modules/juce_gui_basics/layout/juce_Grid.h +++ b/modules/juce_gui_basics/layout/juce_Grid.h @@ -24,6 +24,8 @@ ============================================================================== */ +namespace juce +{ /** Container that handles geometry for grid layouts (fixed columns and rows) using a set of declarative rules. @@ -172,3 +174,9 @@ private: struct AutoPlacement; struct BoxAlignment; }; + +constexpr Grid::Px operator"" _px (long double px) { return Grid::Px { px }; } +constexpr Grid::Px operator"" _px (unsigned long long px) { return Grid::Px { px }; } +constexpr Grid::Fr operator"" _fr (unsigned long long fr) { return Grid::Fr { fr }; } + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_GridItem.cpp b/modules/juce_gui_basics/layout/juce_GridItem.cpp index 63101d9aa2..72088fb70b 100644 --- a/modules/juce_gui_basics/layout/juce_GridItem.cpp +++ b/modules/juce_gui_basics/layout/juce_GridItem.cpp @@ -24,6 +24,8 @@ ============================================================================== */ +namespace juce +{ GridItem::Property::Property() noexcept : isAuto (true) { @@ -180,3 +182,5 @@ GridItem GridItem::withOrder (int newOrder) const noexcept gi.order = newOrder; return gi; } + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_GridItem.h b/modules/juce_gui_basics/layout/juce_GridItem.h index e529079465..f57ab79810 100644 --- a/modules/juce_gui_basics/layout/juce_GridItem.h +++ b/modules/juce_gui_basics/layout/juce_GridItem.h @@ -24,6 +24,8 @@ ============================================================================== */ +namespace juce +{ /** Defines an item in a Grid @@ -221,3 +223,5 @@ public: /** Returns a copy of this object with a new order. */ GridItem withOrder (int newOrder) const noexcept; }; + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_GridUnitTests.cpp b/modules/juce_gui_basics/layout/juce_GridUnitTests.cpp index 52ccda6bd9..99084d0993 100644 --- a/modules/juce_gui_basics/layout/juce_GridUnitTests.cpp +++ b/modules/juce_gui_basics/layout/juce_GridUnitTests.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + struct GridTests : public juce::UnitTest { GridTests() : juce::UnitTest ("Grid class") {} @@ -255,3 +258,5 @@ struct GridTests : public juce::UnitTest }; static GridTests gridUnitTests; + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_GroupComponent.cpp b/modules/juce_gui_basics/layout/juce_GroupComponent.cpp index 172d3d7ef2..c632377069 100644 --- a/modules/juce_gui_basics/layout/juce_GroupComponent.cpp +++ b/modules/juce_gui_basics/layout/juce_GroupComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + GroupComponent::GroupComponent (const String& name, const String& labelText) : Component (name), @@ -66,3 +69,5 @@ void GroupComponent::paint (Graphics& g) void GroupComponent::enablementChanged() { repaint(); } void GroupComponent::colourChanged() { repaint(); } + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_GroupComponent.h b/modules/juce_gui_basics/layout/juce_GroupComponent.h index f8f3a2f05d..47ef9245db 100644 --- a/modules/juce_gui_basics/layout/juce_GroupComponent.h +++ b/modules/juce_gui_basics/layout/juce_GroupComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -107,3 +107,5 @@ private: JUCE_DECLARE_NON_COPYABLE (GroupComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.cpp b/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.cpp index 65c7454200..94d0c88a91 100644 --- a/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.cpp +++ b/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + MultiDocumentPanelWindow::MultiDocumentPanelWindow (Colour backgroundColour) : DocumentWindow (String(), backgroundColour, DocumentWindow::maximiseButton | DocumentWindow::closeButton, false) @@ -507,3 +510,5 @@ void MultiDocumentPanel::updateOrder() if (components != oldList) activeDocumentChanged(); } + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.h b/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.h index b55f3de30b..a19c37c14f 100644 --- a/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.h +++ b/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ class MultiDocumentPanel; @@ -300,3 +301,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MultiDocumentPanel) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.cpp b/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.cpp index ee4b1ee6bf..df67914306 100644 --- a/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.cpp +++ b/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ResizableBorderComponent::Zone::Zone() noexcept : zone (0) {} @@ -201,3 +204,5 @@ void ResizableBorderComponent::updateMouseZone (const MouseEvent& e) setMouseCursor (newZone.getMouseCursor()); } } + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.h b/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.h index 612fd26eb5..53ec37e166 100644 --- a/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.h +++ b/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -191,3 +191,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ResizableBorderComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_ResizableCornerComponent.cpp b/modules/juce_gui_basics/layout/juce_ResizableCornerComponent.cpp index 5e7ef095dc..7b3735cf06 100644 --- a/modules/juce_gui_basics/layout/juce_ResizableCornerComponent.cpp +++ b/modules/juce_gui_basics/layout/juce_ResizableCornerComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ResizableCornerComponent::ResizableCornerComponent (Component* const componentToResize, ComponentBoundsConstrainer* const constrainer_) : component (componentToResize), @@ -99,3 +102,5 @@ bool ResizableCornerComponent::hitTest (int x, int y) return y >= yAtX - getHeight() / 4; } + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_ResizableCornerComponent.h b/modules/juce_gui_basics/layout/juce_ResizableCornerComponent.h index 14b36f22b6..ae1f8264c9 100644 --- a/modules/juce_gui_basics/layout/juce_ResizableCornerComponent.h +++ b/modules/juce_gui_basics/layout/juce_ResizableCornerComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** A component that resizes a parent component when dragged. @@ -87,3 +87,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ResizableCornerComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_ResizableEdgeComponent.cpp b/modules/juce_gui_basics/layout/juce_ResizableEdgeComponent.cpp index 9c3a78d02b..a4c8441be2 100644 --- a/modules/juce_gui_basics/layout/juce_ResizableEdgeComponent.cpp +++ b/modules/juce_gui_basics/layout/juce_ResizableEdgeComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ResizableEdgeComponent::ResizableEdgeComponent (Component* const componentToResize, ComponentBoundsConstrainer* const constrainer_, Edge edge_) @@ -107,3 +110,5 @@ void ResizableEdgeComponent::mouseUp (const MouseEvent&) if (constrainer != nullptr) constrainer->resizeEnd(); } + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_ResizableEdgeComponent.h b/modules/juce_gui_basics/layout/juce_ResizableEdgeComponent.h index 4d8b45e266..2063375c8f 100644 --- a/modules/juce_gui_basics/layout/juce_ResizableEdgeComponent.h +++ b/modules/juce_gui_basics/layout/juce_ResizableEdgeComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -95,3 +95,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ResizableEdgeComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_ScrollBar.cpp b/modules/juce_gui_basics/layout/juce_ScrollBar.cpp index e3aa126fdd..c84b71c126 100644 --- a/modules/juce_gui_basics/layout/juce_ScrollBar.cpp +++ b/modules/juce_gui_basics/layout/juce_ScrollBar.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class ScrollBar::ScrollbarButton : public Button { public: @@ -428,3 +431,5 @@ bool ScrollBar::keyPressed (const KeyPress& key) return false; } + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_ScrollBar.h b/modules/juce_gui_basics/layout/juce_ScrollBar.h index f94e905c21..34996d6a8e 100644 --- a/modules/juce_gui_basics/layout/juce_ScrollBar.h +++ b/modules/juce_gui_basics/layout/juce_ScrollBar.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -402,3 +402,5 @@ private: /** This typedef is just for compatibility with old code - newer code should use the ScrollBar::Listener class directly. */ typedef ScrollBar::Listener ScrollBarListener; + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_StretchableLayoutManager.cpp b/modules/juce_gui_basics/layout/juce_StretchableLayoutManager.cpp index 64d2174714..75a52fa4f8 100644 --- a/modules/juce_gui_basics/layout/juce_StretchableLayoutManager.cpp +++ b/modules/juce_gui_basics/layout/juce_StretchableLayoutManager.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + StretchableLayoutManager::StretchableLayoutManager() : totalSize (0) { @@ -342,3 +345,5 @@ int StretchableLayoutManager::sizeToRealSize (double size, int totalSpace) return roundToInt (size); } + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_StretchableLayoutManager.h b/modules/juce_gui_basics/layout/juce_StretchableLayoutManager.h index 2e86faaa96..e6b72ed40f 100644 --- a/modules/juce_gui_basics/layout/juce_StretchableLayoutManager.h +++ b/modules/juce_gui_basics/layout/juce_StretchableLayoutManager.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -256,3 +256,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (StretchableLayoutManager) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_StretchableLayoutResizerBar.cpp b/modules/juce_gui_basics/layout/juce_StretchableLayoutResizerBar.cpp index c23baabe9b..dd009a7b81 100644 --- a/modules/juce_gui_basics/layout/juce_StretchableLayoutResizerBar.cpp +++ b/modules/juce_gui_basics/layout/juce_StretchableLayoutResizerBar.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + StretchableLayoutResizerBar::StretchableLayoutResizerBar (StretchableLayoutManager* layout_, const int index, const bool vertical) @@ -73,3 +76,5 @@ void StretchableLayoutResizerBar::hasBeenMoved() if (Component* parent = getParentComponent()) parent->resized(); } + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_StretchableLayoutResizerBar.h b/modules/juce_gui_basics/layout/juce_StretchableLayoutResizerBar.h index 87b18cfd2a..e1a20509f8 100644 --- a/modules/juce_gui_basics/layout/juce_StretchableLayoutResizerBar.h +++ b/modules/juce_gui_basics/layout/juce_StretchableLayoutResizerBar.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -100,3 +100,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (StretchableLayoutResizerBar) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_StretchableObjectResizer.cpp b/modules/juce_gui_basics/layout/juce_StretchableObjectResizer.cpp index 7fada6a5b3..bf56dea75a 100644 --- a/modules/juce_gui_basics/layout/juce_StretchableObjectResizer.cpp +++ b/modules/juce_gui_basics/layout/juce_StretchableObjectResizer.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + StretchableObjectResizer::StretchableObjectResizer() {} StretchableObjectResizer::~StretchableObjectResizer() {} @@ -116,3 +119,5 @@ void StretchableObjectResizer::resizeToFit (const double targetSize) break; } } + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_StretchableObjectResizer.h b/modules/juce_gui_basics/layout/juce_StretchableObjectResizer.h index c7e368fd06..32543b115f 100644 --- a/modules/juce_gui_basics/layout/juce_StretchableObjectResizer.h +++ b/modules/juce_gui_basics/layout/juce_StretchableObjectResizer.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -97,3 +97,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (StretchableObjectResizer) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_TabbedButtonBar.cpp b/modules/juce_gui_basics/layout/juce_TabbedButtonBar.cpp index 2e83ec0564..0031a1882d 100644 --- a/modules/juce_gui_basics/layout/juce_TabbedButtonBar.cpp +++ b/modules/juce_gui_basics/layout/juce_TabbedButtonBar.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + TabBarButton::TabBarButton (const String& name, TabbedButtonBar& owner_) : Button (name), owner (owner_), overlapPixels (0), extraCompPlacement (afterText) { @@ -585,3 +588,5 @@ void TabbedButtonBar::currentTabChanged (const int, const String&) void TabbedButtonBar::popupMenuClickOnTab (const int, const String&) { } + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_TabbedButtonBar.h b/modules/juce_gui_basics/layout/juce_TabbedButtonBar.h index cb46a0e332..a788408c93 100644 --- a/modules/juce_gui_basics/layout/juce_TabbedButtonBar.h +++ b/modules/juce_gui_basics/layout/juce_TabbedButtonBar.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ class TabbedButtonBar; @@ -366,3 +367,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TabbedButtonBar) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_TabbedComponent.cpp b/modules/juce_gui_basics/layout/juce_TabbedComponent.cpp index 1e731df3df..d6349e32f1 100644 --- a/modules/juce_gui_basics/layout/juce_TabbedComponent.cpp +++ b/modules/juce_gui_basics/layout/juce_TabbedComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace TabbedComponentHelpers { const Identifier deleteComponentId ("deleteByTabComp_"); @@ -314,3 +317,5 @@ void TabbedComponent::changeCallback (const int newCurrentTabIndex, const String void TabbedComponent::currentTabChanged (const int, const String&) {} void TabbedComponent::popupMenuClickOnTab (const int, const String&) {} + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_TabbedComponent.h b/modules/juce_gui_basics/layout/juce_TabbedComponent.h index 0dac8a02c1..f62846e656 100644 --- a/modules/juce_gui_basics/layout/juce_TabbedComponent.h +++ b/modules/juce_gui_basics/layout/juce_TabbedComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -221,3 +221,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TabbedComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_Viewport.cpp b/modules/juce_gui_basics/layout/juce_Viewport.cpp index aaebbb3249..a1f746aa12 100644 --- a/modules/juce_gui_basics/layout/juce_Viewport.cpp +++ b/modules/juce_gui_basics/layout/juce_Viewport.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + Viewport::Viewport (const String& name) : Component (name) { // content holder is used to clip the contents so they don't overlap the scrollbars @@ -578,3 +581,5 @@ bool Viewport::respondsToKey (const KeyPress& key) { return isUpDownKeyPress (key) || isLeftRightKeyPress (key); } + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_Viewport.h b/modules/juce_gui_basics/layout/juce_Viewport.h index 7da6dfd272..32fe809b2e 100644 --- a/modules/juce_gui_basics/layout/juce_Viewport.h +++ b/modules/juce_gui_basics/layout/juce_Viewport.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -306,3 +306,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Viewport) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp index 4fd176651f..d2faffbaab 100644 --- a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp +++ b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp @@ -24,7 +24,9 @@ ============================================================================== */ -//============================================================================== +namespace juce +{ + static Typeface::Ptr getTypefaceForFontFromLookAndFeel (const Font& font) { return LookAndFeel::getDefaultLookAndFeel().getTypefaceForFont (font); @@ -150,3 +152,5 @@ bool LookAndFeel::isUsingNativeAlertWindows() return useNativeAlertWindows; #endif } + +} // namespace juce diff --git a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.h b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.h index 81267298a0..997180a517 100644 --- a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.h +++ b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** This class is used to hold a few look and feel base classes which are associated @@ -229,3 +230,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LookAndFeel) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V1.cpp b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V1.cpp index d885965656..837bdfb11b 100644 --- a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V1.cpp +++ b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V1.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + LookAndFeel_V1::LookAndFeel_V1() { setColour (TextButton::buttonColourId, Colour (0xffbbbbff)); @@ -567,3 +570,5 @@ void LookAndFeel_V1::positionDocumentWindowButtons (DocumentWindow&, if (minimiseButton != nullptr) minimiseButton->setBounds (x, titleBarY - 2, buttonW, titleBarH); } + +} // namespace juce diff --git a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V1.h b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V1.h index f9f7089403..45950042d1 100644 --- a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V1.h +++ b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V1.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -97,3 +98,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LookAndFeel_V1) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp index 4622efd7b4..14510a9003 100644 --- a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp +++ b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace LookAndFeelHelpers { static Colour createBaseColour (Colour buttonColour, @@ -3018,3 +3021,5 @@ void LookAndFeel_V2::drawGlassLozenge (Graphics& g, g.setColour (colour.darker().withMultipliedAlpha (1.5f)); g.strokePath (outline, PathStrokeType (outlineThickness)); } + +} // namespace juce diff --git a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.h b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.h index 268f22a6d7..af0b365888 100644 --- a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.h +++ b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -373,3 +373,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LookAndFeel_V2) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.cpp b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.cpp index b0090d8e31..25dffe0b29 100644 --- a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.cpp +++ b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + LookAndFeel_V3::LookAndFeel_V3() { setColour (TreeView::selectedItemBackgroundColourId, Colour (0x301111ee)); @@ -637,3 +640,5 @@ Path LookAndFeel_V3::getCrossShape (const float height) p.scaleToFit (0, 0, height * 2.0f, height, true); return p; } + +} // namespace juce diff --git a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.h b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.h index dc0be9ca5c..7a3bdcb4d8 100644 --- a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.h +++ b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -92,3 +93,5 @@ private: Image backgroundTexture; Colour backgroundTextureBaseColour; }; + +} // namespace juce diff --git a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.cpp b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.cpp index 304a321f50..e888e91c55 100644 --- a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.cpp +++ b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.cpp @@ -24,6 +24,8 @@ ============================================================================== */ +namespace juce +{ Colour LookAndFeel_V4::ColourScheme::getUIColour (UIColour index) const noexcept { @@ -1429,3 +1431,5 @@ void LookAndFeel_V4::initialiseColours() for (int i = 0; i < numElementsInArray (coloursToUse); i += 2) setColour ((int) coloursToUse [i], Colour ((uint32) coloursToUse [i + 1])); } + +} // namespace juce diff --git a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.h b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.h index 76b1371f98..2c03e0f894 100644 --- a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.h +++ b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ class JUCE_API LookAndFeel_V4 : public LookAndFeel_V3 { @@ -238,3 +238,5 @@ private: //============================================================================== JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LookAndFeel_V4) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/menus/juce_MenuBarComponent.cpp b/modules/juce_gui_basics/menus/juce_MenuBarComponent.cpp index bc9515b5be..b24072acdf 100644 --- a/modules/juce_gui_basics/menus/juce_MenuBarComponent.cpp +++ b/modules/juce_gui_basics/menus/juce_MenuBarComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + MenuBarComponent::MenuBarComponent (MenuBarModel* m) : model (nullptr), itemUnderMouse (-1), @@ -352,3 +355,5 @@ void MenuBarComponent::timerCallback() stopTimer(); updateItemUnderMouse (getMouseXYRelative()); } + +} // namespace juce diff --git a/modules/juce_gui_basics/menus/juce_MenuBarComponent.h b/modules/juce_gui_basics/menus/juce_MenuBarComponent.h index 96a00c8f53..82f9a4e089 100644 --- a/modules/juce_gui_basics/menus/juce_MenuBarComponent.h +++ b/modules/juce_gui_basics/menus/juce_MenuBarComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -115,3 +115,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MenuBarComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/menus/juce_MenuBarModel.cpp b/modules/juce_gui_basics/menus/juce_MenuBarModel.cpp index e5be870ab8..fcc06afe98 100644 --- a/modules/juce_gui_basics/menus/juce_MenuBarModel.cpp +++ b/modules/juce_gui_basics/menus/juce_MenuBarModel.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + MenuBarModel::MenuBarModel() noexcept : manager (nullptr) { @@ -93,3 +96,5 @@ void MenuBarModel::handleMenuBarActivate (bool isActive) void MenuBarModel::menuBarActivated (bool) {} void MenuBarModel::Listener::menuBarActivated (MenuBarModel*, bool) {} + +} // namespace juce diff --git a/modules/juce_gui_basics/menus/juce_MenuBarModel.h b/modules/juce_gui_basics/menus/juce_MenuBarModel.h index 01e6023d60..a4b7d9c0ec 100644 --- a/modules/juce_gui_basics/menus/juce_MenuBarModel.h +++ b/modules/juce_gui_basics/menus/juce_MenuBarModel.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -189,3 +189,5 @@ private: /** This typedef is just for compatibility with old code - newer code should use the MenuBarModel::Listener class directly. */ typedef MenuBarModel::Listener MenuBarModelListener; + +} // namespace juce diff --git a/modules/juce_gui_basics/menus/juce_PopupMenu.cpp b/modules/juce_gui_basics/menus/juce_PopupMenu.cpp index 738aedb2f1..a36feeb25e 100644 --- a/modules/juce_gui_basics/menus/juce_PopupMenu.cpp +++ b/modules/juce_gui_basics/menus/juce_PopupMenu.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace PopupMenuSettings { const int scrollZone = 24; @@ -1844,3 +1847,5 @@ PopupMenu::Item& PopupMenu::MenuItemIterator::getItem() const noexcept jassert (currentItem != nullptr); return *(currentItem); } + +} // namespace juce diff --git a/modules/juce_gui_basics/menus/juce_PopupMenu.h b/modules/juce_gui_basics/menus/juce_PopupMenu.h index 276fb62a43..10ecd898fc 100644 --- a/modules/juce_gui_basics/menus/juce_PopupMenu.h +++ b/modules/juce_gui_basics/menus/juce_PopupMenu.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** Creates and displays a popup-menu. @@ -750,3 +750,5 @@ private: JUCE_LEAK_DETECTOR (PopupMenu) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/misc/juce_BubbleComponent.cpp b/modules/juce_gui_basics/misc/juce_BubbleComponent.cpp index b2595731a7..13ce260eb6 100644 --- a/modules/juce_gui_basics/misc/juce_BubbleComponent.cpp +++ b/modules/juce_gui_basics/misc/juce_BubbleComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + BubbleComponent::BubbleComponent() : allowablePlacements (above | below | left | right) { @@ -144,3 +147,5 @@ void BubbleComponent::setPosition (Rectangle rectangleToPointTo, setBounds (targetX - arrowTip.x, targetY - arrowTip.y, totalW, totalH); } + +} // namespace juce diff --git a/modules/juce_gui_basics/misc/juce_BubbleComponent.h b/modules/juce_gui_basics/misc/juce_BubbleComponent.h index 4b03495c2b..fe253274fc 100644 --- a/modules/juce_gui_basics/misc/juce_BubbleComponent.h +++ b/modules/juce_gui_basics/misc/juce_BubbleComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -181,3 +181,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (BubbleComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/misc/juce_DropShadower.cpp b/modules/juce_gui_basics/misc/juce_DropShadower.cpp index 42cac3e67b..8f4fcb0724 100644 --- a/modules/juce_gui_basics/misc/juce_DropShadower.cpp +++ b/modules/juce_gui_basics/misc/juce_DropShadower.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class DropShadower::ShadowWindow : public Component { public: @@ -216,3 +219,5 @@ void DropShadower::updateShadows() shadowWindows.clear(); } } + +} // namespace juce diff --git a/modules/juce_gui_basics/misc/juce_DropShadower.h b/modules/juce_gui_basics/misc/juce_DropShadower.h index d201430b7e..9137609869 100644 --- a/modules/juce_gui_basics/misc/juce_DropShadower.h +++ b/modules/juce_gui_basics/misc/juce_DropShadower.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -76,3 +76,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DropShadower) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/misc/juce_JUCESplashScreen.cpp b/modules/juce_gui_basics/misc/juce_JUCESplashScreen.cpp index 387c481283..7ab23c3edd 100644 --- a/modules/juce_gui_basics/misc/juce_JUCESplashScreen.cpp +++ b/modules/juce_gui_basics/misc/juce_JUCESplashScreen.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + /* ============================================================================== @@ -354,3 +357,5 @@ void JUCESplashScreen::mouseUp (const MouseEvent&) } // END SECTION A + +} // namespace juce diff --git a/modules/juce_gui_basics/misc/juce_JUCESplashScreen.h b/modules/juce_gui_basics/misc/juce_JUCESplashScreen.h index fc733568be..ab58d9db17 100644 --- a/modules/juce_gui_basics/misc/juce_JUCESplashScreen.h +++ b/modules/juce_gui_basics/misc/juce_JUCESplashScreen.h @@ -38,7 +38,8 @@ // BEGIN SECTION A -#pragma once +namespace juce +{ /** The standard JUCE splash screen component. @@ -70,3 +71,5 @@ private: }; // END SECTION A + +} // namespace juce diff --git a/modules/juce_gui_basics/mouse/juce_ComponentDragger.cpp b/modules/juce_gui_basics/mouse/juce_ComponentDragger.cpp index d5c9f37092..5f01eb8c98 100644 --- a/modules/juce_gui_basics/mouse/juce_ComponentDragger.cpp +++ b/modules/juce_gui_basics/mouse/juce_ComponentDragger.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ComponentDragger::ComponentDragger() {} ComponentDragger::~ComponentDragger() {} @@ -61,3 +64,5 @@ void ComponentDragger::dragComponent (Component* const componentToDrag, const Mo componentToDrag->setBounds (bounds); } } + +} // namespace juce diff --git a/modules/juce_gui_basics/mouse/juce_ComponentDragger.h b/modules/juce_gui_basics/mouse/juce_ComponentDragger.h index ab6141cdcd..dedf284f7e 100644 --- a/modules/juce_gui_basics/mouse/juce_ComponentDragger.h +++ b/modules/juce_gui_basics/mouse/juce_ComponentDragger.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -96,3 +96,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ComponentDragger) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp b/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp index 14bf227fe8..4fc7e112d8 100644 --- a/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp +++ b/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + bool juce_performDragDropFiles (const StringArray&, const bool copyFiles, bool& shouldStop); bool juce_performDragDropText (const String&, bool& shouldStop); @@ -526,3 +529,5 @@ void FileDragAndDropTarget::fileDragExit (const StringArray&) {} void TextDragAndDropTarget::textDragEnter (const String&, int, int) {} void TextDragAndDropTarget::textDragMove (const String&, int, int) {} void TextDragAndDropTarget::textDragExit (const String&) {} + +} // namespace juce diff --git a/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.h b/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.h index 05793358ea..437037d38c 100644 --- a/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.h +++ b/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -212,3 +212,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DragAndDropContainer) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/mouse/juce_DragAndDropTarget.h b/modules/juce_gui_basics/mouse/juce_DragAndDropTarget.h index 886948e9ff..b7be4d4868 100644 --- a/modules/juce_gui_basics/mouse/juce_DragAndDropTarget.h +++ b/modules/juce_gui_basics/mouse/juce_DragAndDropTarget.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -149,3 +149,5 @@ private: virtual int itemDropped (const String&, Component*, int, int) { return 0; } #endif }; + +} // namespace juce diff --git a/modules/juce_gui_basics/mouse/juce_FileDragAndDropTarget.h b/modules/juce_gui_basics/mouse/juce_FileDragAndDropTarget.h index 465e234c91..e6491dcce5 100644 --- a/modules/juce_gui_basics/mouse/juce_FileDragAndDropTarget.h +++ b/modules/juce_gui_basics/mouse/juce_FileDragAndDropTarget.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ /** Components derived from this class can have files dropped onto them by an external application. @@ -100,3 +101,5 @@ public: */ virtual void filesDropped (const StringArray& files, int x, int y) = 0; }; + +} // namespace juce diff --git a/modules/juce_gui_basics/mouse/juce_LassoComponent.h b/modules/juce_gui_basics/mouse/juce_LassoComponent.h index 77663e5e09..f2c278b118 100644 --- a/modules/juce_gui_basics/mouse/juce_LassoComponent.h +++ b/modules/juce_gui_basics/mouse/juce_LassoComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -219,3 +219,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LassoComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/mouse/juce_MouseCursor.cpp b/modules/juce_gui_basics/mouse/juce_MouseCursor.cpp index 7716e519af..dad75c06d5 100644 --- a/modules/juce_gui_basics/mouse/juce_MouseCursor.cpp +++ b/modules/juce_gui_basics/mouse/juce_MouseCursor.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + struct CustomMouseCursorInfo { CustomMouseCursorInfo (const Image& im, int hsX, int hsY) noexcept @@ -213,3 +216,5 @@ void MouseCursor::hideWaitCursor() { Desktop::getInstance().getMainMouseSource().revealCursor(); } + +} // namespace juce diff --git a/modules/juce_gui_basics/mouse/juce_MouseCursor.h b/modules/juce_gui_basics/mouse/juce_MouseCursor.h index 0856fd6560..4ad39b1de6 100644 --- a/modules/juce_gui_basics/mouse/juce_MouseCursor.h +++ b/modules/juce_gui_basics/mouse/juce_MouseCursor.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -178,3 +178,5 @@ private: JUCE_LEAK_DETECTOR (MouseCursor) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/mouse/juce_MouseEvent.cpp b/modules/juce_gui_basics/mouse/juce_MouseEvent.cpp index 7990995645..126d0ada07 100644 --- a/modules/juce_gui_basics/mouse/juce_MouseEvent.cpp +++ b/modules/juce_gui_basics/mouse/juce_MouseEvent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + MouseEvent::MouseEvent (MouseInputSource inputSource, Point pos, ModifierKeys modKeys, @@ -136,3 +139,5 @@ static int doubleClickTimeOutMs = 400; int MouseEvent::getDoubleClickTimeout() noexcept { return doubleClickTimeOutMs; } void MouseEvent::setDoubleClickTimeout (const int newTime) noexcept { doubleClickTimeOutMs = newTime; } + +} // namespace juce diff --git a/modules/juce_gui_basics/mouse/juce_MouseEvent.h b/modules/juce_gui_basics/mouse/juce_MouseEvent.h index 44a7a49f1a..4643cc368a 100644 --- a/modules/juce_gui_basics/mouse/juce_MouseEvent.h +++ b/modules/juce_gui_basics/mouse/juce_MouseEvent.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -437,3 +438,5 @@ struct PenDetails */ float tiltY; }; + +} // namespace juce diff --git a/modules/juce_gui_basics/mouse/juce_MouseInactivityDetector.cpp b/modules/juce_gui_basics/mouse/juce_MouseInactivityDetector.cpp index 6ac495c0ea..45b35219a0 100644 --- a/modules/juce_gui_basics/mouse/juce_MouseInactivityDetector.cpp +++ b/modules/juce_gui_basics/mouse/juce_MouseInactivityDetector.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + MouseInactivityDetector::MouseInactivityDetector (Component& c) : targetComp (c), delayMs (1500), toleranceDistance (15), isActive (true) { @@ -70,3 +73,5 @@ void MouseInactivityDetector::setActive (bool b) : &Listener::mouseBecameInactive); } } + +} // namespace juce diff --git a/modules/juce_gui_basics/mouse/juce_MouseInactivityDetector.h b/modules/juce_gui_basics/mouse/juce_MouseInactivityDetector.h index 790c44b3a6..f8c6a5e555 100644 --- a/modules/juce_gui_basics/mouse/juce_MouseInactivityDetector.h +++ b/modules/juce_gui_basics/mouse/juce_MouseInactivityDetector.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -107,3 +107,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MouseInactivityDetector) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp b/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp index 3717e06678..541d542183 100644 --- a/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp +++ b/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class MouseInputSourceInternal : private AsyncUpdater { public: @@ -748,3 +751,5 @@ struct MouseInputSource::SourceList : public Timer OwnedArray sources; Array sourceArray; }; + +} // namespace juce diff --git a/modules/juce_gui_basics/mouse/juce_MouseInputSource.h b/modules/juce_gui_basics/mouse/juce_MouseInputSource.h index 3a8d51ad2b..b7e62e511c 100644 --- a/modules/juce_gui_basics/mouse/juce_MouseInputSource.h +++ b/modules/juce_gui_basics/mouse/juce_MouseInputSource.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -252,3 +252,5 @@ private: JUCE_LEAK_DETECTOR (MouseInputSource) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/mouse/juce_MouseListener.cpp b/modules/juce_gui_basics/mouse/juce_MouseListener.cpp index abe9ff512c..984a436f29 100644 --- a/modules/juce_gui_basics/mouse/juce_MouseListener.cpp +++ b/modules/juce_gui_basics/mouse/juce_MouseListener.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + void MouseListener::mouseEnter (const MouseEvent&) {} void MouseListener::mouseExit (const MouseEvent&) {} void MouseListener::mouseDown (const MouseEvent&) {} @@ -32,3 +35,5 @@ void MouseListener::mouseDrag (const MouseEvent&) {} void MouseListener::mouseMove (const MouseEvent&) {} void MouseListener::mouseDoubleClick (const MouseEvent&) {} void MouseListener::mouseWheelMove (const MouseEvent&, const MouseWheelDetails&) {} + +} // namespace juce diff --git a/modules/juce_gui_basics/mouse/juce_MouseListener.h b/modules/juce_gui_basics/mouse/juce_MouseListener.h index fd467ba82b..859b91dec2 100644 --- a/modules/juce_gui_basics/mouse/juce_MouseListener.h +++ b/modules/juce_gui_basics/mouse/juce_MouseListener.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -161,3 +161,5 @@ private: virtual int mouseWheelMove (const MouseEvent&, float, float) { return 0; } #endif }; + +} // namespace juce diff --git a/modules/juce_gui_basics/mouse/juce_SelectedItemSet.h b/modules/juce_gui_basics/mouse/juce_SelectedItemSet.h index c78c970727..19211b0157 100644 --- a/modules/juce_gui_basics/mouse/juce_SelectedItemSet.h +++ b/modules/juce_gui_basics/mouse/juce_SelectedItemSet.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** Manages a list of selectable items. @@ -319,3 +319,5 @@ private: JUCE_LEAK_DETECTOR (SelectedItemSet) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/mouse/juce_TextDragAndDropTarget.h b/modules/juce_gui_basics/mouse/juce_TextDragAndDropTarget.h index 9cba6b2611..088065c249 100644 --- a/modules/juce_gui_basics/mouse/juce_TextDragAndDropTarget.h +++ b/modules/juce_gui_basics/mouse/juce_TextDragAndDropTarget.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -101,3 +101,5 @@ public: */ virtual void textDropped (const String& text, int x, int y) = 0; }; + +} // namespace juce diff --git a/modules/juce_gui_basics/mouse/juce_TooltipClient.h b/modules/juce_gui_basics/mouse/juce_TooltipClient.h index 1219822a68..9f8c0b9152 100644 --- a/modules/juce_gui_basics/mouse/juce_TooltipClient.h +++ b/modules/juce_gui_basics/mouse/juce_TooltipClient.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -81,3 +81,5 @@ protected: private: String tooltipString; }; + +} // namespace juce diff --git a/modules/juce_gui_basics/native/juce_MultiTouchMapper.h b/modules/juce_gui_basics/native/juce_MultiTouchMapper.h index 5cca8b5416..ed27ec1977 100644 --- a/modules/juce_gui_basics/native/juce_MultiTouchMapper.h +++ b/modules/juce_gui_basics/native/juce_MultiTouchMapper.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ template class MultiTouchMapper @@ -62,8 +63,8 @@ public: bool areAnyTouchesActive() const noexcept { - for (int i = currentTouches.size(); --i >= 0;) - if (currentTouches.getUnchecked(i) != 0) + for (auto& t : currentTouches) + if (t != 0) return true; return false; @@ -74,3 +75,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MultiTouchMapper) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/native/juce_android_FileChooser.cpp b/modules/juce_gui_basics/native/juce_android_FileChooser.cpp index aa8ed4f72c..27fb00d238 100644 --- a/modules/juce_gui_basics/native/juce_android_FileChooser.cpp +++ b/modules/juce_gui_basics/native/juce_android_FileChooser.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + void FileChooser::showPlatformDialog (Array& /*results*/, const String& /*title*/, const File& /*currentFileOrDirectory*/, @@ -45,3 +48,5 @@ bool FileChooser::isPlatformDialogAvailable() { return false; } + +} // namespace juce diff --git a/modules/juce_gui_basics/native/juce_android_Windowing.cpp b/modules/juce_gui_basics/native/juce_android_Windowing.cpp index ba5ac8a7f4..9240440be1 100644 --- a/modules/juce_gui_basics/native/juce_android_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_android_Windowing.cpp @@ -24,8 +24,6 @@ ============================================================================== */ -} // (juce namespace) - extern juce::JUCEApplicationBase* juce_CreateApplication(); // (from START_JUCE_APPLICATION) namespace juce @@ -1064,3 +1062,5 @@ const int KeyPress::playKey = extendedKeyModifier + 45; const int KeyPress::stopKey = extendedKeyModifier + 46; const int KeyPress::fastForwardKey = extendedKeyModifier + 47; const int KeyPress::rewindKey = extendedKeyModifier + 48; + +} // namespace juce diff --git a/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm b/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm index 113eacc859..d935d3ceee 100644 --- a/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm +++ b/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class UIViewComponentPeer; // The way rotation works changed in iOS8.. @@ -95,7 +98,7 @@ namespace Orientations } //============================================================================== -} // (juce namespace) +} // namespace juce using namespace juce; @@ -327,8 +330,7 @@ static bool isKioskModeView (JuceUIViewController* c) MultiTouchMapper UIViewComponentPeer::currentTouches; - -} // (juce namespace) +} // namespace juce //============================================================================== //============================================================================== @@ -1169,3 +1171,5 @@ const int KeyPress::playKey = 0x30000; const int KeyPress::stopKey = 0x30001; const int KeyPress::fastForwardKey = 0x30002; const int KeyPress::rewindKey = 0x30003; + +} // namespace juce diff --git a/modules/juce_gui_basics/native/juce_ios_Windowing.mm b/modules/juce_gui_basics/native/juce_ios_Windowing.mm index a82990358d..7007bcaefa 100644 --- a/modules/juce_gui_basics/native/juce_ios_Windowing.mm +++ b/modules/juce_gui_basics/native/juce_ios_Windowing.mm @@ -24,18 +24,19 @@ ============================================================================== */ -extern bool isIOSAppActive; - -struct AppInactivityCallback // NB: careful, this declaration is duplicated in other modules +namespace juce { - virtual ~AppInactivityCallback() {} - virtual void appBecomingInactive() = 0; -}; + extern bool isIOSAppActive; -// This is an internal list of callbacks (but currently used between modules) -Array appBecomingInactiveCallbacks; + struct AppInactivityCallback // NB: careful, this declaration is duplicated in other modules + { + virtual ~AppInactivityCallback() {} + virtual void appBecomingInactive() = 0; + }; -} // (juce namespace) + // This is an internal list of callbacks (but currently used between modules) + Array appBecomingInactiveCallbacks; +} @interface JuceAppStartupDelegate : NSObject { @@ -478,3 +479,5 @@ void Desktop::Displays::findDisplays (float masterScale) displays.add (d); } } + +} // namespace juce diff --git a/modules/juce_gui_basics/native/juce_linux_FileChooser.cpp b/modules/juce_gui_basics/native/juce_linux_FileChooser.cpp index 8a485abc22..ceab192946 100644 --- a/modules/juce_gui_basics/native/juce_linux_FileChooser.cpp +++ b/modules/juce_gui_basics/native/juce_linux_FileChooser.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + static bool exeIsAvailable (const char* const executable) { ChildProcess child; @@ -206,3 +209,5 @@ void FileChooser::showPlatformDialog (Array& results, previousWorkingDirectory.setAsCurrentWorkingDirectory(); } + +} // namespace juce diff --git a/modules/juce_gui_basics/native/juce_linux_X11.cpp b/modules/juce_gui_basics/native/juce_linux_X11.cpp index af009643d8..e9625b65df 100644 --- a/modules/juce_gui_basics/native/juce_linux_X11.cpp +++ b/modules/juce_gui_basics/native/juce_linux_X11.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + typedef void (*WindowMessageReceiveCallback) (XEvent&); WindowMessageReceiveCallback dispatchWindowMessage = nullptr; @@ -333,3 +336,5 @@ GetXProperty::~GetXProperty() if (data != nullptr) XFree (data); } + +} // namespace juce diff --git a/modules/juce_gui_basics/native/juce_linux_X11.h b/modules/juce_gui_basics/native/juce_linux_X11.h index 00c55bf126..f4235a7b9e 100644 --- a/modules/juce_gui_basics/native/juce_linux_X11.h +++ b/modules/juce_gui_basics/native/juce_linux_X11.h @@ -24,13 +24,6 @@ ============================================================================== */ -#pragma once - -// Hack to forward declare _XDisplay outside the -// juce namespace - -} - struct _XDisplay; namespace juce @@ -142,3 +135,5 @@ struct GetXProperty }; #undef ATOM_TYPE + +} // namespace juce diff --git a/modules/juce_gui_basics/native/juce_linux_X11_Clipboard.cpp b/modules/juce_gui_basics/native/juce_linux_X11_Clipboard.cpp index 9c8e92b5bd..8c3427b097 100644 --- a/modules/juce_gui_basics/native/juce_linux_X11_Clipboard.cpp +++ b/modules/juce_gui_basics/native/juce_linux_X11_Clipboard.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + extern ::Window juce_messageWindowHandle; namespace ClipboardHelpers @@ -273,3 +276,5 @@ String SystemClipboard::getTextFromClipboard() return content; } + +} // namespace juce diff --git a/modules/juce_gui_basics/native/juce_linux_X11_Windowing.cpp b/modules/juce_gui_basics/native/juce_linux_X11_Windowing.cpp index 9d5ca6e53b..0182cf4776 100644 --- a/modules/juce_gui_basics/native/juce_linux_X11_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_linux_X11_Windowing.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_DEBUG && ! defined (JUCE_DEBUG_XERRORS) #define JUCE_DEBUG_XERRORS 1 #endif @@ -4358,3 +4361,5 @@ bool DragAndDropContainer::performExternalDragDropOfText (const String& text, Co jassertfalse; return false; } + +} // namespace juce diff --git a/modules/juce_gui_basics/native/juce_mac_FileChooser.mm b/modules/juce_gui_basics/native/juce_mac_FileChooser.mm index f0f99d8d86..333850c5d7 100644 --- a/modules/juce_gui_basics/native/juce_mac_FileChooser.mm +++ b/modules/juce_gui_basics/native/juce_mac_FileChooser.mm @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_MAC struct FileChooserDelegateClass : public ObjCClass @@ -273,3 +276,5 @@ void FileChooser::showPlatformDialog (Array&, } #endif + +} // namespace juce diff --git a/modules/juce_gui_basics/native/juce_mac_MainMenu.mm b/modules/juce_gui_basics/native/juce_mac_MainMenu.mm index 8b5812cbee..2da59ea343 100644 --- a/modules/juce_gui_basics/native/juce_mac_MainMenu.mm +++ b/modules/juce_gui_basics/native/juce_mac_MainMenu.mm @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class JuceMainMenuHandler : private MenuBarModel::Listener, private DeletedAtShutdown { @@ -724,3 +727,5 @@ NSMenu* createNSMenu (const PopupMenu& menu, const String& name, jassertfalse; // calling this before making sure the OSX main menu stuff was initialised? return nil; } + +} // namespace juce diff --git a/modules/juce_gui_basics/native/juce_mac_MouseCursor.mm b/modules/juce_gui_basics/native/juce_mac_MouseCursor.mm index 36e05219d8..5cd37e0fb4 100644 --- a/modules/juce_gui_basics/native/juce_mac_MouseCursor.mm +++ b/modules/juce_gui_basics/native/juce_mac_MouseCursor.mm @@ -24,12 +24,15 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_MAC //============================================================================== namespace MouseCursorHelpers { - NSImage* createNSImage (const Image&, float scaleFactor = 1.f); + NSImage* createNSImage (const Image&, float scaleFactor = 1.0f); NSImage* createNSImage (const Image& image, float scaleFactor) { JUCE_AUTORELEASEPOOL @@ -207,3 +210,5 @@ void MouseCursor::showInAllWindows() const void MouseCursor::showInWindow (ComponentPeer*) const {} #endif + +} // namespace juce diff --git a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm index 3b0244b5ca..1102b0c6dc 100644 --- a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm +++ b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm @@ -24,14 +24,16 @@ ============================================================================== */ -typedef void (*AppFocusChangeCallback)(); -extern AppFocusChangeCallback appFocusChangeCallback; -typedef bool (*CheckEventBlockedByModalComps) (NSEvent*); -extern CheckEventBlockedByModalComps isEventBlockedByModalComps; +namespace juce +{ + typedef void (*AppFocusChangeCallback)(); + extern AppFocusChangeCallback appFocusChangeCallback; + typedef bool (*CheckEventBlockedByModalComps) (NSEvent*); + extern CheckEventBlockedByModalComps isEventBlockedByModalComps; +} //============================================================================== #if ! (defined (MAC_OS_X_VERSION_10_7) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7) -} // (juce namespace) @interface NSEvent (JuceDeviceDelta) - (CGFloat) scrollingDeltaX; @@ -40,9 +42,11 @@ extern CheckEventBlockedByModalComps isEventBlockedByModalComps; - (BOOL) isDirectionInvertedFromDevice; @end -namespace juce { #endif +namespace juce +{ + //============================================================================== static CGFloat getMainScreenHeight() noexcept { @@ -2193,3 +2197,5 @@ const int KeyPress::playKey = 0x30000; const int KeyPress::stopKey = 0x30001; const int KeyPress::fastForwardKey = 0x30002; const int KeyPress::rewindKey = 0x30003; + +} // namespace juce diff --git a/modules/juce_gui_basics/native/juce_mac_Windowing.mm b/modules/juce_gui_basics/native/juce_mac_Windowing.mm index 3a6e57390d..47b9490544 100644 --- a/modules/juce_gui_basics/native/juce_mac_Windowing.mm +++ b/modules/juce_gui_basics/native/juce_mac_Windowing.mm @@ -24,13 +24,9 @@ ============================================================================== */ -} // namespace juce - -#include "../../juce_core/native/juce_osx_ObjCHelpers.h" - -namespace juce { +namespace juce +{ -//============================================================================== void LookAndFeel::playAlertSound() { NSBeep(); @@ -619,3 +615,5 @@ bool Desktop::isOSXDarkModeActive() return [[[NSUserDefaults standardUserDefaults] stringForKey: nsStringLiteral ("AppleInterfaceStyle")] isEqualToString: nsStringLiteral ("Dark")]; } + +} // namespace juce diff --git a/modules/juce_gui_basics/native/juce_win32_DragAndDrop.cpp b/modules/juce_gui_basics/native/juce_win32_DragAndDrop.cpp index 53de33836c..5db2b1266a 100644 --- a/modules/juce_gui_basics/native/juce_win32_DragAndDrop.cpp +++ b/modules/juce_gui_basics/native/juce_win32_DragAndDrop.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace DragAndDropHelpers { //============================================================================== @@ -282,3 +285,5 @@ bool DragAndDropContainer::performExternalDragDropOfText (const String& text, Co return DragAndDropHelpers::performDragDrop (&format, &medium, DROPEFFECT_COPY | DROPEFFECT_MOVE); } + +} // namespace juce diff --git a/modules/juce_gui_basics/native/juce_win32_FileChooser.cpp b/modules/juce_gui_basics/native/juce_win32_FileChooser.cpp index ae2de01ea8..bb352b23b0 100644 --- a/modules/juce_gui_basics/native/juce_win32_FileChooser.cpp +++ b/modules/juce_gui_basics/native/juce_win32_FileChooser.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace FileChooserHelpers { struct FileChooserCallbackInfo @@ -296,3 +299,5 @@ void FileChooser::showPlatformDialog (Array& results, const String& title_ results.add (File (String (files.get()))); } } + +} // namespace juce diff --git a/modules/juce_gui_basics/native/juce_win32_Windowing.cpp b/modules/juce_gui_basics/native/juce_win32_Windowing.cpp index 12602fa149..c6f97e2f52 100644 --- a/modules/juce_gui_basics/native/juce_win32_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_win32_Windowing.cpp @@ -24,6 +24,13 @@ ============================================================================== */ +#if JUCE_MODULE_AVAILABLE_juce_audio_plugin_client + #include +#endif + +namespace juce +{ + #undef GetSystemMetrics // multimon overrides this for some reason and causes a mess.. // these are in the windows SDK, but need to be repeated here for GCC.. @@ -41,10 +48,6 @@ #define WM_APPCOMMAND 0x0319 #endif -#if JUCE_MODULE_AVAILABLE_juce_audio_plugin_client - #include -#endif - extern void juce_repeatLastProcessPriority(); extern void juce_checkCurrentlyFocusedTopLevelWindow(); // in juce_TopLevelWindow.cpp extern bool juce_isRunningInWine(); @@ -4173,3 +4176,5 @@ void MouseCursor::showInAllWindows() const { showInWindow (nullptr); } + +} // namespace juce diff --git a/modules/juce_gui_basics/positioning/juce_MarkerList.cpp b/modules/juce_gui_basics/positioning/juce_MarkerList.cpp index ee61180f07..7651dceedc 100644 --- a/modules/juce_gui_basics/positioning/juce_MarkerList.cpp +++ b/modules/juce_gui_basics/positioning/juce_MarkerList.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + MarkerList::MarkerList() { } @@ -278,3 +281,5 @@ void MarkerList::ValueTreeWrapper::readFrom (const MarkerList& markerList, UndoM for (int i = 0; i < markerList.getNumMarkers(); ++i) setMarker (*markerList.getMarker(i), undoManager); } + +} // namespace juce diff --git a/modules/juce_gui_basics/positioning/juce_MarkerList.h b/modules/juce_gui_basics/positioning/juce_MarkerList.h index 8d6da7f7e0..c73f1f5ab9 100644 --- a/modules/juce_gui_basics/positioning/juce_MarkerList.h +++ b/modules/juce_gui_basics/positioning/juce_MarkerList.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -180,3 +180,5 @@ private: JUCE_LEAK_DETECTOR (MarkerList) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/positioning/juce_RelativeCoordinate.cpp b/modules/juce_gui_basics/positioning/juce_RelativeCoordinate.cpp index ce79716939..fcb803bafb 100644 --- a/modules/juce_gui_basics/positioning/juce_RelativeCoordinate.cpp +++ b/modules/juce_gui_basics/positioning/juce_RelativeCoordinate.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + const String RelativeCoordinate::Strings::parent ("parent"); const String RelativeCoordinate::Strings::left ("left"); const String RelativeCoordinate::Strings::right ("right"); @@ -147,3 +150,5 @@ String RelativeCoordinate::toString() const { return term.toString(); } + +} // namespace juce diff --git a/modules/juce_gui_basics/positioning/juce_RelativeCoordinate.h b/modules/juce_gui_basics/positioning/juce_RelativeCoordinate.h index 507dfcd499..55d3edfded 100644 --- a/modules/juce_gui_basics/positioning/juce_RelativeCoordinate.h +++ b/modules/juce_gui_basics/positioning/juce_RelativeCoordinate.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -175,3 +175,5 @@ private: //============================================================================== Expression term; }; + +} // namespace juce diff --git a/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.cpp b/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.cpp index 7260710de1..9afd38ee78 100644 --- a/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.cpp +++ b/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + struct MarkerListScope : public Expression::Scope { MarkerListScope (Component& comp) : component (comp) {} @@ -317,3 +320,5 @@ void RelativeCoordinatePositionerBase::unregisterListeners() sourceComponents.clear(); sourceMarkerLists.clear(); } + +} // namespace juce diff --git a/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.h b/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.h index 74abf43601..038f9dec65 100644 --- a/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.h +++ b/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -88,3 +88,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (RelativeCoordinatePositionerBase) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/positioning/juce_RelativeParallelogram.cpp b/modules/juce_gui_basics/positioning/juce_RelativeParallelogram.cpp index 92ad11fc4a..3d9f6ed919 100644 --- a/modules/juce_gui_basics/positioning/juce_RelativeParallelogram.cpp +++ b/modules/juce_gui_basics/positioning/juce_RelativeParallelogram.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + RelativeParallelogram::RelativeParallelogram() { } @@ -134,3 +137,5 @@ Rectangle RelativeParallelogram::getBoundingBox (const Point* cons const Point points[] = { p[0], p[1], p[2], p[1] + (p[2] - p[0]) }; return Rectangle::findAreaContainingPoints (points, 4); } + +} // namespace juce diff --git a/modules/juce_gui_basics/positioning/juce_RelativeParallelogram.h b/modules/juce_gui_basics/positioning/juce_RelativeParallelogram.h index 38ab861eac..afd88c9f0c 100644 --- a/modules/juce_gui_basics/positioning/juce_RelativeParallelogram.h +++ b/modules/juce_gui_basics/positioning/juce_RelativeParallelogram.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -61,3 +61,5 @@ public: //============================================================================== RelativePoint topLeft, topRight, bottomLeft; }; + +} // namespace juce diff --git a/modules/juce_gui_basics/positioning/juce_RelativePoint.cpp b/modules/juce_gui_basics/positioning/juce_RelativePoint.cpp index 5f9228c202..51895b2983 100644 --- a/modules/juce_gui_basics/positioning/juce_RelativePoint.cpp +++ b/modules/juce_gui_basics/positioning/juce_RelativePoint.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace RelativePointHelpers { inline void skipComma (String::CharPointerType& s) @@ -95,3 +98,5 @@ bool RelativePoint::isDynamic() const { return x.isDynamic() || y.isDynamic(); } + +} // namespace juce diff --git a/modules/juce_gui_basics/positioning/juce_RelativePoint.h b/modules/juce_gui_basics/positioning/juce_RelativePoint.h index cb874f6e2a..7bf446690b 100644 --- a/modules/juce_gui_basics/positioning/juce_RelativePoint.h +++ b/modules/juce_gui_basics/positioning/juce_RelativePoint.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -86,3 +86,5 @@ public: // The actual X and Y coords... RelativeCoordinate x, y; }; + +} // namespace juce diff --git a/modules/juce_gui_basics/positioning/juce_RelativePointPath.cpp b/modules/juce_gui_basics/positioning/juce_RelativePointPath.cpp index 5f36d46ef8..ee57e48895 100644 --- a/modules/juce_gui_basics/positioning/juce_RelativePointPath.cpp +++ b/modules/juce_gui_basics/positioning/juce_RelativePointPath.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + RelativePointPath::RelativePointPath() : usesNonZeroWinding (true), containsDynamicPoints (false) @@ -292,3 +295,5 @@ RelativePointPath::ElementBase* RelativePointPath::CubicTo::clone() const { return new CubicTo (controlPoints[0], controlPoints[1], controlPoints[2]); } + +} // namespace juce diff --git a/modules/juce_gui_basics/positioning/juce_RelativePointPath.h b/modules/juce_gui_basics/positioning/juce_RelativePointPath.h index ff628db343..6e648a5fe1 100644 --- a/modules/juce_gui_basics/positioning/juce_RelativePointPath.h +++ b/modules/juce_gui_basics/positioning/juce_RelativePointPath.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -187,3 +187,5 @@ private: RelativePointPath& operator= (const RelativePointPath&); JUCE_LEAK_DETECTOR (RelativePointPath) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/positioning/juce_RelativeRectangle.cpp b/modules/juce_gui_basics/positioning/juce_RelativeRectangle.cpp index d2b73580e5..574be97676 100644 --- a/modules/juce_gui_basics/positioning/juce_RelativeRectangle.cpp +++ b/modules/juce_gui_basics/positioning/juce_RelativeRectangle.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace RelativeRectangleHelpers { inline void skipComma (String::CharPointerType& s) @@ -262,3 +265,5 @@ void RelativeRectangle::applyToComponent (Component& component) const component.setBounds (resolve (nullptr).getSmallestIntegerContainer()); } } + +} // namespace juce diff --git a/modules/juce_gui_basics/positioning/juce_RelativeRectangle.h b/modules/juce_gui_basics/positioning/juce_RelativeRectangle.h index b634adc659..4113769de7 100644 --- a/modules/juce_gui_basics/positioning/juce_RelativeRectangle.h +++ b/modules/juce_gui_basics/positioning/juce_RelativeRectangle.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -103,3 +103,5 @@ public: // The actual rectangle coords... RelativeCoordinate left, right, top, bottom; }; + +} // namespace juce diff --git a/modules/juce_gui_basics/properties/juce_BooleanPropertyComponent.cpp b/modules/juce_gui_basics/properties/juce_BooleanPropertyComponent.cpp index bbf568a638..0e5dbdc08f 100644 --- a/modules/juce_gui_basics/properties/juce_BooleanPropertyComponent.cpp +++ b/modules/juce_gui_basics/properties/juce_BooleanPropertyComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + BooleanPropertyComponent::BooleanPropertyComponent (const String& name, const String& buttonTextWhenTrue, const String& buttonTextWhenFalse) @@ -85,3 +88,5 @@ void BooleanPropertyComponent::buttonClicked (Button*) { setState (! getState()); } + +} // namespace juce diff --git a/modules/juce_gui_basics/properties/juce_BooleanPropertyComponent.h b/modules/juce_gui_basics/properties/juce_BooleanPropertyComponent.h index 37e112c682..061541a70d 100644 --- a/modules/juce_gui_basics/properties/juce_BooleanPropertyComponent.h +++ b/modules/juce_gui_basics/properties/juce_BooleanPropertyComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -107,3 +107,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (BooleanPropertyComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/properties/juce_ButtonPropertyComponent.cpp b/modules/juce_gui_basics/properties/juce_ButtonPropertyComponent.cpp index 00343f65a8..3d3a1b0ffa 100644 --- a/modules/juce_gui_basics/properties/juce_ButtonPropertyComponent.cpp +++ b/modules/juce_gui_basics/properties/juce_ButtonPropertyComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ButtonPropertyComponent::ButtonPropertyComponent (const String& name, const bool triggerOnMouseDown) : PropertyComponent (name) @@ -46,3 +49,5 @@ void ButtonPropertyComponent::buttonClicked (Button*) { buttonClicked(); } + +} // namespace juce diff --git a/modules/juce_gui_basics/properties/juce_ButtonPropertyComponent.h b/modules/juce_gui_basics/properties/juce_ButtonPropertyComponent.h index 64390c805a..1415b8cd1c 100644 --- a/modules/juce_gui_basics/properties/juce_ButtonPropertyComponent.h +++ b/modules/juce_gui_basics/properties/juce_ButtonPropertyComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -74,3 +74,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ButtonPropertyComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/properties/juce_ChoicePropertyComponent.cpp b/modules/juce_gui_basics/properties/juce_ChoicePropertyComponent.cpp index 7c26d26362..c788ae3920 100644 --- a/modules/juce_gui_basics/properties/juce_ChoicePropertyComponent.cpp +++ b/modules/juce_gui_basics/properties/juce_ChoicePropertyComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class ChoicePropertyComponent::RemapperValueSource : public Value::ValueSource, private Value::Listener { @@ -152,3 +155,5 @@ void ChoicePropertyComponent::comboBoxChanged (ComboBox*) setIndex (newIndex); } } + +} // namespace juce diff --git a/modules/juce_gui_basics/properties/juce_ChoicePropertyComponent.h b/modules/juce_gui_basics/properties/juce_ChoicePropertyComponent.h index c9ffe6d092..600a23cc7f 100644 --- a/modules/juce_gui_basics/properties/juce_ChoicePropertyComponent.h +++ b/modules/juce_gui_basics/properties/juce_ChoicePropertyComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -119,3 +119,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ChoicePropertyComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/properties/juce_PropertyComponent.cpp b/modules/juce_gui_basics/properties/juce_PropertyComponent.cpp index 81ee114e9b..19136a5e76 100644 --- a/modules/juce_gui_basics/properties/juce_PropertyComponent.cpp +++ b/modules/juce_gui_basics/properties/juce_PropertyComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + PropertyComponent::PropertyComponent (const String& name, const int preferredHeight_) : Component (name), preferredHeight (preferredHeight_) { @@ -50,3 +53,5 @@ void PropertyComponent::enablementChanged() { repaint(); } + +} // namespace juce diff --git a/modules/juce_gui_basics/properties/juce_PropertyComponent.h b/modules/juce_gui_basics/properties/juce_PropertyComponent.h index c6e2ec6e29..263b3b5cf3 100644 --- a/modules/juce_gui_basics/properties/juce_PropertyComponent.h +++ b/modules/juce_gui_basics/properties/juce_PropertyComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -139,3 +139,5 @@ protected: private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PropertyComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/properties/juce_PropertyPanel.cpp b/modules/juce_gui_basics/properties/juce_PropertyPanel.cpp index a12c436a89..c2e5842d5a 100644 --- a/modules/juce_gui_basics/properties/juce_PropertyPanel.cpp +++ b/modules/juce_gui_basics/properties/juce_PropertyPanel.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + struct PropertyPanel::SectionComponent : public Component { SectionComponent (const String& sectionTitle, @@ -374,3 +377,5 @@ const String& PropertyPanel::getMessageWhenEmpty() const noexcept { return messageWhenEmpty; } + +} // namespace juce diff --git a/modules/juce_gui_basics/properties/juce_PropertyPanel.h b/modules/juce_gui_basics/properties/juce_PropertyPanel.h index 24150eb1f7..49ab8fde4e 100644 --- a/modules/juce_gui_basics/properties/juce_PropertyPanel.h +++ b/modules/juce_gui_basics/properties/juce_PropertyPanel.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -173,3 +173,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PropertyPanel) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/properties/juce_SliderPropertyComponent.cpp b/modules/juce_gui_basics/properties/juce_SliderPropertyComponent.cpp index 4db6859a7d..439ef36cf5 100644 --- a/modules/juce_gui_basics/properties/juce_SliderPropertyComponent.cpp +++ b/modules/juce_gui_basics/properties/juce_SliderPropertyComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + SliderPropertyComponent::SliderPropertyComponent (const String& name, const double rangeMin, const double rangeMax, @@ -82,3 +85,5 @@ void SliderPropertyComponent::sliderValueChanged (Slider*) if (getValue() != slider.getValue()) setValue (slider.getValue()); } + +} // namespace juce diff --git a/modules/juce_gui_basics/properties/juce_SliderPropertyComponent.h b/modules/juce_gui_basics/properties/juce_SliderPropertyComponent.h index 9a30dbbc29..944d6c1b9c 100644 --- a/modules/juce_gui_basics/properties/juce_SliderPropertyComponent.h +++ b/modules/juce_gui_basics/properties/juce_SliderPropertyComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -105,3 +105,5 @@ private: //============================================================================== JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SliderPropertyComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/properties/juce_TextPropertyComponent.cpp b/modules/juce_gui_basics/properties/juce_TextPropertyComponent.cpp index 3193f110bf..290b8fd478 100644 --- a/modules/juce_gui_basics/properties/juce_TextPropertyComponent.cpp +++ b/modules/juce_gui_basics/properties/juce_TextPropertyComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class TextPropertyComponent::LabelComp : public Label, public FileDragAndDropTarget { @@ -181,3 +184,5 @@ void TextPropertyComponent::setInterestedInFileDrag (bool isInterested) if (textEditor != nullptr) textEditor->setInterestedInFileDrag (isInterested); } + +} // namespace juce diff --git a/modules/juce_gui_basics/properties/juce_TextPropertyComponent.h b/modules/juce_gui_basics/properties/juce_TextPropertyComponent.h index 5a10ca6f5e..2d208e32a7 100644 --- a/modules/juce_gui_basics/properties/juce_TextPropertyComponent.h +++ b/modules/juce_gui_basics/properties/juce_TextPropertyComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -153,3 +153,5 @@ private: /** This typedef is just for compatibility with old code and VC6 - newer code should use TextPropertyComponent::Listener instead. */ typedef TextPropertyComponent::Listener TextPropertyComponentListener; #endif + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_ComboBox.cpp b/modules/juce_gui_basics/widgets/juce_ComboBox.cpp index a601c86b0e..a3f5dd6485 100644 --- a/modules/juce_gui_basics/widgets/juce_ComboBox.cpp +++ b/modules/juce_gui_basics/widgets/juce_ComboBox.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ComboBox::ComboBox (const String& name) : Component (name), lastCurrentId (0), @@ -651,3 +654,5 @@ void ComboBox::clear (const bool dontSendChange) void ComboBox::setSelectedItemIndex (const int index, const bool dontSendChange) { setSelectedItemIndex (index, dontSendChange ? dontSendNotification : sendNotification); } void ComboBox::setSelectedId (const int newItemId, const bool dontSendChange) { setSelectedId (newItemId, dontSendChange ? dontSendNotification : sendNotification); } void ComboBox::setText (const String& newText, const bool dontSendChange) { setText (newText, dontSendChange ? dontSendNotification : sendNotification); } + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_ComboBox.h b/modules/juce_gui_basics/widgets/juce_ComboBox.h index 09d02984f9..2092287629 100644 --- a/modules/juce_gui_basics/widgets/juce_ComboBox.h +++ b/modules/juce_gui_basics/widgets/juce_ComboBox.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -448,3 +448,5 @@ private: /** This typedef is just for compatibility with old code - newer code should use the ComboBox::Listener class directly. */ typedef ComboBox::Listener ComboBoxListener; + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_ImageComponent.cpp b/modules/juce_gui_basics/widgets/juce_ImageComponent.cpp index 77d2a98074..3dac30c5f6 100644 --- a/modules/juce_gui_basics/widgets/juce_ImageComponent.cpp +++ b/modules/juce_gui_basics/widgets/juce_ImageComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ImageComponent::ImageComponent (const String& name) : Component (name), placement (RectanglePlacement::centred) @@ -77,3 +80,5 @@ void ImageComponent::paint (Graphics& g) g.setOpacity (1.0f); g.drawImage (image, getLocalBounds().toFloat(), placement); } + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_ImageComponent.h b/modules/juce_gui_basics/widgets/juce_ImageComponent.h index 3957d58f64..3872634729 100644 --- a/modules/juce_gui_basics/widgets/juce_ImageComponent.h +++ b/modules/juce_gui_basics/widgets/juce_ImageComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -74,3 +74,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ImageComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_Label.cpp b/modules/juce_gui_basics/widgets/juce_Label.cpp index 7304090f07..403c7d3a45 100644 --- a/modules/juce_gui_basics/widgets/juce_Label.cpp +++ b/modules/juce_gui_basics/widgets/juce_Label.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + Label::Label (const String& name, const String& labelText) : Component (name), textValue (labelText), @@ -472,3 +475,5 @@ void Label::textEditorFocusLost (TextEditor& ed) { textEditorTextChanged (ed); } + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_Label.h b/modules/juce_gui_basics/widgets/juce_Label.h index 7b0aa30d63..34104cdf0d 100644 --- a/modules/juce_gui_basics/widgets/juce_Label.h +++ b/modules/juce_gui_basics/widgets/juce_Label.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -351,3 +351,5 @@ private: /** This typedef is just for compatibility with old code - newer code should use the Label::Listener class directly. */ typedef Label::Listener LabelListener; + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_ListBox.cpp b/modules/juce_gui_basics/widgets/juce_ListBox.cpp index 9c303a9809..7f39a4eca8 100644 --- a/modules/juce_gui_basics/widgets/juce_ListBox.cpp +++ b/modules/juce_gui_basics/widgets/juce_ListBox.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class ListBox::RowComponent : public Component, public TooltipClient { @@ -950,3 +953,5 @@ void ListBoxModel::listWasScrolled() {} var ListBoxModel::getDragSourceDescription (const SparseSet&) { return {}; } String ListBoxModel::getTooltipForRow (int) { return {}; } MouseCursor ListBoxModel::getMouseCursorForRow (int) { return MouseCursor::NormalCursor; } + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_ListBox.h b/modules/juce_gui_basics/widgets/juce_ListBox.h index 31275dc68f..191af7824f 100644 --- a/modules/juce_gui_basics/widgets/juce_ListBox.h +++ b/modules/juce_gui_basics/widgets/juce_ListBox.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -598,3 +598,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ListBox) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_ProgressBar.cpp b/modules/juce_gui_basics/widgets/juce_ProgressBar.cpp index c0ed84250a..67f3e4885d 100644 --- a/modules/juce_gui_basics/widgets/juce_ProgressBar.cpp +++ b/modules/juce_gui_basics/widgets/juce_ProgressBar.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ProgressBar::ProgressBar (double& progress_) : progress (progress_), displayPercentage (true), @@ -111,3 +114,5 @@ void ProgressBar::timerCallback() repaint(); } } + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_ProgressBar.h b/modules/juce_gui_basics/widgets/juce_ProgressBar.h index 5ce9410a34..8837fdff00 100644 --- a/modules/juce_gui_basics/widgets/juce_ProgressBar.h +++ b/modules/juce_gui_basics/widgets/juce_ProgressBar.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -133,3 +133,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ProgressBar) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_Slider.cpp b/modules/juce_gui_basics/widgets/juce_Slider.cpp index 3ed9282792..f667139da9 100644 --- a/modules/juce_gui_basics/widgets/juce_Slider.cpp +++ b/modules/juce_gui_basics/widgets/juce_Slider.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class Slider::Pimpl : private AsyncUpdater, private Button::Listener, private Label::Listener, @@ -1621,3 +1624,5 @@ void Slider::mouseWheelMove (const MouseEvent& e, const MouseWheelDetails& wheel if (! (isEnabled() && pimpl->mouseWheelMove (e, wheel))) Component::mouseWheelMove (e, wheel); } + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_Slider.h b/modules/juce_gui_basics/widgets/juce_Slider.h index 63e583ab6c..ae60454c96 100644 --- a/modules/juce_gui_basics/widgets/juce_Slider.h +++ b/modules/juce_gui_basics/widgets/juce_Slider.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -940,3 +940,5 @@ private: /** This typedef is just for compatibility with old code - newer code should use the Slider::Listener class directly. */ typedef Slider::Listener SliderListener; + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp b/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp index 296888af0e..b939a4ba75 100644 --- a/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp +++ b/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class TableHeaderComponent::DragOverlayComp : public Component { public: @@ -893,3 +896,5 @@ void TableHeaderComponent::showColumnChooserMenu (const int columnIdClicked) void TableHeaderComponent::Listener::tableColumnDraggingChanged (TableHeaderComponent*, int) { } + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.h b/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.h index 51ad376a0f..bccb5bbfe2 100644 --- a/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.h +++ b/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -455,3 +455,5 @@ private: /** This typedef is just for compatibility with old code - newer code should use the TableHeaderComponent::Listener class directly. */ typedef TableHeaderComponent::Listener TableHeaderListener; + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_TableListBox.cpp b/modules/juce_gui_basics/widgets/juce_TableListBox.cpp index 220d50e917..784bdbeba1 100644 --- a/modules/juce_gui_basics/widgets/juce_TableListBox.cpp +++ b/modules/juce_gui_basics/widgets/juce_TableListBox.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class TableListBox::RowComp : public Component, public TooltipClient { @@ -483,3 +486,5 @@ Component* TableListBoxModel::refreshComponentForCell (int, int, bool, Component jassert (existingComponentToUpdate == nullptr); // indicates a failure in the code that recycles the components return nullptr; } + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_TableListBox.h b/modules/juce_gui_basics/widgets/juce_TableListBox.h index 7b36e0707b..050d831012 100644 --- a/modules/juce_gui_basics/widgets/juce_TableListBox.h +++ b/modules/juce_gui_basics/widgets/juce_TableListBox.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -345,3 +345,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TableListBox) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_TextEditor.cpp b/modules/juce_gui_basics/widgets/juce_TextEditor.cpp index 133af341f7..3e9ee97234 100644 --- a/modules/juce_gui_basics/widgets/juce_TextEditor.cpp +++ b/modules/juce_gui_basics/widgets/juce_TextEditor.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + // a word or space that can't be broken down any further struct TextAtom { @@ -2519,3 +2522,5 @@ void TextEditor::coalesceSimilarSections() } } } + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_TextEditor.h b/modules/juce_gui_basics/widgets/juce_TextEditor.h index 30a6465141..9a3960eb24 100644 --- a/modules/juce_gui_basics/widgets/juce_TextEditor.h +++ b/modules/juce_gui_basics/widgets/juce_TextEditor.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -770,3 +770,5 @@ private: /** This typedef is just for compatibility with old code - newer code should use the TextEditor::Listener class directly. */ typedef TextEditor::Listener TextEditorListener; + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_Toolbar.cpp b/modules/juce_gui_basics/widgets/juce_Toolbar.cpp index 258d0e6961..aa5126ae11 100644 --- a/modules/juce_gui_basics/widgets/juce_Toolbar.cpp +++ b/modules/juce_gui_basics/widgets/juce_Toolbar.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + const char* const Toolbar::toolbarDragDescriptor = "_toolbarItem_"; //============================================================================== @@ -811,3 +814,5 @@ void Toolbar::showCustomisationDialog (ToolbarItemFactory& factory, const int op (new CustomisationDialog (factory, *this, optionFlags)) ->enterModalState (true, nullptr, true); } + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_Toolbar.h b/modules/juce_gui_basics/widgets/juce_Toolbar.h index 1065886358..4950dd5b3d 100644 --- a/modules/juce_gui_basics/widgets/juce_Toolbar.h +++ b/modules/juce_gui_basics/widgets/juce_Toolbar.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ class ToolbarItemComponent; class ToolbarItemFactory; @@ -326,3 +327,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Toolbar) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.cpp b/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.cpp index 707d63d2c5..154ef827e9 100644 --- a/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.cpp +++ b/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ToolbarItemFactory::ToolbarItemFactory() {} ToolbarItemFactory::~ToolbarItemFactory() {} @@ -235,3 +238,5 @@ void ToolbarItemComponent::setEditingMode (const ToolbarEditingMode newMode) resized(); } } + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.h b/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.h index 76248b59f2..662ca6bc2c 100644 --- a/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.h +++ b/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -201,3 +201,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ToolbarItemComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_ToolbarItemFactory.h b/modules/juce_gui_basics/widgets/juce_ToolbarItemFactory.h index f9d1520044..d6c4fdde8d 100644 --- a/modules/juce_gui_basics/widgets/juce_ToolbarItemFactory.h +++ b/modules/juce_gui_basics/widgets/juce_ToolbarItemFactory.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -104,3 +104,5 @@ public: */ virtual ToolbarItemComponent* createItem (int itemId) = 0; }; + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_ToolbarItemPalette.cpp b/modules/juce_gui_basics/widgets/juce_ToolbarItemPalette.cpp index c0b47edb96..474e4742a8 100644 --- a/modules/juce_gui_basics/widgets/juce_ToolbarItemPalette.cpp +++ b/modules/juce_gui_basics/widgets/juce_ToolbarItemPalette.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ToolbarItemPalette::ToolbarItemPalette (ToolbarItemFactory& tbf, Toolbar& bar) : factory (tbf), toolbar (bar) { @@ -106,3 +109,5 @@ void ToolbarItemPalette::resized() itemHolder->setSize (maxX, y + height + 8); } + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_ToolbarItemPalette.h b/modules/juce_gui_basics/widgets/juce_ToolbarItemPalette.h index 8321657d00..a281baa258 100644 --- a/modules/juce_gui_basics/widgets/juce_ToolbarItemPalette.h +++ b/modules/juce_gui_basics/widgets/juce_ToolbarItemPalette.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -72,3 +72,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ToolbarItemPalette) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_TreeView.cpp b/modules/juce_gui_basics/widgets/juce_TreeView.cpp index 68874a224b..c34e7ec5f0 100644 --- a/modules/juce_gui_basics/widgets/juce_TreeView.cpp +++ b/modules/juce_gui_basics/widgets/juce_TreeView.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class TreeView::ContentComponent : public Component, public TooltipClient, public AsyncUpdater @@ -1905,3 +1908,5 @@ TreeViewItem::OpennessRestorer::~OpennessRestorer() if (oldOpenness != nullptr) treeViewItem.restoreOpennessState (*oldOpenness); } + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_TreeView.h b/modules/juce_gui_basics/widgets/juce_TreeView.h index e2f407c9c5..1db4dacd37 100644 --- a/modules/juce_gui_basics/widgets/juce_TreeView.h +++ b/modules/juce_gui_basics/widgets/juce_TreeView.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ class TreeView; @@ -934,3 +935,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TreeView) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/windows/juce_AlertWindow.cpp b/modules/juce_gui_basics/windows/juce_AlertWindow.cpp index 87983568c5..b019f7d34f 100644 --- a/modules/juce_gui_basics/windows/juce_AlertWindow.cpp +++ b/modules/juce_gui_basics/windows/juce_AlertWindow.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + static juce_wchar getDefaultPasswordChar() noexcept { #if JUCE_LINUX @@ -721,3 +724,5 @@ bool AlertWindow::showNativeDialogBox (const String& title, return true; } #endif + +} // namespace juce diff --git a/modules/juce_gui_basics/windows/juce_AlertWindow.h b/modules/juce_gui_basics/windows/juce_AlertWindow.h index cd8426cb76..e3f3ce5692 100644 --- a/modules/juce_gui_basics/windows/juce_AlertWindow.h +++ b/modules/juce_gui_basics/windows/juce_AlertWindow.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** A window that displays a message and has buttons for the user to react to it. @@ -486,3 +486,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AlertWindow) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/windows/juce_CallOutBox.cpp b/modules/juce_gui_basics/windows/juce_CallOutBox.cpp index 6ab46c14d3..d867b8748b 100644 --- a/modules/juce_gui_basics/windows/juce_CallOutBox.cpp +++ b/modules/juce_gui_basics/windows/juce_CallOutBox.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + CallOutBox::CallOutBox (Component& c, const Rectangle& area, Component* const parent) : arrowSize (16.0f), content (c), dismissalMouseClicksAreAlwaysConsumed (false) { @@ -259,3 +262,5 @@ void CallOutBox::timerCallback() toFront (true); stopTimer(); } + +} // namespace juce diff --git a/modules/juce_gui_basics/windows/juce_CallOutBox.h b/modules/juce_gui_basics/windows/juce_CallOutBox.h index 728b14af61..0a52efbf3f 100644 --- a/modules/juce_gui_basics/windows/juce_CallOutBox.h +++ b/modules/juce_gui_basics/windows/juce_CallOutBox.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -182,3 +182,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CallOutBox) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp b/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp index 19e3361990..feb9aacd04 100644 --- a/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp +++ b/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + static uint32 lastUniquePeerID = 1; //============================================================================== @@ -574,3 +577,5 @@ void ComponentPeer::setRepresentedFile (const File&) //============================================================================== int ComponentPeer::getCurrentRenderingEngine() const { return 0; } void ComponentPeer::setCurrentRenderingEngine (int index) { jassert (index == 0); ignoreUnused (index); } + +} // namespace juce diff --git a/modules/juce_gui_basics/windows/juce_ComponentPeer.h b/modules/juce_gui_basics/windows/juce_ComponentPeer.h index 65e46e69cc..819cc8d93f 100644 --- a/modules/juce_gui_basics/windows/juce_ComponentPeer.h +++ b/modules/juce_gui_basics/windows/juce_ComponentPeer.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -378,3 +378,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ComponentPeer) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/windows/juce_DialogWindow.cpp b/modules/juce_gui_basics/windows/juce_DialogWindow.cpp index b03824d6dd..0c6af0d1ee 100644 --- a/modules/juce_gui_basics/windows/juce_DialogWindow.cpp +++ b/modules/juce_gui_basics/windows/juce_DialogWindow.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + DialogWindow::DialogWindow (const String& name, Colour colour, const bool escapeCloses, const bool onDesktop) : DocumentWindow (name, colour, DocumentWindow::closeButton, onDesktop), @@ -174,3 +177,5 @@ int DialogWindow::showModalDialog (const String& dialogTitle, return o.runModal(); } #endif + +} // namespace juce diff --git a/modules/juce_gui_basics/windows/juce_DialogWindow.h b/modules/juce_gui_basics/windows/juce_DialogWindow.h index 0ee09dfa44..f0df0a9654 100644 --- a/modules/juce_gui_basics/windows/juce_DialogWindow.h +++ b/modules/juce_gui_basics/windows/juce_DialogWindow.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -258,3 +258,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DialogWindow) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/windows/juce_DocumentWindow.cpp b/modules/juce_gui_basics/windows/juce_DocumentWindow.cpp index ad5d6e7865..c81be075a2 100644 --- a/modules/juce_gui_basics/windows/juce_DocumentWindow.cpp +++ b/modules/juce_gui_basics/windows/juce_DocumentWindow.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class DocumentWindow::ButtonListenerProxy : public Button::Listener { public: @@ -360,3 +363,5 @@ void DocumentWindow::userTriedToCloseWindow() { closeButtonPressed(); } + +} // namespace juce diff --git a/modules/juce_gui_basics/windows/juce_DocumentWindow.h b/modules/juce_gui_basics/windows/juce_DocumentWindow.h index 493f30141c..d6da6cd363 100644 --- a/modules/juce_gui_basics/windows/juce_DocumentWindow.h +++ b/modules/juce_gui_basics/windows/juce_DocumentWindow.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -291,3 +291,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DocumentWindow) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/windows/juce_NativeMessageBox.h b/modules/juce_gui_basics/windows/juce_NativeMessageBox.h index 2aa4d49e9f..347dac1161 100644 --- a/modules/juce_gui_basics/windows/juce_NativeMessageBox.h +++ b/modules/juce_gui_basics/windows/juce_NativeMessageBox.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -203,3 +204,5 @@ private: NativeMessageBox() JUCE_DELETED_FUNCTION; JUCE_DECLARE_NON_COPYABLE (NativeMessageBox) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/windows/juce_ResizableWindow.cpp b/modules/juce_gui_basics/windows/juce_ResizableWindow.cpp index 00ee3c687d..9807ba2fcb 100644 --- a/modules/juce_gui_basics/windows/juce_ResizableWindow.cpp +++ b/modules/juce_gui_basics/windows/juce_ResizableWindow.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ResizableWindow::ResizableWindow (const String& name, bool shouldAddToDesktop) : TopLevelWindow (name, shouldAddToDesktop) { @@ -644,3 +647,5 @@ void ResizableWindow::addAndMakeVisible (Component* const child, int zOrder) Component::addAndMakeVisible (child, zOrder); } #endif + +} // namespace juce diff --git a/modules/juce_gui_basics/windows/juce_ResizableWindow.h b/modules/juce_gui_basics/windows/juce_ResizableWindow.h index df44baf66f..fd81cc933e 100644 --- a/modules/juce_gui_basics/windows/juce_ResizableWindow.h +++ b/modules/juce_gui_basics/windows/juce_ResizableWindow.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -406,3 +406,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ResizableWindow) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/windows/juce_ThreadWithProgressWindow.cpp b/modules/juce_gui_basics/windows/juce_ThreadWithProgressWindow.cpp index 57b3ba79a7..eba08a01f1 100644 --- a/modules/juce_gui_basics/windows/juce_ThreadWithProgressWindow.cpp +++ b/modules/juce_gui_basics/windows/juce_ThreadWithProgressWindow.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ThreadWithProgressWindow::ThreadWithProgressWindow (const String& title, const bool hasProgressBar, const bool hasCancelButton, @@ -114,3 +117,5 @@ bool ThreadWithProgressWindow::runThread (const int priority) return ! wasCancelledByUser; } #endif + +} // namespace juce diff --git a/modules/juce_gui_basics/windows/juce_ThreadWithProgressWindow.h b/modules/juce_gui_basics/windows/juce_ThreadWithProgressWindow.h index 78e913a909..d996157bea 100644 --- a/modules/juce_gui_basics/windows/juce_ThreadWithProgressWindow.h +++ b/modules/juce_gui_basics/windows/juce_ThreadWithProgressWindow.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -170,3 +170,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ThreadWithProgressWindow) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/windows/juce_TooltipWindow.cpp b/modules/juce_gui_basics/windows/juce_TooltipWindow.cpp index 565ad0acca..65db7ff941 100644 --- a/modules/juce_gui_basics/windows/juce_TooltipWindow.cpp +++ b/modules/juce_gui_basics/windows/juce_TooltipWindow.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + TooltipWindow::TooltipWindow (Component* parentComp, int delayMs) : Component ("tooltip"), millisecondsBeforeTipAppears (delayMs) @@ -175,3 +178,5 @@ void TooltipWindow::timerCallback() } } } + +} // namespace juce diff --git a/modules/juce_gui_basics/windows/juce_TooltipWindow.h b/modules/juce_gui_basics/windows/juce_TooltipWindow.h index b4a6656b5f..7ef54a5a31 100644 --- a/modules/juce_gui_basics/windows/juce_TooltipWindow.h +++ b/modules/juce_gui_basics/windows/juce_TooltipWindow.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -140,3 +140,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TooltipWindow) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/windows/juce_TopLevelWindow.cpp b/modules/juce_gui_basics/windows/juce_TopLevelWindow.cpp index c32ea2a372..1f0e135243 100644 --- a/modules/juce_gui_basics/windows/juce_TopLevelWindow.cpp +++ b/modules/juce_gui_basics/windows/juce_TopLevelWindow.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + /** Keeps track of the active top level window. */ class TopLevelWindowManager : private Timer, private DeletedAtShutdown @@ -353,3 +356,5 @@ TopLevelWindow* TopLevelWindow::getActiveTopLevelWindow() noexcept return best; } + +} // namespace juce diff --git a/modules/juce_gui_basics/windows/juce_TopLevelWindow.h b/modules/juce_gui_basics/windows/juce_TopLevelWindow.h index 9ee8d93765..51b146d721 100644 --- a/modules/juce_gui_basics/windows/juce_TopLevelWindow.h +++ b/modules/juce_gui_basics/windows/juce_TopLevelWindow.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -160,3 +160,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TopLevelWindow) }; + +} // namespace juce diff --git a/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniser.cpp b/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniser.cpp index 11555a2f03..778dde8f44 100644 --- a/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniser.cpp +++ b/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniser.cpp @@ -24,8 +24,8 @@ ============================================================================== */ -#include "juce_CPlusPlusCodeTokeniserFunctions.h" - +namespace juce +{ //============================================================================== CPlusPlusCodeTokeniser::CPlusPlusCodeTokeniser() {} @@ -71,3 +71,5 @@ bool CPlusPlusCodeTokeniser::isReservedKeyword (const String& token) noexcept { return CppTokeniserFunctions::isReservedKeyword (token.getCharPointer(), token.length()); } + +} // namespace juce diff --git a/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniser.h b/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniser.h index 88111a8e85..0eaa420460 100644 --- a/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniser.h +++ b/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniser.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -67,3 +67,5 @@ private: //============================================================================== JUCE_LEAK_DETECTOR (CPlusPlusCodeTokeniser) }; + +} // namespace juce diff --git a/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniserFunctions.h b/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniserFunctions.h index f4ddfdf5e7..9eb2d8d0d4 100644 --- a/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniserFunctions.h +++ b/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniserFunctions.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** Class containing some basic functions for simple tokenising of C++ code. @@ -661,3 +661,5 @@ struct CppTokeniserFunctions return mo.toString(); } }; + +} // namespace juce diff --git a/modules/juce_gui_extra/code_editor/juce_CodeDocument.cpp b/modules/juce_gui_extra/code_editor/juce_CodeDocument.cpp index 57bc14a2e2..713b933cf2 100644 --- a/modules/juce_gui_extra/code_editor/juce_CodeDocument.cpp +++ b/modules/juce_gui_extra/code_editor/juce_CodeDocument.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class CodeDocumentLine { public: @@ -990,3 +993,5 @@ void CodeDocument::remove (const int startPos, const int endPos, const bool undo listeners.call (&CodeDocument::Listener::codeDocumentTextDeleted, startPos, endPos); } } + +} // namespace juce diff --git a/modules/juce_gui_extra/code_editor/juce_CodeDocument.h b/modules/juce_gui_extra/code_editor/juce_CodeDocument.h index f0fbd1a009..7c18a00f63 100644 --- a/modules/juce_gui_extra/code_editor/juce_CodeDocument.h +++ b/modules/juce_gui_extra/code_editor/juce_CodeDocument.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ class CodeDocumentLine; @@ -413,3 +414,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CodeDocument) }; + +} // namespace juce diff --git a/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp b/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp index c001c9b4e8..5d9feeb415 100644 --- a/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp +++ b/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class CodeEditorComponent::CodeEditorLine { public: @@ -1642,3 +1645,5 @@ String CodeEditorComponent::State::toString() const { return String (lastTopLine) + ":" + String (lastCaretPos) + ":" + String (lastSelectionEnd); } + +} // namespace juce diff --git a/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.h b/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.h index e0a1265c31..ffa33c4eab 100644 --- a/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.h +++ b/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ class CodeTokeniser; @@ -430,3 +431,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CodeEditorComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_extra/code_editor/juce_CodeTokeniser.h b/modules/juce_gui_extra/code_editor/juce_CodeTokeniser.h index 18834c725a..5e5e1ab3e0 100644 --- a/modules/juce_gui_extra/code_editor/juce_CodeTokeniser.h +++ b/modules/juce_gui_extra/code_editor/juce_CodeTokeniser.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -54,3 +54,5 @@ public: private: JUCE_LEAK_DETECTOR (CodeTokeniser) }; + +} // namespace juce diff --git a/modules/juce_gui_extra/code_editor/juce_LuaCodeTokeniser.cpp b/modules/juce_gui_extra/code_editor/juce_LuaCodeTokeniser.cpp index d4d10478e4..f01bdff66f 100644 --- a/modules/juce_gui_extra/code_editor/juce_LuaCodeTokeniser.cpp +++ b/modules/juce_gui_extra/code_editor/juce_LuaCodeTokeniser.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + struct LuaTokeniserFunctions { static bool isReservedKeyword (String::CharPointerType token, const int tokenLength) noexcept @@ -233,3 +236,5 @@ CodeEditorComponent::ColourScheme LuaTokeniser::getDefaultColourScheme() return cs; } + +} // namespace juce diff --git a/modules/juce_gui_extra/code_editor/juce_LuaCodeTokeniser.h b/modules/juce_gui_extra/code_editor/juce_LuaCodeTokeniser.h index 35f63eef5f..5628cfa59f 100644 --- a/modules/juce_gui_extra/code_editor/juce_LuaCodeTokeniser.h +++ b/modules/juce_gui_extra/code_editor/juce_LuaCodeTokeniser.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -60,3 +60,5 @@ private: //============================================================================== JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LuaTokeniser) }; + +} // namespace juce diff --git a/modules/juce_gui_extra/code_editor/juce_XMLCodeTokeniser.cpp b/modules/juce_gui_extra/code_editor/juce_XMLCodeTokeniser.cpp index 974b7ce55a..192598db5a 100644 --- a/modules/juce_gui_extra/code_editor/juce_XMLCodeTokeniser.cpp +++ b/modules/juce_gui_extra/code_editor/juce_XMLCodeTokeniser.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + XmlTokeniser::XmlTokeniser() {} XmlTokeniser::~XmlTokeniser() {} @@ -166,3 +169,5 @@ int XmlTokeniser::readNextToken (CodeDocument::Iterator& source) return tokenType_identifier; } + +} // namespace juce diff --git a/modules/juce_gui_extra/code_editor/juce_XMLCodeTokeniser.h b/modules/juce_gui_extra/code_editor/juce_XMLCodeTokeniser.h index 20d06fba3d..9fb3f87918 100644 --- a/modules/juce_gui_extra/code_editor/juce_XMLCodeTokeniser.h +++ b/modules/juce_gui_extra/code_editor/juce_XMLCodeTokeniser.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -58,3 +58,5 @@ public: private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (XmlTokeniser) }; + +} // namespace juce diff --git a/modules/juce_gui_extra/documents/juce_FileBasedDocument.cpp b/modules/juce_gui_extra/documents/juce_FileBasedDocument.cpp index 4c34585ca9..2edffd32c0 100644 --- a/modules/juce_gui_extra/documents/juce_FileBasedDocument.cpp +++ b/modules/juce_gui_extra/documents/juce_FileBasedDocument.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + FileBasedDocument::FileBasedDocument (const String& fileExtension_, const String& fileWildcard_, const String& openFileDialogTitle_, @@ -259,3 +262,5 @@ FileBasedDocument::SaveResult FileBasedDocument::saveAsInteractive (const bool w return userCancelledSave; } #endif + +} // namespace juce diff --git a/modules/juce_gui_extra/documents/juce_FileBasedDocument.h b/modules/juce_gui_extra/documents/juce_FileBasedDocument.h index 1191f93c2a..42e39270d5 100644 --- a/modules/juce_gui_extra/documents/juce_FileBasedDocument.h +++ b/modules/juce_gui_extra/documents/juce_FileBasedDocument.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -290,3 +290,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FileBasedDocument) }; + +} // namespace juce diff --git a/modules/juce_gui_extra/embedding/juce_ActiveXControlComponent.h b/modules/juce_gui_extra/embedding/juce_ActiveXControlComponent.h index ed1ce9734a..b4a8f9cba9 100644 --- a/modules/juce_gui_extra/embedding/juce_ActiveXControlComponent.h +++ b/modules/juce_gui_extra/embedding/juce_ActiveXControlComponent.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ #if JUCE_WINDOWS || DOXYGEN @@ -123,3 +124,5 @@ private: }; #endif + +} // namespace juce diff --git a/modules/juce_gui_extra/embedding/juce_NSViewComponent.h b/modules/juce_gui_extra/embedding/juce_NSViewComponent.h index 896722bde8..2db7fe5c93 100644 --- a/modules/juce_gui_extra/embedding/juce_NSViewComponent.h +++ b/modules/juce_gui_extra/embedding/juce_NSViewComponent.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ #if JUCE_MAC || DOXYGEN @@ -85,3 +86,5 @@ private: }; #endif + +} // namespace juce diff --git a/modules/juce_gui_extra/embedding/juce_UIViewComponent.h b/modules/juce_gui_extra/embedding/juce_UIViewComponent.h index 4558bbd9a7..d478aef286 100644 --- a/modules/juce_gui_extra/embedding/juce_UIViewComponent.h +++ b/modules/juce_gui_extra/embedding/juce_UIViewComponent.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ #if JUCE_IOS || DOXYGEN @@ -84,3 +85,5 @@ private: }; #endif + +} // namespace juce diff --git a/modules/juce_gui_extra/embedding/juce_XEmbedComponent.h b/modules/juce_gui_extra/embedding/juce_XEmbedComponent.h index 8456e3d8d7..e3935e451c 100644 --- a/modules/juce_gui_extra/embedding/juce_XEmbedComponent.h +++ b/modules/juce_gui_extra/embedding/juce_XEmbedComponent.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ /** @internal */ bool juce_handleXEmbedEvent (ComponentPeer*, void*); @@ -109,3 +110,5 @@ private: }; #endif + +} // namespace juce diff --git a/modules/juce_gui_extra/juce_gui_extra.cpp b/modules/juce_gui_extra/juce_gui_extra.cpp index f89e0a86ec..457081d807 100644 --- a/modules/juce_gui_extra/juce_gui_extra.cpp +++ b/modules/juce_gui_extra/juce_gui_extra.cpp @@ -83,9 +83,6 @@ #endif //============================================================================== -namespace juce -{ - #include "documents/juce_FileBasedDocument.cpp" #include "code_editor/juce_CodeDocument.cpp" #include "code_editor/juce_CodeEditorComponent.cpp" @@ -102,13 +99,6 @@ namespace juce #include "misc/juce_LiveConstantEditor.cpp" #include "misc/juce_AnimatedAppComponent.cpp" -} - -using namespace juce; - -namespace juce -{ - //============================================================================== #if JUCE_MAC || JUCE_IOS @@ -159,10 +149,12 @@ namespace juce #endif #if JUCE_WEB_BROWSER - bool WebBrowserComponent::pageAboutToLoad (const String&) { return true; } - void WebBrowserComponent::pageFinishedLoading (const String&) {} - bool WebBrowserComponent::pageLoadHadNetworkError (const String&) { return true; } - void WebBrowserComponent::windowCloseRequest() {} - void WebBrowserComponent::newWindowAttemptingToLoad (const String&) {} -#endif +namespace juce +{ + bool WebBrowserComponent::pageAboutToLoad (const String&) { return true; } + void WebBrowserComponent::pageFinishedLoading (const String&) {} + bool WebBrowserComponent::pageLoadHadNetworkError (const String&) { return true; } + void WebBrowserComponent::windowCloseRequest() {} + void WebBrowserComponent::newWindowAttemptingToLoad (const String&) {} } +#endif diff --git a/modules/juce_gui_extra/juce_gui_extra.h b/modules/juce_gui_extra/juce_gui_extra.h index c1162ba751..e01397a1f0 100644 --- a/modules/juce_gui_extra/juce_gui_extra.h +++ b/modules/juce_gui_extra/juce_gui_extra.h @@ -74,9 +74,6 @@ #endif //============================================================================== -namespace juce -{ - #include "documents/juce_FileBasedDocument.h" #include "code_editor/juce_CodeDocument.h" #include "code_editor/juce_CodeEditorComponent.h" @@ -100,5 +97,3 @@ namespace juce #include "misc/juce_WebBrowserComponent.h" #include "misc/juce_LiveConstantEditor.h" #include "misc/juce_AnimatedAppComponent.h" - -} diff --git a/modules/juce_gui_extra/misc/juce_AnimatedAppComponent.cpp b/modules/juce_gui_extra/misc/juce_AnimatedAppComponent.cpp index 6f461d066f..424b973197 100644 --- a/modules/juce_gui_extra/misc/juce_AnimatedAppComponent.cpp +++ b/modules/juce_gui_extra/misc/juce_AnimatedAppComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + AnimatedAppComponent::AnimatedAppComponent() : lastUpdateTime (Time::getCurrentTime()), totalUpdates (0) { @@ -48,3 +51,5 @@ void AnimatedAppComponent::timerCallback() repaint(); lastUpdateTime = Time::getCurrentTime(); } + +} // namespace juce diff --git a/modules/juce_gui_extra/misc/juce_AnimatedAppComponent.h b/modules/juce_gui_extra/misc/juce_AnimatedAppComponent.h index eeb29e1525..9d84552772 100644 --- a/modules/juce_gui_extra/misc/juce_AnimatedAppComponent.h +++ b/modules/juce_gui_extra/misc/juce_AnimatedAppComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -72,3 +72,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AnimatedAppComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_extra/misc/juce_AppleRemote.h b/modules/juce_gui_extra/misc/juce_AppleRemote.h index c784e7129d..1f27dc9d15 100644 --- a/modules/juce_gui_extra/misc/juce_AppleRemote.h +++ b/modules/juce_gui_extra/misc/juce_AppleRemote.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== #if JUCE_MAC || DOXYGEN @@ -112,3 +112,5 @@ private: }; #endif + +} // namespace juce diff --git a/modules/juce_gui_extra/misc/juce_BubbleMessageComponent.cpp b/modules/juce_gui_extra/misc/juce_BubbleMessageComponent.cpp index 556dae356d..a3aa074024 100644 --- a/modules/juce_gui_extra/misc/juce_BubbleMessageComponent.cpp +++ b/modules/juce_gui_extra/misc/juce_BubbleMessageComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + BubbleMessageComponent::BubbleMessageComponent (int fadeOutLengthMs) : fadeOutLength (fadeOutLengthMs), mouseClickCounter (0), expiryTime (0), deleteAfterUse (false) @@ -118,3 +121,5 @@ void BubbleMessageComponent::hide (const bool fadeOut) if (deleteAfterUse) delete this; } + +} // namespace juce diff --git a/modules/juce_gui_extra/misc/juce_BubbleMessageComponent.h b/modules/juce_gui_extra/misc/juce_BubbleMessageComponent.h index d63e107206..785d542a96 100644 --- a/modules/juce_gui_extra/misc/juce_BubbleMessageComponent.h +++ b/modules/juce_gui_extra/misc/juce_BubbleMessageComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -126,3 +126,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (BubbleMessageComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_extra/misc/juce_ColourSelector.cpp b/modules/juce_gui_extra/misc/juce_ColourSelector.cpp index 662fa0dc18..f41c64f849 100644 --- a/modules/juce_gui_extra/misc/juce_ColourSelector.cpp +++ b/modules/juce_gui_extra/misc/juce_ColourSelector.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class ColourSelector::ColourComponentSlider : public Slider { public: @@ -43,7 +46,6 @@ public: return (double) text.getHexValue32(); } -private: JUCE_DECLARE_NON_COPYABLE (ColourComponentSlider) }; @@ -64,7 +66,6 @@ public: g.drawEllipse (2.0f, 2.0f, getWidth() - 4.0f, getHeight() - 4.0f, 1.0f); } -private: JUCE_DECLARE_NON_COPYABLE (ColourSpaceMarker) }; @@ -570,3 +571,5 @@ void ColourSelector::setSwatchColour (int, const Colour&) { jassertfalse; // if you've overridden getNumSwatches(), you also need to implement this method } + +} // namespace juce diff --git a/modules/juce_gui_extra/misc/juce_ColourSelector.h b/modules/juce_gui_extra/misc/juce_ColourSelector.h index 6d9aa2ef90..83c2fe622d 100644 --- a/modules/juce_gui_extra/misc/juce_ColourSelector.h +++ b/modules/juce_gui_extra/misc/juce_ColourSelector.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -167,3 +167,5 @@ private: ColourSelector (bool); #endif }; + +} // namespace juce diff --git a/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.cpp b/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.cpp index 4b87b07595..c619b24120 100644 --- a/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.cpp +++ b/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class KeyMappingEditorComponent::ChangeKeyButton : public Button { public: @@ -468,3 +471,5 @@ String KeyMappingEditorComponent::getDescriptionForKeyPress (const KeyPress& key { return key.getTextDescription(); } + +} // namespace juce diff --git a/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.h b/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.h index e4207bc0be..e206c1e68b 100644 --- a/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.h +++ b/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -130,3 +130,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (KeyMappingEditorComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_extra/misc/juce_LiveConstantEditor.cpp b/modules/juce_gui_extra/misc/juce_LiveConstantEditor.cpp index e87c817d98..f98cb43918 100644 --- a/modules/juce_gui_extra/misc/juce_LiveConstantEditor.cpp +++ b/modules/juce_gui_extra/misc/juce_LiveConstantEditor.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_ENABLE_LIVE_CONSTANT_EDITOR namespace LiveConstantEditor @@ -500,3 +503,5 @@ Component* createBoolSlider (LivePropertyEditorBase& editor) { return new Bo } #endif + +} // namespace juce diff --git a/modules/juce_gui_extra/misc/juce_LiveConstantEditor.h b/modules/juce_gui_extra/misc/juce_LiveConstantEditor.h index 4d44a740b2..9121a5828f 100644 --- a/modules/juce_gui_extra/misc/juce_LiveConstantEditor.h +++ b/modules/juce_gui_extra/misc/juce_LiveConstantEditor.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ #if JUCE_ENABLE_LIVE_CONSTANT_EDITOR && ! DOXYGEN @@ -309,3 +310,5 @@ namespace LiveConstantEditor #define JUCE_LIVE_CONSTANT(initialValue) \ (initialValue) #endif + +} // namespace juce diff --git a/modules/juce_gui_extra/misc/juce_PreferencesPanel.cpp b/modules/juce_gui_extra/misc/juce_PreferencesPanel.cpp index e6f612e37f..cb35ef5165 100644 --- a/modules/juce_gui_extra/misc/juce_PreferencesPanel.cpp +++ b/modules/juce_gui_extra/misc/juce_PreferencesPanel.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + PreferencesPanel::PreferencesPanel() : buttonSize (70) { @@ -150,3 +153,5 @@ void PreferencesPanel::buttonClicked (Button*) } } } + +} // namespace juce diff --git a/modules/juce_gui_extra/misc/juce_PreferencesPanel.h b/modules/juce_gui_extra/misc/juce_PreferencesPanel.h index 6000ed3d13..99de995008 100644 --- a/modules/juce_gui_extra/misc/juce_PreferencesPanel.h +++ b/modules/juce_gui_extra/misc/juce_PreferencesPanel.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -143,3 +143,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PreferencesPanel) }; + +} // namespace juce diff --git a/modules/juce_gui_extra/misc/juce_RecentlyOpenedFilesList.cpp b/modules/juce_gui_extra/misc/juce_RecentlyOpenedFilesList.cpp index d7470f6c92..580b79aa74 100644 --- a/modules/juce_gui_extra/misc/juce_RecentlyOpenedFilesList.cpp +++ b/modules/juce_gui_extra/misc/juce_RecentlyOpenedFilesList.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + RecentlyOpenedFilesList::RecentlyOpenedFilesList() : maxNumberOfItems (10) { @@ -145,3 +148,5 @@ void RecentlyOpenedFilesList::registerRecentFileNatively (const File& file) ignoreUnused (file); #endif } + +} // namespace juce diff --git a/modules/juce_gui_extra/misc/juce_RecentlyOpenedFilesList.h b/modules/juce_gui_extra/misc/juce_RecentlyOpenedFilesList.h index fadcaf71e1..02a24fe00b 100644 --- a/modules/juce_gui_extra/misc/juce_RecentlyOpenedFilesList.h +++ b/modules/juce_gui_extra/misc/juce_RecentlyOpenedFilesList.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -160,3 +160,5 @@ private: JUCE_LEAK_DETECTOR (RecentlyOpenedFilesList) }; + +} // namespace juce diff --git a/modules/juce_gui_extra/misc/juce_SplashScreen.cpp b/modules/juce_gui_extra/misc/juce_SplashScreen.cpp index 654669091a..a33477d817 100644 --- a/modules/juce_gui_extra/misc/juce_SplashScreen.cpp +++ b/modules/juce_gui_extra/misc/juce_SplashScreen.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + SplashScreen::SplashScreen (const String& title, const Image& image, bool useDropShadow) : Component (title), backgroundImage (image), @@ -95,3 +98,5 @@ void SplashScreen::timerCallback() || Desktop::getInstance().getMouseButtonClickCounter() > clickCountToDelete) delete this; } + +} // namespace juce diff --git a/modules/juce_gui_extra/misc/juce_SplashScreen.h b/modules/juce_gui_extra/misc/juce_SplashScreen.h index 62dfc5aace..bf16e5d0aa 100644 --- a/modules/juce_gui_extra/misc/juce_SplashScreen.h +++ b/modules/juce_gui_extra/misc/juce_SplashScreen.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** A component for showing a splash screen while your app starts up. @@ -151,3 +151,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SplashScreen) }; + +} // namespace juce diff --git a/modules/juce_gui_extra/misc/juce_SystemTrayIconComponent.cpp b/modules/juce_gui_extra/misc/juce_SystemTrayIconComponent.cpp index 33ae308285..72c6c983fc 100644 --- a/modules/juce_gui_extra/misc/juce_SystemTrayIconComponent.cpp +++ b/modules/juce_gui_extra/misc/juce_SystemTrayIconComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_WINDOWS || JUCE_LINUX || JUCE_MAC SystemTrayIconComponent::SystemTrayIconComponent() @@ -36,3 +39,5 @@ SystemTrayIconComponent::~SystemTrayIconComponent() } #endif + +} // namespace juce diff --git a/modules/juce_gui_extra/misc/juce_SystemTrayIconComponent.h b/modules/juce_gui_extra/misc/juce_SystemTrayIconComponent.h index c3f3930bf1..6dd877ddd2 100644 --- a/modules/juce_gui_extra/misc/juce_SystemTrayIconComponent.h +++ b/modules/juce_gui_extra/misc/juce_SystemTrayIconComponent.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ #if JUCE_WINDOWS || JUCE_LINUX || JUCE_MAC || DOXYGEN @@ -100,3 +101,5 @@ private: #endif + +} // namespace juce diff --git a/modules/juce_gui_extra/misc/juce_WebBrowserComponent.h b/modules/juce_gui_extra/misc/juce_WebBrowserComponent.h index f26a7309bd..67a055f82e 100644 --- a/modules/juce_gui_extra/misc/juce_WebBrowserComponent.h +++ b/modules/juce_gui_extra/misc/juce_WebBrowserComponent.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ #if JUCE_WEB_BROWSER || DOXYGEN @@ -149,3 +150,5 @@ private: #endif + +} // namespace juce diff --git a/modules/juce_gui_extra/native/juce_android_WebBrowserComponent.cpp b/modules/juce_gui_extra/native/juce_android_WebBrowserComponent.cpp index c236b4b3fa..7fc51d7cc7 100644 --- a/modules/juce_gui_extra/native/juce_android_WebBrowserComponent.cpp +++ b/modules/juce_gui_extra/native/juce_android_WebBrowserComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + WebBrowserComponent::WebBrowserComponent (const bool unloadPageWhenBrowserIsHidden_) : browser (nullptr), blankPageShown (false), @@ -121,3 +124,5 @@ void WebBrowserComponent::focusGained (FocusChangeType) void WebBrowserComponent::clearCookies() { } + +} // namespace juce diff --git a/modules/juce_gui_extra/native/juce_ios_UIViewComponent.mm b/modules/juce_gui_extra/native/juce_ios_UIViewComponent.mm index 933f25ccf1..6a954fd102 100644 --- a/modules/juce_gui_extra/native/juce_ios_UIViewComponent.mm +++ b/modules/juce_gui_extra/native/juce_ios_UIViewComponent.mm @@ -24,14 +24,16 @@ ============================================================================== */ +namespace juce +{ + class UIViewComponent::Pimpl : public ComponentMovementWatcher { public: - Pimpl (UIView* const v, Component& comp) + Pimpl (UIView* v, Component& comp) : ComponentMovementWatcher (&comp), view (v), - owner (comp), - currentPeer (nullptr) + owner (comp) { [view retain]; @@ -47,11 +49,11 @@ public: void componentMovedOrResized (bool /*wasMoved*/, bool /*wasResized*/) override { - Component* const topComp = owner.getTopLevelComponent(); + auto* topComp = owner.getTopLevelComponent(); if (topComp->getPeer() != nullptr) { - const Point pos (topComp->getLocalPoint (&owner, Point())); + auto pos = topComp->getLocalPoint (&owner, Point()); [view setFrame: CGRectMake ((float) pos.x, (float) pos.y, (float) owner.getWidth(), (float) owner.getHeight())]; @@ -60,7 +62,7 @@ public: void componentPeerChanged() override { - ComponentPeer* const peer = owner.getPeer(); + auto* peer = owner.getPeer(); if (currentPeer != peer) { @@ -95,7 +97,7 @@ public: private: Component& owner; - ComponentPeer* currentPeer; + ComponentPeer* currentPeer = nullptr; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Pimpl) }; @@ -127,3 +129,5 @@ void UIViewComponent::resizeToFitView() } void UIViewComponent::paint (Graphics&) {} + +} // namespace juce diff --git a/modules/juce_gui_extra/native/juce_linux_X11_SystemTrayIcon.cpp b/modules/juce_gui_extra/native/juce_linux_X11_SystemTrayIcon.cpp index 35eed37330..c60b9347d6 100644 --- a/modules/juce_gui_extra/native/juce_linux_X11_SystemTrayIcon.cpp +++ b/modules/juce_gui_extra/native/juce_linux_X11_SystemTrayIcon.cpp @@ -24,7 +24,9 @@ ============================================================================== */ -//============================================================================== +namespace juce +{ + class SystemTrayIconComponent::Pimpl { public: @@ -143,3 +145,5 @@ void* SystemTrayIconComponent::getNativeHandle() const { return getWindowHandle(); } + +} // namespace juce diff --git a/modules/juce_gui_extra/native/juce_linux_X11_WebBrowserComponent.cpp b/modules/juce_gui_extra/native/juce_linux_X11_WebBrowserComponent.cpp index 07c64fbe23..6a8f0da89d 100644 --- a/modules/juce_gui_extra/native/juce_linux_X11_WebBrowserComponent.cpp +++ b/modules/juce_gui_extra/native/juce_linux_X11_WebBrowserComponent.cpp @@ -24,7 +24,9 @@ ============================================================================== */ -//============================================================================== +namespace juce +{ + extern int juce_gtkWebkitMain (int argc, const char* argv[]); class CommandReceiver @@ -821,3 +823,5 @@ int juce_gtkWebkitMain (int argc, const char* argv[]) String (argv[3]).getIntValue()); return child.entry(); } + +} // namespace juce diff --git a/modules/juce_gui_extra/native/juce_linux_XEmbedComponent.cpp b/modules/juce_gui_extra/native/juce_linux_XEmbedComponent.cpp index d50a7704d3..916b453333 100644 --- a/modules/juce_gui_extra/native/juce_linux_XEmbedComponent.cpp +++ b/modules/juce_gui_extra/native/juce_linux_XEmbedComponent.cpp @@ -24,7 +24,9 @@ ============================================================================== */ -//============================================================================== +namespace juce +{ + bool juce_handleXEmbedEvent (ComponentPeer*, void*); Window juce_getCurrentFocusWindow (ComponentPeer*); @@ -672,10 +674,12 @@ unsigned long XEmbedComponent::getHostWindowID() { return pimp //============================================================================== bool juce_handleXEmbedEvent (ComponentPeer* p, void* e) { - return ::XEmbedComponent::Pimpl::dispatchX11Event (p, reinterpret_cast (e)); + return XEmbedComponent::Pimpl::dispatchX11Event (p, reinterpret_cast (e)); } unsigned long juce_getCurrentFocusWindow (ComponentPeer* peer) { - return (unsigned long) ::XEmbedComponent::Pimpl::getCurrentFocusWindow (peer); + return (unsigned long) XEmbedComponent::Pimpl::getCurrentFocusWindow (peer); } + +} // namespace juce diff --git a/modules/juce_gui_extra/native/juce_mac_AppleRemote.mm b/modules/juce_gui_extra/native/juce_mac_AppleRemote.mm index b1283c052d..bc07d33172 100644 --- a/modules/juce_gui_extra/native/juce_mac_AppleRemote.mm +++ b/modules/juce_gui_extra/native/juce_mac_AppleRemote.mm @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + AppleRemoteDevice::AppleRemoteDevice() : device (nullptr), queue (nullptr), @@ -262,3 +265,5 @@ void AppleRemoteDevice::handleCallbackInternal() ++buttonNum; } } + +} // namespace juce diff --git a/modules/juce_gui_extra/native/juce_mac_CarbonViewWrapperComponent.h b/modules/juce_gui_extra/native/juce_mac_CarbonViewWrapperComponent.h index 9d38512439..c57277db6b 100644 --- a/modules/juce_gui_extra/native/juce_mac_CarbonViewWrapperComponent.h +++ b/modules/juce_gui_extra/native/juce_mac_CarbonViewWrapperComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -341,3 +341,5 @@ void* getCarbonWindow (Component* possibleCarbonComponent) return nullptr; } + +} // namespace juce diff --git a/modules/juce_gui_extra/native/juce_mac_NSViewComponent.mm b/modules/juce_gui_extra/native/juce_mac_NSViewComponent.mm index d996650918..47dc7e87e3 100644 --- a/modules/juce_gui_extra/native/juce_mac_NSViewComponent.mm +++ b/modules/juce_gui_extra/native/juce_mac_NSViewComponent.mm @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + struct NSViewResizeWatcher { NSViewResizeWatcher() : callback (nil) {} @@ -240,3 +243,5 @@ ReferenceCountedObject* NSViewComponent::attachViewToComponent (Component& comp, { return new NSViewAttachment ((NSView*) view, comp); } + +} // namespace juce diff --git a/modules/juce_gui_extra/native/juce_mac_SystemTrayIcon.cpp b/modules/juce_gui_extra/native/juce_mac_SystemTrayIcon.cpp index 49cde5eb2f..c7d893fa98 100644 --- a/modules/juce_gui_extra/native/juce_mac_SystemTrayIcon.cpp +++ b/modules/juce_gui_extra/native/juce_mac_SystemTrayIcon.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace MouseCursorHelpers { extern NSImage* createNSImage (const Image&, float scaleFactor = 1.f); @@ -274,3 +277,5 @@ void SystemTrayIconComponent::showDropdownMenu (const PopupMenu& menu) if (pimpl != nullptr) pimpl->showMenu (menu); } + +} // namespace juce diff --git a/modules/juce_gui_extra/native/juce_mac_WebBrowserComponent.mm b/modules/juce_gui_extra/native/juce_mac_WebBrowserComponent.mm index 186445ceeb..03078226ba 100644 --- a/modules/juce_gui_extra/native/juce_mac_WebBrowserComponent.mm +++ b/modules/juce_gui_extra/native/juce_mac_WebBrowserComponent.mm @@ -26,6 +26,9 @@ #if JUCE_MAC +namespace juce +{ + struct WebViewKeyEquivalentResponder : public ObjCClass { WebViewKeyEquivalentResponder() : ObjCClass ("WebViewKeyEquivalentResponder_") @@ -152,8 +155,6 @@ private: #else -} // (juce namespace) - //============================================================================== @interface WebViewTapDetector : NSObject { @@ -168,7 +169,7 @@ private: - (BOOL) gestureRecognizer: (UIGestureRecognizer*) gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer: (UIGestureRecognizer*) otherGestureRecognizer { - ignoreUnused (gestureRecognizer, otherGestureRecognizer); + juce::ignoreUnused (gestureRecognizer, otherGestureRecognizer); return YES; } @@ -198,17 +199,18 @@ private: - (BOOL) webView: (UIWebView*) webView shouldStartLoadWithRequest: (NSURLRequest*) request navigationType: (UIWebViewNavigationType) navigationType { - ignoreUnused (webView, navigationType); - return ownerComponent->pageAboutToLoad (nsStringToJuce (request.URL.absoluteString)); + juce::ignoreUnused (webView, navigationType); + return ownerComponent->pageAboutToLoad (juce::nsStringToJuce (request.URL.absoluteString)); } - (void) webViewDidFinishLoad: (UIWebView*) webView { - ownerComponent->pageFinishedLoading (nsStringToJuce (webView.request.URL.absoluteString)); + ownerComponent->pageFinishedLoading (juce::nsStringToJuce (webView.request.URL.absoluteString)); } @end -namespace juce { +namespace juce +{ #endif @@ -485,3 +487,5 @@ void WebBrowserComponent::clearCookies() [[NSUserDefaults standardUserDefaults] synchronize]; } + +} // namespace juce diff --git a/modules/juce_gui_extra/native/juce_win32_ActiveXComponent.cpp b/modules/juce_gui_extra/native/juce_win32_ActiveXComponent.cpp index 188385b632..f0eec0ea44 100644 --- a/modules/juce_gui_extra/native/juce_win32_ActiveXComponent.cpp +++ b/modules/juce_gui_extra/native/juce_win32_ActiveXComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + extern int64 getMouseEventTime(); JUCE_DECLARE_UUID_GETTER (IOleObject, "00000112-0000-0000-C000-000000000046") @@ -451,3 +454,5 @@ LRESULT juce_offerEventToActiveXControl (::MSG& msg) return S_FALSE; } + +} // namespace juce diff --git a/modules/juce_gui_extra/native/juce_win32_SystemTrayIcon.cpp b/modules/juce_gui_extra/native/juce_win32_SystemTrayIcon.cpp index 7e3f9e2a64..b1667be77b 100644 --- a/modules/juce_gui_extra/native/juce_win32_SystemTrayIcon.cpp +++ b/modules/juce_gui_extra/native/juce_win32_SystemTrayIcon.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + extern void* getUser32Function (const char*); namespace IconConverters @@ -236,3 +239,5 @@ void* SystemTrayIconComponent::getNativeHandle() const { return pimpl != nullptr ? &(pimpl->iconData) : nullptr; } + +} // namespace juce diff --git a/modules/juce_gui_extra/native/juce_win32_WebBrowserComponent.cpp b/modules/juce_gui_extra/native/juce_win32_WebBrowserComponent.cpp index 5831a9cc0d..77ba594e24 100644 --- a/modules/juce_gui_extra/native/juce_win32_WebBrowserComponent.cpp +++ b/modules/juce_gui_extra/native/juce_win32_WebBrowserComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + JUCE_DECLARE_UUID_GETTER (DWebBrowserEvents2, "34A715A0-6587-11D0-924A-0020AFC7AC4D") JUCE_DECLARE_UUID_GETTER (IConnectionPointContainer, "B196B284-BAB4-101A-B69C-00AA00341D07") JUCE_DECLARE_UUID_GETTER (IWebBrowser2, "D30C1661-CDAF-11D0-8A3E-00C04FC9E26E") @@ -420,3 +423,5 @@ void WebBrowserComponent::clearCookies() FindCloseUrlCache (urlCacheHandle); } } + +} // namespace juce diff --git a/modules/juce_opengl/geometry/juce_Draggable3DOrientation.h b/modules/juce_opengl/geometry/juce_Draggable3DOrientation.h index 125f65f429..8b11dff6f6 100644 --- a/modules/juce_opengl/geometry/juce_Draggable3DOrientation.h +++ b/modules/juce_opengl/geometry/juce_Draggable3DOrientation.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -154,3 +154,5 @@ private: return QuaternionType::fromAngle (2.0f * std::asin (d), rotationAxis); } }; + +} // namespace juce diff --git a/modules/juce_opengl/geometry/juce_Matrix3D.h b/modules/juce_opengl/geometry/juce_Matrix3D.h index a68e900b23..5bf7bdcf59 100644 --- a/modules/juce_opengl/geometry/juce_Matrix3D.h +++ b/modules/juce_opengl/geometry/juce_Matrix3D.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -150,3 +151,5 @@ public: /** The 4x4 matrix values. These are stored in the standard OpenGL order. */ Type mat[16]; }; + +} // namespace juce diff --git a/modules/juce_opengl/geometry/juce_Quaternion.h b/modules/juce_opengl/geometry/juce_Quaternion.h index fa80ed93dc..9fac1bd7f7 100644 --- a/modules/juce_opengl/geometry/juce_Quaternion.h +++ b/modules/juce_opengl/geometry/juce_Quaternion.h @@ -24,10 +24,8 @@ ============================================================================== */ -#pragma once - -#include "juce_Vector3D.h" -#include "juce_Matrix3D.h" +namespace juce +{ //============================================================================== /** @@ -95,3 +93,5 @@ public: /** The scalar part of the quaternion. */ Type scalar; }; + +} // namespace juce diff --git a/modules/juce_opengl/geometry/juce_Vector3D.h b/modules/juce_opengl/geometry/juce_Vector3D.h index 52d60063c4..ba292075f6 100644 --- a/modules/juce_opengl/geometry/juce_Vector3D.h +++ b/modules/juce_opengl/geometry/juce_Vector3D.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -77,3 +78,5 @@ public: Type x, y, z; }; + +} // namespace juce diff --git a/modules/juce_opengl/juce_opengl.cpp b/modules/juce_opengl/juce_opengl.cpp index 593931b3d8..60021bfbbd 100644 --- a/modules/juce_opengl/juce_opengl.cpp +++ b/modules/juce_opengl/juce_opengl.cpp @@ -84,12 +84,10 @@ #endif #endif +//============================================================================== namespace juce { -//============================================================================== -#include "native/juce_OpenGLExtensions.h" - void OpenGLExtensionFunctions::initialise() { #if JUCE_WINDOWS || JUCE_LINUX @@ -251,6 +249,8 @@ private: OpenGLTargetSaver& operator= (const OpenGLTargetSaver&); }; +} // namespace juce + //============================================================================== #include "opengl/juce_OpenGLFrameBuffer.cpp" #include "opengl/juce_OpenGLGraphicsContext.cpp" @@ -291,5 +291,3 @@ private: #include "opengl/juce_OpenGLContext.cpp" #include "utils/juce_OpenGLAppComponent.cpp" - -} diff --git a/modules/juce_opengl/juce_opengl.h b/modules/juce_opengl/juce_opengl.h index 7db74fbfa3..a0094d2fc4 100644 --- a/modules/juce_opengl/juce_opengl.h +++ b/modules/juce_opengl/juce_opengl.h @@ -164,14 +164,14 @@ //============================================================================== namespace juce { + class OpenGLTexture; + class OpenGLFrameBuffer; + class OpenGLShaderProgram; +} -class OpenGLTexture; -class OpenGLFrameBuffer; -class OpenGLShaderProgram; - -#include "geometry/juce_Quaternion.h" -#include "geometry/juce_Matrix3D.h" #include "geometry/juce_Vector3D.h" +#include "geometry/juce_Matrix3D.h" +#include "geometry/juce_Quaternion.h" #include "geometry/juce_Draggable3DOrientation.h" #include "native/juce_MissingGLDefinitions.h" #include "opengl/juce_OpenGLHelpers.h" @@ -181,11 +181,7 @@ class OpenGLShaderProgram; #include "opengl/juce_OpenGLContext.h" #include "opengl/juce_OpenGLFrameBuffer.h" #include "opengl/juce_OpenGLGraphicsContext.h" -#include "opengl/juce_OpenGLHelpers.h" #include "opengl/juce_OpenGLImage.h" -#include "opengl/juce_OpenGLRenderer.h" #include "opengl/juce_OpenGLShaderProgram.h" #include "opengl/juce_OpenGLTexture.h" #include "utils/juce_OpenGLAppComponent.h" - -} diff --git a/modules/juce_opengl/native/juce_MissingGLDefinitions.h b/modules/juce_opengl/native/juce_MissingGLDefinitions.h index d628556221..dac8bff321 100644 --- a/modules/juce_opengl/native/juce_MissingGLDefinitions.h +++ b/modules/juce_opengl/native/juce_MissingGLDefinitions.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + /** These are important openGL values that aren't defined by default by the GL headers on various platforms. */ @@ -156,3 +159,5 @@ enum MissingOpenGLDefinitions typedef pointer_sized_int GLsizeiptr; typedef pointer_sized_int GLintptr; #endif + +} // namespace juce diff --git a/modules/juce_opengl/native/juce_OpenGLExtensions.h b/modules/juce_opengl/native/juce_OpenGLExtensions.h index 30362501be..23b03af2f1 100644 --- a/modules/juce_opengl/native/juce_OpenGLExtensions.h +++ b/modules/juce_opengl/native/juce_OpenGLExtensions.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ /** @internal This macro contains a list of GL extension functions that need to be dynamically loaded on Windows/Linux. @see OpenGLExtensionFunctions @@ -154,3 +154,5 @@ struct OpenGLExtensionFunctions #undef JUCE_DECLARE_GL_FUNCTION }; + +} // namespace juce diff --git a/modules/juce_opengl/native/juce_OpenGL_android.h b/modules/juce_opengl/native/juce_OpenGL_android.h index 776fe5647b..60f9fdc43d 100644 --- a/modules/juce_opengl/native/juce_OpenGL_android.h +++ b/modules/juce_opengl/native/juce_OpenGL_android.h @@ -24,7 +24,9 @@ ============================================================================== */ -//============================================================================== +namespace juce +{ + #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ METHOD (getParent, "getParent", "()Landroid/view/ViewParent;") \ METHOD (layout, "layout", "(IIII)V" ) \ @@ -306,3 +308,5 @@ bool OpenGLHelpers::isContextActive() { return eglGetCurrentContext() != EGL_NO_CONTEXT; } + +} // namespace juce diff --git a/modules/juce_opengl/native/juce_OpenGL_ios.h b/modules/juce_opengl/native/juce_OpenGL_ios.h index ff810c34fb..a079a4d842 100644 --- a/modules/juce_opengl/native/juce_OpenGL_ios.h +++ b/modules/juce_opengl/native/juce_OpenGL_ios.h @@ -24,8 +24,6 @@ ============================================================================== */ -} // (juce namespace) - @interface JuceGLView : UIView { } @@ -309,3 +307,5 @@ bool OpenGLHelpers::isContextActive() { return [EAGLContext currentContext] != nil; } + +} // namespace juce diff --git a/modules/juce_opengl/native/juce_OpenGL_linux_X11.h b/modules/juce_opengl/native/juce_OpenGL_linux_X11.h index dc287b947d..c1b17d46ce 100644 --- a/modules/juce_opengl/native/juce_OpenGL_linux_X11.h +++ b/modules/juce_opengl/native/juce_OpenGL_linux_X11.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + extern XContext windowHandleXContext; //============================================================================== @@ -249,3 +252,5 @@ bool OpenGLHelpers::isContextActive() return false; } + +} // namespace juce diff --git a/modules/juce_opengl/native/juce_OpenGL_osx.h b/modules/juce_opengl/native/juce_OpenGL_osx.h index 706486ebe5..4b61efd4bf 100644 --- a/modules/juce_opengl/native/juce_OpenGL_osx.h +++ b/modules/juce_opengl/native/juce_OpenGL_osx.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class OpenGLContext::NativeContext { public: @@ -255,3 +258,5 @@ void componentPeerAboutToChange (Component& comp, bool shouldSuspend) for (auto* child : comp.getChildren()) componentPeerAboutToChange (*child, shouldSuspend); } + +} // namespace juce diff --git a/modules/juce_opengl/native/juce_OpenGL_win32.h b/modules/juce_opengl/native/juce_OpenGL_win32.h index 40c9dedeb4..7cbd732b4b 100644 --- a/modules/juce_opengl/native/juce_OpenGL_win32.h +++ b/modules/juce_opengl/native/juce_OpenGL_win32.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + extern ComponentPeer* createNonRepaintingEmbeddedWindowsPeer (Component&, void* parent); //============================================================================== @@ -266,3 +269,5 @@ bool OpenGLHelpers::isContextActive() { return wglGetCurrentContext() != 0; } + +} // namespace juce diff --git a/modules/juce_opengl/opengl/juce_OpenGLContext.cpp b/modules/juce_opengl/opengl/juce_OpenGLContext.cpp index 495ea985d2..b57a50793a 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLContext.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLContext.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_IOS struct AppInactivityCallback // NB: this is a duplicate of an internal declaration in juce_core { @@ -1244,3 +1247,5 @@ void OpenGLContext::NativeContext::surfaceDestroyed (jobject holder) cachedImage->pause(); } #endif + +} // namespace juce diff --git a/modules/juce_opengl/opengl/juce_OpenGLContext.h b/modules/juce_opengl/opengl/juce_OpenGLContext.h index fe6627d35e..a1b9c05436 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLContext.h +++ b/modules/juce_opengl/opengl/juce_OpenGLContext.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -344,3 +344,5 @@ private: template void OpenGLContext::executeOnGLThread (T&& f, bool shouldBlock) { execute (new AsyncWorkerFunctor (f), shouldBlock); } #endif + +} // namespace juce diff --git a/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp b/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp index 38cd7c6fab..c7e4a2a4b6 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class OpenGLFrameBuffer::Pimpl { public: @@ -347,3 +350,5 @@ bool OpenGLFrameBuffer::writePixels (const PixelARGB* data, const Rectangle JUCE_CHECK_OPENGL_ERROR return true; } + +} // namespace juce diff --git a/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.h b/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.h index 366fd68d95..8a466ad96a 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.h +++ b/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -130,3 +130,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OpenGLFrameBuffer) }; + +} // namespace juce diff --git a/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp b/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp index 56252ca487..4aaeb2ffb5 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + extern void (*clearOpenGLGlyphCache)(); // declared in juce_graphics namespace OpenGLRendering @@ -1894,3 +1897,5 @@ Result OpenGLGraphicsContextCustomShader::checkCompilation (LowLevelGraphicsCont return Result::fail (errorMessage); } + +} // namespace juce diff --git a/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.h b/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.h index 755eeb4bba..10176ec423 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.h +++ b/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ /** Creates a graphics context object that will render into the given OpenGL target. The caller is responsible for deleting this object when no longer needed. @@ -92,3 +92,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OpenGLGraphicsContextCustomShader) }; + +} // namespace juce diff --git a/modules/juce_opengl/opengl/juce_OpenGLHelpers.cpp b/modules/juce_opengl/opengl/juce_OpenGLHelpers.cpp index aa7588ef28..23f3b7aeda 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLHelpers.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLHelpers.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + void OpenGLHelpers::resetErrorState() { while (glGetError() != GL_NO_ERROR) {} @@ -128,3 +131,5 @@ String OpenGLHelpers::translateFragmentShaderToV3 (const String& code) return code; } + +} // namespace juce diff --git a/modules/juce_opengl/opengl/juce_OpenGLHelpers.h b/modules/juce_opengl/opengl/juce_OpenGLHelpers.h index 091856ff28..0a64e48b5e 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLHelpers.h +++ b/modules/juce_opengl/opengl/juce_OpenGLHelpers.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -69,3 +69,5 @@ public: */ static String translateFragmentShaderToV3 (const String&); }; + +} // namespace juce diff --git a/modules/juce_opengl/opengl/juce_OpenGLImage.cpp b/modules/juce_opengl/opengl/juce_OpenGLImage.cpp index 36a1e1733b..4b748a2eb6 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLImage.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLImage.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class OpenGLFrameBufferImage : public ImagePixelData { public: @@ -200,3 +203,5 @@ OpenGLFrameBuffer* OpenGLImageType::getFrameBufferFrom (const Image& image) return nullptr; } + +} // namespace juce diff --git a/modules/juce_opengl/opengl/juce_OpenGLImage.h b/modules/juce_opengl/opengl/juce_OpenGLImage.h index 3bac505fe0..15b70e3059 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLImage.h +++ b/modules/juce_opengl/opengl/juce_OpenGLImage.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -49,3 +49,5 @@ public: static OpenGLFrameBuffer* getFrameBufferFrom (const Image&); }; + +} // namespace juce diff --git a/modules/juce_opengl/opengl/juce_OpenGLPixelFormat.cpp b/modules/juce_opengl/opengl/juce_OpenGLPixelFormat.cpp index 60661520ef..567460436c 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLPixelFormat.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLPixelFormat.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + OpenGLPixelFormat::OpenGLPixelFormat (const int bitsPerRGBComponent, const int alphaBits_, const int depthBufferBits_, @@ -61,3 +64,5 @@ bool OpenGLPixelFormat::operator!= (const OpenGLPixelFormat& other) const noexce { return ! operator== (other); } + +} // namespace juce diff --git a/modules/juce_opengl/opengl/juce_OpenGLPixelFormat.h b/modules/juce_opengl/opengl/juce_OpenGLPixelFormat.h index ebc5d934d2..3b6c83b9fb 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLPixelFormat.h +++ b/modules/juce_opengl/opengl/juce_OpenGLPixelFormat.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -66,3 +66,5 @@ public: uint8 multisamplingLevel; /**< The number of samples to use for full-scene multisampled anti-aliasing (if available). */ }; + +} // namespace juce diff --git a/modules/juce_opengl/opengl/juce_OpenGLRenderer.h b/modules/juce_opengl/opengl/juce_OpenGLRenderer.h index 36bf176503..67ad2b808d 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLRenderer.h +++ b/modules/juce_opengl/opengl/juce_OpenGLRenderer.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -76,3 +76,5 @@ public: */ virtual void openGLContextClosing() = 0; }; + +} // namespace juce diff --git a/modules/juce_opengl/opengl/juce_OpenGLShaderProgram.cpp b/modules/juce_opengl/opengl/juce_OpenGLShaderProgram.cpp index 0e41c05410..67611d5999 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLShaderProgram.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLShaderProgram.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + OpenGLShaderProgram::OpenGLShaderProgram (const OpenGLContext& c) noexcept : context (c) { } @@ -186,3 +189,5 @@ void OpenGLShaderProgram::Uniform::set (const GLfloat* values, GLsizei numValues void OpenGLShaderProgram::Uniform::setMatrix2 (const GLfloat* v, GLint num, GLboolean trns) const noexcept { context.extensions.glUniformMatrix2fv (uniformID, num, trns, v); } void OpenGLShaderProgram::Uniform::setMatrix3 (const GLfloat* v, GLint num, GLboolean trns) const noexcept { context.extensions.glUniformMatrix3fv (uniformID, num, trns, v); } void OpenGLShaderProgram::Uniform::setMatrix4 (const GLfloat* v, GLint num, GLboolean trns) const noexcept { context.extensions.glUniformMatrix4fv (uniformID, num, trns, v); } + +} // namespace juce diff --git a/modules/juce_opengl/opengl/juce_OpenGLShaderProgram.h b/modules/juce_opengl/opengl/juce_OpenGLShaderProgram.h index 72eb94b308..4efbf6fbfb 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLShaderProgram.h +++ b/modules/juce_opengl/opengl/juce_OpenGLShaderProgram.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -198,3 +199,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OpenGLShaderProgram) }; + +} // namespace juce diff --git a/modules/juce_opengl/opengl/juce_OpenGLTexture.cpp b/modules/juce_opengl/opengl/juce_OpenGLTexture.cpp index b6254ac01d..d29adccc72 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLTexture.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLTexture.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + static int getAllowedTextureSize (int x) { #if JUCE_OPENGL_ALLOW_NON_POWER_OF_TWO_TEXTURES @@ -185,3 +188,5 @@ void OpenGLTexture::unbind() const { glBindTexture (GL_TEXTURE_2D, 0); } + +} // namespace juce diff --git a/modules/juce_opengl/opengl/juce_OpenGLTexture.h b/modules/juce_opengl/opengl/juce_OpenGLTexture.h index 2794cba03a..8ced3f2faf 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLTexture.h +++ b/modules/juce_opengl/opengl/juce_OpenGLTexture.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -98,3 +99,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OpenGLTexture) }; + +} // namespace juce diff --git a/modules/juce_opengl/utils/juce_OpenGLAppComponent.cpp b/modules/juce_opengl/utils/juce_OpenGLAppComponent.cpp index a6bdb9c489..752c43e147 100644 --- a/modules/juce_opengl/utils/juce_OpenGLAppComponent.cpp +++ b/modules/juce_opengl/utils/juce_OpenGLAppComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + OpenGLAppComponent::OpenGLAppComponent() { setOpaque (true); @@ -63,3 +66,5 @@ void OpenGLAppComponent::openGLContextClosing() { shutdown(); } + +} // namespace juce diff --git a/modules/juce_opengl/utils/juce_OpenGLAppComponent.h b/modules/juce_opengl/utils/juce_OpenGLAppComponent.h index 351bd6ea18..ba23d04da8 100644 --- a/modules/juce_opengl/utils/juce_OpenGLAppComponent.h +++ b/modules/juce_opengl/utils/juce_OpenGLAppComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -92,3 +92,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OpenGLAppComponent) }; + +} // namespace juce diff --git a/modules/juce_osc/juce_osc.cpp b/modules/juce_osc/juce_osc.cpp index 738ef2ba83..6e026de4df 100644 --- a/modules/juce_osc/juce_osc.cpp +++ b/modules/juce_osc/juce_osc.cpp @@ -35,8 +35,6 @@ #include "juce_osc.h" -namespace juce -{ #include "osc/juce_OSCTypes.cpp" #include "osc/juce_OSCTimeTag.cpp" #include "osc/juce_OSCArgument.cpp" @@ -45,4 +43,3 @@ namespace juce #include "osc/juce_OSCBundle.cpp" #include "osc/juce_OSCReceiver.cpp" #include "osc/juce_OSCSender.cpp" -} diff --git a/modules/juce_osc/juce_osc.h b/modules/juce_osc/juce_osc.h index 6fb4e2879c..79b772e07d 100644 --- a/modules/juce_osc/juce_osc.h +++ b/modules/juce_osc/juce_osc.h @@ -56,9 +56,6 @@ //============================================================================== -namespace juce -{ - #include "osc/juce_OSCTypes.h" #include "osc/juce_OSCTimeTag.h" #include "osc/juce_OSCArgument.h" @@ -67,5 +64,3 @@ namespace juce #include "osc/juce_OSCBundle.h" #include "osc/juce_OSCReceiver.h" #include "osc/juce_OSCSender.h" - -} diff --git a/modules/juce_osc/osc/juce_OSCAddress.cpp b/modules/juce_osc/osc/juce_OSCAddress.cpp index 888a3f1010..3e70c9e068 100644 --- a/modules/juce_osc/osc/juce_OSCAddress.cpp +++ b/modules/juce_osc/osc/juce_OSCAddress.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace { //============================================================================== @@ -777,3 +780,5 @@ public: static OSCPatternMatcherTests OSCPatternMatcherUnitTests; #endif // JUCE_UNIT_TESTS + +} // namespace juce diff --git a/modules/juce_osc/osc/juce_OSCAddress.h b/modules/juce_osc/osc/juce_OSCAddress.h index b1b8555af3..2ef578f681 100644 --- a/modules/juce_osc/osc/juce_OSCAddress.h +++ b/modules/juce_osc/osc/juce_OSCAddress.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -146,3 +146,5 @@ private: String asString; bool wasInitialisedWithWildcards; }; + +} // namespace juce diff --git a/modules/juce_osc/osc/juce_OSCArgument.cpp b/modules/juce_osc/osc/juce_OSCArgument.cpp index 1bde638129..6dabbf277d 100644 --- a/modules/juce_osc/osc/juce_OSCArgument.cpp +++ b/modules/juce_osc/osc/juce_OSCArgument.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + OSCArgument::OSCArgument (int32 value) noexcept : type (OSCTypes::int32), intValue (value) { @@ -226,3 +229,5 @@ public: static OSCArgumentTests OSCArgumentUnitTests; #endif // JUCE_UNIT_TESTS + +} // namespace juce diff --git a/modules/juce_osc/osc/juce_OSCArgument.h b/modules/juce_osc/osc/juce_OSCArgument.h index 67e2a741ba..579227f047 100644 --- a/modules/juce_osc/osc/juce_OSCArgument.h +++ b/modules/juce_osc/osc/juce_OSCArgument.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -109,3 +109,5 @@ private: String stringValue; MemoryBlock blob; }; + +} // namespace juce diff --git a/modules/juce_osc/osc/juce_OSCBundle.cpp b/modules/juce_osc/osc/juce_OSCBundle.cpp index d2dcaf1ecf..e2041834d6 100644 --- a/modules/juce_osc/osc/juce_OSCBundle.cpp +++ b/modules/juce_osc/osc/juce_OSCBundle.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + OSCBundle::OSCBundle() { } @@ -237,3 +240,5 @@ public: static OSCBundleElementTests OSCBundleElementUnitTests; #endif // JUCE_UNIT_TESTS + +} // namespace juce diff --git a/modules/juce_osc/osc/juce_OSCBundle.h b/modules/juce_osc/osc/juce_OSCBundle.h index 1ab529860e..b3b0d4861e 100644 --- a/modules/juce_osc/osc/juce_OSCBundle.h +++ b/modules/juce_osc/osc/juce_OSCBundle.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -129,3 +130,5 @@ private: Array elements; OSCTimeTag timeTag; }; + +} // namespace juce diff --git a/modules/juce_osc/osc/juce_OSCMessage.cpp b/modules/juce_osc/osc/juce_OSCMessage.cpp index b62b61e8bc..6bb21cef21 100644 --- a/modules/juce_osc/osc/juce_OSCMessage.cpp +++ b/modules/juce_osc/osc/juce_OSCMessage.cpp @@ -24,7 +24,9 @@ ============================================================================== */ -//============================================================================== +namespace juce +{ + OSCMessage::OSCMessage (const OSCAddressPattern& ap) noexcept : addressPattern (ap) { } @@ -197,3 +199,5 @@ public: static OSCMessageTests OSCMessageUnitTests; #endif // JUCE_UNIT_TESTS + +} // namespace juce diff --git a/modules/juce_osc/osc/juce_OSCMessage.h b/modules/juce_osc/osc/juce_OSCMessage.h index bcc4b7cb5b..1d2f7fcf7e 100644 --- a/modules/juce_osc/osc/juce_OSCMessage.h +++ b/modules/juce_osc/osc/juce_OSCMessage.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -169,3 +169,5 @@ private: addArguments (std::forward (arg1), std::forward (args)...); } #endif + +} // namespace juce diff --git a/modules/juce_osc/osc/juce_OSCReceiver.cpp b/modules/juce_osc/osc/juce_OSCReceiver.cpp index 35da262ef0..3ee4110aef 100644 --- a/modules/juce_osc/osc/juce_OSCReceiver.cpp +++ b/modules/juce_osc/osc/juce_OSCReceiver.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace { //============================================================================== @@ -1156,3 +1159,5 @@ public: static OSCInputStreamTests OSCInputStreamUnitTests; #endif // JUCE_UNIT_TESTS + +} // namespace juce diff --git a/modules/juce_osc/osc/juce_OSCReceiver.h b/modules/juce_osc/osc/juce_OSCReceiver.h index 63871192bc..d9ad9ffb39 100644 --- a/modules/juce_osc/osc/juce_OSCReceiver.h +++ b/modules/juce_osc/osc/juce_OSCReceiver.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -209,3 +210,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OSCReceiver) }; + +} // namespace juce diff --git a/modules/juce_osc/osc/juce_OSCSender.cpp b/modules/juce_osc/osc/juce_OSCSender.cpp index c0fe39854c..dc98d8b993 100644 --- a/modules/juce_osc/osc/juce_OSCSender.cpp +++ b/modules/juce_osc/osc/juce_OSCSender.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace { //============================================================================== @@ -844,3 +847,5 @@ static OSCRoundTripTests OSCRoundTripUnitTests; //============================================================================== #endif // JUCE_UNIT_TESTS + +} // namespace juce diff --git a/modules/juce_osc/osc/juce_OSCSender.h b/modules/juce_osc/osc/juce_OSCSender.h index 3da6df1691..7ec4bdc73b 100644 --- a/modules/juce_osc/osc/juce_OSCSender.h +++ b/modules/juce_osc/osc/juce_OSCSender.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -153,3 +153,5 @@ private: return sendToIPAddress (targetIPAddress, targetPortNumber, OSCMessage (address, std::forward (args)...)); } #endif // JUCE_COMPILER_SUPPORTS_VARIADIC_TEMPLATES + +} // namespace juce diff --git a/modules/juce_osc/osc/juce_OSCTimeTag.cpp b/modules/juce_osc/osc/juce_OSCTimeTag.cpp index cfc7c95203..431062fdc8 100644 --- a/modules/juce_osc/osc/juce_OSCTimeTag.cpp +++ b/modules/juce_osc/osc/juce_OSCTimeTag.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + const OSCTimeTag OSCTimeTag::immediately; static const uint64 millisecondsBetweenOscAndJuceEpochs = 2208988800000ULL; @@ -147,3 +150,5 @@ public: static OSCTimeTagTests OSCTimeTagUnitTests; #endif + +} // namespace juce diff --git a/modules/juce_osc/osc/juce_OSCTimeTag.h b/modules/juce_osc/osc/juce_OSCTimeTag.h index 02f9973a4a..17a5feb72d 100644 --- a/modules/juce_osc/osc/juce_OSCTimeTag.h +++ b/modules/juce_osc/osc/juce_OSCTimeTag.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -81,3 +81,5 @@ private: //============================================================================== uint64 rawTimeTag; }; + +} // namespace juce diff --git a/modules/juce_osc/osc/juce_OSCTypes.cpp b/modules/juce_osc/osc/juce_OSCTypes.cpp index 18d7233de0..a78f21e28e 100644 --- a/modules/juce_osc/osc/juce_OSCTypes.cpp +++ b/modules/juce_osc/osc/juce_OSCTypes.cpp @@ -24,7 +24,10 @@ ============================================================================== */ -const OSCType OSCTypes::int32 = 'i'; -const OSCType OSCTypes::float32 = 'f'; -const OSCType OSCTypes::string = 's'; -const OSCType OSCTypes::blob = 'b'; +namespace juce +{ + const OSCType OSCTypes::int32 = 'i'; + const OSCType OSCTypes::float32 = 'f'; + const OSCType OSCTypes::string = 's'; + const OSCType OSCTypes::blob = 'b'; +} diff --git a/modules/juce_osc/osc/juce_OSCTypes.h b/modules/juce_osc/osc/juce_OSCTypes.h index 295b99056a..83dbee30af 100644 --- a/modules/juce_osc/osc/juce_OSCTypes.h +++ b/modules/juce_osc/osc/juce_OSCTypes.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== @@ -95,3 +96,5 @@ struct OSCInternalError : public OSCException { OSCInternalError (const String& desc) : OSCException (desc) {} }; + +} // namespace juce diff --git a/modules/juce_product_unlocking/in_app_purchases/juce_InAppPurchases.cpp b/modules/juce_product_unlocking/in_app_purchases/juce_InAppPurchases.cpp index 39a8cb17f8..ed5bb817ab 100644 --- a/modules/juce_product_unlocking/in_app_purchases/juce_InAppPurchases.cpp +++ b/modules/juce_product_unlocking/in_app_purchases/juce_InAppPurchases.cpp @@ -24,12 +24,15 @@ ============================================================================== */ +namespace juce +{ InAppPurchases::InAppPurchases() #if JUCE_ANDROID || JUCE_IOS : pimpl (new Pimpl (*this)) #endif {} + InAppPurchases::~InAppPurchases() {} bool InAppPurchases::isInAppPurchasesSupported() const @@ -128,3 +131,5 @@ void InAppPurchases::cancelDownloads (const Array& downloads) ignoreUnused (downloads); #endif } + +} // namespace juce diff --git a/modules/juce_product_unlocking/in_app_purchases/juce_InAppPurchases.h b/modules/juce_product_unlocking/in_app_purchases/juce_InAppPurchases.h index 45695d86a3..157d44c853 100644 --- a/modules/juce_product_unlocking/in_app_purchases/juce_InAppPurchases.h +++ b/modules/juce_product_unlocking/in_app_purchases/juce_InAppPurchases.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + /** Provides in-app purchase functionality. @@ -269,3 +272,5 @@ private: ScopedPointer pimpl; #endif }; + +} // namespace juce diff --git a/modules/juce_product_unlocking/juce_product_unlocking.cpp b/modules/juce_product_unlocking/juce_product_unlocking.cpp index 4e78809c61..7bab6c406d 100644 --- a/modules/juce_product_unlocking/juce_product_unlocking.cpp +++ b/modules/juce_product_unlocking/juce_product_unlocking.cpp @@ -48,25 +48,22 @@ #import #endif -namespace juce -{ - #if JUCE_IN_APP_PURCHASES - #if JUCE_ANDROID - #include "native/juce_android_InAppPurchases.cpp" - #elif JUCE_IOS - #include "native/juce_ios_InAppPurchases.cpp" - #endif - - #include "in_app_purchases/juce_InAppPurchases.cpp" - #endif - - #include "marketplace/juce_OnlineUnlockStatus.cpp" - - #if JUCE_MODULE_AVAILABLE_juce_data_structures - #include "marketplace/juce_TracktionMarketplaceStatus.cpp" - #endif - - #if JUCE_MODULE_AVAILABLE_juce_gui_extra - #include "marketplace/juce_OnlineUnlockForm.cpp" - #endif -} +#if JUCE_IN_APP_PURCHASES + #if JUCE_ANDROID + #include "native/juce_android_InAppPurchases.cpp" + #elif JUCE_IOS + #include "native/juce_ios_InAppPurchases.cpp" + #endif + + #include "in_app_purchases/juce_InAppPurchases.cpp" +#endif + +#include "marketplace/juce_OnlineUnlockStatus.cpp" + +#if JUCE_MODULE_AVAILABLE_juce_data_structures + #include "marketplace/juce_TracktionMarketplaceStatus.cpp" +#endif + +#if JUCE_MODULE_AVAILABLE_juce_gui_extra + #include "marketplace/juce_OnlineUnlockForm.cpp" +#endif diff --git a/modules/juce_product_unlocking/juce_product_unlocking.h b/modules/juce_product_unlocking/juce_product_unlocking.h index 85884e2df0..9e6cae807f 100644 --- a/modules/juce_product_unlocking/juce_product_unlocking.h +++ b/modules/juce_product_unlocking/juce_product_unlocking.h @@ -77,19 +77,17 @@ #include #endif -namespace juce -{ - #if JUCE_IN_APP_PURCHASES - #include "in_app_purchases/juce_InAppPurchases.h" - #endif - - #if JUCE_MODULE_AVAILABLE_juce_data_structures - #include "marketplace/juce_OnlineUnlockStatus.h" - #include "marketplace/juce_TracktionMarketplaceStatus.h" - #endif - #include "marketplace/juce_KeyFileGeneration.h" - - #if JUCE_MODULE_AVAILABLE_juce_gui_extra - #include "marketplace/juce_OnlineUnlockForm.h" - #endif -} +#if JUCE_IN_APP_PURCHASES + #include "in_app_purchases/juce_InAppPurchases.h" +#endif + +#if JUCE_MODULE_AVAILABLE_juce_data_structures + #include "marketplace/juce_OnlineUnlockStatus.h" + #include "marketplace/juce_TracktionMarketplaceStatus.h" +#endif + +#include "marketplace/juce_KeyFileGeneration.h" + +#if JUCE_MODULE_AVAILABLE_juce_gui_extra + #include "marketplace/juce_OnlineUnlockForm.h" +#endif diff --git a/modules/juce_product_unlocking/marketplace/juce_KeyFileGeneration.h b/modules/juce_product_unlocking/marketplace/juce_KeyFileGeneration.h index fbf8b659c7..7e06c6e798 100644 --- a/modules/juce_product_unlocking/marketplace/juce_KeyFileGeneration.h +++ b/modules/juce_product_unlocking/marketplace/juce_KeyFileGeneration.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + /** Contains static utilities for generating key-files that can be unlocked by the OnlineUnlockStatus class. @@ -107,3 +110,5 @@ public: return 0; } }; + +} // namespace juce diff --git a/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockForm.cpp b/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockForm.cpp index 4476997147..debb2384c3 100644 --- a/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockForm.cpp +++ b/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockForm.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + struct Spinner : public Component, private Timer { Spinner() { startTimer (1000 / 50); } @@ -283,3 +286,5 @@ void OnlineUnlockForm::dismiss() { delete this; } + +} // namespace juce diff --git a/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockForm.h b/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockForm.h index c4b20010a8..bc9dd492a5 100644 --- a/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockForm.h +++ b/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockForm.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + /** Acts as a GUI which asks the user for their details, and calls the approriate methods on your OnlineUnlockStatus object to attempt to register the app. @@ -88,3 +91,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OnlineUnlockForm) }; + +} // namespace juce diff --git a/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockStatus.cpp b/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockStatus.cpp index d4001fd084..39affbf700 100644 --- a/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockStatus.cpp +++ b/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockStatus.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + /* Note: there's a bit of light obfuscation in this code, just to make things a bit more annoying for crackers who try to reverse-engineer your binaries, but nothing particularly foolproof. @@ -485,3 +488,5 @@ String KeyGeneration::generateExpiringKeyFile (const String& appName, return KeyFileUtils::createKeyFile (comment, xml, privateKey); } + +} // namespace juce diff --git a/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockStatus.h b/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockStatus.h index 7a72e079dd..0085d570ad 100644 --- a/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockStatus.h +++ b/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockStatus.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + /** A base class for online unlocking systems. @@ -258,3 +261,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OnlineUnlockStatus) }; + +} // namespace juce diff --git a/modules/juce_product_unlocking/marketplace/juce_TracktionMarketplaceStatus.cpp b/modules/juce_product_unlocking/marketplace/juce_TracktionMarketplaceStatus.cpp index 2131c2d096..b30e263163 100644 --- a/modules/juce_product_unlocking/marketplace/juce_TracktionMarketplaceStatus.cpp +++ b/modules/juce_product_unlocking/marketplace/juce_TracktionMarketplaceStatus.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + TracktionMarketplaceStatus::TracktionMarketplaceStatus() {} URL TracktionMarketplaceStatus::getServerAuthenticationURL() @@ -54,3 +57,5 @@ String TracktionMarketplaceStatus::readReplyFromWebserver (const String& email, return url.readEntireTextStream(); } + +} // namespace juce diff --git a/modules/juce_product_unlocking/marketplace/juce_TracktionMarketplaceStatus.h b/modules/juce_product_unlocking/marketplace/juce_TracktionMarketplaceStatus.h index 06566b83a2..c93cd5328c 100644 --- a/modules/juce_product_unlocking/marketplace/juce_TracktionMarketplaceStatus.h +++ b/modules/juce_product_unlocking/marketplace/juce_TracktionMarketplaceStatus.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + /** An implementation of the OnlineUnlockStatus class which talks to the Tracktion Marketplace server. @@ -51,3 +54,5 @@ public: private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TracktionMarketplaceStatus) }; + +} // namespace juce diff --git a/modules/juce_product_unlocking/native/juce_android_InAppPurchases.cpp b/modules/juce_product_unlocking/native/juce_android_InAppPurchases.cpp index f9d4a25d20..da61ce003d 100644 --- a/modules/juce_product_unlocking/native/juce_android_InAppPurchases.cpp +++ b/modules/juce_product_unlocking/native/juce_android_InAppPurchases.cpp @@ -24,6 +24,8 @@ ============================================================================== */ +namespace juce +{ #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ METHOD (isBillingSupported, "isBillingSupported", "(ILjava/lang/String;Ljava/lang/String;)I") \ @@ -931,3 +933,5 @@ void juce_inAppPurchaseCompleted (void* intentData) { InAppPurchases::Pimpl::inAppPurchaseCompleted (static_cast (intentData)); } + +} // namespace juce diff --git a/modules/juce_product_unlocking/native/juce_ios_InAppPurchases.cpp b/modules/juce_product_unlocking/native/juce_ios_InAppPurchases.cpp index 8ff5b98628..aa7415b9f5 100644 --- a/modules/juce_product_unlocking/native/juce_ios_InAppPurchases.cpp +++ b/modules/juce_product_unlocking/native/juce_ios_InAppPurchases.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + template <> struct ContainerDeletePolicy { static void destroy (NSObject* o) { [o release]; } }; template <> struct ContainerDeletePolicy { static void destroy (NSObject* o) { [o release]; } }; template <> struct ContainerDeletePolicy> { static void destroy (NSObject* o) { [o release]; } }; @@ -677,3 +680,5 @@ struct InAppPurchases::Pimpl : public SKDelegateAndPaymentObserver OwnedArray pendingDownloadsTransactions; Array restoredPurchases; }; + +} // namespace juce diff --git a/modules/juce_video/capture/juce_CameraDevice.cpp b/modules/juce_video/capture/juce_CameraDevice.cpp index 91955d59ee..97568e1b79 100644 --- a/modules/juce_video/capture/juce_CameraDevice.cpp +++ b/modules/juce_video/capture/juce_CameraDevice.cpp @@ -24,6 +24,8 @@ ============================================================================== */ +namespace juce +{ #if JUCE_MAC || JUCE_IOS #include "../native/juce_mac_CameraDevice.h" @@ -99,3 +101,5 @@ CameraDevice* CameraDevice::openDevice (int index, return nullptr; } + +} // namespace juce diff --git a/modules/juce_video/capture/juce_CameraDevice.h b/modules/juce_video/capture/juce_CameraDevice.h index 2e4f81a701..18a19b5f7a 100644 --- a/modules/juce_video/capture/juce_CameraDevice.h +++ b/modules/juce_video/capture/juce_CameraDevice.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ #if JUCE_USE_CAMERA || DOXYGEN @@ -164,3 +165,5 @@ private: #endif #endif + +} // namespace juce diff --git a/modules/juce_video/juce_video.cpp b/modules/juce_video/juce_video.cpp index 6edb8a60d6..bec17ed285 100644 --- a/modules/juce_video/juce_video.cpp +++ b/modules/juce_video/juce_video.cpp @@ -67,15 +67,8 @@ #endif //============================================================================== -using namespace juce; - -namespace juce -{ - #include "playback/juce_VideoComponent.cpp" #if JUCE_USE_CAMERA #include "capture/juce_CameraDevice.cpp" #endif - -} diff --git a/modules/juce_video/juce_video.h b/modules/juce_video/juce_video.h index 8d76427fea..4fe138e0f0 100644 --- a/modules/juce_video/juce_video.h +++ b/modules/juce_video/juce_video.h @@ -57,9 +57,6 @@ //============================================================================== #include -//============================================================================= -#include "../juce_gui_extra/juce_gui_extra.h" - //============================================================================= /** Config: JUCE_USE_CAMERA Enables web-cam support using the CameraDevice class (Mac and Windows). @@ -73,10 +70,5 @@ #endif //============================================================================= -namespace juce -{ - #include "playback/juce_VideoComponent.h" #include "capture/juce_CameraDevice.h" - -} diff --git a/modules/juce_video/playback/juce_VideoComponent.cpp b/modules/juce_video/playback/juce_VideoComponent.cpp index 0d0552d1b4..135048b037 100644 --- a/modules/juce_video/playback/juce_VideoComponent.cpp +++ b/modules/juce_video/playback/juce_VideoComponent.cpp @@ -22,6 +22,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_MAC || JUCE_IOS || JUCE_MSVC #if JUCE_MAC || JUCE_IOS @@ -116,3 +119,5 @@ void VideoComponent::timerCallback() } #endif + +} // namespace juce diff --git a/modules/juce_video/playback/juce_VideoComponent.h b/modules/juce_video/playback/juce_VideoComponent.h index 1980e1c897..ea08878039 100644 --- a/modules/juce_video/playback/juce_VideoComponent.h +++ b/modules/juce_video/playback/juce_VideoComponent.h @@ -25,6 +25,8 @@ #ifndef JUCE_VIDEOCOMPONENT_H_INCLUDED #define JUCE_VIDEOCOMPONENT_H_INCLUDED +namespace juce +{ //============================================================================== /** @@ -130,3 +132,5 @@ private: #endif + +} // namespace juce From 0c3faf4b581bb2f0eaf0cc93c99eaaaa638a5e54 Mon Sep 17 00:00:00 2001 From: tpoole Date: Fri, 8 Sep 2017 09:51:41 +0100 Subject: [PATCH 069/129] Added an OS X 10.6 compatibility fix --- modules/juce_core/containers/juce_SortedSet.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/juce_core/containers/juce_SortedSet.h b/modules/juce_core/containers/juce_SortedSet.h index 192de75082..04d096a020 100644 --- a/modules/juce_core/containers/juce_SortedSet.h +++ b/modules/juce_core/containers/juce_SortedSet.h @@ -64,14 +64,14 @@ public: /** Creates a copy of another set. */ // VS2013 doesn't allow defaulted noexcept constructors. - SortedSet (SortedSet&& other) noexcept : data (std::move (other.data)) {} + SortedSet (SortedSet&& other) noexcept : data (static_cast (other.data)) {} /** Makes a copy of another set. */ SortedSet& operator= (const SortedSet&) = default; /** Makes a copy of another set. */ // VS2013 doesn't allow defaulted noexcept constructors. - SortedSet& operator= (SortedSet&& other) noexcept { data = std::move (other.data); return *this; } + SortedSet& operator= (SortedSet&& other) noexcept { data = static_cast (other.data); return *this; } /** Destructor. */ ~SortedSet() noexcept {} From c81c33404d3e7648c418ac949a71c6e441c81ea0 Mon Sep 17 00:00:00 2001 From: jules Date: Fri, 8 Sep 2017 12:00:57 +0100 Subject: [PATCH 070/129] BLOCKS: Added support for tri-state button controls in littlefoot --- .../juce_blocks_basics/blocks/juce_BlockConfigManager.h | 7 ++++--- .../protocol/juce_BlocksProtocolDefinitions.h | 6 ++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/modules/juce_blocks_basics/blocks/juce_BlockConfigManager.h b/modules/juce_blocks_basics/blocks/juce_BlockConfigManager.h index eb591576fb..f24540ded4 100644 --- a/modules/juce_blocks_basics/blocks/juce_BlockConfigManager.h +++ b/modules/juce_blocks_basics/blocks/juce_BlockConfigManager.h @@ -50,7 +50,7 @@ struct BlockConfigManager options }; - static constexpr uint32 numConfigItems = 60; + static constexpr uint32 numConfigItems = 61; struct ConfigDescription { @@ -93,6 +93,7 @@ struct BlockConfigManager { fixedVelocityValue, 127, 1, 127, false, "Fixed Velocity Value", ConfigType::integer, {}, "5D Touch" }, { pianoMode, 0, 0, 1, false, "Piano Mode", ConfigType::boolean, {}, "Play mode" }, { glideLock, 0, 0, 127, false, "Glide Rate", ConfigType::integer, {}, "Play mode" }, + { glideLockEnable, 0, 0, 1, false, "Glidelock Enable", ConfigType::boolean, {}, "Play mode" }, { mode, 4, 1, 5, false, "Mode", ConfigType::integer, {}, "Play mode" }, { volume, 100, 0, 127, false, "Volume", ConfigType::integer, {}, "Play mode" }, { scale, 0, 0, 18, false, "Scale", ConfigType::integer, {}, "Play mode" }, // NOTE: Should be options @@ -255,8 +256,8 @@ struct BlockConfigManager void resetConfigListActiveStatus() { - for (uint32 i = 0; i < numConfigItems; ++i) - configList[i].isActive = false; + for (auto& i : configList) + i.isActive = false; } //============================================================================== diff --git a/modules/juce_blocks_basics/protocol/juce_BlocksProtocolDefinitions.h b/modules/juce_blocks_basics/protocol/juce_BlocksProtocolDefinitions.h index 94910de1f1..5cf40376b0 100644 --- a/modules/juce_blocks_basics/protocol/juce_BlocksProtocolDefinitions.h +++ b/modules/juce_blocks_basics/protocol/juce_BlocksProtocolDefinitions.h @@ -214,6 +214,7 @@ enum ConfigItemId fixedVelocityValue = 16, pianoMode = 17, glideLock = 18, + glideLockEnable = 19, // Live mode = 20, volume = 21, @@ -505,6 +506,11 @@ static constexpr const char* ledProgramLittleFootFunctions[] = "onControlPress/vi", "onControlRelease/vi", "initControl/viiiiiiiii", + "setButtonMode/vii", + "setButtonType/viii", + "setButtonMinMaxDefault/viiii", + "setButtonColours/viii", + "setButtonTriState/vii", nullptr }; From f4bfa6bec5e9a35c03aa0e90df73ead307b1542d Mon Sep 17 00:00:00 2001 From: Lukasz Kozakiewicz Date: Fri, 1 Sep 2017 16:39:08 +0100 Subject: [PATCH 071/129] Android: fix a crash in painting when size of the array to allocate is 0. --- modules/juce_gui_basics/native/juce_android_Windowing.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/juce_gui_basics/native/juce_android_Windowing.cpp b/modules/juce_gui_basics/native/juce_android_Windowing.cpp index 9240440be1..54fa3ea608 100644 --- a/modules/juce_gui_basics/native/juce_android_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_android_Windowing.cpp @@ -526,6 +526,10 @@ public: sizeAllocated = sizeNeeded; buffer = GlobalRef (env->NewIntArray (sizeNeeded)); } + else if (sizeNeeded == 0) + { + return; + } if (jint* dest = env->GetIntArrayElements ((jintArray) buffer.get(), 0)) { From 743c9d55e7eb5c1a204383ae0b0c3983e8016761 Mon Sep 17 00:00:00 2001 From: tpoole Date: Fri, 8 Sep 2017 12:55:44 +0100 Subject: [PATCH 072/129] AU: Implemented GetParameterValueStrings for discrete parameters --- .../AU/juce_AU_Wrapper.mm | 63 ++++++++++++++++++- 1 file changed, 60 insertions(+), 3 deletions(-) diff --git a/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm b/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm index de27773daf..1ee9b0e179 100644 --- a/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm +++ b/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm @@ -90,6 +90,8 @@ static Array activePlugins, activeUIs; static const AudioUnitPropertyID juceFilterObjectPropertyID = 0x1a45ffe9; +template <> struct ContainerDeletePolicy { static void destroy (const __CFString* o) { if (o != nullptr) CFRelease (o); } }; + // make sure the audio processor is initialized before the AUBase class struct AudioProcessorHolder { @@ -880,6 +882,34 @@ public: return kAudioUnitErr_InvalidParameter; } + ComponentResult GetParameterValueStrings (AudioUnitScope inScope, + AudioUnitParameterID inParameterID, + CFArrayRef *outStrings) override + { + if (outStrings == nullptr) + return noErr; + + const int index = getJuceIndexForAUParameterID (inParameterID); + + if (inScope == kAudioUnitScope_Global + && juceFilter != nullptr + && isPositiveAndBelow (index, juceFilter->getNumParameters()) + && juceFilter->isParameterDiscrete (index)) + { + if (auto* valueStrings = parameterValueStringArrays[index]) + { + *outStrings = CFArrayCreate (NULL, + (const void **) valueStrings->getRawDataPointer(), + valueStrings->size(), + NULL); + + return noErr; + } + } + + return kAudioUnitErr_InvalidParameter; + } + ComponentResult GetParameter (AudioUnitParameterID inID, AudioUnitScope inScope, AudioUnitElement inElement, @@ -1613,6 +1643,9 @@ private: //============================================================================== AudioUnitHelpers::ChannelRemapper mapper; + //============================================================================== + OwnedArray> parameterValueStringArrays; + //============================================================================== void pullInputAudio (AudioUnitRenderActionFlags& flags, const AudioTimeStamp& timestamp, const UInt32 nFrames) noexcept { @@ -1747,9 +1780,7 @@ private: if (usingManagedParameter) { - const int n = juceFilter->getNumParameters(); - - for (int i = 0; i < n; ++i) + for (int i = 0; i < numParams; ++i) { const AudioUnitParameterID auParamID = generateAUParameterIDForIndex (i); @@ -1776,6 +1807,32 @@ private: if (param->isDiscrete()) jassert (param->getNumSteps() != juceFilter->getDefaultNumParameterSteps()); #endif + + parameterValueStringArrays.ensureStorageAllocated (numParams); + + for (int index = 0; index < numParams; ++index) + { + OwnedArray* stringValues = nullptr; + + #if ! JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE + if (juceFilter->isParameterDiscrete (index)) + { + if (auto* param = juceFilter->getParameters()[index]) + { + const auto numSteps = juceFilter->getParameterNumSteps (index); + stringValues = new OwnedArray(); + stringValues->ensureStorageAllocated (numSteps); + + const auto maxValue = getMaximumParameterValue (index); + + for (int i = 0; i < numSteps; ++i) + stringValues->add (CFStringCreateCopy (nullptr, (param->getText ((float) i / maxValue, 0)).toCFString())); ; + } + } + #endif + + parameterValueStringArrays.add (stringValues); + } } //============================================================================== From 6d369ac0d6e81fe9e594324cb23e29e57bfd2e45 Mon Sep 17 00:00:00 2001 From: tpoole Date: Mon, 11 Sep 2017 08:41:47 +0100 Subject: [PATCH 073/129] Fixed a double header inclusion bug --- .../Standalone/juce_StandaloneFilterApp.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterApp.cpp b/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterApp.cpp index 9b62d22870..866c02afeb 100644 --- a/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterApp.cpp +++ b/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterApp.cpp @@ -43,10 +43,6 @@ extern juce::AudioProcessor* JUCE_CALLTYPE createPluginFilter(); -#if JucePlugin_Enable_IAA && JUCE_IOS - #include "../../juce_audio_devices/native/juce_ios_Audio.h" -#endif - #include "juce_StandaloneFilterWindow.h" namespace juce From 2f329cec8726dab615ad44b62ff75c71a9e54b1b Mon Sep 17 00:00:00 2001 From: tpoole Date: Mon, 11 Sep 2017 08:59:53 +0100 Subject: [PATCH 074/129] Added the microphone permission to the iOS demo plug-in --- examples/audio plugin demo/JuceDemoPlugin.jucer | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/audio plugin demo/JuceDemoPlugin.jucer b/examples/audio plugin demo/JuceDemoPlugin.jucer index b51c35ae3d..4de6983c40 100644 --- a/examples/audio plugin demo/JuceDemoPlugin.jucer +++ b/examples/audio plugin demo/JuceDemoPlugin.jucer @@ -107,7 +107,7 @@ + iosBackgroundBle="1" microphonePermissionNeeded="1"> From a426feb6c2e2271a8008b17164e682c3a5ee8bb0 Mon Sep 17 00:00:00 2001 From: hogliux Date: Mon, 11 Sep 2017 09:12:28 +0100 Subject: [PATCH 075/129] VST3: checkBusFormatsAreNotDiscrete should return true when buses are disabled --- .../VST3/juce_VST3_Wrapper.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp b/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp index 7f02cc0da0..1632d9ae3d 100644 --- a/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp @@ -1851,12 +1851,20 @@ public: auto numOutputBuses = pluginInstance->getBusCount (false); for (int i = 0; i < numInputBuses; ++i) - if (pluginInstance->getChannelLayoutOfBus (true, i).isDiscreteLayout()) + { + auto& layout = pluginInstance->getChannelLayoutOfBus (true, i); + + if (layout.isDiscreteLayout() && ! layout.isDisabled()) return false; + } for (int i = 0; i < numOutputBuses; ++i) - if (pluginInstance->getChannelLayoutOfBus (false, i).isDiscreteLayout()) + { + auto& layout = pluginInstance->getChannelLayoutOfBus (false, i); + + if (layout.isDiscreteLayout() && ! layout.isDisabled()) return false; + } return true; } From 0a2fabb2e1b483b7e5e99ebb817df7fbac50e860 Mon Sep 17 00:00:00 2001 From: hogliux Date: Mon, 11 Sep 2017 09:24:04 +0100 Subject: [PATCH 076/129] VST3: Fixed a harmless MSVC warning in previous commit --- modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp b/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp index 1632d9ae3d..967d3fd31c 100644 --- a/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp @@ -1852,7 +1852,7 @@ public: for (int i = 0; i < numInputBuses; ++i) { - auto& layout = pluginInstance->getChannelLayoutOfBus (true, i); + auto layout = pluginInstance->getChannelLayoutOfBus (true, i); if (layout.isDiscreteLayout() && ! layout.isDisabled()) return false; @@ -1860,7 +1860,7 @@ public: for (int i = 0; i < numOutputBuses; ++i) { - auto& layout = pluginInstance->getChannelLayoutOfBus (false, i); + auto layout = pluginInstance->getChannelLayoutOfBus (false, i); if (layout.isDiscreteLayout() && ! layout.isDisabled()) return false; From 94e8a43a9556915a6658b6eea50f92970fef3650 Mon Sep 17 00:00:00 2001 From: ed Date: Mon, 11 Sep 2017 09:25:36 +0100 Subject: [PATCH 077/129] AU: Replaced std::unordered_map with HashMap for parameter lookup --- .../format_types/juce_AudioUnitPluginFormat.mm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm b/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm index 942441c2f2..7b08bb0b44 100644 --- a/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm +++ b/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm @@ -53,8 +53,6 @@ #include #endif -#include - #if JUCE_SUPPORT_CARBON #include "../../juce_gui_extra/native/juce_mac_CarbonViewWrapperComponent.h" #endif @@ -1185,7 +1183,7 @@ public: ParamInfo* const param = new ParamInfo(); parameters.add (param); param->paramID = ids[i]; - paramIDToIndex[ids[i]] = i; + paramIDToIndex.getReference (ids[i]) = i; param->minValue = info.minValue; param->maxValue = info.maxValue; param->automatable = (info.flags & kAudioUnitParameterFlag_NonRealTime) == 0; @@ -1281,7 +1279,7 @@ private: }; OwnedArray parameters; - std::unordered_map paramIDToIndex; + HashMap paramIDToIndex; MidiDataConcatenator midiConcatenator; CriticalSection midiInLock; @@ -1367,10 +1365,12 @@ private: || event.mEventType == kAudioUnitEvent_BeginParameterChangeGesture || event.mEventType == kAudioUnitEvent_EndParameterChangeGesture) { - auto it = paramIDToIndex.find (event.mArgument.mParameter.mParameterID); + auto paramID = event.mArgument.mParameter.mParameterID; + + if (! paramIDToIndex.contains (paramID)) + return; - if (it != paramIDToIndex.end()) - paramIndex = (int) it->second; + paramIndex = static_cast (paramIDToIndex [paramID]); if (! isPositiveAndBelow (paramIndex, parameters.size())) return; From 849f9e8f4a6e41e7576ef1da3e984613c3d58ad0 Mon Sep 17 00:00:00 2001 From: tpoole Date: Mon, 11 Sep 2017 09:31:46 +0100 Subject: [PATCH 078/129] Removed a duplicate module configuration parameter --- .../juce_audio_processors/juce_audio_processors.h | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/modules/juce_audio_processors/juce_audio_processors.h b/modules/juce_audio_processors/juce_audio_processors.h index abfcf43bf3..4645514b88 100644 --- a/modules/juce_audio_processors/juce_audio_processors.h +++ b/modules/juce_audio_processors/juce_audio_processors.h @@ -56,19 +56,6 @@ #include #include -/** Config: JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE - - Enable this if you want to force JUCE to use an old scheme for selecting - when parameters are classified as discrete or continuous in a host. If this - is not enabled then DAW projects with automation data written by an - AudioUnit, VST3 or AAX plug-in built with JUCE version 5.1.1 or earlier may - load incorrectly when opened by an AudioUnit, VST3 or AAX plug-in built - with JUCE version 5.2.0 and later. -*/ -#ifndef JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE - #define JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE 0 -#endif - //============================================================================== /** Config: JUCE_PLUGINHOST_VST Enables the VST audio plugin hosting classes. @@ -110,7 +97,6 @@ #define JUCE_SUPPORT_LEGACY_AUDIOPROCESSOR 1 #endif -//============================================================================== //============================================================================== #include "processors/juce_AudioProcessorEditor.h" #include "processors/juce_AudioProcessorListener.h" From 8f54c73686c42c72765d30912f87315df6d2fcda Mon Sep 17 00:00:00 2001 From: tpoole Date: Mon, 11 Sep 2017 10:13:38 +0100 Subject: [PATCH 079/129] Fixed a double inclusion of the Carbon headers --- .../format_types/juce_AudioUnitPluginFormat.mm | 4 ---- .../format_types/juce_VSTPluginFormat.cpp | 5 ----- modules/juce_audio_processors/juce_audio_processors.cpp | 1 + 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm b/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm index 7b08bb0b44..3cb70160c5 100644 --- a/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm +++ b/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm @@ -53,10 +53,6 @@ #include #endif -#if JUCE_SUPPORT_CARBON - #include "../../juce_gui_extra/native/juce_mac_CarbonViewWrapperComponent.h" -#endif - #include "../../juce_audio_basics/native/juce_mac_CoreAudioLayouts.h" #include "../../juce_audio_devices/native/juce_MidiDataConcatenator.h" #include "juce_AU_Shared.h" diff --git a/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp b/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp index cf741b43c9..716b274016 100644 --- a/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp +++ b/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp @@ -26,11 +26,6 @@ #if JUCE_PLUGINHOST_VST -//============================================================================== -#if JUCE_MAC && JUCE_SUPPORT_CARBON - #include "../../juce_gui_extra/native/juce_mac_CarbonViewWrapperComponent.h" -#endif - //============================================================================== #undef PRAGMA_ALIGN_SUPPORTED diff --git a/modules/juce_audio_processors/juce_audio_processors.cpp b/modules/juce_audio_processors/juce_audio_processors.cpp index 9f4e1e67bd..258ba2eefd 100644 --- a/modules/juce_audio_processors/juce_audio_processors.cpp +++ b/modules/juce_audio_processors/juce_audio_processors.cpp @@ -45,6 +45,7 @@ && ((JUCE_PLUGINHOST_VST || JUCE_PLUGINHOST_AU) \ || ! (defined (MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6)) #include + #include "../juce_gui_extra/native/juce_mac_CarbonViewWrapperComponent.h" #endif #endif From 3cd4a9d91791f020d5323006980a69e06ea0966c Mon Sep 17 00:00:00 2001 From: tpoole Date: Mon, 11 Sep 2017 10:14:57 +0100 Subject: [PATCH 080/129] Made the demo host compatible with OS X 10.6 --- examples/audio plugin host/Source/MainHostWindow.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/audio plugin host/Source/MainHostWindow.cpp b/examples/audio plugin host/Source/MainHostWindow.cpp index 37c96af1ed..906564544d 100644 --- a/examples/audio plugin host/Source/MainHostWindow.cpp +++ b/examples/audio plugin host/Source/MainHostWindow.cpp @@ -213,7 +213,12 @@ void MainHostWindow::changeListenerCallback (ChangeBroadcaster* changed) StringArray MainHostWindow::getMenuBarNames() { - return { "File", "Plugins", "Options", "Windows" }; + StringArray names; + names.add ("File"); + names.add ("Plugins"); + names.add ("Options"); + names.add ("Windows"); + return names; } PopupMenu MainHostWindow::getMenuForIndex (int topLevelMenuIndex, const String& /*menuName*/) From 78f34fe51f1b03bfd3a84c665caab35bfdb0990b Mon Sep 17 00:00:00 2001 From: ed Date: Mon, 11 Sep 2017 10:43:56 +0100 Subject: [PATCH 081/129] AU: Fixed an error when targeting 32-bit architectures --- .../format_types/juce_AudioUnitPluginFormat.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm b/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm index 3cb70160c5..db45291f18 100644 --- a/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm +++ b/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm @@ -1275,7 +1275,7 @@ private: }; OwnedArray parameters; - HashMap paramIDToIndex; + HashMap paramIDToIndex; MidiDataConcatenator midiConcatenator; CriticalSection midiInLock; From a234313120cb9a1e05fe35612541291ac43d77ab Mon Sep 17 00:00:00 2001 From: tpoole Date: Mon, 11 Sep 2017 12:26:03 +0100 Subject: [PATCH 082/129] Fixed Digital Performer host detection on MacOS --- .../juce_audio_plugin_client/utility/juce_PluginHostType.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/juce_audio_plugin_client/utility/juce_PluginHostType.h b/modules/juce_audio_plugin_client/utility/juce_PluginHostType.h index d4a31a0fb6..9835e8ad85 100644 --- a/modules/juce_audio_plugin_client/utility/juce_PluginHostType.h +++ b/modules/juce_audio_plugin_client/utility/juce_PluginHostType.h @@ -244,7 +244,7 @@ private: if (hostPath.containsIgnoreCase ("Wavelab 8")) return SteinbergWavelab8; if (hostFilename.containsIgnoreCase ("Wavelab")) return SteinbergWavelabGeneric; if (hostFilename.containsIgnoreCase ("WaveBurner")) return WaveBurner; - if (hostFilename.contains ("Digital Performer")) return DigitalPerformer; + if (hostPath.containsIgnoreCase ("Digital Performer")) return DigitalPerformer; if (hostFilename.containsIgnoreCase ("reaper")) return Reaper; if (hostPath.containsIgnoreCase ("Studio One")) return StudioOne; if (hostFilename.startsWithIgnoreCase ("Waveform")) return TracktionWaveform; @@ -277,7 +277,7 @@ private: if (hostFilename.containsIgnoreCase ("Cubase8.5.exe")) return SteinbergCubase8_5; // Cubase 9 scans plug-ins with a separate executable "vst2xscanner" if (hostFilename.containsIgnoreCase ("Cubase9.exe") - || hostPath.containsIgnoreCase ("Cubase 9")) return SteinbergCubase9; + || hostPath.containsIgnoreCase ("Cubase 9")) return SteinbergCubase9; if (hostFilename.containsIgnoreCase ("Cubase")) return SteinbergCubaseGeneric; if (hostFilename.containsIgnoreCase ("VSTBridgeApp")) return SteinbergCubase5Bridged; if (hostPath.containsIgnoreCase ("Wavelab 5")) return SteinbergWavelab5; From f97f46730f7b526a5c111e2a69c31cf7160daeb4 Mon Sep 17 00:00:00 2001 From: ed Date: Mon, 11 Sep 2017 12:28:48 +0100 Subject: [PATCH 083/129] BLOCKS: Removed some unimplemented functions --- .../protocol/juce_BlocksProtocolDefinitions.h | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/modules/juce_blocks_basics/protocol/juce_BlocksProtocolDefinitions.h b/modules/juce_blocks_basics/protocol/juce_BlocksProtocolDefinitions.h index 5cf40376b0..5d1c2244c6 100644 --- a/modules/juce_blocks_basics/protocol/juce_BlocksProtocolDefinitions.h +++ b/modules/juce_blocks_basics/protocol/juce_BlocksProtocolDefinitions.h @@ -422,10 +422,10 @@ static constexpr const char* ledProgramLittleFootFunctions[] = "mod/iii", "getRandomFloat/f", "getRandomInt/ii", - "getMillisecondCounter/i", - "getFirmwareVersion/i", "log/vi", "logHex/vi", + "getMillisecondCounter/i", + "getFirmwareVersion/i", "getTimeInCurrentFunctionCall/i", "getBatteryLevel/f", "isBatteryCharging/b", @@ -454,22 +454,12 @@ static constexpr const char* ledProgramLittleFootFunctions[] = "setClusteringActive/vb", "makeARGB/iiiii", "blendARGB/iii", - "setDepthShadingActive/viiiib", - "setBlendType/vi", "fillPixel/viii", "blendPixel/viii", - "drawLine/viiiii", - "blendLine/viiiii", "fillRect/viiiii", "blendRect/viiiii", "blendGradientRect/viiiiiiii", - "fillQuad/vifffffffff", - "blendQuad/viffffffff", "blendCircle/vifffb", - "drawLine3D/viiiiiii", - "blendLine3D/viiiiiii", - "fillQuad3D/viffffffffffff", - "blendQuad3D/viffffffffffff", "addPressurePoint/vifff", "drawPressureMap/v", "fadePressureMap/v", From 31e05ad0148f68e338cbde41a27ab464627b9d6d Mon Sep 17 00:00:00 2001 From: tpoole Date: Mon, 11 Sep 2017 12:42:05 +0100 Subject: [PATCH 084/129] Fixed a bug in the demo plug-in slider class --- examples/audio plugin demo/Source/PluginEditor.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/examples/audio plugin demo/Source/PluginEditor.cpp b/examples/audio plugin demo/Source/PluginEditor.cpp index b784080a2b..75634d9630 100644 --- a/examples/audio plugin demo/Source/PluginEditor.cpp +++ b/examples/audio plugin demo/Source/PluginEditor.cpp @@ -42,13 +42,7 @@ public: updateSliderPos(); } - void valueChanged() override - { - if (isMouseButtonDown()) - param.setValueNotifyingHost ((float) Slider::getValue()); - else - param.setValue ((float) Slider::getValue()); - } + void valueChanged() override { param.setValueNotifyingHost ((float) Slider::getValue()); } void timerCallback() override { updateSliderPos(); } @@ -63,7 +57,7 @@ public: const float newValue = param.getValue(); if (newValue != (float) Slider::getValue() && ! isMouseButtonDown()) - Slider::setValue (newValue); + Slider::setValue (newValue, NotificationType::dontSendNotification); } AudioProcessorParameter& param; From cbdf17a6fb7e1a590331e958d3b0177becde0d58 Mon Sep 17 00:00:00 2001 From: tpoole Date: Mon, 11 Sep 2017 12:55:26 +0100 Subject: [PATCH 085/129] Increased the size of the standalone filter settings window --- .../Standalone/juce_StandaloneFilterWindow.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h b/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h index c85641e90a..4460880427 100644 --- a/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h +++ b/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h @@ -256,7 +256,7 @@ public: totalInChannels, totalOutChannels, totalOutChannels)); - o.content->setSize (500, 450); + o.content->setSize (500, 550); o.dialogTitle = TRANS("Audio/MIDI Settings"); o.dialogBackgroundColour = o.content->getLookAndFeel().findColour (ResizableWindow::backgroundColourId); From c5323d2209cc88d49becc2de0692605ab08f3f95 Mon Sep 17 00:00:00 2001 From: hogliux Date: Mon, 11 Sep 2017 15:57:33 +0100 Subject: [PATCH 086/129] iOS: Fixed an ambiguous reference to AudioBuffer when compiling the AudioUnitPluginFormat host code for iOS --- .../format_types/juce_AudioUnitPluginFormat.mm | 1 - modules/juce_audio_processors/juce_audio_processors.cpp | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm b/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm index db45291f18..65b364950f 100644 --- a/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm +++ b/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm @@ -26,7 +26,6 @@ #if JUCE_PLUGINHOST_AU && (JUCE_MAC || JUCE_IOS) -#include #if JUCE_MAC #include #include diff --git a/modules/juce_audio_processors/juce_audio_processors.cpp b/modules/juce_audio_processors/juce_audio_processors.cpp index 258ba2eefd..0dc59ac937 100644 --- a/modules/juce_audio_processors/juce_audio_processors.cpp +++ b/modules/juce_audio_processors/juce_audio_processors.cpp @@ -60,6 +60,10 @@ #define JUCE_PLUGINHOST_VST3 0 #endif +#if JUCE_PLUGINHOST_AU && (JUCE_MAC || JUCE_IOS) + #include +#endif + //============================================================================== namespace juce { From 9f4648f85689ee5862291d57917a417a4613ef51 Mon Sep 17 00:00:00 2001 From: ed Date: Mon, 11 Sep 2017 17:12:31 +0100 Subject: [PATCH 087/129] Fixed some issues when using a touchscreen to interact with PopupMenus --- .../juce_gui_basics/menus/juce_PopupMenu.cpp | 20 +++++++++++++------ .../native/juce_win32_Windowing.cpp | 1 + 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/modules/juce_gui_basics/menus/juce_PopupMenu.cpp b/modules/juce_gui_basics/menus/juce_PopupMenu.cpp index a36feeb25e..b5d8c19f73 100644 --- a/modules/juce_gui_basics/menus/juce_PopupMenu.cpp +++ b/modules/juce_gui_basics/menus/juce_PopupMenu.cpp @@ -513,13 +513,21 @@ public: MouseSourceState& getMouseState (MouseInputSource source) { + MouseSourceState* mouseState = nullptr; + for (auto* ms : mouseSourceStates) - if (ms->source == source) - return *ms; + { + if (ms->source == source) mouseState = ms; + else if (ms->source.getType() != source.getType()) ms->stopTimer(); + } + + if (mouseState == nullptr) + { + mouseState = new MouseSourceState (*this, source); + mouseSourceStates.add (mouseState); + } - auto ms = new MouseSourceState (*this, source); - mouseSourceStates.add (ms); - return *ms; + return *mouseState; } //============================================================================== @@ -999,7 +1007,7 @@ public: }; //============================================================================== -class MouseSourceState : private Timer +class MouseSourceState : public Timer { public: MouseSourceState (MenuWindow& w, MouseInputSource s) diff --git a/modules/juce_gui_basics/native/juce_win32_Windowing.cpp b/modules/juce_gui_basics/native/juce_win32_Windowing.cpp index c6f97e2f52..cb769925fd 100644 --- a/modules/juce_gui_basics/native/juce_win32_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_win32_Windowing.cpp @@ -2379,6 +2379,7 @@ private: else if (isUp) { modsToSend = modsToSend.withoutMouseButtons(); + currentModifiers = modsToSend; currentTouches.clearTouch (touchIndex); if (! currentTouches.areAnyTouchesActive()) From 28eda21b89d7ee9afa25cff660ce4a710bb64c7c Mon Sep 17 00:00:00 2001 From: hogliux Date: Mon, 11 Sep 2017 17:15:26 +0100 Subject: [PATCH 088/129] VST2: Fixed live-resize issue in Bitwig --- modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp b/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp index ee89f838f5..383d1f17f0 100644 --- a/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp @@ -1266,7 +1266,9 @@ public: { ed->setTopLeftPosition (0, 0); ed->setBounds (ed->getLocalArea (this, getLocalBounds())); - updateWindowSize(); + + if (! getHostType().isBitwigStudio()) + updateWindowSize(); } #if JUCE_MAC && ! JUCE_64BIT From 2eaca0526d3a0635cf79c90a1775efd243c45b93 Mon Sep 17 00:00:00 2001 From: tpoole Date: Tue, 12 Sep 2017 10:00:50 +0100 Subject: [PATCH 089/129] Added another fix to 4dcce50 to support AudioProcessor based parameter selection --- modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm b/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm index 1ee9b0e179..24eb820872 100644 --- a/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm +++ b/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm @@ -918,9 +918,9 @@ public: if (inScope == kAudioUnitScope_Global && juceFilter != nullptr) { const auto index = getJuceIndexForAUParameterID (inID); - auto* param = juceFilter->getParameters().getUnchecked (index); + const auto normValue = juceFilter->getParameter (index); - outValue = param->getValue() * getMaximumParameterValue (index); + outValue = normValue * getMaximumParameterValue (index); return noErr; } @@ -936,9 +936,7 @@ public: if (inScope == kAudioUnitScope_Global && juceFilter != nullptr) { const auto index = getJuceIndexForAUParameterID (inID); - auto* param = juceFilter->getParameters().getUnchecked (index); - - param->setValue (inValue / getMaximumParameterValue (index)); + juceFilter->setParameter (index, inValue / getMaximumParameterValue (index)); return noErr; } From 71d10e750a0fb03c63c32b162c6e103600abe656 Mon Sep 17 00:00:00 2001 From: ed Date: Tue, 12 Sep 2017 10:59:51 +0100 Subject: [PATCH 090/129] Fixed a bug where PopupMenus were being dismissed when opening a submenu using touch input --- .../juce_gui_basics/menus/juce_PopupMenu.cpp | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/modules/juce_gui_basics/menus/juce_PopupMenu.cpp b/modules/juce_gui_basics/menus/juce_PopupMenu.cpp index b5d8c19f73..6c92b07e02 100644 --- a/modules/juce_gui_basics/menus/juce_PopupMenu.cpp +++ b/modules/juce_gui_basics/menus/juce_PopupMenu.cpp @@ -1027,6 +1027,13 @@ public: void timerCallback() override { + #if JUCE_WINDOWS + // touch and pen devices on Windows send an offscreen mouse move after mouse up events + // but we don't want to forward these on as they will dismiss the menu + if ((source.isTouch() || source.isPen()) && ! isValidMousePosition()) + return; + #endif + if (window.windowIsStillValid()) handleMousePosition (source.getScreenPosition().roundToInt()); } @@ -1218,6 +1225,20 @@ private: return true; } + #if JUCE_WINDOWS + bool isValidMousePosition() + { + auto screenPos = source.getScreenPosition(); + auto localPos = (window.activeSubMenu == nullptr) ? window.getLocalPoint (nullptr, screenPos) + : window.activeSubMenu->getLocalPoint (nullptr, screenPos); + + if (localPos.x < 0 && localPos.y < 0) + return false; + + return true; + } + #endif + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MouseSourceState) }; From e2c8e30d7280d1a4cb3748ec488f1ed0691d048e Mon Sep 17 00:00:00 2001 From: hogliux Date: Tue, 12 Sep 2017 10:46:36 +0100 Subject: [PATCH 091/129] Added a ScopedNoDenormal class to temporarily disable denormals --- .../DSP module plugin demo.jucer | 2 +- .../JuceLibraryCode/AppConfig.h | 8 +++++ .../Source/PluginProcessor.cpp | 2 ++ .../Projucer/JuceLibraryCode/BinaryData.cpp | 3 +- extras/Projucer/JuceLibraryCode/BinaryData.h | 2 +- .../jucer_AudioPluginFilterTemplate.cpp | 1 + .../buffers/juce_FloatVectorOperations.h | 30 +++++++++++++++++++ modules/juce_audio_basics/juce_audio_basics.h | 1 + modules/juce_dsp/juce_dsp.h | 25 ++++++++++++++++ .../juce_dsp/processors/juce_Oversampling.cpp | 4 +-- 10 files changed, 73 insertions(+), 5 deletions(-) diff --git a/examples/DSP module plugin demo/DSP module plugin demo.jucer b/examples/DSP module plugin demo/DSP module plugin demo.jucer index 67e37a1318..839660664f 100644 --- a/examples/DSP module plugin demo/DSP module plugin demo.jucer +++ b/examples/DSP module plugin demo/DSP module plugin demo.jucer @@ -125,5 +125,5 @@ - + diff --git a/examples/DSP module plugin demo/JuceLibraryCode/AppConfig.h b/examples/DSP module plugin demo/JuceLibraryCode/AppConfig.h index 69c1fbf2cb..31d8d119c3 100644 --- a/examples/DSP module plugin demo/JuceLibraryCode/AppConfig.h +++ b/examples/DSP module plugin demo/JuceLibraryCode/AppConfig.h @@ -130,6 +130,10 @@ //#define JUCE_FORCE_USE_LEGACY_PARAM_IDS 1 #endif +#ifndef JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE + //#define JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE 1 +#endif + #ifndef JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS //#define JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS 1 #endif @@ -214,6 +218,10 @@ //#define JUCE_DSP_USE_STATIC_FFTW 1 #endif +#ifndef JUCE_DSP_ENABLE_SNAP_TO_ZERO + #define JUCE_DSP_ENABLE_SNAP_TO_ZERO 0 +#endif + //============================================================================== // juce_events flags: diff --git a/examples/DSP module plugin demo/Source/PluginProcessor.cpp b/examples/DSP module plugin demo/Source/PluginProcessor.cpp index 8e9ac479ac..389776a3c8 100644 --- a/examples/DSP module plugin demo/Source/PluginProcessor.cpp +++ b/examples/DSP module plugin demo/Source/PluginProcessor.cpp @@ -114,6 +114,8 @@ void DspModulePluginDemoAudioProcessor::releaseResources() void DspModulePluginDemoAudioProcessor::process (dsp::ProcessContextReplacing context) noexcept { + ScopedNoDenormals noDenormals; + // Input volume applied with a LinearSmoothedValue inputVolume.process (context); diff --git a/extras/Projucer/JuceLibraryCode/BinaryData.cpp b/extras/Projucer/JuceLibraryCode/BinaryData.cpp index ab7a9dda7e..543a94bc05 100644 --- a/extras/Projucer/JuceLibraryCode/BinaryData.cpp +++ b/extras/Projucer/JuceLibraryCode/BinaryData.cpp @@ -1617,6 +1617,7 @@ static const unsigned char temp_binary_data_8[] = "\r\n" "void FILTERCLASSNAME::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)\r\n" "{\r\n" +" ScopedNoDenormals noDenormals;\r\n" " const int totalNumInputChannels = getTotalNumInputChannels();\r\n" " const int totalNumOutputChannels = getTotalNumOutputChannels();\r\n" "\r\n" @@ -7028,7 +7029,7 @@ const char* getNamedResource (const char* resourceNameUTF8, int& numBytes) throw case 0xafccbd3f: numBytes = 3141; return jucer_AudioComponentTemplate_cpp; case 0x27c5a93a: numBytes = 1310; return jucer_AudioPluginEditorTemplate_cpp; case 0x4d0721bf: numBytes = 938; return jucer_AudioPluginEditorTemplate_h; - case 0x51b49ac5: numBytes = 5611; return jucer_AudioPluginFilterTemplate_cpp; + case 0x51b49ac5: numBytes = 5647; return jucer_AudioPluginFilterTemplate_cpp; case 0x488afa0a: numBytes = 2245; return jucer_AudioPluginFilterTemplate_h; case 0xabad7041: numBytes = 2151; return jucer_ComponentTemplate_cpp; case 0xfc72fe86: numBytes = 2064; return jucer_ComponentTemplate_h; diff --git a/extras/Projucer/JuceLibraryCode/BinaryData.h b/extras/Projucer/JuceLibraryCode/BinaryData.h index 1ad41adb5c..798ca25825 100644 --- a/extras/Projucer/JuceLibraryCode/BinaryData.h +++ b/extras/Projucer/JuceLibraryCode/BinaryData.h @@ -33,7 +33,7 @@ namespace BinaryData const int jucer_AudioPluginEditorTemplate_hSize = 938; extern const char* jucer_AudioPluginFilterTemplate_cpp; - const int jucer_AudioPluginFilterTemplate_cppSize = 5611; + const int jucer_AudioPluginFilterTemplate_cppSize = 5647; extern const char* jucer_AudioPluginFilterTemplate_h; const int jucer_AudioPluginFilterTemplate_hSize = 2245; diff --git a/extras/Projucer/Source/BinaryData/jucer_AudioPluginFilterTemplate.cpp b/extras/Projucer/Source/BinaryData/jucer_AudioPluginFilterTemplate.cpp index 64b036e975..bec4e61204 100644 --- a/extras/Projucer/Source/BinaryData/jucer_AudioPluginFilterTemplate.cpp +++ b/extras/Projucer/Source/BinaryData/jucer_AudioPluginFilterTemplate.cpp @@ -131,6 +131,7 @@ bool FILTERCLASSNAME::isBusesLayoutSupported (const BusesLayout& layouts) const void FILTERCLASSNAME::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages) { + ScopedNoDenormals noDenormals; const int totalNumInputChannels = getTotalNumInputChannels(); const int totalNumOutputChannels = getTotalNumOutputChannels(); diff --git a/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.h b/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.h index 708f5ac2aa..c44bbd800f 100644 --- a/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.h +++ b/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.h @@ -221,4 +221,34 @@ public: static void JUCE_CALLTYPE disableDenormalisedNumberSupport() noexcept; }; +//============================================================================== +/** + Helper class providing an RAII-based mechanism for temporarily disabling + denormals on your CPU. +*/ +class ScopedNoDenormals +{ +public: + inline ScopedNoDenormals() noexcept + { + #if JUCE_USE_SSE_INTRINSICS + mxcsr = _mm_getcsr(); + _mm_setcsr (mxcsr | 0x8040); // add the DAZ and FZ bits + #endif + } + + + inline ~ScopedNoDenormals() noexcept + { + #if JUCE_USE_SSE_INTRINSICS + _mm_setcsr (mxcsr); + #endif + } + +private: + #if JUCE_USE_SSE_INTRINSICS + unsigned int mxcsr; + #endif +}; + } // namespace juce diff --git a/modules/juce_audio_basics/juce_audio_basics.h b/modules/juce_audio_basics/juce_audio_basics.h index 023fa4760b..a6c7b85f1e 100644 --- a/modules/juce_audio_basics/juce_audio_basics.h +++ b/modules/juce_audio_basics/juce_audio_basics.h @@ -51,6 +51,7 @@ #include +//============================================================================== #undef Complex // apparently some C libraries actually define these symbols (!) #undef Factor diff --git a/modules/juce_dsp/juce_dsp.h b/modules/juce_dsp/juce_dsp.h index 4566489153..c700684cae 100644 --- a/modules/juce_dsp/juce_dsp.h +++ b/modules/juce_dsp/juce_dsp.h @@ -166,6 +166,23 @@ #define JUCE_DSP_USE_STATIC_FFTW 0 #endif +/** Config: JUCE_DSP_ENABLE_SNAP_TO_ZERO + + Enables code in the dsp module to avoid floating point denormals during the + processing of some of the dsp module's filters. + + Enabling this will add a slight performance overhead to the DSP module's + filters and algorithms. If your audio app already disables denormals altogether + (for exmaple, by using the ScopedNoDenormals class or the + FloatVectorOperations::disableDenormalisedNumberSupport method), then you + can safely disable this flag to shave off a few cpu cycles from the DSP module's + filters and algorithms. +*/ +#ifndef JUCE_DSP_ENABLE_SNAP_TO_ZERO + #define JUCE_DSP_ENABLE_SNAP_TO_ZERO 1 +#endif + + //============================================================================== #undef Complex // apparently some C libraries actually define these symbols (!) #undef Factor @@ -185,11 +202,19 @@ namespace juce This function will work with both primitives and simple containers. */ + #if JUCE_DSP_ENABLE_SNAP_TO_ZERO inline void snapToZero (float& x) noexcept { JUCE_SNAP_TO_ZERO (x); } #ifndef DOXYGEN inline void snapToZero (double& x) noexcept { JUCE_SNAP_TO_ZERO (x); } inline void snapToZero (long double& x) noexcept { JUCE_SNAP_TO_ZERO (x); } #endif + #else + inline void snapToZero (float& x) noexcept { ignoreUnused (x); } + #ifndef DOXYGEN + inline void snapToZero (double& x) noexcept { ignoreUnused (x); } + inline void snapToZero (long double& x) noexcept { ignoreUnused (x); } + #endif + #endif } } } diff --git a/modules/juce_dsp/processors/juce_Oversampling.cpp b/modules/juce_dsp/processors/juce_Oversampling.cpp index c039f484b3..2ce6ea6cb9 100644 --- a/modules/juce_dsp/processors/juce_Oversampling.cpp +++ b/modules/juce_dsp/processors/juce_Oversampling.cpp @@ -444,7 +444,7 @@ public: auto numStages = coefficientsUp.size(); for (auto n = 0; n < numStages; n++) - JUCE_SNAP_TO_ZERO (lv1[n]); + util::snapToZero (lv1[n]); } } else @@ -455,7 +455,7 @@ public: auto numStages = coefficientsDown.size(); for (auto n = 0; n < numStages; n++) - JUCE_SNAP_TO_ZERO (lv1[n]); + util::snapToZero (lv1[n]); } } } From 8483aa4aea3af3522baa5a6ba2c22931e3aa7a02 Mon Sep 17 00:00:00 2001 From: hogliux Date: Tue, 12 Sep 2017 12:09:54 +0100 Subject: [PATCH 092/129] Added a new method NativeMessageBox::showMessageBox which asynchronously opens a native dialog box and calls a C++ lambda when dismissed --- .../windows/juce_AlertWindow.cpp | 31 +++++++++++++++ .../windows/juce_NativeMessageBox.h | 38 +++++++++++++++++-- 2 files changed, 65 insertions(+), 4 deletions(-) diff --git a/modules/juce_gui_basics/windows/juce_AlertWindow.cpp b/modules/juce_gui_basics/windows/juce_AlertWindow.cpp index b019f7d34f..34fe815a27 100644 --- a/modules/juce_gui_basics/windows/juce_AlertWindow.cpp +++ b/modules/juce_gui_basics/windows/juce_AlertWindow.cpp @@ -725,4 +725,35 @@ bool AlertWindow::showNativeDialogBox (const String& title, } #endif +//============================================================================== +struct NativeMessageBoxCallback : ModalComponentManager::Callback +{ + NativeMessageBoxCallback (std::function && lambda) + : callback (static_cast&&> (lambda)) + {} + + void modalStateFinished (int returnValue) override { if (callback) callback (returnValue); } + + std::function callback; + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (NativeMessageBoxCallback); +}; + +void NativeMessageBox::showMessageBox (MessageBoxType dialogType, AlertWindow::AlertIconType iconType, + const String& title, const String& message, + std::function && lambda, Component* associatedComponent) +{ + auto* callback = new NativeMessageBoxCallback (static_cast&&> (lambda)); + + switch (dialogType) + { + case okType: showMessageBoxAsync (iconType, title, message, associatedComponent, callback); break; + case okCancelType: showOkCancelBox (iconType, title, message, associatedComponent, callback); break; + case yesNoType: showYesNoBox (iconType, title, message, associatedComponent, callback); break; + case yesNoCancelType: showYesNoCancelBox (iconType, title, message, associatedComponent, callback); break; + default: + jassertfalse; + } +} + } // namespace juce diff --git a/modules/juce_gui_basics/windows/juce_NativeMessageBox.h b/modules/juce_gui_basics/windows/juce_NativeMessageBox.h index 347dac1161..531d3e1cc9 100644 --- a/modules/juce_gui_basics/windows/juce_NativeMessageBox.h +++ b/modules/juce_gui_basics/windows/juce_NativeMessageBox.h @@ -34,6 +34,15 @@ namespace juce class NativeMessageBox { public: + /** A set of enums describing the type of dialog box */ + enum MessageBoxType + { + okType, /** A message box with a simple ok button. */ + okCancelType, /** A message box with an ok and cancel button. */ + yesNoType, /** A message box with a yes and no button. */ + yesNoCancelType, /** A message box with a yes, no and cancel button. */ + }; + /** Shows a dialog box that just has a message and a single 'ok' button to close it. The box is shown modally, and the method will block until the user has clicked its @@ -53,6 +62,27 @@ public: Component* associatedComponent = nullptr); #endif + /** Shows a dialog box asynchronously triggering a lambda when the user dismisses the box. + + The box will be displayed and placed into a modal state, but this method will return + immediately, and the lambda will be invoked later when the user dismisses the box. + + @param dialogType the type of the dialog + @param iconType the type of icon to show + @param title the headline to show at the top of the box + @param message a longer, more descriptive message to show underneath the title + @param lambda a lambda which will be triggered when the box is dismissed + @param associatedComponent if this is non-null, it specifies the component that the + alert window should be associated with. Depending on the look + and feel, this might be used for positioning of the alert window. + */ + static void JUCE_CALLTYPE showMessageBox (MessageBoxType dialogType, + AlertWindow::AlertIconType iconType, + const String& title, + const String& message, + std::function && lambda = {}, + Component* associatedComponent = nullptr); + /** Shows a dialog box that just has a message and a single 'ok' button to close it. The box will be displayed and placed into a modal state, but this method will return @@ -71,10 +101,10 @@ public: before it gets called. */ static void JUCE_CALLTYPE showMessageBoxAsync (AlertWindow::AlertIconType iconType, - const String& title, - const String& message, - Component* associatedComponent = nullptr, - ModalComponentManager::Callback* callback = nullptr); + const String& title, + const String& message, + Component* associatedComponent = nullptr, + ModalComponentManager::Callback* callback = nullptr); /** Shows a dialog box with two buttons. From ed8270fcda28222d07654cc33538ad97c1c21afb Mon Sep 17 00:00:00 2001 From: hogliux Date: Tue, 12 Sep 2017 12:13:27 +0100 Subject: [PATCH 093/129] Fixed an extra semicolon in the previous commit --- modules/juce_gui_basics/windows/juce_AlertWindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/juce_gui_basics/windows/juce_AlertWindow.cpp b/modules/juce_gui_basics/windows/juce_AlertWindow.cpp index 34fe815a27..b5ecdd9f6a 100644 --- a/modules/juce_gui_basics/windows/juce_AlertWindow.cpp +++ b/modules/juce_gui_basics/windows/juce_AlertWindow.cpp @@ -736,7 +736,7 @@ struct NativeMessageBoxCallback : ModalComponentManager::Callback std::function callback; - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (NativeMessageBoxCallback); + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (NativeMessageBoxCallback) }; void NativeMessageBox::showMessageBox (MessageBoxType dialogType, AlertWindow::AlertIconType iconType, From bab3ce9759d0fd2a7e78aed955fdd2df783d6edc Mon Sep 17 00:00:00 2001 From: tpoole Date: Wed, 13 Sep 2017 08:53:53 +0100 Subject: [PATCH 094/129] AU and AUv3: Enabled JucePlugin_AUHighResolutionParameters by default and combined this breaking change with 4dcce50 --- BREAKING-CHANGES.txt | 16 ++++++++++------ .../AU/juce_AU_Wrapper.mm | 2 +- .../AU/juce_AUv3_Wrapper.mm | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/BREAKING-CHANGES.txt b/BREAKING-CHANGES.txt index 8881e6c93e..986381099b 100644 --- a/BREAKING-CHANGES.txt +++ b/BREAKING-CHANGES.txt @@ -7,14 +7,15 @@ Develop Branch Change ------ The method used to classify AudioUnit, VST3 and AAX plug-in parameters as -either continuous or discrete has changed. +either continuous or discrete has changed, and AudioUnit and AudioUnit v3 +parameters are marked as high precision by default. Possible Issues --------------- -Plug-ins: DAW projects with automation data written by an AudioUnit, VST3 or -AAX plug-in built with JUCE version 5.1.1 or earlier may load incorrectly when -opened by an AudioUnit, VST3 or AAX plug-in built with JUCE version 5.2.0 and -later. +Plug-ins: DAW projects with automation data written by an AudioUnit, AudioUnit +v3 VST3 or AAX plug-in built with JUCE version 5.1.1 or earlier may load +incorrectly when opened by an AudioUnit, AudioUnit v3, VST3 or AAX plug-in +built with JUCE version 5.2.0 and later. Hosts: The AudioPluginInstance::getParameterNumSteps method now returns correct values for AU and VST3 plug-ins. @@ -32,7 +33,10 @@ Rationale The old system for presenting plug-in parameters to a host as either continuous or discrete is inconsistent between plug-in types and lacks sufficient flexibility. This change harmonises the behaviour and allows individual -parameters to be marked as continuous or discrete. +parameters to be marked as continuous or discrete. If AudioUnit and AudioUnit +v3 parameters are not marked as high precision then hosts like Logic Pro only +offer a limited number of parameter values, which again produces different +behaviour for different plug-in types. Change diff --git a/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm b/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm index 24eb820872..19b4ed209c 100644 --- a/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm +++ b/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm @@ -835,7 +835,7 @@ public: | kAudioUnitParameterFlag_HasCFNameString | kAudioUnitParameterFlag_ValuesHaveStrings); - #if JucePlugin_AUHighResolutionParameters + #if ! JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE outParameterInfo.flags |= (UInt32) kAudioUnitParameterFlag_IsHighResolution; #endif diff --git a/modules/juce_audio_plugin_client/AU/juce_AUv3_Wrapper.mm b/modules/juce_audio_plugin_client/AU/juce_AUv3_Wrapper.mm index c2fff35401..9c1700a6e4 100644 --- a/modules/juce_audio_plugin_client/AU/juce_AUv3_Wrapper.mm +++ b/modules/juce_audio_plugin_client/AU/juce_AUv3_Wrapper.mm @@ -1102,7 +1102,7 @@ private: | kAudioUnitParameterFlag_HasCFNameString | kAudioUnitParameterFlag_ValuesHaveStrings); - #if JucePlugin_AUHighResolutionParameters + #if ! JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE flags |= (UInt32) kAudioUnitParameterFlag_IsHighResolution; #endif From 74c7633aab673fbb65ebff5fb930ec1d43ea01bd Mon Sep 17 00:00:00 2001 From: hogliux Date: Wed, 13 Sep 2017 10:06:36 +0100 Subject: [PATCH 095/129] DSP: snapToZero is now a public method of the IIR and StateVariable filters so that they can be called manually after sample by sample processing --- modules/juce_dsp/processors/juce_IIRFilter.h | 7 ++++++- modules/juce_dsp/processors/juce_StateVariableFilter.h | 10 +++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/modules/juce_dsp/processors/juce_IIRFilter.h b/modules/juce_dsp/processors/juce_IIRFilter.h index 63a311b940..056f8210cb 100644 --- a/modules/juce_dsp/processors/juce_IIRFilter.h +++ b/modules/juce_dsp/processors/juce_IIRFilter.h @@ -114,9 +114,14 @@ namespace IIR */ SampleType JUCE_VECTOR_CALLTYPE processSample (SampleType sample) noexcept; + /** Ensure that the state variables are rounded to zero if the state + variables are denormals. This is only needed if you are doing + sample by sample processing. + */ + void snapToZero() noexcept; + private: //============================================================================== - void snapToZero() noexcept; void check(); //============================================================================== diff --git a/modules/juce_dsp/processors/juce_StateVariableFilter.h b/modules/juce_dsp/processors/juce_StateVariableFilter.h index a35bc3dfb2..35d24acb11 100644 --- a/modules/juce_dsp/processors/juce_StateVariableFilter.h +++ b/modules/juce_dsp/processors/juce_StateVariableFilter.h @@ -74,6 +74,12 @@ namespace StateVariableFilter /** Resets the filter's processing pipeline. */ void reset() noexcept { s1 = s2 = SampleType {0}; } + /** Ensure that the state variables are rounded to zero if the state + variables are denormals. This is only needed if you are doing + sample by sample processing. + */ + void snapToZero() noexcept { util::snapToZero (s1); util::snapToZero (s2); } + //============================================================================== /** The parameters of the state variable filter. It's up to the called to ensure that these parameters are modified in a thread-safe way. */ @@ -145,9 +151,7 @@ namespace StateVariableFilter for (size_t i = 0 ; i < n; ++i) output[i] = processLoop (input[i], state); - util::snapToZero (s1); - util::snapToZero (s2); - + snapToZero(); *parameters = state; } From 8b3ab7c15214e44ae8b98e3c72207c596a0f8bfc Mon Sep 17 00:00:00 2001 From: hogliux Date: Wed, 13 Sep 2017 10:43:57 +0100 Subject: [PATCH 096/129] Windows: Remove deprecated direct show macro from JUCE demo --- examples/Demo/Source/Demos/VideoDemo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/Demo/Source/Demos/VideoDemo.cpp b/examples/Demo/Source/Demos/VideoDemo.cpp index 9ce757df03..589dc25aba 100644 --- a/examples/Demo/Source/Demos/VideoDemo.cpp +++ b/examples/Demo/Source/Demos/VideoDemo.cpp @@ -26,7 +26,7 @@ #include "../JuceDemoHeader.h" -#if JUCE_MAC || JUCE_DIRECTSHOW +#if JUCE_MAC || JUCE_WINDOWS //============================================================================== // so that we can easily have two video windows each with a file browser, wrap this up as a class.. From 1291f1a06b00307448ceec0e451ba277a238af0d Mon Sep 17 00:00:00 2001 From: hogliux Date: Wed, 13 Sep 2017 11:14:10 +0100 Subject: [PATCH 097/129] Reverted commit 8483aa4 as the same functionality already existed in JUCE with ModalCallbackFunction. Improved the documentation in NativeMessageBox to mention that class. --- .../windows/juce_AlertWindow.cpp | 31 ---------- .../windows/juce_NativeMessageBox.h | 58 +++++++------------ 2 files changed, 20 insertions(+), 69 deletions(-) diff --git a/modules/juce_gui_basics/windows/juce_AlertWindow.cpp b/modules/juce_gui_basics/windows/juce_AlertWindow.cpp index b5ecdd9f6a..b019f7d34f 100644 --- a/modules/juce_gui_basics/windows/juce_AlertWindow.cpp +++ b/modules/juce_gui_basics/windows/juce_AlertWindow.cpp @@ -725,35 +725,4 @@ bool AlertWindow::showNativeDialogBox (const String& title, } #endif -//============================================================================== -struct NativeMessageBoxCallback : ModalComponentManager::Callback -{ - NativeMessageBoxCallback (std::function && lambda) - : callback (static_cast&&> (lambda)) - {} - - void modalStateFinished (int returnValue) override { if (callback) callback (returnValue); } - - std::function callback; - - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (NativeMessageBoxCallback) -}; - -void NativeMessageBox::showMessageBox (MessageBoxType dialogType, AlertWindow::AlertIconType iconType, - const String& title, const String& message, - std::function && lambda, Component* associatedComponent) -{ - auto* callback = new NativeMessageBoxCallback (static_cast&&> (lambda)); - - switch (dialogType) - { - case okType: showMessageBoxAsync (iconType, title, message, associatedComponent, callback); break; - case okCancelType: showOkCancelBox (iconType, title, message, associatedComponent, callback); break; - case yesNoType: showYesNoBox (iconType, title, message, associatedComponent, callback); break; - case yesNoCancelType: showYesNoCancelBox (iconType, title, message, associatedComponent, callback); break; - default: - jassertfalse; - } -} - } // namespace juce diff --git a/modules/juce_gui_basics/windows/juce_NativeMessageBox.h b/modules/juce_gui_basics/windows/juce_NativeMessageBox.h index 531d3e1cc9..52e6d51872 100644 --- a/modules/juce_gui_basics/windows/juce_NativeMessageBox.h +++ b/modules/juce_gui_basics/windows/juce_NativeMessageBox.h @@ -34,15 +34,6 @@ namespace juce class NativeMessageBox { public: - /** A set of enums describing the type of dialog box */ - enum MessageBoxType - { - okType, /** A message box with a simple ok button. */ - okCancelType, /** A message box with an ok and cancel button. */ - yesNoType, /** A message box with a yes and no button. */ - yesNoCancelType, /** A message box with a yes, no and cancel button. */ - }; - /** Shows a dialog box that just has a message and a single 'ok' button to close it. The box is shown modally, and the method will block until the user has clicked its @@ -62,27 +53,6 @@ public: Component* associatedComponent = nullptr); #endif - /** Shows a dialog box asynchronously triggering a lambda when the user dismisses the box. - - The box will be displayed and placed into a modal state, but this method will return - immediately, and the lambda will be invoked later when the user dismisses the box. - - @param dialogType the type of the dialog - @param iconType the type of icon to show - @param title the headline to show at the top of the box - @param message a longer, more descriptive message to show underneath the title - @param lambda a lambda which will be triggered when the box is dismissed - @param associatedComponent if this is non-null, it specifies the component that the - alert window should be associated with. Depending on the look - and feel, this might be used for positioning of the alert window. - */ - static void JUCE_CALLTYPE showMessageBox (MessageBoxType dialogType, - AlertWindow::AlertIconType iconType, - const String& title, - const String& message, - std::function && lambda = {}, - Component* associatedComponent = nullptr); - /** Shows a dialog box that just has a message and a single 'ok' button to close it. The box will be displayed and placed into a modal state, but this method will return @@ -98,13 +68,16 @@ public: modalStateFinished() when the box is dismissed. The callback object will be owned and deleted by the system, so make sure that it works safely and doesn't keep any references to objects that might be deleted - before it gets called. + before it gets called. You can use the ModalCallbackFunction to easily + pass in a lambda for this parameter. + + @see ModalCallbackFunction */ static void JUCE_CALLTYPE showMessageBoxAsync (AlertWindow::AlertIconType iconType, - const String& title, - const String& message, - Component* associatedComponent = nullptr, - ModalComponentManager::Callback* callback = nullptr); + const String& title, + const String& message, + Component* associatedComponent = nullptr, + ModalComponentManager::Callback* callback = nullptr); /** Shows a dialog box with two buttons. @@ -129,10 +102,13 @@ public: being 1 if the ok button was pressed, or 0 for cancel, The callback object will be owned and deleted by the system, so make sure that it works safely and doesn't keep any references to objects that might be deleted - before it gets called. + before it gets called. You can use the ModalCallbackFunction to easily + pass in a lambda for this parameter. @returns true if button 1 was clicked, false if it was button 2. If the callback parameter is not null, the method always returns false, and the user's choice is delivered later by the callback. + + @see ModalCallbackFunction */ static bool JUCE_CALLTYPE showOkCancelBox (AlertWindow::AlertIconType iconType, const String& title, @@ -169,13 +145,16 @@ public: being 1 if the "yes" button was pressed, 2 for the "no" button, or 0 if it was cancelled, The callback object will be owned and deleted by the system, so make sure that it works safely and doesn't keep any references - to objects that might be deleted before it gets called. + to objects that might be deleted before it gets called. You can use the + ModalCallbackFunction to easily pass in a lambda for this parameter. @returns If the callback parameter has been set, this returns 0. Otherwise, it returns one of the following values: - 0 if 'cancel' was pressed - 1 if 'yes' was pressed - 2 if 'no' was pressed + + @see ModalCallbackFunction */ static int JUCE_CALLTYPE showYesNoCancelBox (AlertWindow::AlertIconType iconType, const String& title, @@ -212,12 +191,15 @@ public: being 1 if the "yes" button was pressed or 0 for the "no" button was pressed. The callback object will be owned and deleted by the system, so make sure that it works safely and doesn't keep any references - to objects that might be deleted before it gets called. + to objects that might be deleted before it gets called. You can use the + ModalCallbackFunction to easily pass in a lambda for this parameter. @returns If the callback parameter has been set, this returns 0. Otherwise, it returns one of the following values: - 0 if 'no' was pressed - 1 if 'yes' was pressed + + @see ModalCallbackFunction */ static int JUCE_CALLTYPE showYesNoBox (AlertWindow::AlertIconType iconType, const String& title, From 4bb58c7d5107ba08293f0dbafdf4bb7763c91bcb Mon Sep 17 00:00:00 2001 From: hogliux Date: Thu, 14 Sep 2017 09:59:53 +0100 Subject: [PATCH 098/129] VST3: respect the editor's constrainer when resizing --- .../VST3/juce_VST3_Wrapper.cpp | 22 +++++++------------ 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp b/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp index 967d3fd31c..11d91f39f5 100644 --- a/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp @@ -881,28 +881,22 @@ private: { if (rectToCheck != nullptr && component != nullptr) { - // checkSizeConstraint - auto juceRect = Rectangle::leftTopRightBottom (rectToCheck->left, rectToCheck->top, - rectToCheck->right, rectToCheck->bottom); - if (auto* editor = component->pluginEditor.get()) { + // checkSizeConstraint + auto juceRect = editor->getLocalArea (component, Rectangle::leftTopRightBottom (rectToCheck->left, rectToCheck->top, + rectToCheck->right, rectToCheck->bottom)); if (auto* constrainer = editor->getConstrainer()) { - auto scaledMin = component->getLocalArea (editor, Rectangle (constrainer->getMinimumWidth(), - constrainer->getMinimumHeight())); - - auto scaledMax = component->getLocalArea (editor, Rectangle (constrainer->getMaximumWidth(), - constrainer->getMaximumHeight())); + Rectangle limits (0, 0, constrainer->getMaximumWidth(), constrainer->getMaximumHeight()); + constrainer->checkBounds (juceRect, editor->getBounds(), limits, false, false, false, false); - juceRect.setSize (jlimit (scaledMin.getWidth(), scaledMax.getWidth(), juceRect.getWidth()), - jlimit (scaledMin.getHeight(), scaledMax.getHeight(), juceRect.getHeight())); + juceRect = component->getLocalArea (editor, juceRect); + rectToCheck->right = rectToCheck->left + juceRect.getWidth(); + rectToCheck->bottom = rectToCheck->top + juceRect.getHeight(); } } - rectToCheck->right = rectToCheck->left + juceRect.getWidth(); - rectToCheck->bottom = rectToCheck->top + juceRect.getHeight(); - return kResultTrue; } From 149201d9518a7bd898ab439ea834d9e9c7d5b820 Mon Sep 17 00:00:00 2001 From: ed Date: Thu, 14 Sep 2017 11:02:20 +0100 Subject: [PATCH 099/129] Display current progress in LookAndFeel_V4 linear ProgressBar --- .../lookandfeel/juce_LookAndFeel_V4.cpp | 14 ++++++++++++-- .../lookandfeel/juce_LookAndFeel_V4.h | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.cpp b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.cpp index e888e91c55..68660d1414 100644 --- a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.cpp +++ b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.cpp @@ -472,10 +472,12 @@ void LookAndFeel_V4::drawProgressBar (Graphics& g, ProgressBar& progressBar, if (width == height) drawCircularProgressBar (g, progressBar, textToShow); else - drawLinearProgressBar (g, progressBar, width, height, progress); + drawLinearProgressBar (g, progressBar, width, height, progress, textToShow); } -void LookAndFeel_V4::drawLinearProgressBar (Graphics& g, ProgressBar& progressBar, int width, int height, double progress) +void LookAndFeel_V4::drawLinearProgressBar (Graphics& g, ProgressBar& progressBar, + int width, int height, + double progress, const String& textToShow) { const auto background = progressBar.findColour (ProgressBar::backgroundColourId); const auto foreground = progressBar.findColour (ProgressBar::foregroundColourId); @@ -522,6 +524,14 @@ void LookAndFeel_V4::drawLinearProgressBar (Graphics& g, ProgressBar& progressBa g.setTiledImageFill (im, 0, 0, 0.85f); g.fillPath (p); } + + if (textToShow.isNotEmpty()) + { + g.setColour (Colour::contrasting (background, foreground)); + g.setFont (height * 0.6f); + + g.drawText (textToShow, 0, 0, width, height, Justification::centred, false); + } } void LookAndFeel_V4::drawCircularProgressBar (Graphics& g, ProgressBar& progressBar, const String& progressText) diff --git a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.h b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.h index 2c03e0f894..ad690d5e1e 100644 --- a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.h +++ b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.h @@ -226,7 +226,7 @@ public: private: //============================================================================== - void drawLinearProgressBar (Graphics&, ProgressBar&, int width, int height, double progress); + void drawLinearProgressBar (Graphics&, ProgressBar&, int width, int height, double progress, const String&); void drawCircularProgressBar (Graphics&, ProgressBar&, const String&); int getPropertyComponentIndent (PropertyComponent&); From 2fed2af66981a859307524f0d1b0161b6f3b16dc Mon Sep 17 00:00:00 2001 From: ed Date: Thu, 14 Sep 2017 11:56:47 +0100 Subject: [PATCH 100/129] Updated the documentation in ProgressBar to reflect the circular, spinning ProgressBar that was added in LookAndFeel_V4 --- modules/juce_gui_basics/widgets/juce_ProgressBar.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/juce_gui_basics/widgets/juce_ProgressBar.h b/modules/juce_gui_basics/widgets/juce_ProgressBar.h index 8837fdff00..c4f5123b25 100644 --- a/modules/juce_gui_basics/widgets/juce_ProgressBar.h +++ b/modules/juce_gui_basics/widgets/juce_ProgressBar.h @@ -35,6 +35,10 @@ namespace juce to keep an eye on a variable that you give it, and will automatically redraw itself when the variable changes. + If using LookAndFeel_V4 a circular spinning progress bar will be drawn if + the width and height of the ProgressBar are equal, otherwise the standard, + linear ProgressBar will be drawn. + For an easy way of running a background task with a dialog box showing its progress, see the ThreadWithProgressWindow class. From 8e9edeff8b2ad7991374aab868b99091f5b9662b Mon Sep 17 00:00:00 2001 From: hogliux Date: Thu, 14 Sep 2017 12:17:01 +0100 Subject: [PATCH 101/129] Ensured that the "textWhenNothingSelected" takes the label font of label's lookandfeel into account --- modules/juce_gui_basics/widgets/juce_ComboBox.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/juce_gui_basics/widgets/juce_ComboBox.cpp b/modules/juce_gui_basics/widgets/juce_ComboBox.cpp index a3f5dd6485..2100c123b8 100644 --- a/modules/juce_gui_basics/widgets/juce_ComboBox.cpp +++ b/modules/juce_gui_basics/widgets/juce_ComboBox.cpp @@ -387,7 +387,7 @@ void ComboBox::paint (Graphics& g) && ! label->isBeingEdited()) { g.setColour (findColour (textColourId).withMultipliedAlpha (0.5f)); - g.setFont (label->getFont()); + g.setFont (label->getLookAndFeel().getLabelFont (*label)); g.drawFittedText (textWhenNothingSelected, label->getBounds().reduced (2, 1), label->getJustificationType(), jmax (1, (int) (label->getHeight() / label->getFont().getHeight()))); From 7bb95a8334d520670ea96a895d98f424c4a00333 Mon Sep 17 00:00:00 2001 From: hogliux Date: Thu, 14 Sep 2017 15:30:56 +0100 Subject: [PATCH 102/129] Android: Ensure that jni headers are included if JUCE_CORE_INCLUDE_JNI_HELPERS is set but JUCE_CORE_INCLUDE_NATIVE_HEADERS isn't --- modules/juce_core/juce_core.h | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/juce_core/juce_core.h b/modules/juce_core/juce_core.h index f1bbc4f029..8cd5913622 100644 --- a/modules/juce_core/juce_core.h +++ b/modules/juce_core/juce_core.h @@ -318,6 +318,7 @@ namespace juce #endif #if JUCE_CORE_INCLUDE_JNI_HELPERS && JUCE_ANDROID + #include #include "native/juce_android_JNIHelpers.h" #endif From 320c3476c4a8b9089d7ef873beb065cf58677194 Mon Sep 17 00:00:00 2001 From: ed Date: Thu, 14 Sep 2017 15:41:09 +0100 Subject: [PATCH 103/129] Added some more documentation to ProgressBar --- modules/juce_gui_basics/widgets/juce_ProgressBar.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/juce_gui_basics/widgets/juce_ProgressBar.h b/modules/juce_gui_basics/widgets/juce_ProgressBar.h index c4f5123b25..d462be1d52 100644 --- a/modules/juce_gui_basics/widgets/juce_ProgressBar.h +++ b/modules/juce_gui_basics/widgets/juce_ProgressBar.h @@ -55,9 +55,10 @@ public: @param progress pass in a reference to a double that you're going to update with your task's progress. The ProgressBar will monitor the value of this variable and will redraw itself - when the value changes. The range is from 0 to 1.0. Obviously - you'd better be careful not to delete this variable while the - ProgressBar still exists! + when the value changes. The range is from 0 to 1.0 and JUCE + LookAndFeel classes will draw a spinning animation for values + outside this range. Obviously you'd better be careful not to + delete this variable while the ProgressBar still exists! */ explicit ProgressBar (double& progress); From 2729625efbd0ab41c6feaaed7fb4310c312e0a8d Mon Sep 17 00:00:00 2001 From: hogliux Date: Thu, 14 Sep 2017 17:16:19 +0100 Subject: [PATCH 104/129] Improved the confusing nomenclature of some of the SIMDRegister typedefs --- .../juce_dsp/containers/juce_SIMDRegister.h | 49 ++++++++++--------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/modules/juce_dsp/containers/juce_SIMDRegister.h b/modules/juce_dsp/containers/juce_SIMDRegister.h index 42840ee39b..ffcb086d9e 100644 --- a/modules/juce_dsp/containers/juce_SIMDRegister.h +++ b/modules/juce_dsp/containers/juce_SIMDRegister.h @@ -61,21 +61,24 @@ template struct SIMDRegister { //============================================================================== + /** The type that represents the individual constituents of the SIMD Register */ + typedef Type ElementType; + + /** STL compatible value_type definition (same as ElementType). */ + typedef ElementType value_type; + /** The corresponding primitive integer type, for example, this will be int32_t if type is a float. */ - typedef typename SIMDInternal::MaskTypeFor::type MaskType; + typedef typename SIMDInternal::MaskTypeFor::type MaskType; //============================================================================== // Here are some types which are needed internally /** The native primitive type (used internally). */ - typedef typename SIMDInternal::PrimitiveType::type ElementType; - - /** STL compatible value_type definition. */ - typedef typename SIMDInternal::PrimitiveType::type value_type; + typedef typename SIMDInternal::PrimitiveType::type PrimitiveType; /** The native operations for this platform and type combination (used internally) */ - typedef SIMDNativeOps NativeOps; + typedef SIMDNativeOps NativeOps; /** The native type (used internally). */ typedef typename NativeOps::vSIMDType vSIMDType; @@ -88,14 +91,14 @@ struct SIMDRegister /** Wrapper for operations which need to be handled differently for complex and scalar types (used internally). */ - typedef CmplxSIMDOps CmplxOps; + typedef CmplxSIMDOps CmplxOps; //============================================================================== /** The size in bytes of this register. */ static constexpr size_t SIMDRegisterSize = sizeof (vSIMDType); /** The number of elements that this vector can hold. */ - static constexpr size_t SIMDNumElements = SIMDRegisterSize / sizeof (Type); + static constexpr size_t SIMDNumElements = SIMDRegisterSize / sizeof (ElementType); vSIMDType value; @@ -106,7 +109,7 @@ struct SIMDRegister //============================================================================== /** Creates a new SIMDRegister from the corresponding scalar primitive. The scalar is extended to all elements of the vector. */ - inline static SIMDRegister JUCE_VECTOR_CALLTYPE expand (Type s) noexcept { return {CmplxOps::expand (s)}; } + inline static SIMDRegister JUCE_VECTOR_CALLTYPE expand (ElementType s) noexcept { return {CmplxOps::expand (s)}; } /** Creates a new SIMDRegister from the internal SIMD type (for example __mm128 for single-precision floating point on SSE architectures). */ @@ -115,18 +118,18 @@ struct SIMDRegister //============================================================================== /** Returns the idx-th element of the receiver. Note that this does not check if idx is larger than the native register size. */ - inline Type JUCE_VECTOR_CALLTYPE operator[] (size_t idx) const noexcept + inline ElementType JUCE_VECTOR_CALLTYPE operator[] (size_t idx) const noexcept { jassert (idx < SIMDNumElements); - return reinterpret_cast (&value) [idx]; + return reinterpret_cast (&value) [idx]; } /** Returns the idx-th element of the receiver. Note that this does not check if idx is larger than the native register size. */ - inline Type& JUCE_VECTOR_CALLTYPE operator[] (size_t idx) noexcept + inline ElementType& JUCE_VECTOR_CALLTYPE operator[] (size_t idx) noexcept { jassert (idx < SIMDNumElements); - return reinterpret_cast (&value) [idx]; + return reinterpret_cast (&value) [idx]; } //============================================================================== @@ -141,16 +144,16 @@ struct SIMDRegister //============================================================================== /** Broadcasts the scalar to all elements of the receiver. */ - inline SIMDRegister& JUCE_VECTOR_CALLTYPE operator= (Type s) noexcept { value = CmplxOps::expand (s); return *this; } + inline SIMDRegister& JUCE_VECTOR_CALLTYPE operator= (ElementType s) noexcept { value = CmplxOps::expand (s); return *this; } /** Adds a scalar to the receiver. */ - inline SIMDRegister& JUCE_VECTOR_CALLTYPE operator+= (Type s) noexcept { value = NativeOps::add (value, CmplxOps::expand (s)); return *this; } + inline SIMDRegister& JUCE_VECTOR_CALLTYPE operator+= (ElementType s) noexcept { value = NativeOps::add (value, CmplxOps::expand (s)); return *this; } /** Subtracts a scalar to the receiver. */ - inline SIMDRegister& JUCE_VECTOR_CALLTYPE operator-= (Type s) noexcept { value = NativeOps::sub (value, CmplxOps::expand (s)); return *this; } + inline SIMDRegister& JUCE_VECTOR_CALLTYPE operator-= (ElementType s) noexcept { value = NativeOps::sub (value, CmplxOps::expand (s)); return *this; } /** Multiplies a scalar to the receiver. */ - inline SIMDRegister& JUCE_VECTOR_CALLTYPE operator*= (Type s) noexcept { value = CmplxOps::mul (value, CmplxOps::expand (s)); return *this; } + inline SIMDRegister& JUCE_VECTOR_CALLTYPE operator*= (ElementType s) noexcept { value = CmplxOps::mul (value, CmplxOps::expand (s)); return *this; } //============================================================================== /** Bit-and the reciver with SIMDRegister v and store the result in the receiver. */ @@ -184,13 +187,13 @@ struct SIMDRegister //============================================================================== /** Returns a vector where each element is the sum of the corresponding element in the receiver and the scalar s.*/ - inline SIMDRegister JUCE_VECTOR_CALLTYPE operator+ (Type s) const noexcept { return { NativeOps::add (value, CmplxOps::expand (s)) }; } + inline SIMDRegister JUCE_VECTOR_CALLTYPE operator+ (ElementType s) const noexcept { return { NativeOps::add (value, CmplxOps::expand (s)) }; } /** Returns a vector where each element is the difference of the corresponding element in the receiver and the scalar s.*/ - inline SIMDRegister JUCE_VECTOR_CALLTYPE operator- (Type s) const noexcept { return { NativeOps::sub (value, CmplxOps::expand (s)) }; } + inline SIMDRegister JUCE_VECTOR_CALLTYPE operator- (ElementType s) const noexcept { return { NativeOps::sub (value, CmplxOps::expand (s)) }; } /** Returns a vector where each element is the difference of the corresponding element in the receiver and the scalar s.*/ - inline SIMDRegister JUCE_VECTOR_CALLTYPE operator* (Type s) const noexcept { return { CmplxOps::mul (value, CmplxOps::expand (s)) }; } + inline SIMDRegister JUCE_VECTOR_CALLTYPE operator* (ElementType s) const noexcept { return { CmplxOps::mul (value, CmplxOps::expand (s)) }; } //============================================================================== /** Returns the bit-and of the receiver and v. */ @@ -262,11 +265,11 @@ struct SIMDRegister //============================================================================== /** Returns a scalar which is the sum of all elements of the receiver. */ - inline Type sum() const noexcept { return CmplxOps::sum (value); } + inline ElementType sum() const noexcept { return CmplxOps::sum (value); } //============================================================================== /** Checks if the given pointer is suffeciently aligned for using SIMD operations. */ - static inline bool isSIMDAligned (Type* ptr) noexcept + static inline bool isSIMDAligned (ElementType* ptr) noexcept { uintptr_t bitmask = SIMDRegisterSize - 1; return (reinterpret_cast (ptr) & bitmask) == 0; @@ -277,7 +280,7 @@ struct SIMDRegister If the current position in memory is already aligned then this method will simply return the pointer. */ - static inline Type* getNextSIMDAlignedPtr (Type* ptr) noexcept + static inline ElementType* getNextSIMDAlignedPtr (ElementType* ptr) noexcept { return snapPointerToAlignment (ptr, SIMDRegisterSize); } From 4f204f405d31ca382dc15e74ea6e6c674e7b04bd Mon Sep 17 00:00:00 2001 From: jules Date: Fri, 15 Sep 2017 09:55:53 +0100 Subject: [PATCH 105/129] Added a method var::hasProperty() --- modules/juce_core/containers/juce_Variant.cpp | 39 ++++++++++++------- modules/juce_core/containers/juce_Variant.h | 2 + 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/modules/juce_core/containers/juce_Variant.cpp b/modules/juce_core/containers/juce_Variant.cpp index 7c517bb886..7a2f3c3c0a 100644 --- a/modules/juce_core/containers/juce_Variant.cpp +++ b/modules/juce_core/containers/juce_Variant.cpp @@ -240,7 +240,7 @@ public: void writeToStream (const ValueUnion& data, OutputStream& output) const override { - const String* const s = getString (data); + auto* s = getString (data); const size_t len = s->getNumBytesAsUTF8() + 1; HeapBlock temp (len); s->copyToUTF8 (temp, len); @@ -282,7 +282,7 @@ public: var clone (const var& original) const override { - if (DynamicObject* d = original.getDynamicObject()) + if (auto* d = original.getDynamicObject()) return d->clone().get(); jassertfalse; // can only clone DynamicObjects! @@ -317,8 +317,8 @@ public: bool equals (const ValueUnion& data, const ValueUnion& otherData, const VariantType& otherType) const noexcept override { - const Array* const thisArray = toArray (data); - const Array* const otherArray = otherType.toArray (otherData); + auto* thisArray = toArray (data); + auto* otherArray = otherType.toArray (otherData); return thisArray == otherArray || (thisArray != nullptr && otherArray != nullptr && *otherArray == *thisArray); } @@ -327,8 +327,12 @@ public: Array arrayCopy; if (auto* array = toArray (original.value)) - for (int i = 0; i < array->size(); ++i) - arrayCopy.add (array->getReference(i).clone()); + { + arrayCopy.ensureStorageAllocated (array->size()); + + for (auto& i : *array) + arrayCopy.add (i.clone()); + } return var (arrayCopy); } @@ -338,11 +342,10 @@ public: if (auto* array = toArray (data)) { MemoryOutputStream buffer (512); - const int numItems = array->size(); - buffer.writeCompressedInt (numItems); + buffer.writeCompressedInt (array->size()); - for (int i = 0; i < numItems; ++i) - array->getReference(i).writeToStream (buffer); + for (auto& i : *array) + i.writeToStream (buffer); output.writeCompressedInt (1 + (int) buffer.getDataSize()); output.writeByte (varMarker_Array); @@ -457,12 +460,12 @@ var::var (const MemoryBlock& v) : type (&VariantType_Binary::instance) { v var::var (const StringArray& v) : type (&VariantType_Array::instance) { Array strings; + strings.ensureStorageAllocated (v.size()); - const int n = v.size(); - for (int i = 0; i < n; ++i) - strings.add (var (v[i])); + for (auto& i : v) + strings.add (var (i)); - value.objectValue = new VariantType_Array::RefCountedArray(strings); + value.objectValue = new VariantType_Array::RefCountedArray (strings); } var::var (ReferenceCountedObject* const object) : type (&VariantType_Object::instance) @@ -607,6 +610,14 @@ var var::getProperty (const Identifier& propertyName, const var& defaultReturnVa return defaultReturnValue; } +bool var::hasProperty (const Identifier& propertyName) const noexcept +{ + if (auto* o = getDynamicObject()) + return o->hasProperty (propertyName); + + return false; +} + var::NativeFunction var::getNativeFunction() const { return isMethod() && (value.methodValue != nullptr) ? *value.methodValue : nullptr; diff --git a/modules/juce_core/containers/juce_Variant.h b/modules/juce_core/containers/juce_Variant.h index 6cb65043aa..3a9cb7d24d 100644 --- a/modules/juce_core/containers/juce_Variant.h +++ b/modules/juce_core/containers/juce_Variant.h @@ -243,6 +243,8 @@ public: /** If this variant is an object, this returns one of its properties, or a default fallback value if the property is not set. */ var getProperty (const Identifier& propertyName, const var& defaultReturnValue) const; + /** Returns true if this variant is an object and if it has the given property. */ + bool hasProperty (const Identifier& propertyName) const noexcept; /** Invokes a named method call with no arguments. */ var call (const Identifier& method) const; From f4d1969753064e3869c4e41bc5311212392d0aab Mon Sep 17 00:00:00 2001 From: jules Date: Fri, 15 Sep 2017 10:09:08 +0100 Subject: [PATCH 106/129] Fixed a few documentation typos --- BREAKING-CHANGES.txt | 716 +++++++++--------- .../AU/juce_AUv3_Wrapper.mm | 2 +- .../processors/juce_AudioProcessor.h | 2 +- 3 files changed, 360 insertions(+), 360 deletions(-) diff --git a/BREAKING-CHANGES.txt b/BREAKING-CHANGES.txt index 986381099b..ecdc63a1b6 100644 --- a/BREAKING-CHANGES.txt +++ b/BREAKING-CHANGES.txt @@ -1,358 +1,358 @@ -JUCE breaking changes -===================== - -Develop Branch -============= - -Change ------- -The method used to classify AudioUnit, VST3 and AAX plug-in parameters as -either continuous or discrete has changed, and AudioUnit and AudioUnit v3 -parameters are marked as high precision by default. - -Possible Issues ---------------- -Plug-ins: DAW projects with automation data written by an AudioUnit, AudioUnit -v3 VST3 or AAX plug-in built with JUCE version 5.1.1 or earlier may load -incorrectly when opened by an AudioUnit, AudioUnit v3, VST3 or AAX plug-in -built with JUCE version 5.2.0 and later. - -Hosts: The AudioPluginInstance::getParameterNumSteps method now returns correct -values for AU and VST3 plug-ins. - -Workaround ----------- -Plug-ins: Enable JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE in the -juce_audio_plugin_client module config page in the Projucer. - -Hosts: Use AudioPluginInstance::getDefaultNumParameterSteps as the number of -steps for all parameters. - -Rationale ---------- -The old system for presenting plug-in parameters to a host as either continuous -or discrete is inconsistent between plug-in types and lacks sufficient -flexibility. This change harmonises the behaviour and allows individual -parameters to be marked as continuous or discrete. If AudioUnit and AudioUnit -v3 parameters are not marked as high precision then hosts like Logic Pro only -offer a limited number of parameter values, which again produces different -behaviour for different plug-in types. - - -Change ------- -A new FrameRateType fps23976 has been added to AudioPlayHead, - -Possible Issues ---------------- -Previously JUCE would report the FrameRateType fps24 for both 24 and 23.976 -fps. If your code uses switch statements (or similar) to handle all possible -frame rate types, then this change may cause it to fall through. - -Workaround ----------- -Add fps23976 to your switch statement and handle it appropriately. - -Rationale ---------- -JUCE should be able to handle all popular frame rate codes but was missing -support for 23.976. - - -Change ------- -The String (bool) constructor and operator<< (String&, bool) have been -explicitly deleted. - -Possible Issues ---------------- -Previous code which relied on an implicit bool to int type conversion to -produce a String will not compile. - -Workaround ----------- -Cast your bool to an integer to generate a string representation of it. - -Rationale ---------- -Letting things implicitly convert to bool to produce a String opens the door to -all kinds of nasty type conversion edge cases. Furthermore, before this change, -MacOS would automatically convert bools to ints but this wouldn't occur on -different platform. Now the behaviour is consistent across all operating -systems supported by JUCE. - - -Change ------- -The writeAsJSON virtual method of the DynamicObject class requires an -additional parameter, maximumDecimalPlaces, to specify the maximum precision of -floating point numbers. - -Possible Issues ---------------- -Classes which inherit from DynamicObject and override this method will need to -update their method signature. - -Workaround ----------- -Your custom DynamicObject class can choose to ignore the additional parameter -if you don't wish to support this behaviour. - -Rationale ---------- -When serialising the results of calculations to JSON the rounding of floating -point numbers can result in numbers with 17 significant figures where only a -few are required. This change to DynamicObject is required to support -truncating those numbers. - - - -Version 5.1.0 -============= - -Change ------- -The option to set the C++ language standard is now located in the project -settings instead of the build configuration settings. - -Possible Issues ---------------- -Projects that had a specific verison of the C++ language standard set for -exporter build configurations will instead use the default (C++11) when -re-saving with the new Projucer. - -Workaround ----------- -Change the "C++ Language Standard" setting in the main project settings to the -required version - the Projucer will add this value to the exported project as -a compiler flag when saving exporters. - -Rationale ---------- -Having a different C++ language standard option for each build configuration -was unnecessary and was not fully implemented for all exporters. Changing it to -a per-project settings means that the preference will propagate to all -exporters and only needs to be set in one place. - - -Change ------- -PopupMenus now scale according to the AffineTransform and scaling factor of -their target components. - -Possible Issues ---------------- -Developers who have manually scaled their PopupMenus to fit the scaling factor -of the parent UI will now have the scaling applied two times in a row. - -Workaround ----------- -1. Do not apply your own manual scaling to make your popups match the UI - scaling - -or - -2. Override the Look&Feel method - PopupMenu::LookAndFeelMethods::shouldPopupMenuScaleWithTargetComponent and - return false. See - https://github.com/WeAreROLI/JUCE/blob/c288c94c2914af20f36c03ca9c5401fcb555e4e9/modules/juce_gui_basics/menus/juce_PopupMenu.h#725 - -Rationale ---------- -Previously, PopupMenus would not scale if the GUI of the target component (or -any of it’s parents) were scaled. The only way to scale PopupMenus was via the -global scaling factor. This had several drawbacks as the global scaling factor -would scale everything. This was especially problematic in plug-in editors. - - -Change ------- -Removed the setSecurityFlags() method from the Windows implementation of -WebInputStream as it disabled HTTPS security features. - -Possible Issues ---------------- -Any code previously relying on connections to insecure webpages succeeding will -no longer work. - -Workaround ----------- -Check network connectivity on Windows and re-write any code that relied on -insecure connections. - -Rationale ---------- -The previous behaviour resulted in network connections on Windows having all -the HTTPS security features disabled, exposing users to network attacks. HTTPS -connections on Windows are now secure and will fail when connecting to an -insecure web address. - - -Change ------- -Pointer arithmetic on a pointer will have the same result regardless if it is -wrapped in JUCE's Atomic class or not. - -Possible Issues ---------------- -Any code using pointer arithmetic on Atomic will now have a different -result leading to undefined behaviour or crashes. - -Workaround ----------- -Re-write your code in a way that it does not depend on your pointer being -wrapped in JUCE's Atomic or not. See rationale. - -Rationale ---------- -Before this change, pointer arithmetic with JUCE's Atomic type would yield -confusing results. For example, the following code would assert before this -change: - -int* a; Atomic b; - -jassert (++a == ++b); - -Pointer a in the above code would be advanced by sizeof(int) whereas the JUCE's -Atomic always advances it's underlying pointer by a single byte. The same is -true for operator+=/operator-= and operator--. The difference in behaviour is -confusing and unintuitive. Furthermore, this aligns JUCE's Atomic type with -std::atomic. - - - -Version 4.3.1 -============= - -Change ------- -JUCE has changed the way native VST3/AudioUnit parameter ids are calculated. - -Possible Issues ---------------- -DAW projects with automation data written by an AudioUnit or VST3 plug-in built -with pre JUCE 4.3.1 versions will load incorrectly when opened by an AudioUnit -or VST3 built with JUCE versions 4.3.1 and later. Plug-ins using -JUCE_FORCE_USE_LEGACY_IDS are not affected. - -Workaround ----------- -Disable JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS in the -juce_audio_plugin_client module config page in the Projucer. For new plug-ins, -be sure to use the default value for this property. - -Rationale --------- -JUCE needs to convert between its own JUCE parameter id format (strings) to the -native parameter id formats of the various plug-in backends. For VST3 and -AudioUnits, JUCE uses a hash function to generate a numeric id. However, some -VST3/AudioUnit hosts (specifically Studio One) have a bug that ignore any -parameters that have a negative parameter id. Therefore, the hash function for -VST3/AudioUnits needed to be changed to only return positive-valued hashes. - - - -Version 4.3.0 -============= - -Change ------- -A revised multi-bus API was released which supersedes the previously flawed -multi-bus API - JUCE versions 4.0.0 - 4.2.4 (inclusive). - -Possible Issues ---------------- -If you have developed a plug-in with JUCE versions 4.0.0 - 4.2.4 (inclusive), -then you will need to update your plug-in to the new multi-bus API. Pre JUCE -4.0.0 plug-ins are not affected apart from other breaking changes listed in -this document. - -Woraround ---------- -None. - -Rationale --------- -A flawed multi-bus API was introduced with JUCE versions 4.0.0 up until version -4.2.4 (inclusive) which was not API compatible with pre JUCE 4 plug-ins. JUCE -4.3.0 releases a revised multi-bus API which restores pre JUCE 4 API -compatibility. However, the new multi-bus API is not compatible with the flawed -multi-bus API (JUCE version 4.0.0 - 4.2.4). - - -Change ------- -JUCE now generates the AAX plug-in bus layout configuration id independent from -the position as it appears in the Projucer’s legacy "Channel layout -configuration" field. - -Possible Issues ---------------- -ProTools projects generated with a < 4.3.0 JUCE versions of your plug-in, may -load the incorrect bus configuration when upgrading your plug-in to >= 4.3.0 -versions of JUCE. - -Workaround ----------- -Implement AudioProcessor’s getAAXPluginIDForMainBusConfig callback to manually -override which AAX plug-in id is associated to a specific bus layout of your -plug-in. This workaround is only necessary if you have released your plug-in -built with a version previous to JUCE 4.3.0. - -Rationale --------- -The new multi-bus API offers more features, flexibility and accuracy in -specifying bus layouts which cannot be expressed by the Projucer’s legacy -"Channel layout configuration" field. The native plug-in format backends use -the new multi-bus callback APIs to negotiate channel layouts with the host - -including the AAX plug-in ids assigned to specific bus layouts. With the -callback API, there is no notion of an order in which the channel -configurations appear - as was the case with the legacy "Channel layout -configuration" field - and therefore cannot be used to generate the AAX plug-in -id. To remain backward compatible to pre JUCE 4.0.0 plug-ins, JUCE does -transparently convert the legacy "Channel layout configuration" field to the -new callback based multi-bus API, but this does not take the order into account -in which the channel configurations appear in the legacy "Channel layout -configuration" field. - - - -Version 4.2.1 -============= - -Change ------- -JUCE now uses the paramID property used in AudioProcessorParameterWithID to -uniquely identify parameters to the host. - -Possible Issues ---------------- -DAW projects with automation data written by an audio plug-in built with pre -JUCE 4.2.1 will load incorrectly when opened by an audio plug-in built with -JUCE 4.2.1 and later. - -Workaround ----------- -Enable JUCE_FORCE_USE_LEGACY_IDS in the juce_audio_plugin_client module config -page in the Projucer. For new plug-ins, be sure to disable this property. - -Rationale --------- -Each parameter of the AudioProcessor has an id associated so that the plug-in’s -host can uniquely identify parameters. The id has a different data-type for -different plug-in types (for example VST uses integers, AAX uses string -identifiers). Before 4.2.1, JUCE generated the parameter id by using the index -of the parameter, i.e. the first parameter had id zero, the second parameter -had id one, etc. This caused problems for certain plug-in types where JUCE -needs to add internal parameters to the plug-in (for example VST3 requires the -bypass control to be a parameter - so JUCE automatically creates this parameter -for you in the VST3 backend). This causes subtle problems if a parameter is -added to an update of an already published plug-in. The new parameter’s id -would be identical to the id of the bypass parameter in old versions of your -plug-in, causing seemingly random plug-in bypass behaviour when user’s upgrade -their plug-in. - -Most plug-in backends differentiate between a parameter’s id an index, so this -distinction was adopted starting with JUCE 4.2.1 by deriving the parameter’s -unique id from the paramID property of AudioProcessorParameterWithID class. - +JUCE breaking changes +===================== + +Develop Branch +============= + +Change +------ +The method used to classify AudioUnit, VST3 and AAX plug-in parameters as +either continuous or discrete has changed, and AudioUnit and AudioUnit v3 +parameters are marked as high precision by default. + +Possible Issues +--------------- +Plug-ins: DAW projects with automation data written by an AudioUnit, AudioUnit +v3 VST3 or AAX plug-in built with JUCE version 5.1.1 or earlier may load +incorrectly when opened by an AudioUnit, AudioUnit v3, VST3 or AAX plug-in +built with JUCE version 5.2.0 and later. + +Hosts: The AudioPluginInstance::getParameterNumSteps method now returns correct +values for AU and VST3 plug-ins. + +Workaround +---------- +Plug-ins: Enable JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE in the +juce_audio_plugin_client module config page in the Projucer. + +Hosts: Use AudioPluginInstance::getDefaultNumParameterSteps as the number of +steps for all parameters. + +Rationale +--------- +The old system for presenting plug-in parameters to a host as either continuous +or discrete is inconsistent between plug-in types and lacks sufficient +flexibility. This change harmonises the behaviour and allows individual +parameters to be marked as continuous or discrete. If AudioUnit and AudioUnit +v3 parameters are not marked as high precision then hosts like Logic Pro only +offer a limited number of parameter values, which again produces different +behaviour for different plug-in types. + + +Change +------ +A new FrameRateType fps23976 has been added to AudioPlayHead, + +Possible Issues +--------------- +Previously JUCE would report the FrameRateType fps24 for both 24 and 23.976 +fps. If your code uses switch statements (or similar) to handle all possible +frame rate types, then this change may cause it to fall through. + +Workaround +---------- +Add fps23976 to your switch statement and handle it appropriately. + +Rationale +--------- +JUCE should be able to handle all popular frame rate codes but was missing +support for 23.976. + + +Change +------ +The String (bool) constructor and operator<< (String&, bool) have been +explicitly deleted. + +Possible Issues +--------------- +Previous code which relied on an implicit bool to int type conversion to +produce a String will not compile. + +Workaround +---------- +Cast your bool to an integer to generate a string representation of it. + +Rationale +--------- +Letting things implicitly convert to bool to produce a String opens the door to +all kinds of nasty type conversion edge cases. Furthermore, before this change, +MacOS would automatically convert bools to ints but this wouldn't occur on +different platform. Now the behaviour is consistent across all operating +systems supported by JUCE. + + +Change +------ +The writeAsJSON virtual method of the DynamicObject class requires an +additional parameter, maximumDecimalPlaces, to specify the maximum precision of +floating point numbers. + +Possible Issues +--------------- +Classes which inherit from DynamicObject and override this method will need to +update their method signature. + +Workaround +---------- +Your custom DynamicObject class can choose to ignore the additional parameter +if you don't wish to support this behaviour. + +Rationale +--------- +When serialising the results of calculations to JSON the rounding of floating +point numbers can result in numbers with 17 significant figures where only a +few are required. This change to DynamicObject is required to support +truncating those numbers. + + + +Version 5.1.0 +============= + +Change +------ +The option to set the C++ language standard is now located in the project +settings instead of the build configuration settings. + +Possible Issues +--------------- +Projects that had a specific verison of the C++ language standard set for +exporter build configurations will instead use the default (C++11) when +re-saving with the new Projucer. + +Workaround +---------- +Change the "C++ Language Standard" setting in the main project settings to the +required version - the Projucer will add this value to the exported project as +a compiler flag when saving exporters. + +Rationale +--------- +Having a different C++ language standard option for each build configuration +was unnecessary and was not fully implemented for all exporters. Changing it to +a per-project settings means that the preference will propagate to all +exporters and only needs to be set in one place. + + +Change +------ +PopupMenus now scale according to the AffineTransform and scaling factor of +their target components. + +Possible Issues +--------------- +Developers who have manually scaled their PopupMenus to fit the scaling factor +of the parent UI will now have the scaling applied two times in a row. + +Workaround +---------- +1. Do not apply your own manual scaling to make your popups match the UI + scaling + +or + +2. Override the Look&Feel method + PopupMenu::LookAndFeelMethods::shouldPopupMenuScaleWithTargetComponent and + return false. See + https://github.com/WeAreROLI/JUCE/blob/c288c94c2914af20f36c03ca9c5401fcb555e4e9/modules/juce_gui_basics/menus/juce_PopupMenu.h#725 + +Rationale +--------- +Previously, PopupMenus would not scale if the GUI of the target component (or +any of it’s parents) were scaled. The only way to scale PopupMenus was via the +global scaling factor. This had several drawbacks as the global scaling factor +would scale everything. This was especially problematic in plug-in editors. + + +Change +------ +Removed the setSecurityFlags() method from the Windows implementation of +WebInputStream as it disabled HTTPS security features. + +Possible Issues +--------------- +Any code previously relying on connections to insecure webpages succeeding will +no longer work. + +Workaround +---------- +Check network connectivity on Windows and re-write any code that relied on +insecure connections. + +Rationale +--------- +The previous behaviour resulted in network connections on Windows having all +the HTTPS security features disabled, exposing users to network attacks. HTTPS +connections on Windows are now secure and will fail when connecting to an +insecure web address. + + +Change +------ +Pointer arithmetic on a pointer will have the same result regardless if it is +wrapped in JUCE's Atomic class or not. + +Possible Issues +--------------- +Any code using pointer arithmetic on Atomic will now have a different +result leading to undefined behaviour or crashes. + +Workaround +---------- +Re-write your code in a way that it does not depend on your pointer being +wrapped in JUCE's Atomic or not. See rationale. + +Rationale +--------- +Before this change, pointer arithmetic with JUCE's Atomic type would yield +confusing results. For example, the following code would assert before this +change: + +int* a; Atomic b; + +jassert (++a == ++b); + +Pointer a in the above code would be advanced by sizeof(int) whereas the JUCE's +Atomic always advances it's underlying pointer by a single byte. The same is +true for operator+=/operator-= and operator--. The difference in behaviour is +confusing and unintuitive. Furthermore, this aligns JUCE's Atomic type with +std::atomic. + + + +Version 4.3.1 +============= + +Change +------ +JUCE has changed the way native VST3/AudioUnit parameter ids are calculated. + +Possible Issues +--------------- +DAW projects with automation data written by an AudioUnit or VST3 plug-in built +with pre JUCE 4.3.1 versions will load incorrectly when opened by an AudioUnit +or VST3 built with JUCE versions 4.3.1 and later. Plug-ins using +JUCE_FORCE_USE_LEGACY_PARAM_IDS are not affected. + +Workaround +---------- +Disable JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS in the +juce_audio_plugin_client module config page in the Projucer. For new plug-ins, +be sure to use the default value for this property. + +Rationale +-------- +JUCE needs to convert between its own JUCE parameter id format (strings) to the +native parameter id formats of the various plug-in backends. For VST3 and +AudioUnits, JUCE uses a hash function to generate a numeric id. However, some +VST3/AudioUnit hosts (specifically Studio One) have a bug that ignore any +parameters that have a negative parameter id. Therefore, the hash function for +VST3/AudioUnits needed to be changed to only return positive-valued hashes. + + + +Version 4.3.0 +============= + +Change +------ +A revised multi-bus API was released which supersedes the previously flawed +multi-bus API - JUCE versions 4.0.0 - 4.2.4 (inclusive). + +Possible Issues +--------------- +If you have developed a plug-in with JUCE versions 4.0.0 - 4.2.4 (inclusive), +then you will need to update your plug-in to the new multi-bus API. Pre JUCE +4.0.0 plug-ins are not affected apart from other breaking changes listed in +this document. + +Woraround +--------- +None. + +Rationale +-------- +A flawed multi-bus API was introduced with JUCE versions 4.0.0 up until version +4.2.4 (inclusive) which was not API compatible with pre JUCE 4 plug-ins. JUCE +4.3.0 releases a revised multi-bus API which restores pre JUCE 4 API +compatibility. However, the new multi-bus API is not compatible with the flawed +multi-bus API (JUCE version 4.0.0 - 4.2.4). + + +Change +------ +JUCE now generates the AAX plug-in bus layout configuration id independent from +the position as it appears in the Projucer’s legacy "Channel layout +configuration" field. + +Possible Issues +--------------- +ProTools projects generated with a < 4.3.0 JUCE versions of your plug-in, may +load the incorrect bus configuration when upgrading your plug-in to >= 4.3.0 +versions of JUCE. + +Workaround +---------- +Implement AudioProcessor’s getAAXPluginIDForMainBusConfig callback to manually +override which AAX plug-in id is associated to a specific bus layout of your +plug-in. This workaround is only necessary if you have released your plug-in +built with a version previous to JUCE 4.3.0. + +Rationale +-------- +The new multi-bus API offers more features, flexibility and accuracy in +specifying bus layouts which cannot be expressed by the Projucer’s legacy +"Channel layout configuration" field. The native plug-in format backends use +the new multi-bus callback APIs to negotiate channel layouts with the host - +including the AAX plug-in ids assigned to specific bus layouts. With the +callback API, there is no notion of an order in which the channel +configurations appear - as was the case with the legacy "Channel layout +configuration" field - and therefore cannot be used to generate the AAX plug-in +id. To remain backward compatible to pre JUCE 4.0.0 plug-ins, JUCE does +transparently convert the legacy "Channel layout configuration" field to the +new callback based multi-bus API, but this does not take the order into account +in which the channel configurations appear in the legacy "Channel layout +configuration" field. + + + +Version 4.2.1 +============= + +Change +------ +JUCE now uses the paramID property used in AudioProcessorParameterWithID to +uniquely identify parameters to the host. + +Possible Issues +--------------- +DAW projects with automation data written by an audio plug-in built with pre +JUCE 4.2.1 will load incorrectly when opened by an audio plug-in built with +JUCE 4.2.1 and later. + +Workaround +---------- +Enable JUCE_FORCE_USE_LEGACY_PARAM_IDS in the juce_audio_plugin_client module config +page in the Projucer. For new plug-ins, be sure to disable this property. + +Rationale +-------- +Each parameter of the AudioProcessor has an id associated so that the plug-in’s +host can uniquely identify parameters. The id has a different data-type for +different plug-in types (for example VST uses integers, AAX uses string +identifiers). Before 4.2.1, JUCE generated the parameter id by using the index +of the parameter, i.e. the first parameter had id zero, the second parameter +had id one, etc. This caused problems for certain plug-in types where JUCE +needs to add internal parameters to the plug-in (for example VST3 requires the +bypass control to be a parameter - so JUCE automatically creates this parameter +for you in the VST3 backend). This causes subtle problems if a parameter is +added to an update of an already published plug-in. The new parameter’s id +would be identical to the id of the bypass parameter in old versions of your +plug-in, causing seemingly random plug-in bypass behaviour when user’s upgrade +their plug-in. + +Most plug-in backends differentiate between a parameter’s id an index, so this +distinction was adopted starting with JUCE 4.2.1 by deriving the parameter’s +unique id from the paramID property of AudioProcessorParameterWithID class. + diff --git a/modules/juce_audio_plugin_client/AU/juce_AUv3_Wrapper.mm b/modules/juce_audio_plugin_client/AU/juce_AUv3_Wrapper.mm index 9c1700a6e4..e12653f3d8 100644 --- a/modules/juce_audio_plugin_client/AU/juce_AUv3_Wrapper.mm +++ b/modules/juce_audio_plugin_client/AU/juce_AUv3_Wrapper.mm @@ -1387,7 +1387,7 @@ private: void valueChangedForObserver(AUParameterAddress, AUValue) { - // this will have already been handled bny valueChangedFromHost + // this will have already been handled by valueChangedFromHost } //============================================================================== diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessor.h b/modules/juce_audio_processors/processors/juce_AudioProcessor.h index 32e828fe84..2106db8646 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessor.h +++ b/modules/juce_audio_processors/processors/juce_AudioProcessor.h @@ -1144,7 +1144,7 @@ public: By default, this returns the "generic" category. NOTE! This method will eventually be deprecated! It's recommended that you use - AudioProcessorParameter::isMetaParameter() instead. + AudioProcessorParameter::getCategory() instead. */ virtual AudioProcessorParameter::Category getParameterCategory (int parameterIndex) const; From 0ae8aa812c9227d945ee99ab2da652251599cbe8 Mon Sep 17 00:00:00 2001 From: tpoole Date: Mon, 18 Sep 2017 14:59:57 +0100 Subject: [PATCH 107/129] Bump version number to 5.1.2 --- BREAKING-CHANGES.txt | 4 +- ChangeList.txt | 114 ++++++++++-------- extras/Projucer/Projucer.jucer | 2 +- modules/juce_audio_basics/juce_audio_basics.h | 2 +- .../juce_audio_devices/juce_audio_devices.h | 2 +- .../juce_audio_formats/juce_audio_formats.h | 2 +- .../juce_audio_plugin_client.h | 4 +- .../juce_audio_processors.h | 2 +- modules/juce_audio_utils/juce_audio_utils.h | 2 +- .../juce_blocks_basics/juce_blocks_basics.h | 2 +- modules/juce_box2d/juce_box2d.h | 2 +- modules/juce_core/juce_core.h | 2 +- .../juce_core/system/juce_StandardHeader.h | 2 +- modules/juce_cryptography/juce_cryptography.h | 2 +- .../juce_data_structures.h | 2 +- modules/juce_dsp/juce_dsp.h | 2 +- modules/juce_events/juce_events.h | 2 +- modules/juce_graphics/juce_graphics.h | 2 +- modules/juce_gui_basics/juce_gui_basics.h | 2 +- modules/juce_gui_extra/juce_gui_extra.h | 2 +- modules/juce_opengl/juce_opengl.h | 2 +- modules/juce_osc/juce_osc.h | 2 +- .../juce_product_unlocking.h | 2 +- modules/juce_video/juce_video.h | 2 +- 24 files changed, 89 insertions(+), 75 deletions(-) diff --git a/BREAKING-CHANGES.txt b/BREAKING-CHANGES.txt index ecdc63a1b6..3b89431975 100644 --- a/BREAKING-CHANGES.txt +++ b/BREAKING-CHANGES.txt @@ -1,7 +1,7 @@ JUCE breaking changes ===================== -Develop Branch +Version 5.1.2 ============= Change @@ -15,7 +15,7 @@ Possible Issues Plug-ins: DAW projects with automation data written by an AudioUnit, AudioUnit v3 VST3 or AAX plug-in built with JUCE version 5.1.1 or earlier may load incorrectly when opened by an AudioUnit, AudioUnit v3, VST3 or AAX plug-in -built with JUCE version 5.2.0 and later. +built with JUCE version 5.1.2 and later. Hosts: The AudioPluginInstance::getParameterNumSteps method now returns correct values for AU and VST3 plug-ins. diff --git a/ChangeList.txt b/ChangeList.txt index 6171704bea..6345d60f49 100644 --- a/ChangeList.txt +++ b/ChangeList.txt @@ -1,56 +1,70 @@ -== Major JUCE features and updates == +== Major JUCE features and updates == This file just lists the more notable headline features. For more detailed info -about minor changes and bugfixes, please see the git log! - -Version 5.1.1 - - Fixed Windows live build engine on Visual Studio 2017 - - Fixed a compiler error in juce_MathFunctions.h in Visual Studio 2013 - - Fixed a potential crash when using the ProcessorDuplicator - - Fixed a compiler-error in Filter::IIR - - Fixed an issue where the WavFileFormatWriter could not create files with discrete channels - - Fixed an issue where a window which is beneath a hidden window would not receive any clicks on Linux - - Altered the format of BREAKING-CHANGES.txt to display better on GitHub - - Projucer: Fixed an issue in exporter tilde expansion - - Fixed compiler errors when building the DSP module with a static version of FFTW - - Fixed an audio glitch when bypassing the convolution engine - - Fixed an issue where a JUCE VST2 would not correctly report that it supports resizing of it’s plugin editor - - Various documentation tweaks and fixes - -Version 5.1.0 - - Release of the JUCE DSP module - - Multichannel audio readers and writers - - Plugin editor Hi-DPI scaling support - - Major improvements to Projucer module search paths - - Added Projucer support for iOS app groups - - Added support for AVFoundation and deprecated the use of Quicktime - - Added a new real-time audio thread priority for Android - - Various Projucer UI fixes - - Various documentation fixes - - Various minor improvements and bug fixes - -Version 5.0.2 - - Improved project save speed in the Projucer - - Added option to save individual exporters in the Projucer - - Added the ability to create custom colour schemes for the Projucer’s code editor - - Minor fixes to JUCE’s SVG parser - - Various bug fixes in the way JUCE handles Hi-DPI monitors - - Improved code browsing in Visual Studio Exports - - Improved the handling of audio device buffer size changes on iOS - - Fixed bug in the Win32 FileChooser dialog when selecting a nonexistent root drive - - Fixed a Projucer crash when saving projects with no targets - - Fixed a bug where Projucer generated Makefiles would not trigger a recompilation when header files had changed - - The standalone plugin target is now compatible with effect plug-ins - - Fixed an issue where it was not possible to use the live build engine on plugin projects - - Improved the way the Projucer’s live-build engine searches for platform headers on Windows - - Fixed an issue where the Projucer would complain about not having internet even if the user had a license - - Fixed a use-after-free in the AUv3 wrapper - - Fixed an issue where the channel layout would not be reported correctly in the AUv3 wrapper - - Fixed a potential memory overrun issue when hosting VST2 plugins with more than eight channels - - Fixed a problem with the Mac main menu bar showing menus in the wrong position - - Various Projucer UI fixes - - Various documentation fixes +about minor changes and bugfixes, please see the git log! + +Version 5.1.2 + - Fixed multiple plugin-resizing bugs + - Added support for AUv3 MIDI and screen size negotiation + - Added support for Xcode 9 and iOS 11 + - Added an In-App Purchases module + - Added backwards compatible constexpr support + - Standalone plug-in improvements + - Better .jucer file change monitoring in the Projucer + - Increased the speed of AU parameter lookup + - Improved the Android thread management when dealing with web requests + - Better denormal support + - Plug-in parameters can be explicitly marked as continuous or discrete + - Multiple documentation updates + +Version 5.1.1 + - Fixed Windows live build engine on Visual Studio 2017 + - Fixed a compiler error in juce_MathFunctions.h in Visual Studio 2013 + - Fixed a potential crash when using the ProcessorDuplicator + - Fixed a compiler-error in Filter::IIR + - Fixed an issue where the WavFileFormatWriter could not create files with discrete channels + - Fixed an issue where a window which is beneath a hidden window would not receive any clicks on Linux + - Altered the format of BREAKING-CHANGES.txt to display better on GitHub + - Projucer: Fixed an issue in exporter tilde expansion + - Fixed compiler errors when building the DSP module with a static version of FFTW + - Fixed an audio glitch when bypassing the convolution engine + - Fixed an issue where a JUCE VST2 would not correctly report that it supports resizing of it’s plugin editor + - Various documentation tweaks and fixes + +Version 5.1.0 + - Release of the JUCE DSP module + - Multichannel audio readers and writers + - Plugin editor Hi-DPI scaling support + - Major improvements to Projucer module search paths + - Added Projucer support for iOS app groups + - Added support for AVFoundation and deprecated the use of Quicktime + - Added a new real-time audio thread priority for Android + - Various Projucer UI fixes + - Various documentation fixes + - Various minor improvements and bug fixes + +Version 5.0.2 + - Improved project save speed in the Projucer + - Added option to save individual exporters in the Projucer + - Added the ability to create custom colour schemes for the Projucer’s code editor + - Minor fixes to JUCE’s SVG parser + - Various bug fixes in the way JUCE handles Hi-DPI monitors + - Improved code browsing in Visual Studio Exports + - Improved the handling of audio device buffer size changes on iOS + - Fixed bug in the Win32 FileChooser dialog when selecting a nonexistent root drive + - Fixed a Projucer crash when saving projects with no targets + - Fixed a bug where Projucer generated Makefiles would not trigger a recompilation when header files had changed + - The standalone plugin target is now compatible with effect plug-ins + - Fixed an issue where it was not possible to use the live build engine on plugin projects + - Improved the way the Projucer’s live-build engine searches for platform headers on Windows + - Fixed an issue where the Projucer would complain about not having internet even if the user had a license + - Fixed a use-after-free in the AUv3 wrapper + - Fixed an issue where the channel layout would not be reported correctly in the AUv3 wrapper + - Fixed a potential memory overrun issue when hosting VST2 plugins with more than eight channels + - Fixed a problem with the Mac main menu bar showing menus in the wrong position + - Various Projucer UI fixes + - Various documentation fixes - Various minor improvements and bug fixes Version 5.0.1 diff --git a/extras/Projucer/Projucer.jucer b/extras/Projucer/Projucer.jucer index 69c9b27a7a..743df4b33b 100644 --- a/extras/Projucer/Projucer.jucer +++ b/extras/Projucer/Projucer.jucer @@ -1,7 +1,7 @@ diff --git a/modules/juce_audio_basics/juce_audio_basics.h b/modules/juce_audio_basics/juce_audio_basics.h index a6c7b85f1e..03c99363f6 100644 --- a/modules/juce_audio_basics/juce_audio_basics.h +++ b/modules/juce_audio_basics/juce_audio_basics.h @@ -31,7 +31,7 @@ ID: juce_audio_basics vendor: juce - version: 5.1.1 + version: 5.1.2 name: JUCE audio and MIDI data classes description: Classes for audio buffer manipulation, midi message handling, synthesis, etc. website: http://www.juce.com/juce diff --git a/modules/juce_audio_devices/juce_audio_devices.h b/modules/juce_audio_devices/juce_audio_devices.h index 6dddca865e..9b26405daf 100644 --- a/modules/juce_audio_devices/juce_audio_devices.h +++ b/modules/juce_audio_devices/juce_audio_devices.h @@ -31,7 +31,7 @@ ID: juce_audio_devices vendor: juce - version: 5.1.1 + version: 5.1.2 name: JUCE audio and MIDI I/O device classes description: Classes to play and record from audio and MIDI I/O devices website: http://www.juce.com/juce diff --git a/modules/juce_audio_formats/juce_audio_formats.h b/modules/juce_audio_formats/juce_audio_formats.h index 4fa9e79eeb..c1664704b2 100644 --- a/modules/juce_audio_formats/juce_audio_formats.h +++ b/modules/juce_audio_formats/juce_audio_formats.h @@ -35,7 +35,7 @@ ID: juce_audio_formats vendor: juce - version: 5.1.1 + version: 5.1.2 name: JUCE audio file format codecs description: Classes for reading and writing various audio file formats. website: http://www.juce.com/juce diff --git a/modules/juce_audio_plugin_client/juce_audio_plugin_client.h b/modules/juce_audio_plugin_client/juce_audio_plugin_client.h index 8dcb2d4adf..c9e017bf71 100644 --- a/modules/juce_audio_plugin_client/juce_audio_plugin_client.h +++ b/modules/juce_audio_plugin_client/juce_audio_plugin_client.h @@ -35,7 +35,7 @@ ID: juce_audio_plugin_client vendor: juce - version: 5.1.1 + version: 5.1.2 name: JUCE audio plugin wrapper classes description: Classes for building VST, VST3, AudioUnit, AAX and RTAS plugins. website: http://www.juce.com/juce @@ -72,7 +72,7 @@ DAW projects with automation data written by an AudioUnit, VST3 or AAX plug-in built with JUCE version 5.1.1 or earlier may load incorrectly when opened by an AudioUnit, VST3 or AAX plug-in built - with JUCE version 5.2.0 and later. + with JUCE version 5.1.2 and later. */ #ifndef JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE #define JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE 0 diff --git a/modules/juce_audio_processors/juce_audio_processors.h b/modules/juce_audio_processors/juce_audio_processors.h index 4645514b88..ff0b4f730e 100644 --- a/modules/juce_audio_processors/juce_audio_processors.h +++ b/modules/juce_audio_processors/juce_audio_processors.h @@ -35,7 +35,7 @@ ID: juce_audio_processors vendor: juce - version: 5.1.1 + version: 5.1.2 name: JUCE audio processor classes description: Classes for loading and playing VST, AU, or internally-generated audio processors. website: http://www.juce.com/juce diff --git a/modules/juce_audio_utils/juce_audio_utils.h b/modules/juce_audio_utils/juce_audio_utils.h index d8816ef2d6..0707c72b16 100644 --- a/modules/juce_audio_utils/juce_audio_utils.h +++ b/modules/juce_audio_utils/juce_audio_utils.h @@ -35,7 +35,7 @@ ID: juce_audio_utils vendor: juce - version: 5.1.1 + version: 5.1.2 name: JUCE extra audio utility classes description: Classes for audio-related GUI and miscellaneous tasks. website: http://www.juce.com/juce diff --git a/modules/juce_blocks_basics/juce_blocks_basics.h b/modules/juce_blocks_basics/juce_blocks_basics.h index 700592fbc2..07df52e68c 100644 --- a/modules/juce_blocks_basics/juce_blocks_basics.h +++ b/modules/juce_blocks_basics/juce_blocks_basics.h @@ -31,7 +31,7 @@ ID: juce_blocks_basics vendor: juce - version: 5.1.1 + version: 5.1.2 name: Provides low-level control over ROLI BLOCKS devices description: JUCE wrapper for low-level control over ROLI BLOCKS devices. website: http://developer.roli.com diff --git a/modules/juce_box2d/juce_box2d.h b/modules/juce_box2d/juce_box2d.h index 2eb94954aa..7c2902e472 100644 --- a/modules/juce_box2d/juce_box2d.h +++ b/modules/juce_box2d/juce_box2d.h @@ -35,7 +35,7 @@ ID: juce_box2d vendor: juce - version: 5.1.1 + version: 5.1.2 name: JUCE wrapper for the Box2D physics engine description: The Box2D physics engine and some utility classes. website: http://www.juce.com/juce diff --git a/modules/juce_core/juce_core.h b/modules/juce_core/juce_core.h index 8cd5913622..f340710800 100644 --- a/modules/juce_core/juce_core.h +++ b/modules/juce_core/juce_core.h @@ -32,7 +32,7 @@ ID: juce_core vendor: juce - version: 5.1.1 + version: 5.1.2 name: JUCE core classes description: The essential set of basic JUCE classes, as required by all the other JUCE modules. Includes text, container, memory, threading and i/o functionality. website: http://www.juce.com/juce diff --git a/modules/juce_core/system/juce_StandardHeader.h b/modules/juce_core/system/juce_StandardHeader.h index c658514eb6..f194fe4477 100644 --- a/modules/juce_core/system/juce_StandardHeader.h +++ b/modules/juce_core/system/juce_StandardHeader.h @@ -29,7 +29,7 @@ */ #define JUCE_MAJOR_VERSION 5 #define JUCE_MINOR_VERSION 1 -#define JUCE_BUILDNUMBER 1 +#define JUCE_BUILDNUMBER 2 /** Current Juce version number. diff --git a/modules/juce_cryptography/juce_cryptography.h b/modules/juce_cryptography/juce_cryptography.h index 07b5494658..3d9f6e5c45 100644 --- a/modules/juce_cryptography/juce_cryptography.h +++ b/modules/juce_cryptography/juce_cryptography.h @@ -35,7 +35,7 @@ ID: juce_cryptography vendor: juce - version: 5.1.1 + version: 5.1.2 name: JUCE cryptography classes description: Classes for various basic cryptography functions, including RSA, Blowfish, MD5, SHA, etc. website: http://www.juce.com/juce diff --git a/modules/juce_data_structures/juce_data_structures.h b/modules/juce_data_structures/juce_data_structures.h index 183df62279..7856e1917c 100644 --- a/modules/juce_data_structures/juce_data_structures.h +++ b/modules/juce_data_structures/juce_data_structures.h @@ -35,7 +35,7 @@ ID: juce_data_structures vendor: juce - version: 5.1.1 + version: 5.1.2 name: JUCE data model helper classes description: Classes for undo/redo management, and smart data structures. website: http://www.juce.com/juce diff --git a/modules/juce_dsp/juce_dsp.h b/modules/juce_dsp/juce_dsp.h index c700684cae..c85da40d8b 100644 --- a/modules/juce_dsp/juce_dsp.h +++ b/modules/juce_dsp/juce_dsp.h @@ -36,7 +36,7 @@ ID: juce_dsp vendor: juce - version: 5.1.1 + version: 5.1.2 name: JUCE DSP classes description: Classes for audio buffer manipulation, digital audio processing, filtering, oversampling, fast math functions etc. website: http://www.juce.com/juce diff --git a/modules/juce_events/juce_events.h b/modules/juce_events/juce_events.h index b451c40d6f..d0340e1fd4 100644 --- a/modules/juce_events/juce_events.h +++ b/modules/juce_events/juce_events.h @@ -31,7 +31,7 @@ ID: juce_events vendor: juce - version: 5.1.1 + version: 5.1.2 name: JUCE message and event handling classes description: Classes for running an application's main event loop and sending/receiving messages, timers, etc. website: http://www.juce.com/juce diff --git a/modules/juce_graphics/juce_graphics.h b/modules/juce_graphics/juce_graphics.h index 29b19b1370..41693ec5fb 100644 --- a/modules/juce_graphics/juce_graphics.h +++ b/modules/juce_graphics/juce_graphics.h @@ -35,7 +35,7 @@ ID: juce_graphics vendor: juce - version: 5.1.1 + version: 5.1.2 name: JUCE graphics classes description: Classes for 2D vector graphics, image loading/saving, font handling, etc. website: http://www.juce.com/juce diff --git a/modules/juce_gui_basics/juce_gui_basics.h b/modules/juce_gui_basics/juce_gui_basics.h index 5ddb188b3e..aed77635ca 100644 --- a/modules/juce_gui_basics/juce_gui_basics.h +++ b/modules/juce_gui_basics/juce_gui_basics.h @@ -35,7 +35,7 @@ ID: juce_gui_basics vendor: juce - version: 5.1.1 + version: 5.1.2 name: JUCE GUI core classes description: Basic user-interface components and related classes. website: http://www.juce.com/juce diff --git a/modules/juce_gui_extra/juce_gui_extra.h b/modules/juce_gui_extra/juce_gui_extra.h index e01397a1f0..a5bcc30a7a 100644 --- a/modules/juce_gui_extra/juce_gui_extra.h +++ b/modules/juce_gui_extra/juce_gui_extra.h @@ -35,7 +35,7 @@ ID: juce_gui_extra vendor: juce - version: 5.1.1 + version: 5.1.2 name: JUCE extended GUI classes description: Miscellaneous GUI classes for specialised tasks. website: http://www.juce.com/juce diff --git a/modules/juce_opengl/juce_opengl.h b/modules/juce_opengl/juce_opengl.h index a0094d2fc4..edad48042e 100644 --- a/modules/juce_opengl/juce_opengl.h +++ b/modules/juce_opengl/juce_opengl.h @@ -35,7 +35,7 @@ ID: juce_opengl vendor: juce - version: 5.1.1 + version: 5.1.2 name: JUCE OpenGL classes description: Classes for rendering OpenGL in a JUCE window. website: http://www.juce.com/juce diff --git a/modules/juce_osc/juce_osc.h b/modules/juce_osc/juce_osc.h index 79b772e07d..04961e9b41 100644 --- a/modules/juce_osc/juce_osc.h +++ b/modules/juce_osc/juce_osc.h @@ -35,7 +35,7 @@ ID: juce_osc vendor: juce - version: 5.1.1 + version: 5.1.2 name: JUCE OSC classes description: Open Sound Control implementation. website: http://www.juce.com/juce diff --git a/modules/juce_product_unlocking/juce_product_unlocking.h b/modules/juce_product_unlocking/juce_product_unlocking.h index 9e6cae807f..2f52f17354 100644 --- a/modules/juce_product_unlocking/juce_product_unlocking.h +++ b/modules/juce_product_unlocking/juce_product_unlocking.h @@ -35,7 +35,7 @@ ID: juce_product_unlocking vendor: juce - version: 5.1.1 + version: 5.1.2 name: JUCE Online marketplace support description: Classes for online product authentication website: http://www.juce.com/juce diff --git a/modules/juce_video/juce_video.h b/modules/juce_video/juce_video.h index 4fe138e0f0..b8ae9f3fdb 100644 --- a/modules/juce_video/juce_video.h +++ b/modules/juce_video/juce_video.h @@ -36,7 +36,7 @@ ID: juce_video vendor: juce - version: 5.1.1 + version: 5.1.2 name: JUCE video playback and capture classes description: Classes for playing video and capturing camera input. website: http://www.juce.com/juce From 9fc21a8d5a51be7b081e3ed9a60c6c96b50d5b85 Mon Sep 17 00:00:00 2001 From: tpoole Date: Mon, 18 Sep 2017 15:05:30 +0100 Subject: [PATCH 108/129] Re-saved all projects --- examples/AUv3Synth/AUv3Synth.jucer | 2 +- examples/AUv3Synth/JuceLibraryCode/AppConfig.h | 4 ++++ examples/AnimationAppExample/AnimationAppExample.jucer | 2 +- examples/AudioAppExample/AudioAppExample.jucer | 2 +- examples/BLOCKS/BlocksDrawing/BlocksDrawing.jucer | 2 +- examples/BLOCKS/BlocksMonitor/BlocksMonitor.jucer | 2 +- examples/BLOCKS/BlocksSynth/BlocksSynth.jucer | 2 +- .../BouncingBallWavetableDemo.jucer | 2 +- .../ComponentTutorialExample.jucer | 2 +- .../DSP module plugin demo/DSP module plugin demo.jucer | 2 +- examples/DSPDemo/DSPDemo.jucer | 2 +- examples/DSPDemo/JuceLibraryCode/AppConfig.h | 4 ++++ examples/Demo/JuceDemo.jucer | 2 +- examples/HelloWorld/HelloWorld.jucer | 2 +- examples/InAppPurchase/InAppPurchase.jucer | 2 +- examples/MPETest/MPETest.jucer | 2 +- examples/MidiTest/MidiTest.jucer | 2 +- examples/NetworkGraphicsDemo/NetworkGraphicsDemo.jucer | 2 +- examples/OSCMonitor/OSCMonitor.jucer | 2 +- examples/OSCReceiver/OSCReceiver.jucer | 2 +- examples/OSCSender/OSCSender.jucer | 2 +- examples/OpenGLAppExample/OpenGLAppExample.jucer | 2 +- examples/PluckedStringsDemo/PluckedStringsDemo.jucer | 2 +- examples/PlugInSamples/Arpeggiator/Arpeggiator.jucer | 2 +- .../PlugInSamples/Arpeggiator/JuceLibraryCode/AppConfig.h | 4 ++++ examples/PlugInSamples/GainPlugIn/GainPlugIn.jucer | 2 +- .../PlugInSamples/GainPlugIn/JuceLibraryCode/AppConfig.h | 4 ++++ .../InterAppAudioEffect/InterAppAudioEffect.jucer | 2 +- .../InterAppAudioEffect/JuceLibraryCode/AppConfig.h | 4 ++++ .../MultiOutSynth/JuceLibraryCode/AppConfig.h | 4 ++++ examples/PlugInSamples/MultiOutSynth/MultiOutSynth.jucer | 2 +- .../PlugInSamples/NoiseGate/JuceLibraryCode/AppConfig.h | 4 ++++ examples/PlugInSamples/NoiseGate/NoiseGate.jucer | 2 +- .../PlugInSamples/Surround/JuceLibraryCode/AppConfig.h | 4 ++++ examples/PlugInSamples/Surround/Surround.jucer | 2 +- examples/SimpleFFTExample/JuceLibraryCode/AppConfig.h | 4 ++++ examples/SimpleFFTExample/SimpleFFTExample.jucer | 2 +- .../Builds/iOS/Info-AUv3_AppExtension.plist | 2 ++ .../Builds/iOS/Info-Standalone_Plugin.plist | 2 ++ examples/audio plugin demo/JuceDemoPlugin.jucer | 2 +- examples/audio plugin demo/JuceLibraryCode/AppConfig.h | 4 ++++ examples/audio plugin host/Plugin Host.jucer | 2 +- extras/AudioPerformanceTest/AudioPerformanceTest.jucer | 2 +- extras/Projucer/Builds/LinuxMakefile/Makefile | 4 ++-- extras/Projucer/Builds/MacOSX/Info-App.plist | 4 ++-- .../Builds/MacOSX/Projucer.xcodeproj/project.pbxproj | 8 ++++---- .../Projucer/Builds/VisualStudio2013/Projucer_App.vcxproj | 4 ++-- extras/Projucer/Builds/VisualStudio2013/resources.rc | 6 +++--- .../Projucer/Builds/VisualStudio2015/Projucer_App.vcxproj | 4 ++-- extras/Projucer/Builds/VisualStudio2015/resources.rc | 6 +++--- .../Projucer/Builds/VisualStudio2017/Projucer_App.vcxproj | 4 ++-- extras/Projucer/Builds/VisualStudio2017/resources.rc | 6 +++--- extras/Projucer/JuceLibraryCode/JuceHeader.h | 4 ++-- extras/Projucer/Projucer.jucer | 2 +- extras/UnitTestRunner/JuceLibraryCode/AppConfig.h | 4 ++++ extras/UnitTestRunner/UnitTestRunner.jucer | 2 +- extras/binarybuilder/BinaryBuilder.jucer | 2 +- extras/windows dll/jucedll.jucer | 2 +- 58 files changed, 108 insertions(+), 60 deletions(-) diff --git a/examples/AUv3Synth/AUv3Synth.jucer b/examples/AUv3Synth/AUv3Synth.jucer index 0c7c06a559..7b17373909 100644 --- a/examples/AUv3Synth/AUv3Synth.jucer +++ b/examples/AUv3Synth/AUv3Synth.jucer @@ -8,7 +8,7 @@ pluginCode="AUv3" pluginChannelConfigs="" pluginIsSynth="1" pluginWantsMidiIn="1" pluginProducesMidiOut="0" pluginIsMidiEffectPlugin="0" pluginEditorRequiresKeys="0" pluginAUExportPrefix="AUv3SynthAU" pluginRTASCategory="" aaxIdentifier="com.roli.development.AUv3Synth" - pluginAAXCategory="AAX_ePlugInCategory_Dynamics" jucerVersion="5.1.1" + pluginAAXCategory="AAX_ePlugInCategory_Dynamics" jucerVersion="5.1.2" buildStandalone="1" enableIAA="0" displaySplashScreen="0" reportAppUsage="0" splashScreenColour="Dark" companyName="ROLI Ltd." cppLanguageStandard="11"> diff --git a/examples/AUv3Synth/JuceLibraryCode/AppConfig.h b/examples/AUv3Synth/JuceLibraryCode/AppConfig.h index 2e47abbced..9fe27141c5 100644 --- a/examples/AUv3Synth/JuceLibraryCode/AppConfig.h +++ b/examples/AUv3Synth/JuceLibraryCode/AppConfig.h @@ -128,6 +128,10 @@ //#define JUCE_FORCE_USE_LEGACY_PARAM_IDS 1 #endif +#ifndef JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE + //#define JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE 1 +#endif + #ifndef JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS //#define JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS 1 #endif diff --git a/examples/AnimationAppExample/AnimationAppExample.jucer b/examples/AnimationAppExample/AnimationAppExample.jucer index e43013d113..2e7b99820b 100644 --- a/examples/AnimationAppExample/AnimationAppExample.jucer +++ b/examples/AnimationAppExample/AnimationAppExample.jucer @@ -2,7 +2,7 @@ diff --git a/examples/AudioAppExample/AudioAppExample.jucer b/examples/AudioAppExample/AudioAppExample.jucer index b4d3b3527e..2bf41dc1cc 100644 --- a/examples/AudioAppExample/AudioAppExample.jucer +++ b/examples/AudioAppExample/AudioAppExample.jucer @@ -2,7 +2,7 @@ diff --git a/examples/BLOCKS/BlocksDrawing/BlocksDrawing.jucer b/examples/BLOCKS/BlocksDrawing/BlocksDrawing.jucer index e34cd4f0ec..628bc9205b 100644 --- a/examples/BLOCKS/BlocksDrawing/BlocksDrawing.jucer +++ b/examples/BLOCKS/BlocksDrawing/BlocksDrawing.jucer @@ -2,7 +2,7 @@ diff --git a/examples/BLOCKS/BlocksMonitor/BlocksMonitor.jucer b/examples/BLOCKS/BlocksMonitor/BlocksMonitor.jucer index f60f16577d..e6dbb8b747 100644 --- a/examples/BLOCKS/BlocksMonitor/BlocksMonitor.jucer +++ b/examples/BLOCKS/BlocksMonitor/BlocksMonitor.jucer @@ -2,7 +2,7 @@ diff --git a/examples/BLOCKS/BlocksSynth/BlocksSynth.jucer b/examples/BLOCKS/BlocksSynth/BlocksSynth.jucer index c6b5c4543a..6bd522aea2 100644 --- a/examples/BLOCKS/BlocksSynth/BlocksSynth.jucer +++ b/examples/BLOCKS/BlocksSynth/BlocksSynth.jucer @@ -2,7 +2,7 @@ diff --git a/examples/BouncingBallWavetableDemo/BouncingBallWavetableDemo.jucer b/examples/BouncingBallWavetableDemo/BouncingBallWavetableDemo.jucer index 7242e4f028..3f2ad15dc2 100644 --- a/examples/BouncingBallWavetableDemo/BouncingBallWavetableDemo.jucer +++ b/examples/BouncingBallWavetableDemo/BouncingBallWavetableDemo.jucer @@ -2,7 +2,7 @@ diff --git a/examples/ComponentTutorialExample/ComponentTutorialExample.jucer b/examples/ComponentTutorialExample/ComponentTutorialExample.jucer index 206f63e255..fa6139fa01 100644 --- a/examples/ComponentTutorialExample/ComponentTutorialExample.jucer +++ b/examples/ComponentTutorialExample/ComponentTutorialExample.jucer @@ -2,7 +2,7 @@ diff --git a/examples/DSP module plugin demo/DSP module plugin demo.jucer b/examples/DSP module plugin demo/DSP module plugin demo.jucer index 839660664f..102740cc95 100644 --- a/examples/DSP module plugin demo/DSP module plugin demo.jucer +++ b/examples/DSP module plugin demo/DSP module plugin demo.jucer @@ -11,7 +11,7 @@ pluginProducesMidiOut="0" pluginIsMidiEffectPlugin="0" pluginEditorRequiresKeys="0" pluginAUExportPrefix="DSPmoduleplugindemoAU" pluginRTASCategory="" aaxIdentifier="com.yourcompany.DSPmoduleplugindemo" pluginAAXCategory="AAX_ePlugInCategory_Dynamics" - jucerVersion="5.1.1" companyName="ROLI Ltd." companyWebsite="www.juce.com" + jucerVersion="5.1.2" companyName="ROLI Ltd." companyWebsite="www.juce.com" companyEmail="info@juce.com" cppLanguageStandard="14"> diff --git a/examples/DSPDemo/DSPDemo.jucer b/examples/DSPDemo/DSPDemo.jucer index f7122fb571..2535f5fa48 100644 --- a/examples/DSPDemo/DSPDemo.jucer +++ b/examples/DSPDemo/DSPDemo.jucer @@ -3,7 +3,7 @@ diff --git a/examples/DSPDemo/JuceLibraryCode/AppConfig.h b/examples/DSPDemo/JuceLibraryCode/AppConfig.h index 877ee18bfd..e24fe2a763 100644 --- a/examples/DSPDemo/JuceLibraryCode/AppConfig.h +++ b/examples/DSPDemo/JuceLibraryCode/AppConfig.h @@ -201,6 +201,10 @@ //#define JUCE_DSP_USE_STATIC_FFTW 1 #endif +#ifndef JUCE_DSP_ENABLE_SNAP_TO_ZERO + //#define JUCE_DSP_ENABLE_SNAP_TO_ZERO 1 +#endif + //============================================================================== // juce_events flags: diff --git a/examples/Demo/JuceDemo.jucer b/examples/Demo/JuceDemo.jucer index 7cfc8cddde..6f91ac3866 100644 --- a/examples/Demo/JuceDemo.jucer +++ b/examples/Demo/JuceDemo.jucer @@ -1,7 +1,7 @@ diff --git a/examples/HelloWorld/HelloWorld.jucer b/examples/HelloWorld/HelloWorld.jucer index c62cfb62a5..9c27df9b70 100644 --- a/examples/HelloWorld/HelloWorld.jucer +++ b/examples/HelloWorld/HelloWorld.jucer @@ -1,7 +1,7 @@ diff --git a/examples/InAppPurchase/InAppPurchase.jucer b/examples/InAppPurchase/InAppPurchase.jucer index 98e28db6ac..4f2cd498a0 100644 --- a/examples/InAppPurchase/InAppPurchase.jucer +++ b/examples/InAppPurchase/InAppPurchase.jucer @@ -3,7 +3,7 @@ diff --git a/examples/MPETest/MPETest.jucer b/examples/MPETest/MPETest.jucer index a7574f7f2a..26099e8141 100644 --- a/examples/MPETest/MPETest.jucer +++ b/examples/MPETest/MPETest.jucer @@ -2,7 +2,7 @@ diff --git a/examples/MidiTest/MidiTest.jucer b/examples/MidiTest/MidiTest.jucer index 5e08b301f9..84d21167a9 100644 --- a/examples/MidiTest/MidiTest.jucer +++ b/examples/MidiTest/MidiTest.jucer @@ -2,7 +2,7 @@ diff --git a/examples/NetworkGraphicsDemo/NetworkGraphicsDemo.jucer b/examples/NetworkGraphicsDemo/NetworkGraphicsDemo.jucer index fd89c51559..7954f7fc5b 100644 --- a/examples/NetworkGraphicsDemo/NetworkGraphicsDemo.jucer +++ b/examples/NetworkGraphicsDemo/NetworkGraphicsDemo.jucer @@ -2,7 +2,7 @@ diff --git a/examples/OSCMonitor/OSCMonitor.jucer b/examples/OSCMonitor/OSCMonitor.jucer index c3b0d1f571..c21aa3d0fe 100644 --- a/examples/OSCMonitor/OSCMonitor.jucer +++ b/examples/OSCMonitor/OSCMonitor.jucer @@ -2,7 +2,7 @@ diff --git a/examples/OSCReceiver/OSCReceiver.jucer b/examples/OSCReceiver/OSCReceiver.jucer index 6624a3879e..d27c37dc7c 100644 --- a/examples/OSCReceiver/OSCReceiver.jucer +++ b/examples/OSCReceiver/OSCReceiver.jucer @@ -2,7 +2,7 @@ diff --git a/examples/OSCSender/OSCSender.jucer b/examples/OSCSender/OSCSender.jucer index 8fdfe0c582..0c5de38ba1 100644 --- a/examples/OSCSender/OSCSender.jucer +++ b/examples/OSCSender/OSCSender.jucer @@ -2,7 +2,7 @@ diff --git a/examples/OpenGLAppExample/OpenGLAppExample.jucer b/examples/OpenGLAppExample/OpenGLAppExample.jucer index ef137b42cd..b8e5d5e68e 100644 --- a/examples/OpenGLAppExample/OpenGLAppExample.jucer +++ b/examples/OpenGLAppExample/OpenGLAppExample.jucer @@ -2,7 +2,7 @@ diff --git a/examples/PluckedStringsDemo/PluckedStringsDemo.jucer b/examples/PluckedStringsDemo/PluckedStringsDemo.jucer index d214cac8f6..1661329a13 100644 --- a/examples/PluckedStringsDemo/PluckedStringsDemo.jucer +++ b/examples/PluckedStringsDemo/PluckedStringsDemo.jucer @@ -2,7 +2,7 @@ diff --git a/examples/PlugInSamples/Arpeggiator/Arpeggiator.jucer b/examples/PlugInSamples/Arpeggiator/Arpeggiator.jucer index 4eeb120eb7..a76785c114 100644 --- a/examples/PlugInSamples/Arpeggiator/Arpeggiator.jucer +++ b/examples/PlugInSamples/Arpeggiator/Arpeggiator.jucer @@ -9,7 +9,7 @@ pluginIsMidiEffectPlugin="1" pluginSilenceInIsSilenceOut="0" pluginEditorRequiresKeys="0" pluginAUExportPrefix="ArpeggiatorAU" pluginRTASCategory="" aaxIdentifier="com.roli.Arpeggiator" pluginAAXCategory="AAX_EPlugInCategory_Effect" - jucerVersion="5.1.1" companyName="ROLI Ltd." companyWebsite="www.juce.com" + jucerVersion="5.1.2" companyName="ROLI Ltd." companyWebsite="www.juce.com" companyEmail="info@juce.com" buildAUv3="0" buildStandalone="0" enableIAA="0" displaySplashScreen="0" reportAppUsage="0" splashScreenColour="Dark" cppLanguageStandard="11"> diff --git a/examples/PlugInSamples/Arpeggiator/JuceLibraryCode/AppConfig.h b/examples/PlugInSamples/Arpeggiator/JuceLibraryCode/AppConfig.h index 08038a2297..c3963d4f4d 100644 --- a/examples/PlugInSamples/Arpeggiator/JuceLibraryCode/AppConfig.h +++ b/examples/PlugInSamples/Arpeggiator/JuceLibraryCode/AppConfig.h @@ -130,6 +130,10 @@ //#define JUCE_FORCE_USE_LEGACY_PARAM_IDS 1 #endif +#ifndef JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE + //#define JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE 1 +#endif + #ifndef JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS //#define JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS 1 #endif diff --git a/examples/PlugInSamples/GainPlugIn/GainPlugIn.jucer b/examples/PlugInSamples/GainPlugIn/GainPlugIn.jucer index f38d22c649..9ecefdf286 100644 --- a/examples/PlugInSamples/GainPlugIn/GainPlugIn.jucer +++ b/examples/PlugInSamples/GainPlugIn/GainPlugIn.jucer @@ -8,7 +8,7 @@ pluginIsSynth="0" pluginWantsMidiIn="0" pluginProducesMidiOut="0" pluginSilenceInIsSilenceOut="1" pluginEditorRequiresKeys="0" pluginAUExportPrefix="GainPlugInAU" pluginRTASCategory="" aaxIdentifier="com.roli.GainPlugIn" - pluginAAXCategory="AAX_ePlugInCategory_Dynamics" jucerVersion="5.1.1" + pluginAAXCategory="AAX_ePlugInCategory_Dynamics" jucerVersion="5.1.2" pluginIsMidiEffectPlugin="0" buildAUv3="0" buildStandalone="0" enableIAA="0" displaySplashScreen="0" reportAppUsage="0" splashScreenColour="Dark" companyName="ROLI Ltd." cppLanguageStandard="11"> diff --git a/examples/PlugInSamples/GainPlugIn/JuceLibraryCode/AppConfig.h b/examples/PlugInSamples/GainPlugIn/JuceLibraryCode/AppConfig.h index 1d746960fb..157a337615 100644 --- a/examples/PlugInSamples/GainPlugIn/JuceLibraryCode/AppConfig.h +++ b/examples/PlugInSamples/GainPlugIn/JuceLibraryCode/AppConfig.h @@ -130,6 +130,10 @@ //#define JUCE_FORCE_USE_LEGACY_PARAM_IDS 1 #endif +#ifndef JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE + //#define JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE 1 +#endif + #ifndef JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS //#define JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS 1 #endif diff --git a/examples/PlugInSamples/InterAppAudioEffect/InterAppAudioEffect.jucer b/examples/PlugInSamples/InterAppAudioEffect/InterAppAudioEffect.jucer index cde05c83aa..b0f27099ec 100644 --- a/examples/PlugInSamples/InterAppAudioEffect/InterAppAudioEffect.jucer +++ b/examples/PlugInSamples/InterAppAudioEffect/InterAppAudioEffect.jucer @@ -9,7 +9,7 @@ pluginIsSynth="0" pluginWantsMidiIn="0" pluginProducesMidiOut="0" pluginIsMidiEffectPlugin="0" pluginEditorRequiresKeys="0" pluginAUExportPrefix="InterAppAudioEffectAU" pluginRTASCategory="" aaxIdentifier="com.yourcompany.InterAppAudioEffect" - pluginAAXCategory="AAX_ePlugInCategory_Dynamics" jucerVersion="5.1.1" + pluginAAXCategory="AAX_ePlugInCategory_Dynamics" jucerVersion="5.1.2" companyName="ROLI Ltd." buildStandalone="1" displaySplashScreen="0" reportAppUsage="0" splashScreenColour="Dark" cppLanguageStandard="11"> diff --git a/examples/PlugInSamples/InterAppAudioEffect/JuceLibraryCode/AppConfig.h b/examples/PlugInSamples/InterAppAudioEffect/JuceLibraryCode/AppConfig.h index 94faef9153..874aaf986d 100644 --- a/examples/PlugInSamples/InterAppAudioEffect/JuceLibraryCode/AppConfig.h +++ b/examples/PlugInSamples/InterAppAudioEffect/JuceLibraryCode/AppConfig.h @@ -128,6 +128,10 @@ //#define JUCE_FORCE_USE_LEGACY_PARAM_IDS 1 #endif +#ifndef JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE + //#define JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE 1 +#endif + #ifndef JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS //#define JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS 1 #endif diff --git a/examples/PlugInSamples/MultiOutSynth/JuceLibraryCode/AppConfig.h b/examples/PlugInSamples/MultiOutSynth/JuceLibraryCode/AppConfig.h index 629e3b3eeb..aa8bb36c67 100644 --- a/examples/PlugInSamples/MultiOutSynth/JuceLibraryCode/AppConfig.h +++ b/examples/PlugInSamples/MultiOutSynth/JuceLibraryCode/AppConfig.h @@ -130,6 +130,10 @@ //#define JUCE_FORCE_USE_LEGACY_PARAM_IDS 1 #endif +#ifndef JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE + //#define JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE 1 +#endif + #ifndef JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS //#define JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS 1 #endif diff --git a/examples/PlugInSamples/MultiOutSynth/MultiOutSynth.jucer b/examples/PlugInSamples/MultiOutSynth/MultiOutSynth.jucer index bab2d8948a..8a61647ea6 100644 --- a/examples/PlugInSamples/MultiOutSynth/MultiOutSynth.jucer +++ b/examples/PlugInSamples/MultiOutSynth/MultiOutSynth.jucer @@ -9,7 +9,7 @@ pluginSilenceInIsSilenceOut="0" pluginEditorRequiresKeys="0" pluginAUExportPrefix="MultiOutSynthAU" pluginRTASCategory="" aaxIdentifier="com.roli.MultiOutSynth" pluginAAXCategory="AAX_ePlugInCategory_SWGenerators" - jucerVersion="5.1.1" companyName="ROLI Ltd." companyWebsite="www.roli.com" + jucerVersion="5.1.2" companyName="ROLI Ltd." companyWebsite="www.roli.com" companyEmail="info@juce.com" pluginIsMidiEffectPlugin="0" buildAUv3="0" buildStandalone="0" enableIAA="0" displaySplashScreen="0" reportAppUsage="0" splashScreenColour="Dark" cppLanguageStandard="11"> diff --git a/examples/PlugInSamples/NoiseGate/JuceLibraryCode/AppConfig.h b/examples/PlugInSamples/NoiseGate/JuceLibraryCode/AppConfig.h index 78542a2d27..c10b904a77 100644 --- a/examples/PlugInSamples/NoiseGate/JuceLibraryCode/AppConfig.h +++ b/examples/PlugInSamples/NoiseGate/JuceLibraryCode/AppConfig.h @@ -130,6 +130,10 @@ //#define JUCE_FORCE_USE_LEGACY_PARAM_IDS 1 #endif +#ifndef JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE + //#define JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE 1 +#endif + #ifndef JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS //#define JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS 1 #endif diff --git a/examples/PlugInSamples/NoiseGate/NoiseGate.jucer b/examples/PlugInSamples/NoiseGate/NoiseGate.jucer index 753184be60..a763194384 100644 --- a/examples/PlugInSamples/NoiseGate/NoiseGate.jucer +++ b/examples/PlugInSamples/NoiseGate/NoiseGate.jucer @@ -8,7 +8,7 @@ pluginIsSynth="0" pluginWantsMidiIn="0" pluginProducesMidiOut="0" pluginSilenceInIsSilenceOut="0" pluginEditorRequiresKeys="0" pluginAUExportPrefix="NoiseGateAU" pluginRTASCategory="" aaxIdentifier="com.roli.NoiseGate" - pluginAAXCategory="AAX_ePlugInCategory_Dynamics" jucerVersion="5.1.1" + pluginAAXCategory="AAX_ePlugInCategory_Dynamics" jucerVersion="5.1.2" pluginIsMidiEffectPlugin="0" buildAUv3="0" buildStandalone="0" enableIAA="0" displaySplashScreen="0" reportAppUsage="0" splashScreenColour="Dark" companyName="ROLI Ltd." cppLanguageStandard="11"> diff --git a/examples/PlugInSamples/Surround/JuceLibraryCode/AppConfig.h b/examples/PlugInSamples/Surround/JuceLibraryCode/AppConfig.h index 5f6397a551..203fb76c64 100644 --- a/examples/PlugInSamples/Surround/JuceLibraryCode/AppConfig.h +++ b/examples/PlugInSamples/Surround/JuceLibraryCode/AppConfig.h @@ -130,6 +130,10 @@ //#define JUCE_FORCE_USE_LEGACY_PARAM_IDS 1 #endif +#ifndef JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE + //#define JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE 1 +#endif + #ifndef JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS //#define JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS 1 #endif diff --git a/examples/PlugInSamples/Surround/Surround.jucer b/examples/PlugInSamples/Surround/Surround.jucer index 98ec9f8070..7a228fe8c2 100644 --- a/examples/PlugInSamples/Surround/Surround.jucer +++ b/examples/PlugInSamples/Surround/Surround.jucer @@ -9,7 +9,7 @@ pluginIsMidiEffectPlugin="0" pluginSilenceInIsSilenceOut="0" pluginEditorRequiresKeys="0" pluginAUExportPrefix="SurroundAU" pluginRTASCategory="" aaxIdentifier="com.roli.Surround" pluginAAXCategory="AAX_ePlugInCategory_Dynamics" - jucerVersion="5.1.1" buildAUv3="0" buildStandalone="0" enableIAA="0" + jucerVersion="5.1.2" buildAUv3="0" buildStandalone="0" enableIAA="0" displaySplashScreen="0" reportAppUsage="0" splashScreenColour="Dark" companyName="ROLI Ltd." cppLanguageStandard="11"> diff --git a/examples/SimpleFFTExample/JuceLibraryCode/AppConfig.h b/examples/SimpleFFTExample/JuceLibraryCode/AppConfig.h index 52023e5800..eb24028469 100644 --- a/examples/SimpleFFTExample/JuceLibraryCode/AppConfig.h +++ b/examples/SimpleFFTExample/JuceLibraryCode/AppConfig.h @@ -201,6 +201,10 @@ //#define JUCE_DSP_USE_STATIC_FFTW 1 #endif +#ifndef JUCE_DSP_ENABLE_SNAP_TO_ZERO + //#define JUCE_DSP_ENABLE_SNAP_TO_ZERO 1 +#endif + //============================================================================== // juce_events flags: diff --git a/examples/SimpleFFTExample/SimpleFFTExample.jucer b/examples/SimpleFFTExample/SimpleFFTExample.jucer index 7e712fb522..e3c909f46f 100644 --- a/examples/SimpleFFTExample/SimpleFFTExample.jucer +++ b/examples/SimpleFFTExample/SimpleFFTExample.jucer @@ -2,7 +2,7 @@ diff --git a/examples/audio plugin demo/Builds/iOS/Info-AUv3_AppExtension.plist b/examples/audio plugin demo/Builds/iOS/Info-AUv3_AppExtension.plist index 10cbd2bb3a..e953c8ba86 100644 --- a/examples/audio plugin demo/Builds/iOS/Info-AUv3_AppExtension.plist +++ b/examples/audio plugin demo/Builds/iOS/Info-AUv3_AppExtension.plist @@ -5,6 +5,8 @@ LSRequiresIPhoneOS + NSMicrophoneUsageDescription + This app requires microphone input. CFBundleExecutable ${EXECUTABLE_NAME} CFBundleIdentifier diff --git a/examples/audio plugin demo/Builds/iOS/Info-Standalone_Plugin.plist b/examples/audio plugin demo/Builds/iOS/Info-Standalone_Plugin.plist index c5c93b2e42..114168eac4 100644 --- a/examples/audio plugin demo/Builds/iOS/Info-Standalone_Plugin.plist +++ b/examples/audio plugin demo/Builds/iOS/Info-Standalone_Plugin.plist @@ -5,6 +5,8 @@ LSRequiresIPhoneOS + NSMicrophoneUsageDescription + This app requires microphone input. UIViewControllerBasedStatusBarAppearance CFBundleExecutable diff --git a/examples/audio plugin demo/JuceDemoPlugin.jucer b/examples/audio plugin demo/JuceDemoPlugin.jucer index 4de6983c40..d3c69da7cb 100644 --- a/examples/audio plugin demo/JuceDemoPlugin.jucer +++ b/examples/audio plugin demo/JuceDemoPlugin.jucer @@ -8,7 +8,7 @@ pluginProducesMidiOut="1" pluginSilenceInIsSilenceOut="0" pluginTailLength="0" pluginEditorRequiresKeys="1" pluginAUExportPrefix="JuceDemoProjectAU" pluginAUViewClass="JuceDemoProjectAU_V1" pluginRTASCategory="" - bundleIdentifier="com.juce.JuceDemoPlugin" jucerVersion="5.1.1" + bundleIdentifier="com.juce.JuceDemoPlugin" jucerVersion="5.1.2" companyName="ROLI Ltd." aaxIdentifier="com.yourcompany.JuceDemoPlugin" buildAAX="0" pluginAAXCategory="AAX_ePlugInCategory_Dynamics" includeBinaryInAppConfig="1" buildVST3="0" pluginManufacturerEmail="support@yourcompany.com" diff --git a/examples/audio plugin demo/JuceLibraryCode/AppConfig.h b/examples/audio plugin demo/JuceLibraryCode/AppConfig.h index 250fbd91ef..1f68648ae9 100644 --- a/examples/audio plugin demo/JuceLibraryCode/AppConfig.h +++ b/examples/audio plugin demo/JuceLibraryCode/AppConfig.h @@ -128,6 +128,10 @@ //#define JUCE_FORCE_USE_LEGACY_PARAM_IDS 1 #endif +#ifndef JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE + //#define JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE 1 +#endif + #ifndef JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS //#define JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS 1 #endif diff --git a/examples/audio plugin host/Plugin Host.jucer b/examples/audio plugin host/Plugin Host.jucer index 9d147f89b5..b291a47c01 100644 --- a/examples/audio plugin host/Plugin Host.jucer +++ b/examples/audio plugin host/Plugin Host.jucer @@ -2,7 +2,7 @@ diff --git a/extras/AudioPerformanceTest/AudioPerformanceTest.jucer b/extras/AudioPerformanceTest/AudioPerformanceTest.jucer index 8893078e29..0b0d218a99 100644 --- a/extras/AudioPerformanceTest/AudioPerformanceTest.jucer +++ b/extras/AudioPerformanceTest/AudioPerformanceTest.jucer @@ -2,7 +2,7 @@ diff --git a/extras/Projucer/Builds/LinuxMakefile/Makefile b/extras/Projucer/Builds/LinuxMakefile/Makefile index 4f27f8d945..cc718ff446 100644 --- a/extras/Projucer/Builds/LinuxMakefile/Makefile +++ b/extras/Projucer/Builds/LinuxMakefile/Makefile @@ -33,7 +33,7 @@ ifeq ($(CONFIG),Debug) TARGET_ARCH := -march=native endif - JUCE_CPPFLAGS := $(DEPFLAGS) -DLINUX=1 -DDEBUG=1 -D_DEBUG=1 -DJUCER_LINUX_MAKE_6D53C8B4=1 -DJUCE_APP_VERSION=5.1.1 -DJUCE_APP_VERSION_HEX=0x50101 $(shell pkg-config --cflags freetype2 libcurl x11 xext xinerama webkit2gtk-4.0 gtk+-x11-3.0) -pthread -I../../JuceLibraryCode -I../../../../modules $(CPPFLAGS) + JUCE_CPPFLAGS := $(DEPFLAGS) -DLINUX=1 -DDEBUG=1 -D_DEBUG=1 -DJUCER_LINUX_MAKE_6D53C8B4=1 -DJUCE_APP_VERSION=5.1.2 -DJUCE_APP_VERSION_HEX=0x50102 $(shell pkg-config --cflags freetype2 libcurl x11 xext xinerama webkit2gtk-4.0 gtk+-x11-3.0) -pthread -I../../JuceLibraryCode -I../../../../modules $(CPPFLAGS) JUCE_CPPFLAGS_APP := -DJucePlugin_Build_VST=0 -DJucePlugin_Build_VST3=0 -DJucePlugin_Build_AU=0 -DJucePlugin_Build_AUv3=0 -DJucePlugin_Build_RTAS=0 -DJucePlugin_Build_AAX=0 -DJucePlugin_Build_Standalone=0 JUCE_TARGET_APP := Projucer @@ -54,7 +54,7 @@ ifeq ($(CONFIG),Release) TARGET_ARCH := -march=native endif - JUCE_CPPFLAGS := $(DEPFLAGS) -DLINUX=1 -DNDEBUG=1 -DJUCER_LINUX_MAKE_6D53C8B4=1 -DJUCE_APP_VERSION=5.1.1 -DJUCE_APP_VERSION_HEX=0x50101 $(shell pkg-config --cflags freetype2 libcurl x11 xext xinerama webkit2gtk-4.0 gtk+-x11-3.0) -pthread -I../../JuceLibraryCode -I../../../../modules $(CPPFLAGS) + JUCE_CPPFLAGS := $(DEPFLAGS) -DLINUX=1 -DNDEBUG=1 -DJUCER_LINUX_MAKE_6D53C8B4=1 -DJUCE_APP_VERSION=5.1.2 -DJUCE_APP_VERSION_HEX=0x50102 $(shell pkg-config --cflags freetype2 libcurl x11 xext xinerama webkit2gtk-4.0 gtk+-x11-3.0) -pthread -I../../JuceLibraryCode -I../../../../modules $(CPPFLAGS) JUCE_CPPFLAGS_APP := -DJucePlugin_Build_VST=0 -DJucePlugin_Build_VST3=0 -DJucePlugin_Build_AU=0 -DJucePlugin_Build_AUv3=0 -DJucePlugin_Build_RTAS=0 -DJucePlugin_Build_AAX=0 -DJucePlugin_Build_Standalone=0 JUCE_TARGET_APP := Projucer diff --git a/extras/Projucer/Builds/MacOSX/Info-App.plist b/extras/Projucer/Builds/MacOSX/Info-App.plist index 9eec9db917..e5c569a0cc 100644 --- a/extras/Projucer/Builds/MacOSX/Info-App.plist +++ b/extras/Projucer/Builds/MacOSX/Info-App.plist @@ -33,9 +33,9 @@ CFBundleSignature ???? CFBundleShortVersionString - 5.1.1 + 5.1.2 CFBundleVersion - 5.1.1 + 5.1.2 NSHumanReadableCopyright ROLI Ltd. NSHighResolutionCapable diff --git a/extras/Projucer/Builds/MacOSX/Projucer.xcodeproj/project.pbxproj b/extras/Projucer/Builds/MacOSX/Projucer.xcodeproj/project.pbxproj index d22dc08488..e6199c459a 100644 --- a/extras/Projucer/Builds/MacOSX/Projucer.xcodeproj/project.pbxproj +++ b/extras/Projucer/Builds/MacOSX/Projucer.xcodeproj/project.pbxproj @@ -738,8 +738,8 @@ "_DEBUG=1", "DEBUG=1", "JUCER_XCODE_MAC_F6D2F4CF=1", - "JUCE_APP_VERSION=5.1.1", - "JUCE_APP_VERSION_HEX=0x50101", + "JUCE_APP_VERSION=5.1.2", + "JUCE_APP_VERSION_HEX=0x50102", "JucePlugin_Build_VST=0", "JucePlugin_Build_VST3=0", "JucePlugin_Build_AU=0", @@ -771,8 +771,8 @@ "_NDEBUG=1", "NDEBUG=1", "JUCER_XCODE_MAC_F6D2F4CF=1", - "JUCE_APP_VERSION=5.1.1", - "JUCE_APP_VERSION_HEX=0x50101", + "JUCE_APP_VERSION=5.1.2", + "JUCE_APP_VERSION_HEX=0x50102", "JucePlugin_Build_VST=0", "JucePlugin_Build_VST3=0", "JucePlugin_Build_AU=0", diff --git a/extras/Projucer/Builds/VisualStudio2013/Projucer_App.vcxproj b/extras/Projucer/Builds/VisualStudio2013/Projucer_App.vcxproj index 1dcb17b056..5398caf988 100644 --- a/extras/Projucer/Builds/VisualStudio2013/Projucer_App.vcxproj +++ b/extras/Projucer/Builds/VisualStudio2013/Projucer_App.vcxproj @@ -73,7 +73,7 @@ Disabled ProgramDatabase ..\..\JuceLibraryCode;..\..\..\..\modules;%(AdditionalIncludeDirectories) - _CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;DEBUG;_DEBUG;JUCER_VS2013_78A5020=1;JUCE_APP_VERSION=5.1.1;JUCE_APP_VERSION_HEX=0x50101;JucePlugin_Build_VST=0;JucePlugin_Build_VST3=0;JucePlugin_Build_AU=0;JucePlugin_Build_AUv3=0;JucePlugin_Build_RTAS=0;JucePlugin_Build_AAX=0;JucePlugin_Build_Standalone=0;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;DEBUG;_DEBUG;JUCER_VS2013_78A5020=1;JUCE_APP_VERSION=5.1.2;JUCE_APP_VERSION_HEX=0x50102;JucePlugin_Build_VST=0;JucePlugin_Build_VST3=0;JucePlugin_Build_AU=0;JucePlugin_Build_AUv3=0;JucePlugin_Build_RTAS=0;JucePlugin_Build_AAX=0;JucePlugin_Build_Standalone=0;%(PreprocessorDefinitions) MultiThreadedDebugDLL true @@ -113,7 +113,7 @@ Full ..\..\JuceLibraryCode;..\..\..\..\modules;%(AdditionalIncludeDirectories) - _CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;NDEBUG;JUCER_VS2013_78A5020=1;JUCE_APP_VERSION=5.1.1;JUCE_APP_VERSION_HEX=0x50101;JucePlugin_Build_VST=0;JucePlugin_Build_VST3=0;JucePlugin_Build_AU=0;JucePlugin_Build_AUv3=0;JucePlugin_Build_RTAS=0;JucePlugin_Build_AAX=0;JucePlugin_Build_Standalone=0;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;NDEBUG;JUCER_VS2013_78A5020=1;JUCE_APP_VERSION=5.1.2;JUCE_APP_VERSION_HEX=0x50102;JucePlugin_Build_VST=0;JucePlugin_Build_VST3=0;JucePlugin_Build_AU=0;JucePlugin_Build_AUv3=0;JucePlugin_Build_RTAS=0;JucePlugin_Build_AAX=0;JucePlugin_Build_Standalone=0;%(PreprocessorDefinitions) MultiThreaded true diff --git a/extras/Projucer/Builds/VisualStudio2013/resources.rc b/extras/Projucer/Builds/VisualStudio2013/resources.rc index 871b0544aa..09499a2f88 100644 --- a/extras/Projucer/Builds/VisualStudio2013/resources.rc +++ b/extras/Projucer/Builds/VisualStudio2013/resources.rc @@ -7,7 +7,7 @@ #include VS_VERSION_INFO VERSIONINFO -FILEVERSION 5,1,1,0 +FILEVERSION 5,1,2,0 BEGIN BLOCK "StringFileInfo" BEGIN @@ -15,9 +15,9 @@ BEGIN BEGIN VALUE "CompanyName", "ROLI Ltd.\0" VALUE "FileDescription", "Projucer\0" - VALUE "FileVersion", "5.1.1\0" + VALUE "FileVersion", "5.1.2\0" VALUE "ProductName", "Projucer\0" - VALUE "ProductVersion", "5.1.1\0" + VALUE "ProductVersion", "5.1.2\0" END END diff --git a/extras/Projucer/Builds/VisualStudio2015/Projucer_App.vcxproj b/extras/Projucer/Builds/VisualStudio2015/Projucer_App.vcxproj index 4f3a2a8936..0bc3af50d4 100644 --- a/extras/Projucer/Builds/VisualStudio2015/Projucer_App.vcxproj +++ b/extras/Projucer/Builds/VisualStudio2015/Projucer_App.vcxproj @@ -73,7 +73,7 @@ Disabled ProgramDatabase ..\..\JuceLibraryCode;..\..\..\..\modules;%(AdditionalIncludeDirectories) - _CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;DEBUG;_DEBUG;JUCER_VS2015_78A5022=1;JUCE_APP_VERSION=5.1.1;JUCE_APP_VERSION_HEX=0x50101;JucePlugin_Build_VST=0;JucePlugin_Build_VST3=0;JucePlugin_Build_AU=0;JucePlugin_Build_AUv3=0;JucePlugin_Build_RTAS=0;JucePlugin_Build_AAX=0;JucePlugin_Build_Standalone=0;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;DEBUG;_DEBUG;JUCER_VS2015_78A5022=1;JUCE_APP_VERSION=5.1.2;JUCE_APP_VERSION_HEX=0x50102;JucePlugin_Build_VST=0;JucePlugin_Build_VST3=0;JucePlugin_Build_AU=0;JucePlugin_Build_AUv3=0;JucePlugin_Build_RTAS=0;JucePlugin_Build_AAX=0;JucePlugin_Build_Standalone=0;%(PreprocessorDefinitions) MultiThreadedDebugDLL true @@ -113,7 +113,7 @@ Full ..\..\JuceLibraryCode;..\..\..\..\modules;%(AdditionalIncludeDirectories) - _CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;NDEBUG;JUCER_VS2015_78A5022=1;JUCE_APP_VERSION=5.1.1;JUCE_APP_VERSION_HEX=0x50101;JucePlugin_Build_VST=0;JucePlugin_Build_VST3=0;JucePlugin_Build_AU=0;JucePlugin_Build_AUv3=0;JucePlugin_Build_RTAS=0;JucePlugin_Build_AAX=0;JucePlugin_Build_Standalone=0;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;NDEBUG;JUCER_VS2015_78A5022=1;JUCE_APP_VERSION=5.1.2;JUCE_APP_VERSION_HEX=0x50102;JucePlugin_Build_VST=0;JucePlugin_Build_VST3=0;JucePlugin_Build_AU=0;JucePlugin_Build_AUv3=0;JucePlugin_Build_RTAS=0;JucePlugin_Build_AAX=0;JucePlugin_Build_Standalone=0;%(PreprocessorDefinitions) MultiThreaded true diff --git a/extras/Projucer/Builds/VisualStudio2015/resources.rc b/extras/Projucer/Builds/VisualStudio2015/resources.rc index 871b0544aa..09499a2f88 100644 --- a/extras/Projucer/Builds/VisualStudio2015/resources.rc +++ b/extras/Projucer/Builds/VisualStudio2015/resources.rc @@ -7,7 +7,7 @@ #include VS_VERSION_INFO VERSIONINFO -FILEVERSION 5,1,1,0 +FILEVERSION 5,1,2,0 BEGIN BLOCK "StringFileInfo" BEGIN @@ -15,9 +15,9 @@ BEGIN BEGIN VALUE "CompanyName", "ROLI Ltd.\0" VALUE "FileDescription", "Projucer\0" - VALUE "FileVersion", "5.1.1\0" + VALUE "FileVersion", "5.1.2\0" VALUE "ProductName", "Projucer\0" - VALUE "ProductVersion", "5.1.1\0" + VALUE "ProductVersion", "5.1.2\0" END END diff --git a/extras/Projucer/Builds/VisualStudio2017/Projucer_App.vcxproj b/extras/Projucer/Builds/VisualStudio2017/Projucer_App.vcxproj index 35d04e7107..4016040ec2 100644 --- a/extras/Projucer/Builds/VisualStudio2017/Projucer_App.vcxproj +++ b/extras/Projucer/Builds/VisualStudio2017/Projucer_App.vcxproj @@ -73,7 +73,7 @@ Disabled ProgramDatabase ..\..\JuceLibraryCode;..\..\..\..\modules;%(AdditionalIncludeDirectories) - _CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;DEBUG;_DEBUG;JUCER_VS2017_78A5024=1;JUCE_APP_VERSION=5.1.1;JUCE_APP_VERSION_HEX=0x50101;JucePlugin_Build_VST=0;JucePlugin_Build_VST3=0;JucePlugin_Build_AU=0;JucePlugin_Build_AUv3=0;JucePlugin_Build_RTAS=0;JucePlugin_Build_AAX=0;JucePlugin_Build_Standalone=0;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;DEBUG;_DEBUG;JUCER_VS2017_78A5024=1;JUCE_APP_VERSION=5.1.2;JUCE_APP_VERSION_HEX=0x50102;JucePlugin_Build_VST=0;JucePlugin_Build_VST3=0;JucePlugin_Build_AU=0;JucePlugin_Build_AUv3=0;JucePlugin_Build_RTAS=0;JucePlugin_Build_AAX=0;JucePlugin_Build_Standalone=0;%(PreprocessorDefinitions) MultiThreadedDebug true @@ -113,7 +113,7 @@ Full ..\..\JuceLibraryCode;..\..\..\..\modules;%(AdditionalIncludeDirectories) - _CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;NDEBUG;JUCER_VS2017_78A5024=1;JUCE_APP_VERSION=5.1.1;JUCE_APP_VERSION_HEX=0x50101;JucePlugin_Build_VST=0;JucePlugin_Build_VST3=0;JucePlugin_Build_AU=0;JucePlugin_Build_AUv3=0;JucePlugin_Build_RTAS=0;JucePlugin_Build_AAX=0;JucePlugin_Build_Standalone=0;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;NDEBUG;JUCER_VS2017_78A5024=1;JUCE_APP_VERSION=5.1.2;JUCE_APP_VERSION_HEX=0x50102;JucePlugin_Build_VST=0;JucePlugin_Build_VST3=0;JucePlugin_Build_AU=0;JucePlugin_Build_AUv3=0;JucePlugin_Build_RTAS=0;JucePlugin_Build_AAX=0;JucePlugin_Build_Standalone=0;%(PreprocessorDefinitions) MultiThreaded true diff --git a/extras/Projucer/Builds/VisualStudio2017/resources.rc b/extras/Projucer/Builds/VisualStudio2017/resources.rc index 871b0544aa..09499a2f88 100644 --- a/extras/Projucer/Builds/VisualStudio2017/resources.rc +++ b/extras/Projucer/Builds/VisualStudio2017/resources.rc @@ -7,7 +7,7 @@ #include VS_VERSION_INFO VERSIONINFO -FILEVERSION 5,1,1,0 +FILEVERSION 5,1,2,0 BEGIN BLOCK "StringFileInfo" BEGIN @@ -15,9 +15,9 @@ BEGIN BEGIN VALUE "CompanyName", "ROLI Ltd.\0" VALUE "FileDescription", "Projucer\0" - VALUE "FileVersion", "5.1.1\0" + VALUE "FileVersion", "5.1.2\0" VALUE "ProductName", "Projucer\0" - VALUE "ProductVersion", "5.1.1\0" + VALUE "ProductVersion", "5.1.2\0" END END diff --git a/extras/Projucer/JuceLibraryCode/JuceHeader.h b/extras/Projucer/JuceLibraryCode/JuceHeader.h index dc53643137..02c8a12178 100644 --- a/extras/Projucer/JuceLibraryCode/JuceHeader.h +++ b/extras/Projucer/JuceLibraryCode/JuceHeader.h @@ -34,7 +34,7 @@ namespace ProjectInfo { const char* const projectName = "Projucer"; - const char* const versionString = "5.1.1"; - const int versionNumber = 0x50101; + const char* const versionString = "5.1.2"; + const int versionNumber = 0x50102; } #endif diff --git a/extras/Projucer/Projucer.jucer b/extras/Projucer/Projucer.jucer index 743df4b33b..09554746e6 100644 --- a/extras/Projucer/Projucer.jucer +++ b/extras/Projucer/Projucer.jucer @@ -1,7 +1,7 @@ diff --git a/extras/UnitTestRunner/JuceLibraryCode/AppConfig.h b/extras/UnitTestRunner/JuceLibraryCode/AppConfig.h index a81ea387e7..1bb6c9105c 100644 --- a/extras/UnitTestRunner/JuceLibraryCode/AppConfig.h +++ b/extras/UnitTestRunner/JuceLibraryCode/AppConfig.h @@ -207,6 +207,10 @@ //#define JUCE_DSP_USE_STATIC_FFTW 1 #endif +#ifndef JUCE_DSP_ENABLE_SNAP_TO_ZERO + //#define JUCE_DSP_ENABLE_SNAP_TO_ZERO 1 +#endif + //============================================================================== // juce_events flags: diff --git a/extras/UnitTestRunner/UnitTestRunner.jucer b/extras/UnitTestRunner/UnitTestRunner.jucer index c99d591238..f3ecfd90b9 100644 --- a/extras/UnitTestRunner/UnitTestRunner.jucer +++ b/extras/UnitTestRunner/UnitTestRunner.jucer @@ -2,7 +2,7 @@ diff --git a/extras/binarybuilder/BinaryBuilder.jucer b/extras/binarybuilder/BinaryBuilder.jucer index 6639199173..0e7cc17a1d 100644 --- a/extras/binarybuilder/BinaryBuilder.jucer +++ b/extras/binarybuilder/BinaryBuilder.jucer @@ -1,7 +1,7 @@ diff --git a/extras/windows dll/jucedll.jucer b/extras/windows dll/jucedll.jucer index 9c310e7527..ddd1fbc219 100644 --- a/extras/windows dll/jucedll.jucer +++ b/extras/windows dll/jucedll.jucer @@ -1,7 +1,7 @@ From efacd83ab514e05dd9b15cf3839b77b44000ae56 Mon Sep 17 00:00:00 2001 From: hogliux Date: Tue, 19 Sep 2017 11:02:25 +0100 Subject: [PATCH 109/129] Added a missing juce namespace to juce_mac_AudioCDBurner.mm --- .../native/juce_mac_AudioCDBurner.mm | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/modules/juce_audio_utils/native/juce_mac_AudioCDBurner.mm b/modules/juce_audio_utils/native/juce_mac_AudioCDBurner.mm index 1d4f14e7a4..bad7206d6c 100644 --- a/modules/juce_audio_utils/native/juce_mac_AudioCDBurner.mm +++ b/modules/juce_audio_utils/native/juce_mac_AudioCDBurner.mm @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + const int kilobytesPerSecond1x = 176; struct AudioTrackProducerClass : public ObjCClass @@ -32,7 +35,13 @@ struct AudioTrackProducerClass : public ObjCClass { addIvar ("source"); + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wundeclared-selector" addMethod (@selector (initWithAudioSourceHolder:), initWithAudioSourceHolder, "@@:^v"); + addMethod (@selector (verifyDataForTrack:intoBuffer:length:atAddress:blockSize:ioFlags:), + produceDataForTrack, "I@:@^cIQI^I"); + #pragma clang diagnostic pop + addMethod (@selector (cleanupTrackAfterBurn:), cleanupTrackAfterBurn, "v@:@"); addMethod (@selector (cleanupTrackAfterVerification:), cleanupTrackAfterVerification, "c@:@"); addMethod (@selector (estimateLengthOfTrack:), estimateLengthOfTrack, "Q@:@"); @@ -42,8 +51,6 @@ struct AudioTrackProducerClass : public ObjCClass produceDataForTrack, "I@:@^cIQI^I"); addMethod (@selector (producePreGapForTrack:intoBuffer:length:atAddress:blockSize:ioFlags:), produceDataForTrack, "I@:@^cIQI^I"); - addMethod (@selector (verifyDataForTrack:intoBuffer:length:atAddress:blockSize:ioFlags:), - produceDataForTrack, "I@:@^cIQI^I"); registerClass(); } @@ -182,8 +189,11 @@ struct OpenDiskDevice static AudioTrackProducerClass cls; + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wundeclared-selector" NSObject* producer = [cls.createInstance() performSelector: @selector (initWithAudioSourceHolder:) withObject: (id) new AudioTrackProducerClass::AudioSourceHolder (source, numFrames)]; + #pragma clang diagnostic pop DRTrack* track = [[DRTrack alloc] initWithProducer: producer]; { @@ -455,3 +465,5 @@ String AudioCDBurner::burn (AudioCDBurner::BurnProgressListener* listener, return "Couldn't open or write to the CD device"; } + +} From e0c079c448da50403c552833dd191b78071e6f72 Mon Sep 17 00:00:00 2001 From: jules Date: Tue, 19 Sep 2017 09:03:45 +0100 Subject: [PATCH 110/129] Added a couple of assertions in IIR::Coefficients --- modules/juce_dsp/processors/juce_IIRFilter.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/juce_dsp/processors/juce_IIRFilter.cpp b/modules/juce_dsp/processors/juce_IIRFilter.cpp index bebcf701a5..1c9229cbbb 100644 --- a/modules/juce_dsp/processors/juce_IIRFilter.cpp +++ b/modules/juce_dsp/processors/juce_IIRFilter.cpp @@ -331,6 +331,7 @@ typename IIR::Coefficients::Ptr IIR::Coefficients::mak jassert (sampleRate > 0); jassert (frequency > 0 && frequency <= static_cast (sampleRate * 0.5)); jassert (Q > 0); + jassert (gainFactor > 0); auto A = jmax (static_cast (0.0), std::sqrt (gainFactor)); auto omega = (2 * MathConstants::pi * jmax (frequency, static_cast (2.0))) / static_cast (sampleRate); @@ -451,6 +452,8 @@ template void IIR::Coefficients::getPhaseForFrequencyArray (double* frequencies, double* phases, size_t numSamples, double sampleRate) const noexcept { + jassert (sampleRate > 0); + constexpr Complex j (0, 1); const auto order = getFilterOrder(); const auto* coefs = coefficients.begin(); From 0b7d163d49e849d9340cb2fb035109107150fbaa Mon Sep 17 00:00:00 2001 From: ed Date: Tue, 19 Sep 2017 12:23:41 +0100 Subject: [PATCH 111/129] Increased the contrast for selected text when using LookAndFeel_V4 --- modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.cpp b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.cpp index 68660d1414..6e23eb0fc2 100644 --- a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.cpp +++ b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.cpp @@ -1305,7 +1305,7 @@ void LookAndFeel_V4::initialiseColours() TextEditor::backgroundColourId, currentColourScheme.getUIColour (ColourScheme::UIColour::widgetBackground).getARGB(), TextEditor::textColourId, currentColourScheme.getUIColour (ColourScheme::UIColour::defaultText).getARGB(), - TextEditor::highlightColourId, currentColourScheme.getUIColour (ColourScheme::UIColour::highlightedFill).getARGB(), + TextEditor::highlightColourId, currentColourScheme.getUIColour (ColourScheme::UIColour::defaultFill).withAlpha (0.4f).getARGB(), TextEditor::highlightedTextColourId, currentColourScheme.getUIColour (ColourScheme::UIColour::highlightedText).getARGB(), TextEditor::outlineColourId, currentColourScheme.getUIColour (ColourScheme::UIColour::outline).getARGB(), TextEditor::focusedOutlineColourId, currentColourScheme.getUIColour (ColourScheme::UIColour::outline).getARGB(), @@ -1362,7 +1362,7 @@ void LookAndFeel_V4::initialiseColours() Slider::rotarySliderOutlineColourId, currentColourScheme.getUIColour (ColourScheme::UIColour::widgetBackground).getARGB(), Slider::textBoxTextColourId, currentColourScheme.getUIColour (ColourScheme::UIColour::defaultText).getARGB(), Slider::textBoxBackgroundColourId, currentColourScheme.getUIColour (ColourScheme::UIColour::widgetBackground).withAlpha (0.0f).getARGB(), - Slider::textBoxHighlightColourId, currentColourScheme.getUIColour (ColourScheme::UIColour::highlightedFill).getARGB(), + Slider::textBoxHighlightColourId, currentColourScheme.getUIColour (ColourScheme::UIColour::defaultFill).withAlpha (0.4f).getARGB(), Slider::textBoxOutlineColourId, currentColourScheme.getUIColour (ColourScheme::UIColour::outline).getARGB(), ResizableWindow::backgroundColourId, currentColourScheme.getUIColour (ColourScheme::UIColour::windowBackground).getARGB(), @@ -1422,7 +1422,7 @@ void LookAndFeel_V4::initialiseColours() 0x1005008, /*MidiKeyboardComponent::shadowColourId*/ 0x4c000000, 0x1004500, /*CodeEditorComponent::backgroundColourId*/ currentColourScheme.getUIColour (ColourScheme::UIColour::widgetBackground).getARGB(), - 0x1004502, /*CodeEditorComponent::highlightColourId*/ currentColourScheme.getUIColour (ColourScheme::UIColour::highlightedFill).getARGB(), + 0x1004502, /*CodeEditorComponent::highlightColourId*/ currentColourScheme.getUIColour (ColourScheme::UIColour::defaultFill).withAlpha (0.4f).getARGB(), 0x1004503, /*CodeEditorComponent::defaultTextColourId*/ currentColourScheme.getUIColour (ColourScheme::UIColour::defaultText).getARGB(), 0x1004504, /*CodeEditorComponent::lineNumberBackgroundId*/ currentColourScheme.getUIColour (ColourScheme::UIColour::highlightedFill).withAlpha (0.5f).getARGB(), 0x1004505, /*CodeEditorComponent::lineNumberTextId*/ currentColourScheme.getUIColour (ColourScheme::UIColour::defaultFill).getARGB(), From fa093cd7984abe0fa3798972a0bd57a827270345 Mon Sep 17 00:00:00 2001 From: jules Date: Tue, 19 Sep 2017 15:02:01 +0100 Subject: [PATCH 112/129] Modernised some String internals --- modules/juce_core/text/juce_String.cpp | 326 ++++++++++++------------- 1 file changed, 156 insertions(+), 170 deletions(-) diff --git a/modules/juce_core/text/juce_String.cpp b/modules/juce_core/text/juce_String.cpp index 7de15744e0..3fb472299a 100644 --- a/modules/juce_core/text/juce_String.cpp +++ b/modules/juce_core/text/juce_String.cpp @@ -71,7 +71,7 @@ public: static CharPointerType createUninitialisedBytes (size_t numBytes) { numBytes = (numBytes + 3) & ~(size_t) 3; - StringHolder* const s = reinterpret_cast (new char [sizeof (StringHolder) - sizeof (CharType) + numBytes]); + auto s = reinterpret_cast (new char [sizeof (StringHolder) - sizeof (CharType) + numBytes]); s->refCount.value = 0; s->allocatedNumBytes = numBytes; return CharPointerType (s->text); @@ -83,8 +83,8 @@ public: if (text.getAddress() == nullptr || text.isEmpty()) return CharPointerType (&(emptyString.text)); - const size_t bytesNeeded = sizeof (CharType) + CharPointerType::getBytesRequiredFor (text); - const CharPointerType dest (createUninitialisedBytes (bytesNeeded)); + auto bytesNeeded = sizeof (CharType) + CharPointerType::getBytesRequiredFor (text); + auto dest = createUninitialisedBytes (bytesNeeded); CharPointerType (dest).writeAll (text); return dest; } @@ -95,7 +95,7 @@ public: if (text.getAddress() == nullptr || text.isEmpty() || maxChars == 0) return CharPointerType (&(emptyString.text)); - CharPointer end (text); + auto end = text; size_t numChars = 0; size_t bytesNeeded = sizeof (CharType); @@ -105,7 +105,7 @@ public: ++numChars; } - const CharPointerType dest (createUninitialisedBytes (bytesNeeded)); + auto dest = createUninitialisedBytes (bytesNeeded); CharPointerType (dest).writeWithCharLimit (text, (int) numChars + 1); return dest; } @@ -116,9 +116,9 @@ public: if (start.getAddress() == nullptr || start.isEmpty()) return CharPointerType (&(emptyString.text)); - CharPointer e (start); + auto e = start; int numChars = 0; - size_t bytesNeeded = sizeof (CharType); + auto bytesNeeded = sizeof (CharType); while (e < end && ! e.isEmpty()) { @@ -126,7 +126,7 @@ public: ++numChars; } - const CharPointerType dest (createUninitialisedBytes (bytesNeeded)); + auto dest = createUninitialisedBytes (bytesNeeded); CharPointerType (dest).writeWithCharLimit (start, numChars + 1); return dest; } @@ -136,9 +136,9 @@ public: if (start.getAddress() == nullptr || start.isEmpty()) return CharPointerType (&(emptyString.text)); - const size_t numBytes = (size_t) (reinterpret_cast (end.getAddress()) - - reinterpret_cast (start.getAddress())); - const CharPointerType dest (createUninitialisedBytes (numBytes + sizeof (CharType))); + auto numBytes = (size_t) (reinterpret_cast (end.getAddress()) + - reinterpret_cast (start.getAddress())); + auto dest = createUninitialisedBytes (numBytes + sizeof (CharType)); memcpy (dest.getAddress(), start, numBytes); dest.getAddress()[numBytes / sizeof (CharType)] = 0; return dest; @@ -146,7 +146,7 @@ public: static CharPointerType createFromFixedLength (const char* const src, const size_t numChars) { - const CharPointerType dest (createUninitialisedBytes (numChars * sizeof (CharType) + sizeof (CharType))); + auto dest = createUninitialisedBytes (numChars * sizeof (CharType) + sizeof (CharType)); CharPointerType (dest).writeWithCharLimit (CharPointer_UTF8 (src), (int) (numChars + 1)); return dest; } @@ -154,7 +154,7 @@ public: //============================================================================== static void retain (const CharPointerType text) noexcept { - StringHolder* const b = bufferFromText (text); + auto* b = bufferFromText (text); if (b != (StringHolder*) &emptyString) ++(b->refCount); @@ -180,11 +180,11 @@ public: //============================================================================== static CharPointerType makeUniqueWithByteSize (const CharPointerType text, size_t numBytes) { - StringHolder* const b = bufferFromText (text); + auto* b = bufferFromText (text); if (b == (StringHolder*) &emptyString) { - CharPointerType newText (createUninitialisedBytes (numBytes)); + auto newText = createUninitialisedBytes (numBytes); newText.writeNull(); return newText; } @@ -192,7 +192,7 @@ public: if (b->allocatedNumBytes >= numBytes && b->refCount.get() <= 0) return text; - CharPointerType newText (createUninitialisedBytes (jmax (b->allocatedNumBytes, numBytes))); + auto newText = createUninitialisedBytes (jmax (b->allocatedNumBytes, numBytes)); memcpy (newText.getAddress(), text.getAddress(), b->allocatedNumBytes); release (b); @@ -476,9 +476,9 @@ namespace NumberToStringConverters { if (numDecPlaces > 0 && numDecPlaces < 7 && n > -1.0e20 && n < 1.0e20) { - char* const end = buffer + numChars; - char* t = end; - int64 v = (int64) (pow (10.0, numDecPlaces) * std::abs (n) + 0.5); + auto* end = buffer + numChars; + auto* t = end; + auto v = (int64) (pow (10.0, numDecPlaces) * std::abs (n) + 0.5); *--t = (char) 0; while (numDecPlaces >= 0 || v > 0) @@ -509,8 +509,8 @@ namespace NumberToStringConverters static String::CharPointerType createFromInteger (const IntegerType number) { char buffer [charsNeededForInt]; - char* const end = buffer + numElementsInArray (buffer); - char* const start = numberToString (end, number); + auto* end = buffer + numElementsInArray (buffer); + auto* start = numberToString (end, number); return StringHolder::createFromFixedLength (start, (size_t) (end - start - 1)); } @@ -518,25 +518,25 @@ namespace NumberToStringConverters { char buffer [charsNeededForDouble]; size_t len; - char* const start = doubleToString (buffer, numElementsInArray (buffer), (double) number, numberOfDecimalPlaces, len); + auto start = doubleToString (buffer, numElementsInArray (buffer), (double) number, numberOfDecimalPlaces, len); return StringHolder::createFromFixedLength (start, len); } } //============================================================================== -String::String (const int number) : text (NumberToStringConverters::createFromInteger (number)) {} -String::String (const unsigned int number) : text (NumberToStringConverters::createFromInteger (number)) {} -String::String (const short number) : text (NumberToStringConverters::createFromInteger ((int) number)) {} -String::String (const unsigned short number) : text (NumberToStringConverters::createFromInteger ((unsigned int) number)) {} -String::String (const int64 number) : text (NumberToStringConverters::createFromInteger (number)) {} -String::String (const uint64 number) : text (NumberToStringConverters::createFromInteger (number)) {} -String::String (const long number) : text (NumberToStringConverters::createFromInteger (number)) {} -String::String (const unsigned long number) : text (NumberToStringConverters::createFromInteger (number)) {} - -String::String (const float number) : text (NumberToStringConverters::createFromDouble ((double) number, 0)) {} -String::String (const double number) : text (NumberToStringConverters::createFromDouble (number, 0)) {} -String::String (const float number, const int numberOfDecimalPlaces) : text (NumberToStringConverters::createFromDouble ((double) number, numberOfDecimalPlaces)) {} -String::String (const double number, const int numberOfDecimalPlaces) : text (NumberToStringConverters::createFromDouble (number, numberOfDecimalPlaces)) {} +String::String (int number) : text (NumberToStringConverters::createFromInteger (number)) {} +String::String (unsigned int number) : text (NumberToStringConverters::createFromInteger (number)) {} +String::String (short number) : text (NumberToStringConverters::createFromInteger ((int) number)) {} +String::String (unsigned short number) : text (NumberToStringConverters::createFromInteger ((unsigned int) number)) {} +String::String (int64 number) : text (NumberToStringConverters::createFromInteger (number)) {} +String::String (uint64 number) : text (NumberToStringConverters::createFromInteger (number)) {} +String::String (long number) : text (NumberToStringConverters::createFromInteger (number)) {} +String::String (unsigned long number) : text (NumberToStringConverters::createFromInteger (number)) {} + +String::String (float number) : text (NumberToStringConverters::createFromDouble ((double) number, 0)) {} +String::String (double number) : text (NumberToStringConverters::createFromDouble (number, 0)) {} +String::String (float number, int numberOfDecimalPlaces) : text (NumberToStringConverters::createFromDouble ((double) number, numberOfDecimalPlaces)) {} +String::String (double number, int numberOfDecimalPlaces) : text (NumberToStringConverters::createFromDouble (number, numberOfDecimalPlaces)) {} //============================================================================== int String::length() const noexcept @@ -633,11 +633,11 @@ static int stringCompareRight (String::CharPointerType s1, String::CharPointerTy { for (int bias = 0;;) { - const juce_wchar c1 = s1.getAndAdvance(); - const bool isDigit1 = CharacterFunctions::isDigit (c1); + auto c1 = s1.getAndAdvance(); + bool isDigit1 = CharacterFunctions::isDigit (c1); - const juce_wchar c2 = s2.getAndAdvance(); - const bool isDigit2 = CharacterFunctions::isDigit (c2); + auto c2 = s2.getAndAdvance(); + bool isDigit2 = CharacterFunctions::isDigit (c2); if (! (isDigit1 || isDigit2)) return bias; if (! isDigit1) return -1; @@ -654,11 +654,11 @@ static int stringCompareLeft (String::CharPointerType s1, String::CharPointerTyp { for (;;) { - const juce_wchar c1 = s1.getAndAdvance(); - const bool isDigit1 = CharacterFunctions::isDigit (c1); + auto c1 = s1.getAndAdvance(); + bool isDigit1 = CharacterFunctions::isDigit (c1); - const juce_wchar c2 = s2.getAndAdvance(); - const bool isDigit2 = CharacterFunctions::isDigit (c2); + auto c2 = s2.getAndAdvance(); + bool isDigit2 = CharacterFunctions::isDigit (c2); if (! (isDigit1 || isDigit2)) return 0; if (! isDigit1) return -1; @@ -694,8 +694,8 @@ static int naturalStringCompare (String::CharPointerType s1, String::CharPointer return result; } - juce_wchar c1 = s1.getAndAdvance(); - juce_wchar c2 = s2.getAndAdvance(); + auto c1 = s1.getAndAdvance(); + auto c2 = s2.getAndAdvance(); if (c1 != c2 && ! isCaseSensitive) { @@ -751,10 +751,10 @@ void String::appendCharPointer (const CharPointerType startOfTextToAppend, if (extraBytesNeeded > 0) { - const size_t byteOffsetOfNull = getByteOffsetOfEnd(); + auto byteOffsetOfNull = getByteOffsetOfEnd(); preallocateBytes (byteOffsetOfNull + (size_t) extraBytesNeeded); - CharPointerType::CharType* const newStringStart = addBytesToPointer (text.getAddress(), (int) byteOffsetOfNull); + auto* newStringStart = addBytesToPointer (text.getAddress(), (int) byteOffsetOfNull); memcpy (newStringStart, startOfTextToAppend.getAddress(), (size_t) extraBytesNeeded); CharPointerType (addBytesToPointer (newStringStart, extraBytesNeeded)).writeNull(); } @@ -816,8 +816,8 @@ namespace StringHelpers inline String& operationAddAssign (String& str, const T number) { char buffer [(sizeof(T) * 8) / 2]; - char* end = buffer + numElementsInArray (buffer); - char* start = NumberToStringConverters::numberToString (end, number); + auto* end = buffer + numElementsInArray (buffer); + auto* start = NumberToStringConverters::numberToString (end, number); #if JUCE_STRING_UTF_TYPE == 8 str.appendCharPointer (String::CharPointerType (start), String::CharPointerType (end)); @@ -902,7 +902,7 @@ int String::indexOfChar (const juce_wchar character) const noexcept int String::indexOfChar (const int startIndex, const juce_wchar character) const noexcept { - CharPointerType t (text); + auto t = text; for (int i = 0; ! t.isEmpty(); ++i) { @@ -922,7 +922,7 @@ int String::indexOfChar (const int startIndex, const juce_wchar character) const int String::lastIndexOfChar (const juce_wchar character) const noexcept { - CharPointerType t (text); + auto t = text; int last = -1; for (int i = 0; ! t.isEmpty(); ++i) @@ -934,7 +934,7 @@ int String::lastIndexOfChar (const juce_wchar character) const noexcept int String::indexOfAnyOf (StringRef charactersToLookFor, const int startIndex, const bool ignoreCase) const noexcept { - CharPointerType t (text); + auto t = text; for (int i = 0; ! t.isEmpty(); ++i) { @@ -967,7 +967,7 @@ int String::indexOf (const int startIndex, StringRef other) const noexcept if (other.isEmpty()) return -1; - CharPointerType t (text); + auto t = text; for (int i = startIndex; --i >= 0;) { @@ -977,10 +977,8 @@ int String::indexOf (const int startIndex, StringRef other) const noexcept ++t; } - int found = t.indexOf (other.text); - if (found >= 0) - found += startIndex; - return found; + auto found = t.indexOf (other.text); + return found >= 0 ? found + startIndex : found; } int String::indexOfIgnoreCase (const int startIndex, StringRef other) const noexcept @@ -988,7 +986,7 @@ int String::indexOfIgnoreCase (const int startIndex, StringRef other) const noex if (other.isEmpty()) return -1; - CharPointerType t (text); + auto t = text; for (int i = startIndex; --i >= 0;) { @@ -998,22 +996,20 @@ int String::indexOfIgnoreCase (const int startIndex, StringRef other) const noex ++t; } - int found = CharacterFunctions::indexOfIgnoreCase (t, other.text); - if (found >= 0) - found += startIndex; - return found; + auto found = CharacterFunctions::indexOfIgnoreCase (t, other.text); + return found >= 0 ? found + startIndex : found; } int String::lastIndexOf (StringRef other) const noexcept { if (other.isNotEmpty()) { - const int len = other.length(); + auto len = other.length(); int i = length() - len; if (i >= 0) { - for (CharPointerType n (text + i); i >= 0; --i) + for (auto n = text + i; i >= 0; --i) { if (n.compareUpTo (other.text, len) == 0) return i; @@ -1030,12 +1026,12 @@ int String::lastIndexOfIgnoreCase (StringRef other) const noexcept { if (other.isNotEmpty()) { - const int len = other.length(); + auto len = other.length(); int i = length() - len; if (i >= 0) { - for (CharPointerType n (text + i); i >= 0; --i) + for (auto n = text + i; i >= 0; --i) { if (n.compareIgnoreCaseUpTo (other.text, len) == 0) return i; @@ -1050,7 +1046,7 @@ int String::lastIndexOfIgnoreCase (StringRef other) const noexcept int String::lastIndexOfAnyOf (StringRef charactersToLookFor, const bool ignoreCase) const noexcept { - CharPointerType t (text); + auto t = text; int last = -1; for (int i = 0; ! t.isEmpty(); ++i) @@ -1079,9 +1075,9 @@ int String::indexOfWholeWord (StringRef word) const noexcept { if (word.isNotEmpty()) { - CharPointerType t (text); - const int wordLen = word.length(); - const int end = (int) t.length() - wordLen; + auto t = text; + auto wordLen = word.length(); + auto end = (int) t.length() - wordLen; for (int i = 0; i <= end; ++i) { @@ -1101,9 +1097,9 @@ int String::indexOfWholeWordIgnoreCase (StringRef word) const noexcept { if (word.isNotEmpty()) { - CharPointerType t (text); - const int wordLen = word.length(); - const int end = (int) t.length() - wordLen; + auto t = text; + auto wordLen = word.length(); + auto end = (int) t.length() - wordLen; for (int i = 0; i <= end; ++i) { @@ -1137,7 +1133,7 @@ struct WildCardMatcher { for (;;) { - const juce_wchar wc = wildcard.getAndAdvance(); + auto wc = wildcard.getAndAdvance(); if (wc == '*') return wildcard.isEmpty() || matchesAnywhere (wildcard, test, ignoreCase); @@ -1178,7 +1174,7 @@ String String::repeatedString (StringRef stringToRepeat, int numberOfTimesToRepe return {}; String result (PreallocationBytes (findByteOffsetOfEnd (stringToRepeat) * (size_t) numberOfTimesToRepeat)); - CharPointerType n (result.text); + auto n = result.text; while (--numberOfTimesToRepeat >= 0) n.writeAll (stringToRepeat.text); @@ -1190,8 +1186,8 @@ String String::paddedLeft (const juce_wchar padCharacter, int minimumLength) con { jassert (padCharacter != 0); - int extraChars = minimumLength; - CharPointerType end (text); + auto extraChars = minimumLength; + auto end = text; while (! end.isEmpty()) { @@ -1202,9 +1198,9 @@ String String::paddedLeft (const juce_wchar padCharacter, int minimumLength) con if (extraChars <= 0 || padCharacter == 0) return *this; - const size_t currentByteSize = (size_t) (((char*) end.getAddress()) - (char*) text.getAddress()); + auto currentByteSize = (size_t) (((char*) end.getAddress()) - (char*) text.getAddress()); String result (PreallocationBytes (currentByteSize + (size_t) extraChars * CharPointerType::getBytesRequiredFor (padCharacter))); - CharPointerType n (result.text); + auto n = result.text; while (--extraChars >= 0) n.write (padCharacter); @@ -1217,7 +1213,7 @@ String String::paddedRight (const juce_wchar padCharacter, int minimumLength) co { jassert (padCharacter != 0); - int extraChars = minimumLength; + auto extraChars = minimumLength; CharPointerType end (text); while (! end.isEmpty()) @@ -1229,9 +1225,9 @@ String String::paddedRight (const juce_wchar padCharacter, int minimumLength) co if (extraChars <= 0 || padCharacter == 0) return *this; - const size_t currentByteSize = (size_t) (((char*) end.getAddress()) - (char*) text.getAddress()); + auto currentByteSize = (size_t) (((char*) end.getAddress()) - (char*) text.getAddress()); String result (PreallocationBytes (currentByteSize + (size_t) extraChars * CharPointerType::getBytesRequiredFor (padCharacter))); - CharPointerType n (result.text); + auto n = result.text; n.writeAll (text); @@ -1259,7 +1255,7 @@ String String::replaceSection (int index, int numCharsToReplace, StringRef strin jassertfalse; } - CharPointerType insertPoint (text); + auto insertPoint = text; for (int i = 0; i < index; ++i) { @@ -1273,7 +1269,7 @@ String String::replaceSection (int index, int numCharsToReplace, StringRef strin ++insertPoint; } - CharPointerType startOfRemainder (insertPoint); + auto startOfRemainder = insertPoint; for (int i = 0; i < numCharsToReplace && ! startOfRemainder.isEmpty(); ++i) ++startOfRemainder; @@ -1281,17 +1277,18 @@ String String::replaceSection (int index, int numCharsToReplace, StringRef strin if (insertPoint == text && startOfRemainder.isEmpty()) return stringToInsert.text; - const size_t initialBytes = (size_t) (((char*) insertPoint.getAddress()) - (char*) text.getAddress()); - const size_t newStringBytes = findByteOffsetOfEnd (stringToInsert); - const size_t remainderBytes = (size_t) (((char*) startOfRemainder.findTerminatingNull().getAddress()) - (char*) startOfRemainder.getAddress()); + auto initialBytes = (size_t) (((char*) insertPoint.getAddress()) - (char*) text.getAddress()); + auto newStringBytes = findByteOffsetOfEnd (stringToInsert); + auto remainderBytes = (size_t) (((char*) startOfRemainder.findTerminatingNull().getAddress()) - (char*) startOfRemainder.getAddress()); + + auto newTotalBytes = initialBytes + newStringBytes + remainderBytes; - const size_t newTotalBytes = initialBytes + newStringBytes + remainderBytes; if (newTotalBytes <= 0) return {}; String result (PreallocationBytes ((size_t) newTotalBytes)); - char* dest = (char*) result.text.getAddress(); + auto* dest = (char*) result.text.getAddress(); memcpy (dest, text.getAddress(), initialBytes); dest += initialBytes; memcpy (dest, stringToInsert.text.getAddress(), newStringBytes); @@ -1305,8 +1302,8 @@ String String::replaceSection (int index, int numCharsToReplace, StringRef strin String String::replace (StringRef stringToReplace, StringRef stringToInsert, const bool ignoreCase) const { - const int stringToReplaceLen = stringToReplace.length(); - const int stringToInsertLen = stringToInsert.length(); + auto stringToReplaceLen = stringToReplace.length(); + auto stringToInsertLen = stringToInsert.length(); int i = 0; String result (*this); @@ -1323,9 +1320,9 @@ String String::replace (StringRef stringToReplace, StringRef stringToInsert, con String String::replaceFirstOccurrenceOf (StringRef stringToReplace, StringRef stringToInsert, const bool ignoreCase) const { - const int stringToReplaceLen = stringToReplace.length(); - const int index = ignoreCase ? indexOfIgnoreCase (stringToReplace) - : indexOf (stringToReplace); + auto stringToReplaceLen = stringToReplace.length(); + auto index = ignoreCase ? indexOfIgnoreCase (stringToReplace) + : indexOf (stringToReplace); if (index >= 0) return replaceSection (index, stringToReplaceLen, stringToInsert); @@ -1333,18 +1330,16 @@ String String::replaceFirstOccurrenceOf (StringRef stringToReplace, StringRef st return *this; } -class StringCreationHelper +struct StringCreationHelper { -public: - StringCreationHelper (const size_t initialBytes) - : source (nullptr), dest (nullptr), allocatedBytes (initialBytes), bytesWritten (0) + StringCreationHelper (size_t initialBytes) : allocatedBytes (initialBytes) { result.preallocateBytes (allocatedBytes); dest = result.getCharPointer(); } StringCreationHelper (const String::CharPointerType s) - : source (s), dest (nullptr), allocatedBytes (StringHolder::getAllocatedNumBytes (s)), bytesWritten (0) + : source (s), allocatedBytes (StringHolder::getAllocatedNumBytes (s)) { result.preallocateBytes (allocatedBytes); dest = result.getCharPointer(); @@ -1357,7 +1352,7 @@ public: if (bytesWritten > allocatedBytes) { allocatedBytes += jmax ((size_t) 8, allocatedBytes / 16); - const size_t destOffset = (size_t) (((char*) dest.getAddress()) - (char*) result.getCharPointer().getAddress()); + auto destOffset = (size_t) (((char*) dest.getAddress()) - (char*) result.getCharPointer().getAddress()); result.preallocateBytes (allocatedBytes); dest = addBytesToPointer (result.getCharPointer().getAddress(), (int) destOffset); } @@ -1365,12 +1360,11 @@ public: dest.write (c); } - String result; - String::CharPointerType source; + String&& get() noexcept { return static_cast (result); } -private: - String::CharPointerType dest; - size_t allocatedBytes, bytesWritten; + String result; + String::CharPointerType source { nullptr }, dest { nullptr }; + size_t allocatedBytes, bytesWritten = 0; }; String String::replaceCharacter (const juce_wchar charToReplace, const juce_wchar charToInsert) const @@ -1382,7 +1376,7 @@ String String::replaceCharacter (const juce_wchar charToReplace, const juce_wcha for (;;) { - juce_wchar c = builder.source.getAndAdvance(); + auto c = builder.source.getAndAdvance(); if (c == charToReplace) c = charToInsert; @@ -1393,7 +1387,7 @@ String String::replaceCharacter (const juce_wchar charToReplace, const juce_wcha break; } - return builder.result; + return builder.get(); } String String::replaceCharacters (StringRef charactersToReplace, StringRef charactersToInsertInstead) const @@ -1406,9 +1400,9 @@ String String::replaceCharacters (StringRef charactersToReplace, StringRef chara for (;;) { - juce_wchar c = builder.source.getAndAdvance(); + auto c = builder.source.getAndAdvance(); + auto index = charactersToReplace.text.indexOf (c); - const int index = charactersToReplace.text.indexOf (c); if (index >= 0) c = charactersToInsertInstead [index]; @@ -1418,7 +1412,7 @@ String String::replaceCharacters (StringRef charactersToReplace, StringRef chara break; } - return builder.result; + return builder.get(); } //============================================================================== @@ -1446,14 +1440,14 @@ bool String::endsWithChar (const juce_wchar character) const noexcept if (text.isEmpty()) return false; - CharPointerType t (text.findTerminatingNull()); + auto t = text.findTerminatingNull(); return *--t == character; } bool String::endsWith (StringRef other) const noexcept { - CharPointerType end (text.findTerminatingNull()); - CharPointerType otherEnd (other.text.findTerminatingNull()); + auto end = text.findTerminatingNull(); + auto otherEnd = other.text.findTerminatingNull(); while (end > text && otherEnd > other.text) { @@ -1469,8 +1463,8 @@ bool String::endsWith (StringRef other) const noexcept bool String::endsWithIgnoreCase (StringRef other) const noexcept { - CharPointerType end (text.findTerminatingNull()); - CharPointerType otherEnd (other.text.findTerminatingNull()); + auto end = text.findTerminatingNull(); + auto otherEnd = other.text.findTerminatingNull(); while (end > text && otherEnd > other.text) { @@ -1491,7 +1485,7 @@ String String::toUpperCase() const for (;;) { - const juce_wchar c = builder.source.toUpperCase(); + auto c = builder.source.toUpperCase(); builder.write (c); if (c == 0) @@ -1500,7 +1494,7 @@ String String::toUpperCase() const ++(builder.source); } - return builder.result; + return builder.get(); } String String::toLowerCase() const @@ -1509,7 +1503,7 @@ String String::toLowerCase() const for (;;) { - const juce_wchar c = builder.source.toLowerCase(); + auto c = builder.source.toLowerCase(); builder.write (c); if (c == 0) @@ -1518,7 +1512,7 @@ String String::toLowerCase() const ++(builder.source); } - return builder.result; + return builder.get(); } //============================================================================== @@ -1536,7 +1530,7 @@ String String::substring (int start, const int end) const return {}; int i = 0; - CharPointerType t1 (text); + auto t1 = text; while (i < start) { @@ -1547,7 +1541,8 @@ String String::substring (int start, const int end) const ++t1; } - CharPointerType t2 (t1); + auto t2 = t1; + while (i < end) { if (t2.isEmpty()) @@ -1570,7 +1565,7 @@ String String::substring (int start) const if (start <= 0) return *this; - CharPointerType t (text); + auto t = text; while (--start >= 0) { @@ -1593,48 +1588,40 @@ String String::getLastCharacters (const int numCharacters) const return String (text + jmax (0, length() - jmax (0, numCharacters))); } -String String::fromFirstOccurrenceOf (StringRef sub, - const bool includeSubString, - const bool ignoreCase) const +String String::fromFirstOccurrenceOf (StringRef sub, bool includeSubString, bool ignoreCase) const { - const int i = ignoreCase ? indexOfIgnoreCase (sub) - : indexOf (sub); + auto i = ignoreCase ? indexOfIgnoreCase (sub) + : indexOf (sub); if (i < 0) return {}; return substring (includeSubString ? i : i + sub.length()); } -String String::fromLastOccurrenceOf (StringRef sub, - const bool includeSubString, - const bool ignoreCase) const +String String::fromLastOccurrenceOf (StringRef sub, bool includeSubString, bool ignoreCase) const { - const int i = ignoreCase ? lastIndexOfIgnoreCase (sub) - : lastIndexOf (sub); + auto i = ignoreCase ? lastIndexOfIgnoreCase (sub) + : lastIndexOf (sub); if (i < 0) return *this; return substring (includeSubString ? i : i + sub.length()); } -String String::upToFirstOccurrenceOf (StringRef sub, - const bool includeSubString, - const bool ignoreCase) const +String String::upToFirstOccurrenceOf (StringRef sub, bool includeSubString, bool ignoreCase) const { - const int i = ignoreCase ? indexOfIgnoreCase (sub) - : indexOf (sub); + auto i = ignoreCase ? indexOfIgnoreCase (sub) + : indexOf (sub); if (i < 0) return *this; return substring (0, includeSubString ? i + sub.length() : i); } -String String::upToLastOccurrenceOf (StringRef sub, - const bool includeSubString, - const bool ignoreCase) const +String String::upToLastOccurrenceOf (StringRef sub, bool includeSubString, bool ignoreCase) const { - const int i = ignoreCase ? lastIndexOfIgnoreCase (sub) - : lastIndexOf (sub); + auto i = ignoreCase ? lastIndexOfIgnoreCase (sub) + : lastIndexOf (sub); if (i < 0) return *this; @@ -1660,7 +1647,7 @@ String String::unquoted() const return substring (1, len - (isQuoteCharacter (text[len - 1]) ? 1 : 0)); } -String String::quoted (const juce_wchar quoteCharacter) const +String String::quoted (juce_wchar quoteCharacter) const { if (isEmpty()) return charToString (quoteCharacter) + quoteCharacter; @@ -1696,10 +1683,9 @@ String String::trim() const { if (isNotEmpty()) { - CharPointerType start (text.findEndOfWhitespace()); - - const CharPointerType end (start.findTerminatingNull()); - CharPointerType trimmedEnd (findTrimmedEnd (start, end)); + auto start = text.findEndOfWhitespace(); + auto end = start.findTerminatingNull(); + auto trimmedEnd = findTrimmedEnd (start, end); if (trimmedEnd <= start) return {}; @@ -1715,7 +1701,7 @@ String String::trimStart() const { if (isNotEmpty()) { - const CharPointerType t (text.findEndOfWhitespace()); + auto t = text.findEndOfWhitespace(); if (t != text) return String (t); @@ -1728,8 +1714,8 @@ String String::trimEnd() const { if (isNotEmpty()) { - const CharPointerType end (text.findTerminatingNull()); - CharPointerType trimmedEnd (findTrimmedEnd (text, end)); + auto end = text.findTerminatingNull(); + auto trimmedEnd = findTrimmedEnd (text, end); if (trimmedEnd < end) return String (text, trimmedEnd); @@ -1740,7 +1726,7 @@ String String::trimEnd() const String String::trimCharactersAtStart (StringRef charactersToTrim) const { - CharPointerType t (text); + auto t = text; while (charactersToTrim.text.indexOf (*t) >= 0) ++t; @@ -1752,8 +1738,8 @@ String String::trimCharactersAtEnd (StringRef charactersToTrim) const { if (isNotEmpty()) { - const CharPointerType end (text.findTerminatingNull()); - CharPointerType trimmedEnd (end); + auto end = text.findTerminatingNull(); + auto trimmedEnd = end; while (trimmedEnd > text) { @@ -1781,7 +1767,7 @@ String String::retainCharacters (StringRef charactersToRetain) const for (;;) { - juce_wchar c = builder.source.getAndAdvance(); + auto c = builder.source.getAndAdvance(); if (charactersToRetain.text.indexOf (c) >= 0) builder.write (c); @@ -1791,7 +1777,7 @@ String String::retainCharacters (StringRef charactersToRetain) const } builder.write (0); - return builder.result; + return builder.get(); } String String::removeCharacters (StringRef charactersToRemove) const @@ -1803,7 +1789,7 @@ String String::removeCharacters (StringRef charactersToRemove) const for (;;) { - juce_wchar c = builder.source.getAndAdvance(); + auto c = builder.source.getAndAdvance(); if (charactersToRemove.text.indexOf (c) < 0) builder.write (c); @@ -1812,12 +1798,12 @@ String String::removeCharacters (StringRef charactersToRemove) const break; } - return builder.result; + return builder.get(); } String String::initialSectionContainingOnly (StringRef permittedCharacters) const { - for (CharPointerType t (text); ! t.isEmpty(); ++t) + for (auto t = text; ! t.isEmpty(); ++t) if (permittedCharacters.text.indexOf (*t) < 0) return String (text, t); @@ -1826,7 +1812,7 @@ String String::initialSectionContainingOnly (StringRef permittedCharacters) cons String String::initialSectionNotContaining (StringRef charactersToStopAt) const { - for (CharPointerType t (text); ! t.isEmpty(); ++t) + for (auto t = text; ! t.isEmpty(); ++t) if (charactersToStopAt.text.indexOf (*t) >= 0) return String (text, t); @@ -1835,7 +1821,7 @@ String String::initialSectionNotContaining (StringRef charactersToStopAt) const bool String::containsOnly (StringRef chars) const noexcept { - for (CharPointerType t (text); ! t.isEmpty();) + for (auto t = text; ! t.isEmpty();) if (chars.text.indexOf (t.getAndAdvance()) < 0) return false; @@ -1844,7 +1830,7 @@ bool String::containsOnly (StringRef chars) const noexcept bool String::containsAnyOf (StringRef chars) const noexcept { - for (CharPointerType t (text); ! t.isEmpty();) + for (auto t = text; ! t.isEmpty();) if (chars.text.indexOf (t.getAndAdvance()) >= 0) return true; @@ -1853,7 +1839,7 @@ bool String::containsAnyOf (StringRef chars) const noexcept bool String::containsNonWhitespaceChars() const noexcept { - for (CharPointerType t (text); ! t.isEmpty(); ++t) + for (auto t = text; ! t.isEmpty(); ++t) if (! t.isWhitespace()) return true; @@ -1909,7 +1895,7 @@ int String::getTrailingIntValue() const noexcept { int n = 0; int mult = 1; - CharPointerType t (text.findTerminatingNull()); + auto t = text.findTerminatingNull(); while (--t >= text) { @@ -1966,7 +1952,7 @@ String String::toHexString (const void* const d, const int size, const int group String s (PreallocationBytes (sizeof (CharPointerType::CharType) * (size_t) numChars)); auto* data = static_cast (d); - CharPointerType dest (s.text); + auto dest = s.text; for (int i = 0; i < size; ++i) { @@ -2014,7 +2000,7 @@ String String::createStringFromData (const void* const unknownData, int size) StringCreationHelper builder ((size_t) numChars); - const uint16* const src = (const uint16*) (data + 2); + auto src = (const uint16*) (data + 2); if (CharPointer_UTF16::isByteOrderMarkBigEndian (data)) { @@ -2028,7 +2014,7 @@ String String::createStringFromData (const void* const unknownData, int size) } builder.write (0); - return builder.result; + return builder.get(); } auto* start = (const char*) data; @@ -2062,9 +2048,9 @@ struct StringEncodingConverter return CharPointerType_Dest (reinterpret_cast (&emptyChar)); CharPointerType_Src text (source.getCharPointer()); - const size_t extraBytesNeeded = CharPointerType_Dest::getBytesRequiredFor (text) + sizeof (typename CharPointerType_Dest::CharType); - const size_t endOffset = (text.sizeInBytes() + 3) & ~3u; // the new string must be word-aligned or many Windows - // functions will fail to read it correctly! + auto extraBytesNeeded = CharPointerType_Dest::getBytesRequiredFor (text) + sizeof (typename CharPointerType_Dest::CharType); + auto endOffset = (text.sizeInBytes() + 3) & ~3u; // the new string must be word-aligned or many Windows + // functions will fail to read it correctly! source.preallocateBytes (endOffset + extraBytesNeeded); text = source.getCharPointer(); @@ -2072,7 +2058,7 @@ struct StringEncodingConverter const CharPointerType_Dest extraSpace (static_cast (newSpace)); #if JUCE_DEBUG // (This just avoids spurious warnings from valgrind about the uninitialised bytes at the end of the buffer..) - const size_t bytesToClear = (size_t) jmin ((int) extraBytesNeeded, 4); + auto bytesToClear = (size_t) jmin ((int) extraBytesNeeded, 4); zeromem (addBytesToPointer (newSpace, extraBytesNeeded - bytesToClear), bytesToClear); #endif From 4b75bbdab683edbfe6af9a0bd2a58fc13d2eef30 Mon Sep 17 00:00:00 2001 From: ed Date: Tue, 19 Sep 2017 15:14:37 +0100 Subject: [PATCH 113/129] Littlefoot: Add pitch correction functions --- .../protocol/juce_BlocksProtocolDefinitions.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/juce_blocks_basics/protocol/juce_BlocksProtocolDefinitions.h b/modules/juce_blocks_basics/protocol/juce_BlocksProtocolDefinitions.h index 5d1c2244c6..ed0f7d5f36 100644 --- a/modules/juce_blocks_basics/protocol/juce_BlocksProtocolDefinitions.h +++ b/modules/juce_blocks_basics/protocol/juce_BlocksProtocolDefinitions.h @@ -477,6 +477,9 @@ static constexpr const char* ledProgramLittleFootFunctions[] = "sendPitchBend/vii", "sendPitchBend/viii", "sendChannelPressure/vii", + "addPitchCorrectionPad/viiffff", + "setPitchCorrectionEnabled/vb", + "getPitchCorrectionPitchBend/iii", "setChannelRange/vbii", "assignChannel/ii", "deassignChannel/vii", From 2878bc2f75918942c1bc6850789364dc025f893e Mon Sep 17 00:00:00 2001 From: jules Date: Tue, 19 Sep 2017 16:20:53 +0100 Subject: [PATCH 114/129] Added a copy constructor for MidiBuffer::Iterator --- modules/juce_audio_basics/midi/juce_MidiBuffer.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/juce_audio_basics/midi/juce_MidiBuffer.h b/modules/juce_audio_basics/midi/juce_MidiBuffer.h index d4bfead789..01389edd54 100644 --- a/modules/juce_audio_basics/midi/juce_MidiBuffer.h +++ b/modules/juce_audio_basics/midi/juce_MidiBuffer.h @@ -160,8 +160,8 @@ public: /** Used to iterate through the events in a MidiBuffer. - Note that altering the buffer while an iterator is using it isn't a - safe operation. + Note that altering the buffer while an iterator is using it will produce + undefined behaviour. @see MidiBuffer */ @@ -172,6 +172,9 @@ public: /** Creates an Iterator for this MidiBuffer. */ Iterator (const MidiBuffer&) noexcept; + /** Creates a copy of an iterator. */ + Iterator (const Iterator&) noexcept = default; + /** Destructor. */ ~Iterator() noexcept; @@ -214,8 +217,6 @@ public: //============================================================================== const MidiBuffer& buffer; const uint8* data; - - JUCE_DECLARE_NON_COPYABLE (Iterator) }; /** The raw data holding this buffer. From 94669f2b1473f0b244b7d3ce988620afc2cfe116 Mon Sep 17 00:00:00 2001 From: jules Date: Tue, 19 Sep 2017 16:28:35 +0100 Subject: [PATCH 115/129] whitespace --- modules/juce_audio_basics/midi/juce_MidiBuffer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/juce_audio_basics/midi/juce_MidiBuffer.h b/modules/juce_audio_basics/midi/juce_MidiBuffer.h index 01389edd54..e856bfbd2b 100644 --- a/modules/juce_audio_basics/midi/juce_MidiBuffer.h +++ b/modules/juce_audio_basics/midi/juce_MidiBuffer.h @@ -160,7 +160,7 @@ public: /** Used to iterate through the events in a MidiBuffer. - Note that altering the buffer while an iterator is using it will produce + Note that altering the buffer while an iterator is using it will produce undefined behaviour. @see MidiBuffer From fcffaa6751c213063679b601e3d262493e2afe7e Mon Sep 17 00:00:00 2001 From: hogliux Date: Tue, 19 Sep 2017 16:51:52 +0100 Subject: [PATCH 116/129] VST3: Fixed an issue with the VST3 implementation of isInputChannelStereoPair/isOutputChannelStereoPair --- .../format_types/juce_VST3PluginFormat.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp b/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp index 18f3db32a6..29f7d1a55d 100644 --- a/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp +++ b/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp @@ -2183,14 +2183,16 @@ struct VST3PluginInstance : public AudioPluginInstance bool isInputChannelStereoPair (int channelIndex) const override { - return isPositiveAndBelow (channelIndex, getTotalNumInputChannels()) - && getBusInfo (true, true).channelCount == 2; + int busIdx; + return getOffsetInBusBufferForAbsoluteChannelIndex (true, channelIndex, busIdx) >= 0 + && getBusInfo (true, true, busIdx).channelCount == 2; } bool isOutputChannelStereoPair (int channelIndex) const override { - return isPositiveAndBelow (channelIndex, getTotalNumOutputChannels()) - && getBusInfo (false, true).channelCount == 2; + int busIdx; + return getOffsetInBusBufferForAbsoluteChannelIndex (false, channelIndex, busIdx) >= 0 + && getBusInfo (false, true, busIdx).channelCount == 2; } bool acceptsMidi() const override { return getBusInfo (true, false).channelCount > 0; } From 70aa86413aaa856533ba54d868bca46159c9b7c5 Mon Sep 17 00:00:00 2001 From: hogliux Date: Tue, 19 Sep 2017 17:04:38 +0100 Subject: [PATCH 117/129] Standalone Plug-In: Fixed an issue where the editor would not resize correctly on mobile when the feedback warning was dismissed --- .../Standalone/juce_StandaloneFilterWindow.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h b/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h index 4460880427..06cb07599d 100644 --- a/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h +++ b/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h @@ -788,9 +788,13 @@ private: shouldShowNotification = newInputMutedValue; notification.setVisible (shouldShowNotification); + #if JUCE_IOS || JUCE_ANDROID + resized(); + #else setSize (editor->getWidth(), editor->getHeight() + (shouldShowNotification ? NotificationArea::height : 0)); + #endif } void valueChanged (Value& value) override { inputMutedChanged (value.getValue()); } From fec19eeadebd896c077dd3355fcd93acdf1e37b5 Mon Sep 17 00:00:00 2001 From: tpoole Date: Wed, 20 Sep 2017 09:56:44 +0100 Subject: [PATCH 118/129] MacOS: Fixed a bug detecting changes to the number of hardware output channels --- modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp b/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp index 4442d15603..40629e7a69 100644 --- a/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp +++ b/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp @@ -581,6 +581,8 @@ public: stop (false); + updateDetailsFromDevice(); + activeInputChans = inputChannels; activeInputChans.setRange (inChanNames.size(), activeInputChans.getHighestBit() + 1 - inChanNames.size(), From 554d055a8f36c1db2c399f031dba3711cd4e1007 Mon Sep 17 00:00:00 2001 From: tpoole Date: Wed, 20 Sep 2017 10:04:11 +0100 Subject: [PATCH 119/129] WinRT MIDI: Increased the maximum size of outgoing messages --- modules/juce_audio_devices/native/juce_win32_Midi.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/juce_audio_devices/native/juce_win32_Midi.cpp b/modules/juce_audio_devices/native/juce_win32_Midi.cpp index 8aacbae9ce..c45ab2dc53 100644 --- a/modules/juce_audio_devices/native/juce_win32_Midi.cpp +++ b/modules/juce_audio_devices/native/juce_win32_Midi.cpp @@ -998,7 +998,7 @@ private: if (bufferFactory == nullptr) throw std::runtime_error ("Failed to create output buffer factory"); - HRESULT hr = bufferFactory->Create (static_cast (256), buffer.resetAndGetPointerAddress()); + HRESULT hr = bufferFactory->Create (static_cast (65536), buffer.resetAndGetPointerAddress()); if (FAILED (hr)) throw std::runtime_error ("Failed to create output buffer"); From 9e356135a1afea04e1e1e975a3504173345fec7b Mon Sep 17 00:00:00 2001 From: jules Date: Wed, 20 Sep 2017 10:12:18 +0100 Subject: [PATCH 120/129] Added a minimum number of columns option to the PopupMenu, and did a bit of internal modernising on the class's internals --- .../juce_gui_basics/menus/juce_PopupMenu.cpp | 108 ++++++++---------- .../juce_gui_basics/menus/juce_PopupMenu.h | 48 ++++---- 2 files changed, 71 insertions(+), 85 deletions(-) diff --git a/modules/juce_gui_basics/menus/juce_PopupMenu.cpp b/modules/juce_gui_basics/menus/juce_PopupMenu.cpp index 6c92b07e02..530a49f7ee 100644 --- a/modules/juce_gui_basics/menus/juce_PopupMenu.cpp +++ b/modules/juce_gui_basics/menus/juce_PopupMenu.cpp @@ -74,9 +74,7 @@ struct HeaderItemComponent : public PopupMenu::CustomComponent struct ItemComponent : public Component { ItemComponent (const PopupMenu::Item& i, int standardItemHeight, MenuWindow& parent) - : item (i), - customComp (i.customComponent), - isHighlighted (false) + : item (i), customComp (i.customComponent) { if (item.isSectionHeader) customComp = new HeaderItemComponent (item.text); @@ -152,7 +150,7 @@ struct ItemComponent : public Component private: // NB: we use a copy of the one from the item info in case we're using our own section comp ReferenceCountedObjectPtr customComp; - bool isHighlighted; + bool isHighlighted = false; void updateShortcutKeyDescription() { @@ -200,7 +198,7 @@ public: parent (parentWindow), options (opts), managerOfChosenCommand (manager), - componentAttachedTo (options.targetComponent), + componentAttachedTo (options.getTargetComponent()), dismissOnMouseUp (shouldDismissOnMouseUp), windowCreationTime (Time::getMillisecondCounter()), lastFocusedTime (windowCreationTime), @@ -230,23 +228,22 @@ public: auto item = menu.items.getUnchecked (i); if (i < menu.items.size() - 1 || ! item->isSeparator) - items.add (new ItemComponent (*item, options.standardHeight, *this)); + items.add (new ItemComponent (*item, options.getStandardItemHeight(), *this)); } - Rectangle targetArea = options.targetArea / scaleFactor; + auto targetArea = options.getTargetScreenArea() / scaleFactor; calculateWindowPos (targetArea, alignToRectangle); setTopLeftPosition (windowPos.getPosition()); updateYPositions(); - if (options.visibleItemID != 0) + if (auto visibleID = options.getItemThatMustBeVisible()) { auto targetPosition = parentComponent != nullptr ? parentComponent->getLocalPoint (nullptr, targetArea.getTopLeft()) : targetArea.getTopLeft(); auto y = targetPosition.getY() - windowPos.getY(); - ensureItemIsVisible (options.visibleItemID, - isPositiveAndBelow (y, windowPos.getHeight()) ? y : -1); + ensureItemIsVisible (visibleID, isPositiveAndBelow (y, windowPos.getHeight()) ? y : -1); } resizeToBestWindowPos(); @@ -492,7 +489,7 @@ public: if (! isVisible()) return false; - if (componentAttachedTo != options.targetComponent) + if (componentAttachedTo != options.getTargetComponent()) { dismissMenu (nullptr); return false; @@ -629,8 +626,8 @@ public: { x = target.getX(); - const int spaceUnder = parentArea.getHeight() - (target.getBottom() - parentArea.getY()); - const int spaceOver = target.getY() - parentArea.getY(); + auto spaceUnder = parentArea.getHeight() - (target.getBottom() - parentArea.getY()); + auto spaceOver = target.getY() - parentArea.getY(); if (heightToUse < spaceUnder - 30 || spaceUnder >= spaceOver) y = target.getBottom(); @@ -697,15 +694,14 @@ public: void layoutMenuItems (const int maxMenuW, const int maxMenuH, int& width, int& height) { - numColumns = 0; + numColumns = options.getMinimumNumColumns(); contentHeight = 0; int totalW; - const int maximumNumColumns = options.maxColumns > 0 ? options.maxColumns : 7; + auto maximumNumColumns = options.getMaximumNumColumns() > 0 ? options.getMaximumNumColumns() : 7; - do + for (;;) { - ++numColumns; totalW = workOutBestSize (maxMenuW); if (totalW > maxMenuW) @@ -715,12 +711,15 @@ public: break; } - if (totalW > maxMenuW / 2 || contentHeight < maxMenuH) + if (totalW > maxMenuW / 2 + || contentHeight < maxMenuH + || numColumns >= maximumNumColumns) break; - } while (numColumns < maximumNumColumns); + ++numColumns; + } - const int actualH = jmin (contentHeight, maxMenuH); + auto actualH = jmin (contentHeight, maxMenuH); needsToScroll = contentHeight > actualH; @@ -736,7 +735,7 @@ public: for (int col = 0; col < numColumns; ++col) { - int colW = options.standardHeight, colH = 0; + int colW = options.getStandardItemHeight(), colH = 0; const int numChildren = jmin (items.size() - childNum, (items.size() + numColumns - 1) / numColumns); @@ -757,7 +756,7 @@ public: } // width must never be larger than the screen - const int minWidth = jmin (maxMenuW, options.minWidth); + auto minWidth = jmin (maxMenuW, options.getMinimumWidth()); if (totalW < minWidth) { @@ -1321,13 +1320,6 @@ void PopupMenu::clear() //============================================================================== PopupMenu::Item::Item() noexcept - : itemID (0), - commandManager (nullptr), - colour (0x00000000), - isEnabled (true), - isTicked (false), - isSeparator (false), - isSectionHeader (false) { } @@ -1526,12 +1518,6 @@ void PopupMenu::addSectionHeader (const String& title) //============================================================================== PopupMenu::Options::Options() - : targetComponent (nullptr), - parentComponent (nullptr), - visibleItemID (0), - minWidth (0), - maxColumns (0), - standardHeight (0) { targetArea.setPosition (Desktop::getMousePosition()); } @@ -1547,7 +1533,7 @@ PopupMenu::Options PopupMenu::Options::withTargetComponent (Component* comp) con return o; } -PopupMenu::Options PopupMenu::Options::withTargetScreenArea (const Rectangle& area) const noexcept +PopupMenu::Options PopupMenu::Options::withTargetScreenArea (Rectangle area) const noexcept { Options o (*this); o.targetArea = area; @@ -1561,6 +1547,13 @@ PopupMenu::Options PopupMenu::Options::withMinimumWidth (int w) const noexcept return o; } +PopupMenu::Options PopupMenu::Options::withMinimumNumColumns (int cols) const noexcept +{ + Options o (*this); + o.minColumns = cols; + return o; +} + PopupMenu::Options PopupMenu::Options::withMaximumNumColumns (int cols) const noexcept { Options o (*this); @@ -1592,13 +1585,11 @@ PopupMenu::Options PopupMenu::Options::withParentComponent (Component* parent) c Component* PopupMenu::createWindow (const Options& options, ApplicationCommandManager** managerOfChosenCommand) const { - if (items.size() > 0) - return new HelperClasses::MenuWindow (*this, nullptr, options, - ! options.targetArea.isEmpty(), - ModifierKeys::getCurrentModifiers().isAnyMouseButtonDown(), - managerOfChosenCommand); - - return nullptr; + return items.isEmpty() ? nullptr + : new HelperClasses::MenuWindow (*this, nullptr, options, + ! options.getTargetScreenArea().isEmpty(), + ModifierKeys::getCurrentModifiers().isAnyMouseButtonDown(), + managerOfChosenCommand); } //============================================================================== @@ -1690,9 +1681,8 @@ void PopupMenu::showMenuAsync (const Options& options, ModalComponentManager::Ca //============================================================================== #if JUCE_MODAL_LOOPS_PERMITTED -int PopupMenu::show (const int itemIDThatMustBeVisible, - const int minimumWidth, const int maximumNumColumns, - const int standardItemHeight, +int PopupMenu::show (int itemIDThatMustBeVisible, int minimumWidth, + int maximumNumColumns, int standardItemHeight, ModalComponentManager::Callback* callback) { return showWithOptionalCallback (Options().withItemThatMustBeVisible (itemIDThatMustBeVisible) @@ -1702,10 +1692,9 @@ int PopupMenu::show (const int itemIDThatMustBeVisible, callback, true); } -int PopupMenu::showAt (const Rectangle& screenAreaToAttachTo, - const int itemIDThatMustBeVisible, - const int minimumWidth, const int maximumNumColumns, - const int standardItemHeight, +int PopupMenu::showAt (Rectangle screenAreaToAttachTo, + int itemIDThatMustBeVisible, int minimumWidth, + int maximumNumColumns, int standardItemHeight, ModalComponentManager::Callback* callback) { return showWithOptionalCallback (Options().withTargetScreenArea (screenAreaToAttachTo) @@ -1717,15 +1706,14 @@ int PopupMenu::showAt (const Rectangle& screenAreaToAttachTo, } int PopupMenu::showAt (Component* componentToAttachTo, - const int itemIDThatMustBeVisible, - const int minimumWidth, const int maximumNumColumns, - const int standardItemHeight, + int itemIDThatMustBeVisible, int minimumWidth, + int maximumNumColumns, int standardItemHeight, ModalComponentManager::Callback* callback) { - Options options (Options().withItemThatMustBeVisible (itemIDThatMustBeVisible) - .withMinimumWidth (minimumWidth) - .withMaximumNumColumns (maximumNumColumns) - .withStandardItemHeight (standardItemHeight)); + auto options = Options().withItemThatMustBeVisible (itemIDThatMustBeVisible) + .withMinimumWidth (minimumWidth) + .withMaximumNumColumns (maximumNumColumns) + .withStandardItemHeight (standardItemHeight); if (componentToAttachTo != nullptr) options = options.withTargetComponent (componentToAttachTo); @@ -1793,8 +1781,7 @@ void PopupMenu::setLookAndFeel (LookAndFeel* const newLookAndFeel) //============================================================================== PopupMenu::CustomComponent::CustomComponent (bool autoTrigger) - : isHighlighted (false), - triggeredAutomatically (autoTrigger) + : triggeredAutomatically (autoTrigger) { } @@ -1835,9 +1822,8 @@ PopupMenu::CustomCallback::CustomCallback() {} PopupMenu::CustomCallback::~CustomCallback() {} //============================================================================== -PopupMenu::MenuItemIterator::MenuItemIterator (const PopupMenu& m, bool searchR) : searchRecursively (searchR) +PopupMenu::MenuItemIterator::MenuItemIterator (const PopupMenu& m, bool recurse) : searchRecursively (recurse) { - currentItem = nullptr; index.add (0); menus.add (&m); } diff --git a/modules/juce_gui_basics/menus/juce_PopupMenu.h b/modules/juce_gui_basics/menus/juce_PopupMenu.h index 10ecd898fc..d3a91b94ce 100644 --- a/modules/juce_gui_basics/menus/juce_PopupMenu.h +++ b/modules/juce_gui_basics/menus/juce_PopupMenu.h @@ -89,19 +89,19 @@ public: PopupMenu(); /** Creates a copy of another menu. */ - PopupMenu (const PopupMenu& other); + PopupMenu (const PopupMenu&); /** Destructor. */ ~PopupMenu(); /** Copies this menu from another one. */ - PopupMenu& operator= (const PopupMenu& other); + PopupMenu& operator= (const PopupMenu&); /** Move constructor */ - PopupMenu (PopupMenu&& other) noexcept; + PopupMenu (PopupMenu&&) noexcept; /** Move assignment operator */ - PopupMenu& operator= (PopupMenu&& other) noexcept; + PopupMenu& operator= (PopupMenu&&) noexcept; //============================================================================== /** Resets the menu, removing all its items. */ @@ -125,8 +125,8 @@ public: /** The menu item's name. */ String text; - /** The menu item's ID. This can not be 0 if you want the item to be triggerable! */ - int itemID; + /** The menu item's ID. This must not be 0 if you want the item to be triggerable! */ + int itemID = 0; /** A sub-menu, or nullptr if there isn't one. */ ScopedPointer subMenu; @@ -141,7 +141,7 @@ public: ReferenceCountedObjectPtr customCallback; /** A command manager to use to automatically invoke the command, or nullptr if none is specified. */ - ApplicationCommandManager* commandManager; + ApplicationCommandManager* commandManager = nullptr; /** An optional string describing the shortcut key for this item. This is only used for displaying at the right-hand edge of a menu item - the @@ -157,16 +157,16 @@ public: Colour colour; /** True if this menu item is enabled. */ - bool isEnabled; + bool isEnabled = true; /** True if this menu item should have a tick mark next to it. */ - bool isTicked; + bool isTicked = false; /** True if this menu item is a separator line. */ - bool isSeparator; + bool isSeparator = false; /** True if this menu item is a section header. */ - bool isSectionHeader; + bool isSectionHeader = false; }; /** Adds an item to the menu. @@ -247,8 +247,6 @@ public: const String& displayName = String(), Drawable* iconToUse = nullptr); - - /** Appends a text item with a special colour. This is the same as addItem(), but specifies a colour to use for the @@ -389,11 +387,14 @@ public: { public: Options(); + Options (const Options&) = default; + Options& operator= (const Options&) = default; //============================================================================== Options withTargetComponent (Component* targetComponent) const noexcept; - Options withTargetScreenArea (const Rectangle& targetArea) const noexcept; + Options withTargetScreenArea (Rectangle targetArea) const noexcept; Options withMinimumWidth (int minWidth) const noexcept; + Options withMinimumNumColumns (int minNumColumns) const noexcept; Options withMaximumNumColumns (int maxNumColumns) const noexcept; Options withStandardItemHeight (int standardHeight) const noexcept; Options withItemThatMustBeVisible (int idOfItemToBeVisible) const noexcept; @@ -405,17 +406,16 @@ public: Rectangle getTargetScreenArea() const noexcept { return targetArea; } int getMinimumWidth() const noexcept { return minWidth; } int getMaximumNumColumns() const noexcept { return maxColumns; } + int getMinimumNumColumns() const noexcept { return minColumns; } int getStandardItemHeight() const noexcept { return standardHeight; } int getItemThatMustBeVisible() const noexcept { return visibleItemID; } private: //============================================================================== - friend class PopupMenu; - friend class PopupMenu::Window; Rectangle targetArea; - Component* targetComponent; - Component* parentComponent; - int visibleItemID, minWidth, maxColumns, standardHeight; + Component* targetComponent = nullptr; + Component* parentComponent = nullptr; + int visibleItemID = 0, minWidth = 0, minColumns = 1, maxColumns = 0, standardHeight = 0; }; //============================================================================== @@ -473,7 +473,7 @@ public: @see show() */ - int showAt (const Rectangle& screenAreaToAttachTo, + int showAt (Rectangle screenAreaToAttachTo, int itemIDThatMustBeVisible = 0, int minimumWidth = 0, int maximumNumColumns = 0, @@ -585,9 +585,9 @@ public: //============================================================================== bool searchRecursively; - Array index; - Array menus; - PopupMenu::Item *currentItem; + Array index; + Array menus; + PopupMenu::Item* currentItem = nullptr; MenuItemIterator& operator= (const MenuItemIterator&); JUCE_LEAK_DETECTOR (MenuItemIterator) @@ -638,7 +638,7 @@ public: private: //============================================================================== - bool isHighlighted, triggeredAutomatically; + bool isHighlighted = false, triggeredAutomatically; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CustomComponent) }; From 47698a86b1d6245604775fba3b0d88b8f5eb1111 Mon Sep 17 00:00:00 2001 From: tpoole Date: Wed, 20 Sep 2017 12:53:27 +0100 Subject: [PATCH 121/129] MinGW: Fixed some 32 bit build errors --- examples/Demo/Source/Demos/VideoDemo.cpp | 2 +- modules/juce_core/juce_core.cpp | 2 ++ .../juce_core/native/juce_win32_Network.cpp | 23 +++++++++++-------- .../native/juce_win32_SystemStats.cpp | 8 +++++++ .../juce_core/system/juce_StandardHeader.h | 5 ++++ .../juce_core/text/juce_CharPointer_UTF8.h | 2 +- .../juce_core/text/juce_CharacterFunctions.h | 23 +++++++++++-------- modules/juce_graphics/juce_graphics.cpp | 1 + .../native/juce_win32_WebBrowserComponent.cpp | 16 +++++++++++-- 9 files changed, 60 insertions(+), 22 deletions(-) diff --git a/examples/Demo/Source/Demos/VideoDemo.cpp b/examples/Demo/Source/Demos/VideoDemo.cpp index 589dc25aba..66b7a9da33 100644 --- a/examples/Demo/Source/Demos/VideoDemo.cpp +++ b/examples/Demo/Source/Demos/VideoDemo.cpp @@ -26,7 +26,7 @@ #include "../JuceDemoHeader.h" -#if JUCE_MAC || JUCE_WINDOWS +#if JUCE_MAC || (JUCE_WINDOWS && ! JUCE_MINGW) //============================================================================== // so that we can easily have two video windows each with a file browser, wrap this up as a class.. diff --git a/modules/juce_core/juce_core.cpp b/modules/juce_core/juce_core.cpp index df5d73287b..136dd284e7 100644 --- a/modules/juce_core/juce_core.cpp +++ b/modules/juce_core/juce_core.cpp @@ -61,6 +61,8 @@ #if JUCE_MINGW #include + #include + #include #endif #else diff --git a/modules/juce_core/native/juce_win32_Network.cpp b/modules/juce_core/native/juce_win32_Network.cpp index 21da41aba4..bdc7dc9c4d 100644 --- a/modules/juce_core/native/juce_win32_Network.cpp +++ b/modules/juce_core/native/juce_win32_Network.cpp @@ -503,6 +503,17 @@ namespace MACAddressHelpers } } } + + static void split (const sockaddr_in6* sa_in6, int off, uint8* split) + { + #if JUCE_MINGW + split[0] = sa_in6->sin6_addr._S6_un._S6_u8[off + 1]; + split[1] = sa_in6->sin6_addr._S6_un._S6_u8[off]; + #else + split[0] = sa_in6->sin6_addr.u.Byte[off + 1]; + split[1] = sa_in6->sin6_addr.u.Byte[off]; + #endif + } } void MACAddress::findAllAddresses (Array& result) @@ -541,9 +552,7 @@ void IPAddress::findAllAddresses (Array& result, bool includeIPv6) for (int i = 0; i < 8; ++i) { - temp.split[0] = sa_in6->sin6_addr.u.Byte[i * 2 + 1]; - temp.split[1] = sa_in6->sin6_addr.u.Byte[i * 2]; - + MACAddressHelpers::split (sa_in6, i * 2, temp.split); arr[i] = temp.combined; } @@ -570,9 +579,7 @@ void IPAddress::findAllAddresses (Array& result, bool includeIPv6) for (int i = 0; i < 8; ++i) { - temp.split[0] = sa_in6->sin6_addr.u.Byte[i * 2 + 1]; - temp.split[1] = sa_in6->sin6_addr.u.Byte[i * 2]; - + MACAddressHelpers::split (sa_in6, i * 2, temp.split); arr[i] = temp.combined; } @@ -599,9 +606,7 @@ void IPAddress::findAllAddresses (Array& result, bool includeIPv6) for (int i = 0; i < 8; ++i) { - temp.split[0] = sa_in6->sin6_addr.u.Byte[i * 2 + 1]; - temp.split[1] = sa_in6->sin6_addr.u.Byte[i * 2]; - + MACAddressHelpers::split (sa_in6, i * 2, temp.split); arr[i] = temp.combined; } diff --git a/modules/juce_core/native/juce_win32_SystemStats.cpp b/modules/juce_core/native/juce_win32_SystemStats.cpp index 3f28dded45..e2b4409350 100644 --- a/modules/juce_core/native/juce_win32_SystemStats.cpp +++ b/modules/juce_core/native/juce_win32_SystemStats.cpp @@ -107,6 +107,13 @@ String SystemStats::getCpuModel() static int findNumberOfPhysicalCores() noexcept { + #if JUCE_MINGW + // Not implemented in MinGW + jassertfalse; + + return 1; + #else + int numPhysicalCores = 0; DWORD bufferSize = 0; GetLogicalProcessorInformation (nullptr, &bufferSize); @@ -122,6 +129,7 @@ static int findNumberOfPhysicalCores() noexcept } return numPhysicalCores; + #endif // JUCE_MINGW } //============================================================================== diff --git a/modules/juce_core/system/juce_StandardHeader.h b/modules/juce_core/system/juce_StandardHeader.h index f194fe4477..896d5b4da1 100644 --- a/modules/juce_core/system/juce_StandardHeader.h +++ b/modules/juce_core/system/juce_StandardHeader.h @@ -114,6 +114,11 @@ #include "../misc/juce_StdFunctionCompat.h" #endif +// The live build fails to compile std::stringstream +#if ! JUCE_PROJUCER_LIVE_BUILD + #include +#endif + // Include std::atomic if it's supported by the compiler #if JUCE_ATOMIC_AVAILABLE #include diff --git a/modules/juce_core/text/juce_CharPointer_UTF8.h b/modules/juce_core/text/juce_CharPointer_UTF8.h index 0d3c5d6634..7b5a91df90 100644 --- a/modules/juce_core/text/juce_CharPointer_UTF8.h +++ b/modules/juce_core/text/juce_CharPointer_UTF8.h @@ -471,7 +471,7 @@ public: /** Parses this string as a 64-bit integer. */ int64 getIntValue64() const noexcept { - #if JUCE_WINDOWS + #if JUCE_WINDOWS && ! JUCE_MINGW return _atoi64 (data); #else return atoll (data); diff --git a/modules/juce_core/text/juce_CharacterFunctions.h b/modules/juce_core/text/juce_CharacterFunctions.h index 27894bd8f5..d9cec4bac6 100644 --- a/modules/juce_core/text/juce_CharacterFunctions.h +++ b/modules/juce_core/text/juce_CharacterFunctions.h @@ -231,17 +231,22 @@ public: *currentCharacter++ = '0'; } - #if JUCE_WINDOWS - static _locale_t locale = _create_locale (LC_ALL, "C"); - return _strtod_l (&buffer[0], nullptr, locale); - #else - static locale_t locale = newlocale (LC_ALL_MASK, "C", nullptr); - #if JUCE_ANDROID - return (double) strtold_l (&buffer[0], nullptr, locale); + #if JUCE_PROJUCER_LIVE_BUILD + // This will change with locale! + return strtod (&buffer[0], nullptr); #else - return strtod_l (&buffer[0], nullptr, locale); + double result = 0; + const size_t stringSize = (size_t) (currentCharacter - &buffer[0]) + 1; + + if (stringSize > 1) + { + std::istringstream is (std::string (&buffer[0], stringSize)); + is.imbue (std::locale ("C")); + is >> result; + } + + return result; #endif - #endif } /** Parses a character string, to read a floating-point value. */ diff --git a/modules/juce_graphics/juce_graphics.cpp b/modules/juce_graphics/juce_graphics.cpp index 373c9f4e4d..2dcbc5e8bb 100644 --- a/modules/juce_graphics/juce_graphics.cpp +++ b/modules/juce_graphics/juce_graphics.cpp @@ -68,6 +68,7 @@ #if JUCE_MINGW #include + #include #endif #ifdef JUCE_MSVC diff --git a/modules/juce_gui_extra/native/juce_win32_WebBrowserComponent.cpp b/modules/juce_gui_extra/native/juce_win32_WebBrowserComponent.cpp index 77ba594e24..7ca294913c 100644 --- a/modules/juce_gui_extra/native/juce_win32_WebBrowserComponent.cpp +++ b/modules/juce_gui_extra/native/juce_win32_WebBrowserComponent.cpp @@ -30,6 +30,12 @@ namespace juce JUCE_DECLARE_UUID_GETTER (DWebBrowserEvents2, "34A715A0-6587-11D0-924A-0020AFC7AC4D") JUCE_DECLARE_UUID_GETTER (IConnectionPointContainer, "B196B284-BAB4-101A-B69C-00AA00341D07") JUCE_DECLARE_UUID_GETTER (IWebBrowser2, "D30C1661-CDAF-11D0-8A3E-00C04FC9E26E") + +#if JUCE_MINGW + #define DISPID_NAVIGATEERROR 271 + class WebBrowser; +#endif + JUCE_DECLARE_UUID_GETTER (WebBrowser, "8856F961-340A-11D0-A96B-00C04FD705A2") class WebBrowserComponent::Pimpl : public ActiveXControlComponent @@ -392,12 +398,18 @@ void WebBrowserComponent::clearCookies() { HeapBlock<::INTERNET_CACHE_ENTRY_INFO> entry; ::DWORD entrySize = sizeof (::INTERNET_CACHE_ENTRY_INFO); - ::HANDLE urlCacheHandle = ::FindFirstUrlCacheEntry (TEXT ("cookie:"), entry.getData(), &entrySize); + + #if JUCE_MINGW + const auto searchPattern = "cookie:"; + #else + const auto searchPattern = TEXT ("cookie:"); + #endif + ::HANDLE urlCacheHandle = ::FindFirstUrlCacheEntry (searchPattern, entry.getData(), &entrySize); if (urlCacheHandle == nullptr && GetLastError() == ERROR_INSUFFICIENT_BUFFER) { entry.realloc (1, entrySize); - urlCacheHandle = ::FindFirstUrlCacheEntry (TEXT ("cookie:"), entry.getData(), &entrySize); + urlCacheHandle = ::FindFirstUrlCacheEntry (searchPattern, entry.getData(), &entrySize); } if (urlCacheHandle != nullptr) From e6ae3f7aa7e49944775e7802d2bf9e6aa8783ca4 Mon Sep 17 00:00:00 2001 From: jules Date: Wed, 20 Sep 2017 13:57:30 +0100 Subject: [PATCH 122/129] Fixed a problem in a static assert in Atomic. --- modules/juce_core/memory/juce_Atomic.h | 954 ++++++++++++------------- 1 file changed, 477 insertions(+), 477 deletions(-) diff --git a/modules/juce_core/memory/juce_Atomic.h b/modules/juce_core/memory/juce_Atomic.h index 353ca2a0d5..dd15c9893f 100644 --- a/modules/juce_core/memory/juce_Atomic.h +++ b/modules/juce_core/memory/juce_Atomic.h @@ -1,477 +1,477 @@ -/* - ============================================================================== - - This file is part of the JUCE library. - Copyright (c) 2017 - ROLI Ltd. - - JUCE is an open source library subject to commercial or open-source - licensing. - - The code included in this file is provided under the terms of the ISC license - http://www.isc.org/downloads/software-support-policy/isc-license. Permission - To use, copy, modify, and/or distribute this software for any purpose with or - without fee is hereby granted provided that the above copyright notice and - this permission notice appear in all copies. - - JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER - EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE - DISCLAIMED. - - ============================================================================== -*/ - -namespace juce -{ - -#ifndef DOXYGEN - namespace AtomicHelpers - { - template struct DiffTypeHelper { typedef T Type; }; - template struct DiffTypeHelper { typedef std::ptrdiff_t Type; }; - } -#endif - -#if JUCE_ATOMIC_AVAILABLE - //============================================================================== - /** - A simple wrapper around std::atomic. - */ - template - struct Atomic - { - typedef typename AtomicHelpers::DiffTypeHelper::Type DiffType; - - /** Creates a new value, initialised to zero. */ - Atomic() noexcept : value (0) {} - - /** Creates a new value, with a given initial value. */ - Atomic (const Type initialValue) noexcept : value (initialValue) {} - - /** Copies another value (atomically). */ - Atomic (const Atomic& other) noexcept : value (other.get()) {} - - /** Destructor. */ - ~Atomic() noexcept - { - #if __cpp_lib_atomic_is_always_lock_free - static_assert (std::atomic::is_always_lock_free(), - "This class can only be used for lock-free types"); - #endif - } - - /** Atomically reads and returns the current value. */ - Type get() const noexcept { return value.load(); } - - /** Atomically sets the current value. */ - void set (Type newValue) noexcept { value = newValue; } - - /** Atomically sets the current value, returning the value that was replaced. */ - Type exchange (Type newValue) noexcept { return value.exchange (newValue); } - - /** Atomically compares this value with a target value, and if it is equal, sets - this to be equal to a new value. - - This operation is the atomic equivalent of doing this: - @code - bool compareAndSetBool (Type newValue, Type valueToCompare) - { - if (get() == valueToCompare) - { - set (newValue); - return true; - } - - return false; - } - @endcode - - Internally, this method calls std::atomic::compare_exchange_strong with - memory_order_seq_cst (the strictest std::memory_order). - - @returns true if the comparison was true and the value was replaced; false if - the comparison failed and the value was left unchanged. - @see compareAndSetValue - */ - bool compareAndSetBool (Type newValue, Type valueToCompare) noexcept - { - return value.compare_exchange_strong (valueToCompare, newValue); - } - - /** Copies another value into this one (atomically). */ - Atomic& operator= (const Atomic& other) noexcept - { - value = other.value.load(); - return *this; - } - - /** Copies another value into this one (atomically). */ - Atomic& operator= (const Type newValue) noexcept - { - value = newValue; - return *this; - } - - /** Atomically adds a number to this value, returning the new value. */ - Type operator+= (DiffType amountToAdd) noexcept { return value += amountToAdd; } - - /** Atomically subtracts a number from this value, returning the new value. */ - Type operator-= (DiffType amountToSubtract) noexcept { return value -= amountToSubtract; } - - /** Atomically increments this value, returning the new value. */ - Type operator++() noexcept { return ++value; } - - /** Atomically decrements this value, returning the new value. */ - Type operator--() noexcept { return --value; } - - /** Implements a memory read/write barrier. - - Internally this calls std::atomic_thread_fence with - memory_order_seq_cst (the strictest std::memory_order). - */ - void memoryBarrier() noexcept { atomic_thread_fence (std::memory_order_seq_cst); } - - /** The std::atomic object that this class operates on. */ - std::atomic value; - - //============================================================================== - #ifndef DOXYGEN - // This method has been deprecated as there is no equivalent method in std::atomic. - JUCE_DEPRECATED (Type compareAndSetValue (Type, Type) noexcept); - #endif - }; - -#else - - #ifndef DOXYGEN - template class AtomicBase; - #endif - - //============================================================================== - /** - Simple class to hold a primitive value and perform atomic operations on it. - - The type used must be a 32 or 64 bit primitive, like an int, pointer, etc. - There are methods to perform most of the basic atomic operations. - */ - template - class Atomic : public AtomicBase - { - public: - /** Resulting type when subtracting the underlying Type. */ - typedef typename AtomicBase::DiffType DiffType; - - /** Creates a new value, initialised to zero. */ - inline Atomic() noexcept {} - - /** Creates a new value, with a given initial value. */ - inline explicit Atomic (const Type initialValue) noexcept : AtomicBase (initialValue) {} - - /** Copies another value (atomically). */ - inline Atomic (const Atomic& other) noexcept : AtomicBase (other) {} - - /** Destructor. */ - inline ~Atomic() noexcept - { - static_assert (sizeof (Type) == 4 || sizeof (Type) == 8, - "Atomic can only be used for types which are 32 or 64 bits in size"); - } - - /** Atomically reads and returns the current value. */ - inline Type get() const noexcept { return AtomicBase::get(); } - - /** Copies another value into this one (atomically). */ - inline Atomic& operator= (const Atomic& other) noexcept { AtomicBase::operator= (other); return *this; } - - /** Copies another value into this one (atomically). */ - inline Atomic& operator= (const Type newValue) noexcept { AtomicBase::operator= (newValue); return *this; } - - /** Atomically sets the current value. */ - inline void set (Type newValue) noexcept { exchange (newValue); } - - /** Atomically sets the current value, returning the value that was replaced. */ - inline Type exchange (Type v) noexcept { return AtomicBase::exchange (v); } - - /** Atomically adds a number to this value, returning the new value. */ - Type operator+= (DiffType amountToAdd) noexcept; - - /** Atomically subtracts a number from this value, returning the new value. */ - Type operator-= (DiffType amountToSubtract) noexcept; - - /** Atomically increments this value, returning the new value. */ - Type operator++() noexcept; - - /** Atomically decrements this value, returning the new value. */ - Type operator--() noexcept; - - /** Atomically compares this value with a target value, and if it is equal, sets - this to be equal to a new value. - - This operation is the atomic equivalent of doing this: - @code - bool compareAndSetBool (Type newValue, Type valueToCompare) - { - if (get() == valueToCompare) - { - set (newValue); - return true; - } - - return false; - } - @endcode - - @returns true if the comparison was true and the value was replaced; false if - the comparison failed and the value was left unchanged. - @see compareAndSetValue - */ - inline bool compareAndSetBool (Type newValue, Type valueToCompare) noexcept { return AtomicBase::compareAndSetBool (newValue, valueToCompare); } - - /** Atomically compares this value with a target value, and if it is equal, sets - this to be equal to a new value. - - This operation is the atomic equivalent of doing this: - @code - Type compareAndSetValue (Type newValue, Type valueToCompare) - { - Type oldValue = get(); - if (oldValue == valueToCompare) - set (newValue); - - return oldValue; - } - @endcode - - @returns the old value before it was changed. - @see compareAndSetBool - */ - inline Type compareAndSetValue (Type newValue, Type valueToCompare) noexcept { return AtomicBase::compareAndSetValue (newValue, valueToCompare); } - - /** Implements a memory read/write barrier. */ - static inline void memoryBarrier() noexcept { AtomicBase::memoryBarrier (); } - }; - - #ifndef DOXYGEN - - //============================================================================== - // Internal implementation follows - //============================================================================== - template - class AtomicBase - { - public: - typedef typename AtomicHelpers::DiffTypeHelper::Type DiffType; - - inline AtomicBase() noexcept : value (0) {} - inline explicit AtomicBase (const Type v) noexcept : value (v) {} - inline AtomicBase (const AtomicBase& other) noexcept : value (other.get()) {} - Type get() const noexcept; - inline AtomicBase& operator= (const AtomicBase& other) noexcept { exchange (other.get()); return *this; } - inline AtomicBase& operator= (const Type newValue) noexcept { exchange (newValue); return *this; } - void set (Type newValue) noexcept { exchange (newValue); } - Type exchange (Type) noexcept; - bool compareAndSetBool (Type, Type) noexcept; - Type compareAndSetValue (Type, Type) noexcept; - static void memoryBarrier() noexcept; - - //============================================================================== - #if JUCE_64BIT - JUCE_ALIGN (8) - #else - JUCE_ALIGN (4) - #endif - - /** The raw value that this class operates on. - This is exposed publicly in case you need to manipulate it directly - for performance reasons. - */ - volatile Type value; - - protected: - template - static inline Dest castTo (Source value) noexcept { union { Dest d; Source s; } u; u.s = value; return u.d; } - - static inline Type castFrom32Bit (int32 value) noexcept { return castTo (value); } - static inline Type castFrom64Bit (int64 value) noexcept { return castTo (value); } - static inline int32 castTo32Bit (Type value) noexcept { return castTo (value); } - static inline int64 castTo64Bit (Type value) noexcept { return castTo (value); } - - Type operator++ (int); // better to just use pre-increment with atomics.. - Type operator-- (int); - - /** This templated negate function will negate pointers as well as integers */ - template - inline ValueType negateValue (ValueType n) noexcept - { - return sizeof (ValueType) == 1 ? (ValueType) -(signed char) n - : (sizeof (ValueType) == 2 ? (ValueType) -(short) n - : (sizeof (ValueType) == 4 ? (ValueType) -(int) n - : ((ValueType) -(int64) n))); - } - - /** This templated negate function will negate pointers as well as integers */ - template - inline PointerType* negateValue (PointerType* n) noexcept - { - return reinterpret_cast (-reinterpret_cast (n)); - } - }; - - //============================================================================== - // Specialisation for void* which does not include the pointer arithmetic - template <> - class Atomic : public AtomicBase - { - public: - inline Atomic() noexcept {} - inline explicit Atomic (void* const initialValue) noexcept : AtomicBase (initialValue) {} - inline Atomic (const Atomic& other) noexcept : AtomicBase (other) {} - inline void* get() const noexcept { return AtomicBase::get(); } - inline Atomic& operator= (const Atomic& other) noexcept { AtomicBase::operator= (other); return *this; } - inline Atomic& operator= (void* const newValue) noexcept { AtomicBase::operator= (newValue); return *this; } - inline void set (void* newValue) noexcept { exchange (newValue); } - inline void* exchange (void* v) noexcept { return AtomicBase::exchange (v); } - inline bool compareAndSetBool (void* newValue, void* valueToCompare) noexcept { return AtomicBase::compareAndSetBool (newValue, valueToCompare); } - inline void* compareAndSetValue (void* newValue, void* valueToCompare) noexcept { return AtomicBase::compareAndSetValue (newValue, valueToCompare); } - static inline void memoryBarrier() noexcept { AtomicBase::memoryBarrier(); } - }; - - //============================================================================== - /* - The following code is in the header so that the atomics can be inlined where possible... - */ - #if JUCE_MAC && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 2)) - #define JUCE_ATOMICS_MAC_LEGACY 1 // Older OSX builds using gcc4.1 or earlier - #elif JUCE_GCC || JUCE_CLANG - #define JUCE_ATOMICS_GCC 1 // GCC with intrinsics - #if JUCE_IOS || JUCE_ANDROID // (64-bit ops will compile but not link on these mobile OSes) - #define JUCE_64BIT_ATOMICS_UNAVAILABLE 1 - #endif - #endif - - template - struct AtomicIncrementDecrement - { - static inline Type inc (AtomicBase& a) noexcept - { - #if JUCE_ATOMICS_MAC_LEGACY - return sizeof (Type) == 4 ? (Type) OSAtomicIncrement32Barrier ((volatile int32_t*) &a.value) - : (Type) OSAtomicIncrement64Barrier ((volatile int64_t*) &a.value); - #elif JUCE_ATOMICS_GCC - return sizeof (Type) == 4 ? (Type) __sync_add_and_fetch (& (a.value), (Type) 1) - : (Type) __sync_add_and_fetch ((int64_t*) & (a.value), 1); - #endif - } - - static inline Type dec (AtomicBase& a) noexcept - { - #if JUCE_ATOMICS_MAC_LEGACY - return sizeof (Type) == 4 ? (Type) OSAtomicDecrement32Barrier ((volatile int32_t*) &a.value) - : (Type) OSAtomicDecrement64Barrier ((volatile int64_t*) &a.value); - #elif JUCE_ATOMICS_GCC - return sizeof (Type) == 4 ? (Type) __sync_add_and_fetch (& (a.value), (Type) -1) - : (Type) __sync_add_and_fetch ((int64_t*) & (a.value), -1); - #endif - } - }; - - template - struct AtomicIncrementDecrement - { - static inline Type* inc (Atomic& a) noexcept { return a.operator+= (1); } - static inline Type* dec (Atomic& a) noexcept { return a.operator-= (1); } - }; - - //============================================================================== - template - inline Type AtomicBase::get() const noexcept - { - #if JUCE_ATOMICS_MAC_LEGACY - return sizeof (Type) == 4 ? castFrom32Bit ((int32) OSAtomicAdd32Barrier ((int32_t) 0, (volatile int32_t*) &value)) - : castFrom64Bit ((int64) OSAtomicAdd64Barrier ((int64_t) 0, (volatile int64_t*) &value)); - #elif JUCE_ATOMICS_GCC - return sizeof (Type) == 4 ? castFrom32Bit ((int32) __sync_add_and_fetch ((volatile int32*) &value, 0)) - : castFrom64Bit ((int64) __sync_add_and_fetch ((volatile int64*) &value, 0)); - #endif - } - - template - inline Type AtomicBase::exchange (const Type newValue) noexcept - { - #if JUCE_ATOMICS_MAC_LEGACY || JUCE_ATOMICS_GCC - Type currentVal = value; - while (! compareAndSetBool (newValue, currentVal)) { currentVal = value; } - return currentVal; - #endif - } - - template - inline Type Atomic::operator+= (const DiffType amountToAdd) noexcept - { - Type amount = (Type() + amountToAdd); - - #if JUCE_ATOMICS_MAC_LEGACY - return sizeof (Type) == 4 ? (Type) OSAtomicAdd32Barrier ((int32_t) castTo32Bit (amount), (volatile int32_t*) &AtomicBase::value) - : (Type) OSAtomicAdd64Barrier ((int64_t) amount, (volatile int64_t*) &AtomicBase::value); - #elif JUCE_ATOMICS_GCC - return (Type) __sync_add_and_fetch (& (AtomicBase::value), amount); - #endif - } - - template - inline Type Atomic::operator-= (const DiffType amountToSubtract) noexcept - { - return operator+= (AtomicBase::negateValue (amountToSubtract)); - } - - template - inline Type Atomic::operator++() noexcept { return AtomicIncrementDecrement::inc (*this); } - - template - inline Type Atomic::operator--() noexcept { return AtomicIncrementDecrement::dec (*this); } - - template - inline bool AtomicBase::compareAndSetBool (const Type newValue, const Type valueToCompare) noexcept - { - #if JUCE_ATOMICS_MAC_LEGACY - return sizeof (Type) == 4 ? OSAtomicCompareAndSwap32Barrier ((int32_t) castTo32Bit (valueToCompare), (int32_t) castTo32Bit (newValue), (volatile int32_t*) &value) - : OSAtomicCompareAndSwap64Barrier ((int64_t) castTo64Bit (valueToCompare), (int64_t) castTo64Bit (newValue), (volatile int64_t*) &value); - #elif JUCE_ATOMICS_GCC - return sizeof (Type) == 4 ? __sync_bool_compare_and_swap ((volatile int32*) &value, castTo32Bit (valueToCompare), castTo32Bit (newValue)) - : __sync_bool_compare_and_swap ((volatile int64*) &value, castTo64Bit (valueToCompare), castTo64Bit (newValue)); - #endif - } - - template - inline Type AtomicBase::compareAndSetValue (const Type newValue, const Type valueToCompare) noexcept - { - #if JUCE_ATOMICS_MAC_LEGACY - for (;;) // Annoying workaround for only having a bool CAS operation.. - { - if (compareAndSetBool (newValue, valueToCompare)) - return valueToCompare; - - const Type result = value; - if (result != valueToCompare) - return result; - } - #elif JUCE_ATOMICS_GCC - return sizeof (Type) == 4 ? castFrom32Bit ((int32) __sync_val_compare_and_swap ((volatile int32*) &value, castTo32Bit (valueToCompare), castTo32Bit (newValue))) - : castFrom64Bit ((int64) __sync_val_compare_and_swap ((volatile int64*) &value, castTo64Bit (valueToCompare), castTo64Bit (newValue))); - #endif - } - - template - inline void AtomicBase::memoryBarrier() noexcept - { - #if JUCE_ATOMICS_MAC_LEGACY - OSMemoryBarrier(); - #elif JUCE_ATOMICS_GCC - __sync_synchronize(); - #endif - } - - #endif - -#endif - -} // namespace juce +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2017 - ROLI Ltd. + + JUCE is an open source library subject to commercial or open-source + licensing. + + The code included in this file is provided under the terms of the ISC license + http://www.isc.org/downloads/software-support-policy/isc-license. Permission + To use, copy, modify, and/or distribute this software for any purpose with or + without fee is hereby granted provided that the above copyright notice and + this permission notice appear in all copies. + + JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER + EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE + DISCLAIMED. + + ============================================================================== +*/ + +namespace juce +{ + +#ifndef DOXYGEN + namespace AtomicHelpers + { + template struct DiffTypeHelper { typedef T Type; }; + template struct DiffTypeHelper { typedef std::ptrdiff_t Type; }; + } +#endif + +#if JUCE_ATOMIC_AVAILABLE + //============================================================================== + /** + A simple wrapper around std::atomic. + */ + template + struct Atomic + { + typedef typename AtomicHelpers::DiffTypeHelper::Type DiffType; + + /** Creates a new value, initialised to zero. */ + Atomic() noexcept : value (0) {} + + /** Creates a new value, with a given initial value. */ + Atomic (Type initialValue) noexcept : value (initialValue) {} + + /** Copies another value (atomically). */ + Atomic (const Atomic& other) noexcept : value (other.get()) {} + + /** Destructor. */ + ~Atomic() noexcept + { + #if __cpp_lib_atomic_is_always_lock_free + static_assert (std::atomic::is_always_lock_free, + "This class can only be used for lock-free types"); + #endif + } + + /** Atomically reads and returns the current value. */ + Type get() const noexcept { return value.load(); } + + /** Atomically sets the current value. */ + void set (Type newValue) noexcept { value = newValue; } + + /** Atomically sets the current value, returning the value that was replaced. */ + Type exchange (Type newValue) noexcept { return value.exchange (newValue); } + + /** Atomically compares this value with a target value, and if it is equal, sets + this to be equal to a new value. + + This operation is the atomic equivalent of doing this: + @code + bool compareAndSetBool (Type newValue, Type valueToCompare) + { + if (get() == valueToCompare) + { + set (newValue); + return true; + } + + return false; + } + @endcode + + Internally, this method calls std::atomic::compare_exchange_strong with + memory_order_seq_cst (the strictest std::memory_order). + + @returns true if the comparison was true and the value was replaced; false if + the comparison failed and the value was left unchanged. + @see compareAndSetValue + */ + bool compareAndSetBool (Type newValue, Type valueToCompare) noexcept + { + return value.compare_exchange_strong (valueToCompare, newValue); + } + + /** Copies another value into this one (atomically). */ + Atomic& operator= (const Atomic& other) noexcept + { + value = other.value.load(); + return *this; + } + + /** Copies another value into this one (atomically). */ + Atomic& operator= (Type newValue) noexcept + { + value = newValue; + return *this; + } + + /** Atomically adds a number to this value, returning the new value. */ + Type operator+= (DiffType amountToAdd) noexcept { return value += amountToAdd; } + + /** Atomically subtracts a number from this value, returning the new value. */ + Type operator-= (DiffType amountToSubtract) noexcept { return value -= amountToSubtract; } + + /** Atomically increments this value, returning the new value. */ + Type operator++() noexcept { return ++value; } + + /** Atomically decrements this value, returning the new value. */ + Type operator--() noexcept { return --value; } + + /** Implements a memory read/write barrier. + + Internally this calls std::atomic_thread_fence with + memory_order_seq_cst (the strictest std::memory_order). + */ + void memoryBarrier() noexcept { atomic_thread_fence (std::memory_order_seq_cst); } + + /** The std::atomic object that this class operates on. */ + std::atomic value; + + //============================================================================== + #ifndef DOXYGEN + // This method has been deprecated as there is no equivalent method in std::atomic. + JUCE_DEPRECATED (Type compareAndSetValue (Type, Type) noexcept); + #endif + }; + +#else + + #ifndef DOXYGEN + template class AtomicBase; + #endif + + //============================================================================== + /** + Simple class to hold a primitive value and perform atomic operations on it. + + The type used must be a 32 or 64 bit primitive, like an int, pointer, etc. + There are methods to perform most of the basic atomic operations. + */ + template + class Atomic : public AtomicBase + { + public: + /** Resulting type when subtracting the underlying Type. */ + typedef typename AtomicBase::DiffType DiffType; + + /** Creates a new value, initialised to zero. */ + inline Atomic() noexcept {} + + /** Creates a new value, with a given initial value. */ + inline explicit Atomic (const Type initialValue) noexcept : AtomicBase (initialValue) {} + + /** Copies another value (atomically). */ + inline Atomic (const Atomic& other) noexcept : AtomicBase (other) {} + + /** Destructor. */ + inline ~Atomic() noexcept + { + static_assert (sizeof (Type) == 4 || sizeof (Type) == 8, + "Atomic can only be used for types which are 32 or 64 bits in size"); + } + + /** Atomically reads and returns the current value. */ + inline Type get() const noexcept { return AtomicBase::get(); } + + /** Copies another value into this one (atomically). */ + inline Atomic& operator= (const Atomic& other) noexcept { AtomicBase::operator= (other); return *this; } + + /** Copies another value into this one (atomically). */ + inline Atomic& operator= (const Type newValue) noexcept { AtomicBase::operator= (newValue); return *this; } + + /** Atomically sets the current value. */ + inline void set (Type newValue) noexcept { exchange (newValue); } + + /** Atomically sets the current value, returning the value that was replaced. */ + inline Type exchange (Type v) noexcept { return AtomicBase::exchange (v); } + + /** Atomically adds a number to this value, returning the new value. */ + Type operator+= (DiffType amountToAdd) noexcept; + + /** Atomically subtracts a number from this value, returning the new value. */ + Type operator-= (DiffType amountToSubtract) noexcept; + + /** Atomically increments this value, returning the new value. */ + Type operator++() noexcept; + + /** Atomically decrements this value, returning the new value. */ + Type operator--() noexcept; + + /** Atomically compares this value with a target value, and if it is equal, sets + this to be equal to a new value. + + This operation is the atomic equivalent of doing this: + @code + bool compareAndSetBool (Type newValue, Type valueToCompare) + { + if (get() == valueToCompare) + { + set (newValue); + return true; + } + + return false; + } + @endcode + + @returns true if the comparison was true and the value was replaced; false if + the comparison failed and the value was left unchanged. + @see compareAndSetValue + */ + inline bool compareAndSetBool (Type newValue, Type valueToCompare) noexcept { return AtomicBase::compareAndSetBool (newValue, valueToCompare); } + + /** Atomically compares this value with a target value, and if it is equal, sets + this to be equal to a new value. + + This operation is the atomic equivalent of doing this: + @code + Type compareAndSetValue (Type newValue, Type valueToCompare) + { + Type oldValue = get(); + if (oldValue == valueToCompare) + set (newValue); + + return oldValue; + } + @endcode + + @returns the old value before it was changed. + @see compareAndSetBool + */ + inline Type compareAndSetValue (Type newValue, Type valueToCompare) noexcept { return AtomicBase::compareAndSetValue (newValue, valueToCompare); } + + /** Implements a memory read/write barrier. */ + static inline void memoryBarrier() noexcept { AtomicBase::memoryBarrier (); } + }; + + #ifndef DOXYGEN + + //============================================================================== + // Internal implementation follows + //============================================================================== + template + class AtomicBase + { + public: + typedef typename AtomicHelpers::DiffTypeHelper::Type DiffType; + + inline AtomicBase() noexcept : value (0) {} + inline explicit AtomicBase (const Type v) noexcept : value (v) {} + inline AtomicBase (const AtomicBase& other) noexcept : value (other.get()) {} + Type get() const noexcept; + inline AtomicBase& operator= (const AtomicBase& other) noexcept { exchange (other.get()); return *this; } + inline AtomicBase& operator= (const Type newValue) noexcept { exchange (newValue); return *this; } + void set (Type newValue) noexcept { exchange (newValue); } + Type exchange (Type) noexcept; + bool compareAndSetBool (Type, Type) noexcept; + Type compareAndSetValue (Type, Type) noexcept; + static void memoryBarrier() noexcept; + + //============================================================================== + #if JUCE_64BIT + JUCE_ALIGN (8) + #else + JUCE_ALIGN (4) + #endif + + /** The raw value that this class operates on. + This is exposed publicly in case you need to manipulate it directly + for performance reasons. + */ + volatile Type value; + + protected: + template + static inline Dest castTo (Source value) noexcept { union { Dest d; Source s; } u; u.s = value; return u.d; } + + static inline Type castFrom32Bit (int32 value) noexcept { return castTo (value); } + static inline Type castFrom64Bit (int64 value) noexcept { return castTo (value); } + static inline int32 castTo32Bit (Type value) noexcept { return castTo (value); } + static inline int64 castTo64Bit (Type value) noexcept { return castTo (value); } + + Type operator++ (int); // better to just use pre-increment with atomics.. + Type operator-- (int); + + /** This templated negate function will negate pointers as well as integers */ + template + inline ValueType negateValue (ValueType n) noexcept + { + return sizeof (ValueType) == 1 ? (ValueType) -(signed char) n + : (sizeof (ValueType) == 2 ? (ValueType) -(short) n + : (sizeof (ValueType) == 4 ? (ValueType) -(int) n + : ((ValueType) -(int64) n))); + } + + /** This templated negate function will negate pointers as well as integers */ + template + inline PointerType* negateValue (PointerType* n) noexcept + { + return reinterpret_cast (-reinterpret_cast (n)); + } + }; + + //============================================================================== + // Specialisation for void* which does not include the pointer arithmetic + template <> + class Atomic : public AtomicBase + { + public: + inline Atomic() noexcept {} + inline explicit Atomic (void* const initialValue) noexcept : AtomicBase (initialValue) {} + inline Atomic (const Atomic& other) noexcept : AtomicBase (other) {} + inline void* get() const noexcept { return AtomicBase::get(); } + inline Atomic& operator= (const Atomic& other) noexcept { AtomicBase::operator= (other); return *this; } + inline Atomic& operator= (void* const newValue) noexcept { AtomicBase::operator= (newValue); return *this; } + inline void set (void* newValue) noexcept { exchange (newValue); } + inline void* exchange (void* v) noexcept { return AtomicBase::exchange (v); } + inline bool compareAndSetBool (void* newValue, void* valueToCompare) noexcept { return AtomicBase::compareAndSetBool (newValue, valueToCompare); } + inline void* compareAndSetValue (void* newValue, void* valueToCompare) noexcept { return AtomicBase::compareAndSetValue (newValue, valueToCompare); } + static inline void memoryBarrier() noexcept { AtomicBase::memoryBarrier(); } + }; + + //============================================================================== + /* + The following code is in the header so that the atomics can be inlined where possible... + */ + #if JUCE_MAC && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 2)) + #define JUCE_ATOMICS_MAC_LEGACY 1 // Older OSX builds using gcc4.1 or earlier + #elif JUCE_GCC || JUCE_CLANG + #define JUCE_ATOMICS_GCC 1 // GCC with intrinsics + #if JUCE_IOS || JUCE_ANDROID // (64-bit ops will compile but not link on these mobile OSes) + #define JUCE_64BIT_ATOMICS_UNAVAILABLE 1 + #endif + #endif + + template + struct AtomicIncrementDecrement + { + static inline Type inc (AtomicBase& a) noexcept + { + #if JUCE_ATOMICS_MAC_LEGACY + return sizeof (Type) == 4 ? (Type) OSAtomicIncrement32Barrier ((volatile int32_t*) &a.value) + : (Type) OSAtomicIncrement64Barrier ((volatile int64_t*) &a.value); + #elif JUCE_ATOMICS_GCC + return sizeof (Type) == 4 ? (Type) __sync_add_and_fetch (& (a.value), (Type) 1) + : (Type) __sync_add_and_fetch ((int64_t*) & (a.value), 1); + #endif + } + + static inline Type dec (AtomicBase& a) noexcept + { + #if JUCE_ATOMICS_MAC_LEGACY + return sizeof (Type) == 4 ? (Type) OSAtomicDecrement32Barrier ((volatile int32_t*) &a.value) + : (Type) OSAtomicDecrement64Barrier ((volatile int64_t*) &a.value); + #elif JUCE_ATOMICS_GCC + return sizeof (Type) == 4 ? (Type) __sync_add_and_fetch (& (a.value), (Type) -1) + : (Type) __sync_add_and_fetch ((int64_t*) & (a.value), -1); + #endif + } + }; + + template + struct AtomicIncrementDecrement + { + static inline Type* inc (Atomic& a) noexcept { return a.operator+= (1); } + static inline Type* dec (Atomic& a) noexcept { return a.operator-= (1); } + }; + + //============================================================================== + template + inline Type AtomicBase::get() const noexcept + { + #if JUCE_ATOMICS_MAC_LEGACY + return sizeof (Type) == 4 ? castFrom32Bit ((int32) OSAtomicAdd32Barrier ((int32_t) 0, (volatile int32_t*) &value)) + : castFrom64Bit ((int64) OSAtomicAdd64Barrier ((int64_t) 0, (volatile int64_t*) &value)); + #elif JUCE_ATOMICS_GCC + return sizeof (Type) == 4 ? castFrom32Bit ((int32) __sync_add_and_fetch ((volatile int32*) &value, 0)) + : castFrom64Bit ((int64) __sync_add_and_fetch ((volatile int64*) &value, 0)); + #endif + } + + template + inline Type AtomicBase::exchange (const Type newValue) noexcept + { + #if JUCE_ATOMICS_MAC_LEGACY || JUCE_ATOMICS_GCC + Type currentVal = value; + while (! compareAndSetBool (newValue, currentVal)) { currentVal = value; } + return currentVal; + #endif + } + + template + inline Type Atomic::operator+= (const DiffType amountToAdd) noexcept + { + Type amount = (Type() + amountToAdd); + + #if JUCE_ATOMICS_MAC_LEGACY + return sizeof (Type) == 4 ? (Type) OSAtomicAdd32Barrier ((int32_t) castTo32Bit (amount), (volatile int32_t*) &AtomicBase::value) + : (Type) OSAtomicAdd64Barrier ((int64_t) amount, (volatile int64_t*) &AtomicBase::value); + #elif JUCE_ATOMICS_GCC + return (Type) __sync_add_and_fetch (& (AtomicBase::value), amount); + #endif + } + + template + inline Type Atomic::operator-= (const DiffType amountToSubtract) noexcept + { + return operator+= (AtomicBase::negateValue (amountToSubtract)); + } + + template + inline Type Atomic::operator++() noexcept { return AtomicIncrementDecrement::inc (*this); } + + template + inline Type Atomic::operator--() noexcept { return AtomicIncrementDecrement::dec (*this); } + + template + inline bool AtomicBase::compareAndSetBool (const Type newValue, const Type valueToCompare) noexcept + { + #if JUCE_ATOMICS_MAC_LEGACY + return sizeof (Type) == 4 ? OSAtomicCompareAndSwap32Barrier ((int32_t) castTo32Bit (valueToCompare), (int32_t) castTo32Bit (newValue), (volatile int32_t*) &value) + : OSAtomicCompareAndSwap64Barrier ((int64_t) castTo64Bit (valueToCompare), (int64_t) castTo64Bit (newValue), (volatile int64_t*) &value); + #elif JUCE_ATOMICS_GCC + return sizeof (Type) == 4 ? __sync_bool_compare_and_swap ((volatile int32*) &value, castTo32Bit (valueToCompare), castTo32Bit (newValue)) + : __sync_bool_compare_and_swap ((volatile int64*) &value, castTo64Bit (valueToCompare), castTo64Bit (newValue)); + #endif + } + + template + inline Type AtomicBase::compareAndSetValue (const Type newValue, const Type valueToCompare) noexcept + { + #if JUCE_ATOMICS_MAC_LEGACY + for (;;) // Annoying workaround for only having a bool CAS operation.. + { + if (compareAndSetBool (newValue, valueToCompare)) + return valueToCompare; + + const Type result = value; + if (result != valueToCompare) + return result; + } + #elif JUCE_ATOMICS_GCC + return sizeof (Type) == 4 ? castFrom32Bit ((int32) __sync_val_compare_and_swap ((volatile int32*) &value, castTo32Bit (valueToCompare), castTo32Bit (newValue))) + : castFrom64Bit ((int64) __sync_val_compare_and_swap ((volatile int64*) &value, castTo64Bit (valueToCompare), castTo64Bit (newValue))); + #endif + } + + template + inline void AtomicBase::memoryBarrier() noexcept + { + #if JUCE_ATOMICS_MAC_LEGACY + OSMemoryBarrier(); + #elif JUCE_ATOMICS_GCC + __sync_synchronize(); + #endif + } + + #endif + +#endif + +} // namespace juce From a5eebb37efcd1359d58051ead73214f18a4f65e2 Mon Sep 17 00:00:00 2001 From: jules Date: Wed, 20 Sep 2017 14:04:43 +0100 Subject: [PATCH 123/129] whitespace --- modules/juce_core/memory/juce_Atomic.h | 954 ++++++++++++------------- 1 file changed, 477 insertions(+), 477 deletions(-) diff --git a/modules/juce_core/memory/juce_Atomic.h b/modules/juce_core/memory/juce_Atomic.h index dd15c9893f..585b135504 100644 --- a/modules/juce_core/memory/juce_Atomic.h +++ b/modules/juce_core/memory/juce_Atomic.h @@ -1,477 +1,477 @@ -/* - ============================================================================== - - This file is part of the JUCE library. - Copyright (c) 2017 - ROLI Ltd. - - JUCE is an open source library subject to commercial or open-source - licensing. - - The code included in this file is provided under the terms of the ISC license - http://www.isc.org/downloads/software-support-policy/isc-license. Permission - To use, copy, modify, and/or distribute this software for any purpose with or - without fee is hereby granted provided that the above copyright notice and - this permission notice appear in all copies. - - JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER - EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE - DISCLAIMED. - - ============================================================================== -*/ - -namespace juce -{ - -#ifndef DOXYGEN - namespace AtomicHelpers - { - template struct DiffTypeHelper { typedef T Type; }; - template struct DiffTypeHelper { typedef std::ptrdiff_t Type; }; - } -#endif - -#if JUCE_ATOMIC_AVAILABLE - //============================================================================== - /** - A simple wrapper around std::atomic. - */ - template - struct Atomic - { - typedef typename AtomicHelpers::DiffTypeHelper::Type DiffType; - - /** Creates a new value, initialised to zero. */ - Atomic() noexcept : value (0) {} - - /** Creates a new value, with a given initial value. */ - Atomic (Type initialValue) noexcept : value (initialValue) {} - - /** Copies another value (atomically). */ - Atomic (const Atomic& other) noexcept : value (other.get()) {} - - /** Destructor. */ - ~Atomic() noexcept - { - #if __cpp_lib_atomic_is_always_lock_free - static_assert (std::atomic::is_always_lock_free, - "This class can only be used for lock-free types"); - #endif - } - - /** Atomically reads and returns the current value. */ - Type get() const noexcept { return value.load(); } - - /** Atomically sets the current value. */ - void set (Type newValue) noexcept { value = newValue; } - - /** Atomically sets the current value, returning the value that was replaced. */ - Type exchange (Type newValue) noexcept { return value.exchange (newValue); } - - /** Atomically compares this value with a target value, and if it is equal, sets - this to be equal to a new value. - - This operation is the atomic equivalent of doing this: - @code - bool compareAndSetBool (Type newValue, Type valueToCompare) - { - if (get() == valueToCompare) - { - set (newValue); - return true; - } - - return false; - } - @endcode - - Internally, this method calls std::atomic::compare_exchange_strong with - memory_order_seq_cst (the strictest std::memory_order). - - @returns true if the comparison was true and the value was replaced; false if - the comparison failed and the value was left unchanged. - @see compareAndSetValue - */ - bool compareAndSetBool (Type newValue, Type valueToCompare) noexcept - { - return value.compare_exchange_strong (valueToCompare, newValue); - } - - /** Copies another value into this one (atomically). */ - Atomic& operator= (const Atomic& other) noexcept - { - value = other.value.load(); - return *this; - } - - /** Copies another value into this one (atomically). */ - Atomic& operator= (Type newValue) noexcept - { - value = newValue; - return *this; - } - - /** Atomically adds a number to this value, returning the new value. */ - Type operator+= (DiffType amountToAdd) noexcept { return value += amountToAdd; } - - /** Atomically subtracts a number from this value, returning the new value. */ - Type operator-= (DiffType amountToSubtract) noexcept { return value -= amountToSubtract; } - - /** Atomically increments this value, returning the new value. */ - Type operator++() noexcept { return ++value; } - - /** Atomically decrements this value, returning the new value. */ - Type operator--() noexcept { return --value; } - - /** Implements a memory read/write barrier. - - Internally this calls std::atomic_thread_fence with - memory_order_seq_cst (the strictest std::memory_order). - */ - void memoryBarrier() noexcept { atomic_thread_fence (std::memory_order_seq_cst); } - - /** The std::atomic object that this class operates on. */ - std::atomic value; - - //============================================================================== - #ifndef DOXYGEN - // This method has been deprecated as there is no equivalent method in std::atomic. - JUCE_DEPRECATED (Type compareAndSetValue (Type, Type) noexcept); - #endif - }; - -#else - - #ifndef DOXYGEN - template class AtomicBase; - #endif - - //============================================================================== - /** - Simple class to hold a primitive value and perform atomic operations on it. - - The type used must be a 32 or 64 bit primitive, like an int, pointer, etc. - There are methods to perform most of the basic atomic operations. - */ - template - class Atomic : public AtomicBase - { - public: - /** Resulting type when subtracting the underlying Type. */ - typedef typename AtomicBase::DiffType DiffType; - - /** Creates a new value, initialised to zero. */ - inline Atomic() noexcept {} - - /** Creates a new value, with a given initial value. */ - inline explicit Atomic (const Type initialValue) noexcept : AtomicBase (initialValue) {} - - /** Copies another value (atomically). */ - inline Atomic (const Atomic& other) noexcept : AtomicBase (other) {} - - /** Destructor. */ - inline ~Atomic() noexcept - { - static_assert (sizeof (Type) == 4 || sizeof (Type) == 8, - "Atomic can only be used for types which are 32 or 64 bits in size"); - } - - /** Atomically reads and returns the current value. */ - inline Type get() const noexcept { return AtomicBase::get(); } - - /** Copies another value into this one (atomically). */ - inline Atomic& operator= (const Atomic& other) noexcept { AtomicBase::operator= (other); return *this; } - - /** Copies another value into this one (atomically). */ - inline Atomic& operator= (const Type newValue) noexcept { AtomicBase::operator= (newValue); return *this; } - - /** Atomically sets the current value. */ - inline void set (Type newValue) noexcept { exchange (newValue); } - - /** Atomically sets the current value, returning the value that was replaced. */ - inline Type exchange (Type v) noexcept { return AtomicBase::exchange (v); } - - /** Atomically adds a number to this value, returning the new value. */ - Type operator+= (DiffType amountToAdd) noexcept; - - /** Atomically subtracts a number from this value, returning the new value. */ - Type operator-= (DiffType amountToSubtract) noexcept; - - /** Atomically increments this value, returning the new value. */ - Type operator++() noexcept; - - /** Atomically decrements this value, returning the new value. */ - Type operator--() noexcept; - - /** Atomically compares this value with a target value, and if it is equal, sets - this to be equal to a new value. - - This operation is the atomic equivalent of doing this: - @code - bool compareAndSetBool (Type newValue, Type valueToCompare) - { - if (get() == valueToCompare) - { - set (newValue); - return true; - } - - return false; - } - @endcode - - @returns true if the comparison was true and the value was replaced; false if - the comparison failed and the value was left unchanged. - @see compareAndSetValue - */ - inline bool compareAndSetBool (Type newValue, Type valueToCompare) noexcept { return AtomicBase::compareAndSetBool (newValue, valueToCompare); } - - /** Atomically compares this value with a target value, and if it is equal, sets - this to be equal to a new value. - - This operation is the atomic equivalent of doing this: - @code - Type compareAndSetValue (Type newValue, Type valueToCompare) - { - Type oldValue = get(); - if (oldValue == valueToCompare) - set (newValue); - - return oldValue; - } - @endcode - - @returns the old value before it was changed. - @see compareAndSetBool - */ - inline Type compareAndSetValue (Type newValue, Type valueToCompare) noexcept { return AtomicBase::compareAndSetValue (newValue, valueToCompare); } - - /** Implements a memory read/write barrier. */ - static inline void memoryBarrier() noexcept { AtomicBase::memoryBarrier (); } - }; - - #ifndef DOXYGEN - - //============================================================================== - // Internal implementation follows - //============================================================================== - template - class AtomicBase - { - public: - typedef typename AtomicHelpers::DiffTypeHelper::Type DiffType; - - inline AtomicBase() noexcept : value (0) {} - inline explicit AtomicBase (const Type v) noexcept : value (v) {} - inline AtomicBase (const AtomicBase& other) noexcept : value (other.get()) {} - Type get() const noexcept; - inline AtomicBase& operator= (const AtomicBase& other) noexcept { exchange (other.get()); return *this; } - inline AtomicBase& operator= (const Type newValue) noexcept { exchange (newValue); return *this; } - void set (Type newValue) noexcept { exchange (newValue); } - Type exchange (Type) noexcept; - bool compareAndSetBool (Type, Type) noexcept; - Type compareAndSetValue (Type, Type) noexcept; - static void memoryBarrier() noexcept; - - //============================================================================== - #if JUCE_64BIT - JUCE_ALIGN (8) - #else - JUCE_ALIGN (4) - #endif - - /** The raw value that this class operates on. - This is exposed publicly in case you need to manipulate it directly - for performance reasons. - */ - volatile Type value; - - protected: - template - static inline Dest castTo (Source value) noexcept { union { Dest d; Source s; } u; u.s = value; return u.d; } - - static inline Type castFrom32Bit (int32 value) noexcept { return castTo (value); } - static inline Type castFrom64Bit (int64 value) noexcept { return castTo (value); } - static inline int32 castTo32Bit (Type value) noexcept { return castTo (value); } - static inline int64 castTo64Bit (Type value) noexcept { return castTo (value); } - - Type operator++ (int); // better to just use pre-increment with atomics.. - Type operator-- (int); - - /** This templated negate function will negate pointers as well as integers */ - template - inline ValueType negateValue (ValueType n) noexcept - { - return sizeof (ValueType) == 1 ? (ValueType) -(signed char) n - : (sizeof (ValueType) == 2 ? (ValueType) -(short) n - : (sizeof (ValueType) == 4 ? (ValueType) -(int) n - : ((ValueType) -(int64) n))); - } - - /** This templated negate function will negate pointers as well as integers */ - template - inline PointerType* negateValue (PointerType* n) noexcept - { - return reinterpret_cast (-reinterpret_cast (n)); - } - }; - - //============================================================================== - // Specialisation for void* which does not include the pointer arithmetic - template <> - class Atomic : public AtomicBase - { - public: - inline Atomic() noexcept {} - inline explicit Atomic (void* const initialValue) noexcept : AtomicBase (initialValue) {} - inline Atomic (const Atomic& other) noexcept : AtomicBase (other) {} - inline void* get() const noexcept { return AtomicBase::get(); } - inline Atomic& operator= (const Atomic& other) noexcept { AtomicBase::operator= (other); return *this; } - inline Atomic& operator= (void* const newValue) noexcept { AtomicBase::operator= (newValue); return *this; } - inline void set (void* newValue) noexcept { exchange (newValue); } - inline void* exchange (void* v) noexcept { return AtomicBase::exchange (v); } - inline bool compareAndSetBool (void* newValue, void* valueToCompare) noexcept { return AtomicBase::compareAndSetBool (newValue, valueToCompare); } - inline void* compareAndSetValue (void* newValue, void* valueToCompare) noexcept { return AtomicBase::compareAndSetValue (newValue, valueToCompare); } - static inline void memoryBarrier() noexcept { AtomicBase::memoryBarrier(); } - }; - - //============================================================================== - /* - The following code is in the header so that the atomics can be inlined where possible... - */ - #if JUCE_MAC && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 2)) - #define JUCE_ATOMICS_MAC_LEGACY 1 // Older OSX builds using gcc4.1 or earlier - #elif JUCE_GCC || JUCE_CLANG - #define JUCE_ATOMICS_GCC 1 // GCC with intrinsics - #if JUCE_IOS || JUCE_ANDROID // (64-bit ops will compile but not link on these mobile OSes) - #define JUCE_64BIT_ATOMICS_UNAVAILABLE 1 - #endif - #endif - - template - struct AtomicIncrementDecrement - { - static inline Type inc (AtomicBase& a) noexcept - { - #if JUCE_ATOMICS_MAC_LEGACY - return sizeof (Type) == 4 ? (Type) OSAtomicIncrement32Barrier ((volatile int32_t*) &a.value) - : (Type) OSAtomicIncrement64Barrier ((volatile int64_t*) &a.value); - #elif JUCE_ATOMICS_GCC - return sizeof (Type) == 4 ? (Type) __sync_add_and_fetch (& (a.value), (Type) 1) - : (Type) __sync_add_and_fetch ((int64_t*) & (a.value), 1); - #endif - } - - static inline Type dec (AtomicBase& a) noexcept - { - #if JUCE_ATOMICS_MAC_LEGACY - return sizeof (Type) == 4 ? (Type) OSAtomicDecrement32Barrier ((volatile int32_t*) &a.value) - : (Type) OSAtomicDecrement64Barrier ((volatile int64_t*) &a.value); - #elif JUCE_ATOMICS_GCC - return sizeof (Type) == 4 ? (Type) __sync_add_and_fetch (& (a.value), (Type) -1) - : (Type) __sync_add_and_fetch ((int64_t*) & (a.value), -1); - #endif - } - }; - - template - struct AtomicIncrementDecrement - { - static inline Type* inc (Atomic& a) noexcept { return a.operator+= (1); } - static inline Type* dec (Atomic& a) noexcept { return a.operator-= (1); } - }; - - //============================================================================== - template - inline Type AtomicBase::get() const noexcept - { - #if JUCE_ATOMICS_MAC_LEGACY - return sizeof (Type) == 4 ? castFrom32Bit ((int32) OSAtomicAdd32Barrier ((int32_t) 0, (volatile int32_t*) &value)) - : castFrom64Bit ((int64) OSAtomicAdd64Barrier ((int64_t) 0, (volatile int64_t*) &value)); - #elif JUCE_ATOMICS_GCC - return sizeof (Type) == 4 ? castFrom32Bit ((int32) __sync_add_and_fetch ((volatile int32*) &value, 0)) - : castFrom64Bit ((int64) __sync_add_and_fetch ((volatile int64*) &value, 0)); - #endif - } - - template - inline Type AtomicBase::exchange (const Type newValue) noexcept - { - #if JUCE_ATOMICS_MAC_LEGACY || JUCE_ATOMICS_GCC - Type currentVal = value; - while (! compareAndSetBool (newValue, currentVal)) { currentVal = value; } - return currentVal; - #endif - } - - template - inline Type Atomic::operator+= (const DiffType amountToAdd) noexcept - { - Type amount = (Type() + amountToAdd); - - #if JUCE_ATOMICS_MAC_LEGACY - return sizeof (Type) == 4 ? (Type) OSAtomicAdd32Barrier ((int32_t) castTo32Bit (amount), (volatile int32_t*) &AtomicBase::value) - : (Type) OSAtomicAdd64Barrier ((int64_t) amount, (volatile int64_t*) &AtomicBase::value); - #elif JUCE_ATOMICS_GCC - return (Type) __sync_add_and_fetch (& (AtomicBase::value), amount); - #endif - } - - template - inline Type Atomic::operator-= (const DiffType amountToSubtract) noexcept - { - return operator+= (AtomicBase::negateValue (amountToSubtract)); - } - - template - inline Type Atomic::operator++() noexcept { return AtomicIncrementDecrement::inc (*this); } - - template - inline Type Atomic::operator--() noexcept { return AtomicIncrementDecrement::dec (*this); } - - template - inline bool AtomicBase::compareAndSetBool (const Type newValue, const Type valueToCompare) noexcept - { - #if JUCE_ATOMICS_MAC_LEGACY - return sizeof (Type) == 4 ? OSAtomicCompareAndSwap32Barrier ((int32_t) castTo32Bit (valueToCompare), (int32_t) castTo32Bit (newValue), (volatile int32_t*) &value) - : OSAtomicCompareAndSwap64Barrier ((int64_t) castTo64Bit (valueToCompare), (int64_t) castTo64Bit (newValue), (volatile int64_t*) &value); - #elif JUCE_ATOMICS_GCC - return sizeof (Type) == 4 ? __sync_bool_compare_and_swap ((volatile int32*) &value, castTo32Bit (valueToCompare), castTo32Bit (newValue)) - : __sync_bool_compare_and_swap ((volatile int64*) &value, castTo64Bit (valueToCompare), castTo64Bit (newValue)); - #endif - } - - template - inline Type AtomicBase::compareAndSetValue (const Type newValue, const Type valueToCompare) noexcept - { - #if JUCE_ATOMICS_MAC_LEGACY - for (;;) // Annoying workaround for only having a bool CAS operation.. - { - if (compareAndSetBool (newValue, valueToCompare)) - return valueToCompare; - - const Type result = value; - if (result != valueToCompare) - return result; - } - #elif JUCE_ATOMICS_GCC - return sizeof (Type) == 4 ? castFrom32Bit ((int32) __sync_val_compare_and_swap ((volatile int32*) &value, castTo32Bit (valueToCompare), castTo32Bit (newValue))) - : castFrom64Bit ((int64) __sync_val_compare_and_swap ((volatile int64*) &value, castTo64Bit (valueToCompare), castTo64Bit (newValue))); - #endif - } - - template - inline void AtomicBase::memoryBarrier() noexcept - { - #if JUCE_ATOMICS_MAC_LEGACY - OSMemoryBarrier(); - #elif JUCE_ATOMICS_GCC - __sync_synchronize(); - #endif - } - - #endif - -#endif - -} // namespace juce +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2017 - ROLI Ltd. + + JUCE is an open source library subject to commercial or open-source + licensing. + + The code included in this file is provided under the terms of the ISC license + http://www.isc.org/downloads/software-support-policy/isc-license. Permission + To use, copy, modify, and/or distribute this software for any purpose with or + without fee is hereby granted provided that the above copyright notice and + this permission notice appear in all copies. + + JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER + EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE + DISCLAIMED. + + ============================================================================== +*/ + +namespace juce +{ + +#ifndef DOXYGEN + namespace AtomicHelpers + { + template struct DiffTypeHelper { typedef T Type; }; + template struct DiffTypeHelper { typedef std::ptrdiff_t Type; }; + } +#endif + +#if JUCE_ATOMIC_AVAILABLE + //============================================================================== + /** + A simple wrapper around std::atomic. + */ + template + struct Atomic + { + typedef typename AtomicHelpers::DiffTypeHelper::Type DiffType; + + /** Creates a new value, initialised to zero. */ + Atomic() noexcept : value (0) {} + + /** Creates a new value, with a given initial value. */ + Atomic (Type initialValue) noexcept : value (initialValue) {} + + /** Copies another value (atomically). */ + Atomic (const Atomic& other) noexcept : value (other.get()) {} + + /** Destructor. */ + ~Atomic() noexcept + { + #if __cpp_lib_atomic_is_always_lock_free + static_assert (std::atomic::is_always_lock_free, + "This class can only be used for lock-free types"); + #endif + } + + /** Atomically reads and returns the current value. */ + Type get() const noexcept { return value.load(); } + + /** Atomically sets the current value. */ + void set (Type newValue) noexcept { value = newValue; } + + /** Atomically sets the current value, returning the value that was replaced. */ + Type exchange (Type newValue) noexcept { return value.exchange (newValue); } + + /** Atomically compares this value with a target value, and if it is equal, sets + this to be equal to a new value. + + This operation is the atomic equivalent of doing this: + @code + bool compareAndSetBool (Type newValue, Type valueToCompare) + { + if (get() == valueToCompare) + { + set (newValue); + return true; + } + + return false; + } + @endcode + + Internally, this method calls std::atomic::compare_exchange_strong with + memory_order_seq_cst (the strictest std::memory_order). + + @returns true if the comparison was true and the value was replaced; false if + the comparison failed and the value was left unchanged. + @see compareAndSetValue + */ + bool compareAndSetBool (Type newValue, Type valueToCompare) noexcept + { + return value.compare_exchange_strong (valueToCompare, newValue); + } + + /** Copies another value into this one (atomically). */ + Atomic& operator= (const Atomic& other) noexcept + { + value = other.value.load(); + return *this; + } + + /** Copies another value into this one (atomically). */ + Atomic& operator= (Type newValue) noexcept + { + value = newValue; + return *this; + } + + /** Atomically adds a number to this value, returning the new value. */ + Type operator+= (DiffType amountToAdd) noexcept { return value += amountToAdd; } + + /** Atomically subtracts a number from this value, returning the new value. */ + Type operator-= (DiffType amountToSubtract) noexcept { return value -= amountToSubtract; } + + /** Atomically increments this value, returning the new value. */ + Type operator++() noexcept { return ++value; } + + /** Atomically decrements this value, returning the new value. */ + Type operator--() noexcept { return --value; } + + /** Implements a memory read/write barrier. + + Internally this calls std::atomic_thread_fence with + memory_order_seq_cst (the strictest std::memory_order). + */ + void memoryBarrier() noexcept { atomic_thread_fence (std::memory_order_seq_cst); } + + /** The std::atomic object that this class operates on. */ + std::atomic value; + + //============================================================================== + #ifndef DOXYGEN + // This method has been deprecated as there is no equivalent method in std::atomic. + JUCE_DEPRECATED (Type compareAndSetValue (Type, Type) noexcept); + #endif + }; + +#else + + #ifndef DOXYGEN + template class AtomicBase; + #endif + + //============================================================================== + /** + Simple class to hold a primitive value and perform atomic operations on it. + + The type used must be a 32 or 64 bit primitive, like an int, pointer, etc. + There are methods to perform most of the basic atomic operations. + */ + template + class Atomic : public AtomicBase + { + public: + /** Resulting type when subtracting the underlying Type. */ + typedef typename AtomicBase::DiffType DiffType; + + /** Creates a new value, initialised to zero. */ + inline Atomic() noexcept {} + + /** Creates a new value, with a given initial value. */ + inline explicit Atomic (const Type initialValue) noexcept : AtomicBase (initialValue) {} + + /** Copies another value (atomically). */ + inline Atomic (const Atomic& other) noexcept : AtomicBase (other) {} + + /** Destructor. */ + inline ~Atomic() noexcept + { + static_assert (sizeof (Type) == 4 || sizeof (Type) == 8, + "Atomic can only be used for types which are 32 or 64 bits in size"); + } + + /** Atomically reads and returns the current value. */ + inline Type get() const noexcept { return AtomicBase::get(); } + + /** Copies another value into this one (atomically). */ + inline Atomic& operator= (const Atomic& other) noexcept { AtomicBase::operator= (other); return *this; } + + /** Copies another value into this one (atomically). */ + inline Atomic& operator= (const Type newValue) noexcept { AtomicBase::operator= (newValue); return *this; } + + /** Atomically sets the current value. */ + inline void set (Type newValue) noexcept { exchange (newValue); } + + /** Atomically sets the current value, returning the value that was replaced. */ + inline Type exchange (Type v) noexcept { return AtomicBase::exchange (v); } + + /** Atomically adds a number to this value, returning the new value. */ + Type operator+= (DiffType amountToAdd) noexcept; + + /** Atomically subtracts a number from this value, returning the new value. */ + Type operator-= (DiffType amountToSubtract) noexcept; + + /** Atomically increments this value, returning the new value. */ + Type operator++() noexcept; + + /** Atomically decrements this value, returning the new value. */ + Type operator--() noexcept; + + /** Atomically compares this value with a target value, and if it is equal, sets + this to be equal to a new value. + + This operation is the atomic equivalent of doing this: + @code + bool compareAndSetBool (Type newValue, Type valueToCompare) + { + if (get() == valueToCompare) + { + set (newValue); + return true; + } + + return false; + } + @endcode + + @returns true if the comparison was true and the value was replaced; false if + the comparison failed and the value was left unchanged. + @see compareAndSetValue + */ + inline bool compareAndSetBool (Type newValue, Type valueToCompare) noexcept { return AtomicBase::compareAndSetBool (newValue, valueToCompare); } + + /** Atomically compares this value with a target value, and if it is equal, sets + this to be equal to a new value. + + This operation is the atomic equivalent of doing this: + @code + Type compareAndSetValue (Type newValue, Type valueToCompare) + { + Type oldValue = get(); + if (oldValue == valueToCompare) + set (newValue); + + return oldValue; + } + @endcode + + @returns the old value before it was changed. + @see compareAndSetBool + */ + inline Type compareAndSetValue (Type newValue, Type valueToCompare) noexcept { return AtomicBase::compareAndSetValue (newValue, valueToCompare); } + + /** Implements a memory read/write barrier. */ + static inline void memoryBarrier() noexcept { AtomicBase::memoryBarrier (); } + }; + + #ifndef DOXYGEN + + //============================================================================== + // Internal implementation follows + //============================================================================== + template + class AtomicBase + { + public: + typedef typename AtomicHelpers::DiffTypeHelper::Type DiffType; + + inline AtomicBase() noexcept : value (0) {} + inline explicit AtomicBase (const Type v) noexcept : value (v) {} + inline AtomicBase (const AtomicBase& other) noexcept : value (other.get()) {} + Type get() const noexcept; + inline AtomicBase& operator= (const AtomicBase& other) noexcept { exchange (other.get()); return *this; } + inline AtomicBase& operator= (const Type newValue) noexcept { exchange (newValue); return *this; } + void set (Type newValue) noexcept { exchange (newValue); } + Type exchange (Type) noexcept; + bool compareAndSetBool (Type, Type) noexcept; + Type compareAndSetValue (Type, Type) noexcept; + static void memoryBarrier() noexcept; + + //============================================================================== + #if JUCE_64BIT + JUCE_ALIGN (8) + #else + JUCE_ALIGN (4) + #endif + + /** The raw value that this class operates on. + This is exposed publicly in case you need to manipulate it directly + for performance reasons. + */ + volatile Type value; + + protected: + template + static inline Dest castTo (Source value) noexcept { union { Dest d; Source s; } u; u.s = value; return u.d; } + + static inline Type castFrom32Bit (int32 value) noexcept { return castTo (value); } + static inline Type castFrom64Bit (int64 value) noexcept { return castTo (value); } + static inline int32 castTo32Bit (Type value) noexcept { return castTo (value); } + static inline int64 castTo64Bit (Type value) noexcept { return castTo (value); } + + Type operator++ (int); // better to just use pre-increment with atomics.. + Type operator-- (int); + + /** This templated negate function will negate pointers as well as integers */ + template + inline ValueType negateValue (ValueType n) noexcept + { + return sizeof (ValueType) == 1 ? (ValueType) -(signed char) n + : (sizeof (ValueType) == 2 ? (ValueType) -(short) n + : (sizeof (ValueType) == 4 ? (ValueType) -(int) n + : ((ValueType) -(int64) n))); + } + + /** This templated negate function will negate pointers as well as integers */ + template + inline PointerType* negateValue (PointerType* n) noexcept + { + return reinterpret_cast (-reinterpret_cast (n)); + } + }; + + //============================================================================== + // Specialisation for void* which does not include the pointer arithmetic + template <> + class Atomic : public AtomicBase + { + public: + inline Atomic() noexcept {} + inline explicit Atomic (void* const initialValue) noexcept : AtomicBase (initialValue) {} + inline Atomic (const Atomic& other) noexcept : AtomicBase (other) {} + inline void* get() const noexcept { return AtomicBase::get(); } + inline Atomic& operator= (const Atomic& other) noexcept { AtomicBase::operator= (other); return *this; } + inline Atomic& operator= (void* const newValue) noexcept { AtomicBase::operator= (newValue); return *this; } + inline void set (void* newValue) noexcept { exchange (newValue); } + inline void* exchange (void* v) noexcept { return AtomicBase::exchange (v); } + inline bool compareAndSetBool (void* newValue, void* valueToCompare) noexcept { return AtomicBase::compareAndSetBool (newValue, valueToCompare); } + inline void* compareAndSetValue (void* newValue, void* valueToCompare) noexcept { return AtomicBase::compareAndSetValue (newValue, valueToCompare); } + static inline void memoryBarrier() noexcept { AtomicBase::memoryBarrier(); } + }; + + //============================================================================== + /* + The following code is in the header so that the atomics can be inlined where possible... + */ + #if JUCE_MAC && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 2)) + #define JUCE_ATOMICS_MAC_LEGACY 1 // Older OSX builds using gcc4.1 or earlier + #elif JUCE_GCC || JUCE_CLANG + #define JUCE_ATOMICS_GCC 1 // GCC with intrinsics + #if JUCE_IOS || JUCE_ANDROID // (64-bit ops will compile but not link on these mobile OSes) + #define JUCE_64BIT_ATOMICS_UNAVAILABLE 1 + #endif + #endif + + template + struct AtomicIncrementDecrement + { + static inline Type inc (AtomicBase& a) noexcept + { + #if JUCE_ATOMICS_MAC_LEGACY + return sizeof (Type) == 4 ? (Type) OSAtomicIncrement32Barrier ((volatile int32_t*) &a.value) + : (Type) OSAtomicIncrement64Barrier ((volatile int64_t*) &a.value); + #elif JUCE_ATOMICS_GCC + return sizeof (Type) == 4 ? (Type) __sync_add_and_fetch (& (a.value), (Type) 1) + : (Type) __sync_add_and_fetch ((int64_t*) & (a.value), 1); + #endif + } + + static inline Type dec (AtomicBase& a) noexcept + { + #if JUCE_ATOMICS_MAC_LEGACY + return sizeof (Type) == 4 ? (Type) OSAtomicDecrement32Barrier ((volatile int32_t*) &a.value) + : (Type) OSAtomicDecrement64Barrier ((volatile int64_t*) &a.value); + #elif JUCE_ATOMICS_GCC + return sizeof (Type) == 4 ? (Type) __sync_add_and_fetch (& (a.value), (Type) -1) + : (Type) __sync_add_and_fetch ((int64_t*) & (a.value), -1); + #endif + } + }; + + template + struct AtomicIncrementDecrement + { + static inline Type* inc (Atomic& a) noexcept { return a.operator+= (1); } + static inline Type* dec (Atomic& a) noexcept { return a.operator-= (1); } + }; + + //============================================================================== + template + inline Type AtomicBase::get() const noexcept + { + #if JUCE_ATOMICS_MAC_LEGACY + return sizeof (Type) == 4 ? castFrom32Bit ((int32) OSAtomicAdd32Barrier ((int32_t) 0, (volatile int32_t*) &value)) + : castFrom64Bit ((int64) OSAtomicAdd64Barrier ((int64_t) 0, (volatile int64_t*) &value)); + #elif JUCE_ATOMICS_GCC + return sizeof (Type) == 4 ? castFrom32Bit ((int32) __sync_add_and_fetch ((volatile int32*) &value, 0)) + : castFrom64Bit ((int64) __sync_add_and_fetch ((volatile int64*) &value, 0)); + #endif + } + + template + inline Type AtomicBase::exchange (const Type newValue) noexcept + { + #if JUCE_ATOMICS_MAC_LEGACY || JUCE_ATOMICS_GCC + Type currentVal = value; + while (! compareAndSetBool (newValue, currentVal)) { currentVal = value; } + return currentVal; + #endif + } + + template + inline Type Atomic::operator+= (const DiffType amountToAdd) noexcept + { + Type amount = (Type() + amountToAdd); + + #if JUCE_ATOMICS_MAC_LEGACY + return sizeof (Type) == 4 ? (Type) OSAtomicAdd32Barrier ((int32_t) castTo32Bit (amount), (volatile int32_t*) &AtomicBase::value) + : (Type) OSAtomicAdd64Barrier ((int64_t) amount, (volatile int64_t*) &AtomicBase::value); + #elif JUCE_ATOMICS_GCC + return (Type) __sync_add_and_fetch (& (AtomicBase::value), amount); + #endif + } + + template + inline Type Atomic::operator-= (const DiffType amountToSubtract) noexcept + { + return operator+= (AtomicBase::negateValue (amountToSubtract)); + } + + template + inline Type Atomic::operator++() noexcept { return AtomicIncrementDecrement::inc (*this); } + + template + inline Type Atomic::operator--() noexcept { return AtomicIncrementDecrement::dec (*this); } + + template + inline bool AtomicBase::compareAndSetBool (const Type newValue, const Type valueToCompare) noexcept + { + #if JUCE_ATOMICS_MAC_LEGACY + return sizeof (Type) == 4 ? OSAtomicCompareAndSwap32Barrier ((int32_t) castTo32Bit (valueToCompare), (int32_t) castTo32Bit (newValue), (volatile int32_t*) &value) + : OSAtomicCompareAndSwap64Barrier ((int64_t) castTo64Bit (valueToCompare), (int64_t) castTo64Bit (newValue), (volatile int64_t*) &value); + #elif JUCE_ATOMICS_GCC + return sizeof (Type) == 4 ? __sync_bool_compare_and_swap ((volatile int32*) &value, castTo32Bit (valueToCompare), castTo32Bit (newValue)) + : __sync_bool_compare_and_swap ((volatile int64*) &value, castTo64Bit (valueToCompare), castTo64Bit (newValue)); + #endif + } + + template + inline Type AtomicBase::compareAndSetValue (const Type newValue, const Type valueToCompare) noexcept + { + #if JUCE_ATOMICS_MAC_LEGACY + for (;;) // Annoying workaround for only having a bool CAS operation.. + { + if (compareAndSetBool (newValue, valueToCompare)) + return valueToCompare; + + const Type result = value; + if (result != valueToCompare) + return result; + } + #elif JUCE_ATOMICS_GCC + return sizeof (Type) == 4 ? castFrom32Bit ((int32) __sync_val_compare_and_swap ((volatile int32*) &value, castTo32Bit (valueToCompare), castTo32Bit (newValue))) + : castFrom64Bit ((int64) __sync_val_compare_and_swap ((volatile int64*) &value, castTo64Bit (valueToCompare), castTo64Bit (newValue))); + #endif + } + + template + inline void AtomicBase::memoryBarrier() noexcept + { + #if JUCE_ATOMICS_MAC_LEGACY + OSMemoryBarrier(); + #elif JUCE_ATOMICS_GCC + __sync_synchronize(); + #endif + } + + #endif + +#endif + +} // namespace juce From 33f075212e21bb80e34ca58e0cc041a06b3ee146 Mon Sep 17 00:00:00 2001 From: ed Date: Thu, 21 Sep 2017 10:09:57 +0100 Subject: [PATCH 124/129] Fixed a typo in TextPropertyComponent --- modules/juce_gui_basics/properties/juce_TextPropertyComponent.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/juce_gui_basics/properties/juce_TextPropertyComponent.h b/modules/juce_gui_basics/properties/juce_TextPropertyComponent.h index 2d208e32a7..8769ac1b9e 100644 --- a/modules/juce_gui_basics/properties/juce_TextPropertyComponent.h +++ b/modules/juce_gui_basics/properties/juce_TextPropertyComponent.h @@ -53,7 +53,7 @@ protected: public: /** Creates a text property component. - @param valueToControl The Value that is controlled by the TextPropertyCOmponent + @param valueToControl The Value that is controlled by the TextPropertyComponent @param propertyName The name of the property @param maxNumChars If not zero, then this specifies the maximum allowable length of the string. If zero, then the string will have no length limit. From c800d07983dbddd1e681011e69a54e9c66cb28dc Mon Sep 17 00:00:00 2001 From: ed Date: Thu, 21 Sep 2017 10:11:47 +0100 Subject: [PATCH 125/129] Projucer: Changed the method for setting the Windows Target Platform option in the VS exporters to a text box --- .../Source/Project Saving/jucer_ProjectExport_MSVC.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/extras/Projucer/Source/Project Saving/jucer_ProjectExport_MSVC.h b/extras/Projucer/Source/Project Saving/jucer_ProjectExport_MSVC.h index eff6772e31..350e46440a 100644 --- a/extras/Projucer/Source/Project Saving/jucer_ProjectExport_MSVC.h +++ b/extras/Projucer/Source/Project Saving/jucer_ProjectExport_MSVC.h @@ -80,12 +80,10 @@ public: void addWindowsTargetPlatformProperties (PropertyListBuilder& props) { - static const char* targetPlatformNames[] = { "(default)", "8.1", "10.0.10240.0", "10.0.10586.0", "10.0.14393.0", "10.0.15063.0" }; - static const var targetPlatforms[] = { var(), "8.1", "10.0.10240.0", "10.0.10586.0", "10.0.14393.0", "10.0.15063.0" }; + if (getWindowsTargetPlatformVersionValue() == Value()) + getWindowsTargetPlatformVersionValue() = getDefaultWindowsTargetPlatformVersion(); - props.add (new ChoicePropertyComponent (getWindowsTargetPlatformVersionValue(), "Windows Target Platform", - StringArray (targetPlatformNames, numElementsInArray (targetPlatformNames)), - Array (targetPlatforms, numElementsInArray (targetPlatforms))), + props.add (new TextPropertyComponent (getWindowsTargetPlatformVersionValue(), "Windows Target Platform", 20, false), "Specifies the version of the Windows SDK that will be used when building this project. " "The default value for this exporter is " + getDefaultWindowsTargetPlatformVersion()); } From 0b6f02a29e32b67d78aef4278d922fcc9008b5f3 Mon Sep 17 00:00:00 2001 From: ed Date: Thu, 21 Sep 2017 10:59:24 +0100 Subject: [PATCH 126/129] Fixed some errors and warnings when building with JUCE_DLL_BUILD=1 --- modules/juce_core/text/juce_String.h | 2 +- modules/juce_gui_basics/widgets/juce_Slider.cpp | 3 ++- modules/juce_gui_basics/windows/juce_DialogWindow.h | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/juce_core/text/juce_String.h b/modules/juce_core/text/juce_String.h index 642c10dd15..4ba4156d42 100644 --- a/modules/juce_core/text/juce_String.h +++ b/modules/juce_core/text/juce_String.h @@ -1348,7 +1348,7 @@ JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, double number); // Automatically creating a String from a bool opens up lots of nasty type conversion edge cases. // If you want a String representation of a bool you can cast the bool to an int first. -JUCE_API String& JUCE_CALLTYPE operator<< (String&, bool) = delete; +String& JUCE_CALLTYPE operator<< (String&, bool) = delete; //============================================================================== /** Case-sensitive comparison of two strings. */ diff --git a/modules/juce_gui_basics/widgets/juce_Slider.cpp b/modules/juce_gui_basics/widgets/juce_Slider.cpp index f667139da9..bd6b0a268f 100644 --- a/modules/juce_gui_basics/widgets/juce_Slider.cpp +++ b/modules/juce_gui_basics/widgets/juce_Slider.cpp @@ -27,7 +27,8 @@ namespace juce { -class Slider::Pimpl : private AsyncUpdater, +class Slider::Pimpl : public AsyncUpdater, // this needs to be public otherwise it will cause an + // error when JUCE_DLL_BUILD=1 private Button::Listener, private Label::Listener, private Value::Listener diff --git a/modules/juce_gui_basics/windows/juce_DialogWindow.h b/modules/juce_gui_basics/windows/juce_DialogWindow.h index f0df0a9654..090af5697a 100644 --- a/modules/juce_gui_basics/windows/juce_DialogWindow.h +++ b/modules/juce_gui_basics/windows/juce_DialogWindow.h @@ -144,6 +144,8 @@ public: */ int runModal(); #endif + + JUCE_DECLARE_NON_COPYABLE (LaunchOptions) }; //============================================================================== From 8bb64a5ddc9acb937ee4ec5ae4fe3ca994aa37b1 Mon Sep 17 00:00:00 2001 From: hogliux Date: Thu, 21 Sep 2017 15:49:02 +0100 Subject: [PATCH 127/129] Added getXRunCount to AudioIODevice as a way to get Xrun counts from underlying hardware --- .../audio_io/juce_AudioIODevice.cpp | 1 + .../audio_io/juce_AudioIODevice.h | 13 +++++ .../native/juce_android_Audio.cpp | 9 ++++ .../native/juce_android_OpenSL.cpp | 49 ++++++++++++++----- .../native/juce_ios_Audio.cpp | 31 ++++++++++++ .../native/juce_ios_Audio.h | 2 + .../native/juce_linux_ALSA.cpp | 47 +++++++++++++++--- .../native/juce_linux_JackAudio.cpp | 16 ++++++ .../native/juce_mac_CoreAudio.cpp | 6 +++ .../native/juce_win32_ASIO.cpp | 12 ++++- .../native/juce_win32_DirectSound.cpp | 30 +++++++++++- .../native/juce_win32_WASAPI.cpp | 15 ++++-- 12 files changed, 208 insertions(+), 23 deletions(-) diff --git a/modules/juce_audio_devices/audio_io/juce_AudioIODevice.cpp b/modules/juce_audio_devices/audio_io/juce_AudioIODevice.cpp index 95ae0c8e41..935de58d07 100644 --- a/modules/juce_audio_devices/audio_io/juce_AudioIODevice.cpp +++ b/modules/juce_audio_devices/audio_io/juce_AudioIODevice.cpp @@ -33,6 +33,7 @@ AudioIODevice::~AudioIODevice() {} void AudioIODeviceCallback::audioDeviceError (const String&) {} bool AudioIODevice::setAudioPreprocessingEnabled (bool) { return false; } bool AudioIODevice::hasControlPanel() const { return false; } +int AudioIODevice::getXRunCount() const noexcept { return -1; } bool AudioIODevice::showControlPanel() { diff --git a/modules/juce_audio_devices/audio_io/juce_AudioIODevice.h b/modules/juce_audio_devices/audio_io/juce_AudioIODevice.h index d1cb0d52f0..a1599f4d2b 100644 --- a/modules/juce_audio_devices/audio_io/juce_AudioIODevice.h +++ b/modules/juce_audio_devices/audio_io/juce_AudioIODevice.h @@ -293,6 +293,19 @@ public: */ virtual bool setAudioPreprocessingEnabled (bool shouldBeEnabled); + //============================================================================== + /** Returns the number of under- or over runs reported by the OS since + playback/recording has started. + + This number may be different than determining the Xrun count manually (by + measuring the time spent in the audio callback) as the OS may be doing + some buffering internally - especially on mobile devices. + + Returns -1 if playback/recording has not started yet or if getting the underrun + count is not supported for this device (Android SDK 23 and lower). + */ + virtual int getXRunCount() const noexcept; + //============================================================================== protected: /** Creates a device, setting its name and type member variables. */ diff --git a/modules/juce_audio_devices/native/juce_android_Audio.cpp b/modules/juce_audio_devices/native/juce_android_Audio.cpp index 6ff8c32261..66634137f0 100644 --- a/modules/juce_audio_devices/native/juce_android_Audio.cpp +++ b/modules/juce_audio_devices/native/juce_android_Audio.cpp @@ -33,6 +33,7 @@ namespace juce METHOD (release, "release", "()V") \ METHOD (flush, "flush", "()V") \ METHOD (write, "write", "([SII)I") \ + METHOD (getUnderrunCount, "getUnderrunCount", "()I") \ DECLARE_JNI_CLASS (AudioTrack, "android/media/AudioTrack"); #undef JNI_CLASS_MEMBERS @@ -281,6 +282,14 @@ public: String getLastError() override { return lastError; } bool isPlaying() override { return isRunning && callback != 0; } + int getXRunCount() const noexcept override + { + if (outputDevice != nullptr) + return getEnv()->CallIntMethod (outputDevice, AudioTrack.getUnderrunCount); + + return -1; + } + void start (AudioIODeviceCallback* newCallback) override { if (isRunning && callback != newCallback) diff --git a/modules/juce_audio_devices/native/juce_android_OpenSL.cpp b/modules/juce_audio_devices/native/juce_android_OpenSL.cpp index 65362b8565..9da627fe0d 100644 --- a/modules/juce_audio_devices/native/juce_android_OpenSL.cpp +++ b/modules/juce_audio_devices/native/juce_android_OpenSL.cpp @@ -291,12 +291,32 @@ public: nextBlock (0), numBlocksOut (0) {} + ~OpenSLQueueRunner() + { + if (config != nullptr && javaProxy != nullptr) + { + javaProxy.clear(); + (*config)->ReleaseJavaProxy (config, SL_ANDROID_JAVA_PROXY_ROUTING); + } + } + bool init() { runner = crtp().createPlayerOrRecorder(); if (runner == nullptr) return false; + // may return nullptr on some platforms - that's ok + config = SlRef::cast (runner); + if (config != nullptr) + { + jobject audioRoutingJni; + auto status = (*config)->AcquireJavaProxy (config, SL_ANDROID_JAVA_PROXY_ROUTING, &audioRoutingJni); + + if (status == SL_RESULT_SUCCESS && audioRoutingJni != 0) + javaProxy = GlobalRef (audioRoutingJni); + } + queue = SlRef::cast (runner); if (queue == nullptr) return false; @@ -347,6 +367,8 @@ public: SlRef runner; SlRef queue; + SlRef config; + GlobalRef javaProxy; int numChannels; @@ -379,12 +401,12 @@ public: SLDataSource source = {&queueLocator, &dataFormat}; SLDataSink sink = {&outputMix, nullptr}; - SLInterfaceID queueInterfaces[] = { &IntfIID::iid }; - SLboolean trueFlag = SL_BOOLEAN_TRUE; + SLInterfaceID queueInterfaces[] = { &IntfIID::iid, &IntfIID::iid }; + SLboolean interfaceRequired[] = {SL_BOOLEAN_TRUE, SL_BOOLEAN_FALSE}; SLObjectItf obj = nullptr; - SLresult status = (*Base::owner.engine)->CreateAudioPlayer (Base::owner.engine, &obj, &source, &sink, 1, queueInterfaces, &trueFlag); + SLresult status = (*Base::owner.engine)->CreateAudioPlayer (Base::owner.engine, &obj, &source, &sink, 2, queueInterfaces, interfaceRequired); if (status != SL_RESULT_SUCCESS || obj == nullptr || (*obj)->Realize (obj, 0) != SL_RESULT_SUCCESS) { if (obj != nullptr) @@ -437,15 +459,12 @@ public: SlRef recorder = SlRef::cast (SlObjectRef (obj)); - // may return nullptr on some platforms - that's ok - config = SlRef::cast (recorder); - return recorder; } bool setAudioPreprocessingEnabled (bool shouldEnable) { - if (config != nullptr) + if (Base::config != nullptr) { const bool supportsUnprocessed = (getEnv()->GetStaticIntField (AndroidBuildVersion, AndroidBuildVersion.SDK_INT) >= 25); const SLuint32 recordingPresetValue @@ -453,8 +472,8 @@ public: : (supportsUnprocessed ? SL_ANDROID_RECORDING_PRESET_UNPROCESSED : SL_ANDROID_RECORDING_PRESET_VOICE_RECOGNITION)); - SLresult status = (*config)->SetConfiguration (config, SL_ANDROID_KEY_RECORDING_PRESET, - &recordingPresetValue, sizeof (recordingPresetValue)); + SLresult status = (*Base::config)->SetConfiguration (Base::config, SL_ANDROID_KEY_RECORDING_PRESET, + &recordingPresetValue, sizeof (recordingPresetValue)); return (status == SL_RESULT_SUCCESS); } @@ -463,8 +482,6 @@ public: } void setState (bool running) { (*Base::runner)->SetRecordState (Base::runner, running ? SL_RECORDSTATE_RECORDING : SL_RECORDSTATE_STOPPED); } - - SlRef config; }; //============================================================================== @@ -521,6 +538,7 @@ public: virtual void stop() { running = false; } virtual bool setAudioPreprocessingEnabled (bool shouldEnable) = 0; virtual bool supportsFloatingPoint() const noexcept = 0; + virtual int getXRunCount() const noexcept = 0; void setCallback (AudioIODeviceCallback* callbackToUse) { @@ -678,6 +696,14 @@ public: return true; } + int getXRunCount() const noexcept override + { + if (player != nullptr && player->javaProxy != nullptr) + return getEnv()->CallIntMethod (player->javaProxy, AudioTrack.getUnderrunCount); + + return -1; + } + bool supportsFloatingPoint() const noexcept override { return (BufferHelpers::isFloatingPoint != 0); } void doSomeWorkOnAudioThread() @@ -892,6 +918,7 @@ public: BigInteger getActiveInputChannels() const override { return activeInputChans; } String getLastError() override { return lastError; } bool isPlaying() override { return callback != nullptr; } + int getXRunCount() const noexcept override { return (session != nullptr ? session->getXRunCount() : -1); } int getDefaultBufferSize() override { diff --git a/modules/juce_audio_devices/native/juce_ios_Audio.cpp b/modules/juce_audio_devices/native/juce_ios_Audio.cpp index c123849b06..432bb228bd 100644 --- a/modules/juce_audio_devices/native/juce_ios_Audio.cpp +++ b/modules/juce_audio_devices/native/juce_ios_Audio.cpp @@ -313,6 +313,9 @@ struct iOSAudioIODevice::Pimpl : public AudioPlayHead, { close(); + firstHostTime = true; + lastNumFrames = 0; + xrun = 0; lastError.clear(); preferredBufferSize = bufferSize <= 0 ? defaultBufferSize : bufferSize; @@ -714,6 +717,8 @@ struct iOSAudioIODevice::Pimpl : public AudioPlayHead, { OSStatus err = noErr; + recordXruns (time, numFrames); + if (audioInputIsAvailable && numInputChannels > 0) err = AudioUnitRender (audioUnit, flags, time, 1, numFrames, data); @@ -799,6 +804,26 @@ struct iOSAudioIODevice::Pimpl : public AudioPlayHead, updateSampleRateAndAudioInput(); } + void recordXruns (const AudioTimeStamp* time, UInt32 numFrames) + { + if (time != nullptr && (time->mFlags & kAudioTimeStampSampleTimeValid) != 0) + { + if (! firstHostTime) + { + if ((time->mSampleTime - lastSampleTime) != lastNumFrames) + xrun++; + } + else + firstHostTime = false; + + lastSampleTime = time->mSampleTime; + } + else + firstHostTime = true; + + lastNumFrames = numFrames; + } + //============================================================================== static OSStatus processStatic (void* client, AudioUnitRenderActionFlags* flags, const AudioTimeStamp* time, UInt32 /*busNumber*/, UInt32 numFrames, AudioBufferList* data) @@ -1063,6 +1088,11 @@ struct iOSAudioIODevice::Pimpl : public AudioPlayHead, float* outputChannels[3]; bool monoInputChannelNumber, monoOutputChannelNumber; + bool firstHostTime; + Float64 lastSampleTime; + unsigned int lastNumFrames; + int xrun; + JUCE_DECLARE_NON_COPYABLE (Pimpl) }; @@ -1108,6 +1138,7 @@ BigInteger iOSAudioIODevice::getActiveInputChannels() const { return pim int iOSAudioIODevice::getOutputLatencyInSamples() { return roundToInt (pimpl->sampleRate * [AVAudioSession sharedInstance].outputLatency); } int iOSAudioIODevice::getInputLatencyInSamples() { return roundToInt (pimpl->sampleRate * [AVAudioSession sharedInstance].inputLatency); } +int iOSAudioIODevice::getXRunCount() const noexcept { return pimpl->xrun; } void iOSAudioIODevice::setMidiMessageCollector (MidiMessageCollector* collector) { pimpl->messageCollector = collector; } AudioPlayHead* iOSAudioIODevice::getAudioPlayHead() const { return pimpl; } diff --git a/modules/juce_audio_devices/native/juce_ios_Audio.h b/modules/juce_audio_devices/native/juce_ios_Audio.h index f0b3733268..b06be4d97d 100644 --- a/modules/juce_audio_devices/native/juce_ios_Audio.h +++ b/modules/juce_audio_devices/native/juce_ios_Audio.h @@ -62,6 +62,8 @@ public: int getOutputLatencyInSamples() override; int getInputLatencyInSamples() override; + int getXRunCount() const noexcept override; + //============================================================================== void setMidiMessageCollector (MidiMessageCollector*); AudioPlayHead* getAudioPlayHead() const; diff --git a/modules/juce_audio_devices/native/juce_linux_ALSA.cpp b/modules/juce_audio_devices/native/juce_linux_ALSA.cpp index db984ebd44..7a521f468f 100644 --- a/modules/juce_audio_devices/native/juce_linux_ALSA.cpp +++ b/modules/juce_audio_devices/native/juce_linux_ALSA.cpp @@ -333,8 +333,14 @@ public: numDone = snd_pcm_writen (handle, (void**) data, (snd_pcm_uframes_t) numSamples); } - if (numDone < 0 && JUCE_ALSA_FAILED (snd_pcm_recover (handle, (int) numDone, 1 /* silent */))) - return false; + if (numDone < 0) + { + if (numDone == -(EPIPE)) + underrunCount++; + + if (JUCE_ALSA_FAILED (snd_pcm_recover (handle, (int) numDone, 1 /* silent */))) + return false; + } if (numDone < numSamples) JUCE_ALSA_LOG ("Did not write all samples: numDone: " << numDone << ", numSamples: " << numSamples); @@ -354,8 +360,15 @@ public: snd_pcm_sframes_t num = snd_pcm_readi (handle, scratch.getData(), (snd_pcm_uframes_t) numSamples); - if (num < 0 && JUCE_ALSA_FAILED (snd_pcm_recover (handle, (int) num, 1 /* silent */))) - return false; + if (num < 0) + { + if (num == -(EPIPE)) + overrunCount++; + + if (JUCE_ALSA_FAILED (snd_pcm_recover (handle, (int) num, 1 /* silent */))) + return false; + } + if (num < numSamples) JUCE_ALSA_LOG ("Did not read all samples: num: " << num << ", numSamples: " << numSamples); @@ -367,8 +380,14 @@ public: { snd_pcm_sframes_t num = snd_pcm_readn (handle, (void**) data, (snd_pcm_uframes_t) numSamples); - if (num < 0 && JUCE_ALSA_FAILED (snd_pcm_recover (handle, (int) num, 1 /* silent */))) - return false; + if (num < 0) + { + if (num == -(EPIPE)) + overrunCount++; + + if (JUCE_ALSA_FAILED (snd_pcm_recover (handle, (int) num, 1 /* silent */))) + return false; + } if (num < numSamples) JUCE_ALSA_LOG ("Did not read all samples: num: " << num << ", numSamples: " << numSamples); @@ -384,6 +403,7 @@ public: snd_pcm_t* handle; String error; int bitDepth, numChannelsRunning, latency; + int underrunCount = 0, overrunCount = 0; private: //============================================================================== @@ -749,6 +769,19 @@ public: return 16; } + int getXRunCount() const noexcept + { + int result = 0; + + if (outputDevice != nullptr) + result += outputDevice->underrunCount; + + if (inputDevice != nullptr) + result += inputDevice->overrunCount; + + return result; + } + //============================================================================== String error; double sampleRate; @@ -908,6 +941,8 @@ public: int getOutputLatencyInSamples() override { return internal.outputLatency; } int getInputLatencyInSamples() override { return internal.inputLatency; } + int getXRunCount() const noexcept override { return internal.getXRunCount(); } + void start (AudioIODeviceCallback* callback) override { if (! isOpen_) diff --git a/modules/juce_audio_devices/native/juce_linux_JackAudio.cpp b/modules/juce_audio_devices/native/juce_linux_JackAudio.cpp index eb25bd7622..35302a3160 100644 --- a/modules/juce_audio_devices/native/juce_linux_JackAudio.cpp +++ b/modules/juce_audio_devices/native/juce_linux_JackAudio.cpp @@ -69,6 +69,7 @@ JUCE_DECL_JACK_FUNCTION (void*, jack_set_port_connect_callback, (jack_client_t* JUCE_DECL_JACK_FUNCTION (jack_port_t* , jack_port_by_id, (jack_client_t* client, jack_port_id_t port_id), (client, port_id)); JUCE_DECL_JACK_FUNCTION (int, jack_port_connected, (const jack_port_t* port), (port)); JUCE_DECL_JACK_FUNCTION (int, jack_port_connected_to, (const jack_port_t* port, const char* port_name), (port, port_name)); +JUCE_DECL_JACK_FUNCTION (int, jack_set_xrun_callback, (jack_client_t* client, JackXRunCallback xrun_callback, void* arg), (client, xrun_callback, arg)); #if JUCE_DEBUG #define JACK_LOGGING_ENABLED 1 @@ -258,9 +259,11 @@ public: lastError.clear(); close(); + xruns = 0; juce::jack_set_process_callback (client, processCallback, this); juce::jack_set_port_connect_callback (client, portConnectCallback, this); juce::jack_on_shutdown (client, shutdownCallback, this); + juce::jack_set_xrun_callback (client, xrunCallback, this); juce::jack_activate (client); deviceIsOpen = true; @@ -302,6 +305,8 @@ public: if (client != nullptr) { juce::jack_deactivate (client); + + juce::jack_set_xrun_callback (client, xrunCallback, nullptr); juce::jack_set_process_callback (client, processCallback, nullptr); juce::jack_set_port_connect_callback (client, portConnectCallback, nullptr); juce::jack_on_shutdown (client, shutdownCallback, nullptr); @@ -338,6 +343,7 @@ public: bool isPlaying() override { return callback != nullptr; } int getCurrentBitDepth() override { return 32; } String getLastError() override { return lastError; } + int getXRunCount() const noexcept override { return xruns; } BigInteger getActiveOutputChannels() const override { return activeOutputChannels; } BigInteger getActiveInputChannels() const override { return activeInputChannels; } @@ -408,6 +414,14 @@ private: return 0; } + static int xrunCallback (void* callbackArgument) + { + if (callbackArgument != nullptr) + ((JackAudioIODevice*) callbackArgument)->xruns++; + + return 0; + } + void updateActivePorts() { BigInteger newOutputChannels, newInputChannels; @@ -477,6 +491,8 @@ private: int totalNumberOfOutputChannels; Array inputPorts, outputPorts; BigInteger activeInputChannels, activeOutputChannels; + + int xruns; }; diff --git a/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp b/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp index 40629e7a69..0bd8f3fbcb 100644 --- a/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp +++ b/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp @@ -796,6 +796,7 @@ public: int inputLatency = 0; int outputLatency = 0; int bitDepth = 32; + int xruns = 0; BigInteger activeInputChans, activeOutputChans; StringArray inChanNames, outChanNames; Array sampleRates; @@ -837,6 +838,9 @@ private: switch (pa->mSelector) { + case kAudioDeviceProcessorOverload: + intern->xruns++; + break; case kAudioDevicePropertyBufferSize: case kAudioDevicePropertyBufferFrameSize: case kAudioDevicePropertyNominalSampleRate: @@ -962,6 +966,7 @@ public: double getCurrentSampleRate() override { return internal->getSampleRate(); } int getCurrentBitDepth() override { return internal->bitDepth; } int getCurrentBufferSizeSamples() override { return internal->getBufferSize(); } + int getXRunCount() const noexcept override { return internal->xruns; } int getDefaultBufferSize() override { @@ -982,6 +987,7 @@ public: { isOpen_ = true; + internal->xruns = 0; if (bufferSizeSamples <= 0) bufferSizeSamples = getDefaultBufferSize(); diff --git a/modules/juce_audio_devices/native/juce_win32_ASIO.cpp b/modules/juce_audio_devices/native/juce_win32_ASIO.cpp index 54bc1e7b51..11645bb6c2 100644 --- a/modules/juce_audio_devices/native/juce_win32_ASIO.cpp +++ b/modules/juce_audio_devices/native/juce_win32_ASIO.cpp @@ -409,6 +409,8 @@ public: Array getAvailableBufferSizes() override { return bufferSizes; } int getDefaultBufferSize() override { return preferredBufferSize; } + int getXRunCount() const noexcept override { return xruns; } + String open (const BigInteger& inputChannels, const BigInteger& outputChannels, double sr, int bufferSizeSamples) override @@ -464,6 +466,9 @@ public: err = asioObject->getChannels (&totalNumInputChans, &totalNumOutputChans); jassert (err == ASE_OK); + if (asioObject->future (kAsioCanReportOverload, nullptr) != ASE_OK) + xruns = -1; + inBuffers.calloc (totalNumInputChans + 8); outBuffers.calloc (totalNumOutputChans + 8); @@ -789,6 +794,7 @@ private: bool volatile littleEndian, postOutput, needToReset; bool volatile insideControlPanelModalLoop; bool volatile shouldUsePreferredSize; + int xruns = 0; //============================================================================== static String convertASIOString (char* const text, int length) @@ -1180,6 +1186,7 @@ private: totalNumOutputChans = 0; numActiveInputChans = 0; numActiveOutputChans = 0; + xruns = 0; currentCallback = nullptr; error.clear(); @@ -1349,7 +1356,7 @@ private: { case kAsioSelectorSupported: if (value == kAsioResetRequest || value == kAsioEngineVersion || value == kAsioResyncRequest - || value == kAsioLatenciesChanged || value == kAsioSupportsInputMonitor) + || value == kAsioLatenciesChanged || value == kAsioSupportsInputMonitor || value == kAsioOverload) return 1; break; @@ -1360,7 +1367,8 @@ private: case kAsioEngineVersion: return 2; case kAsioSupportsTimeInfo: - case kAsioSupportsTimeCode: return 0; + case kAsioSupportsTimeCode: return 0; + case kAsioOverload: xruns++; return 1; } return 0; diff --git a/modules/juce_audio_devices/native/juce_win32_DirectSound.cpp b/modules/juce_audio_devices/native/juce_win32_DirectSound.cpp index 83b60ce691..10ea41abae 100644 --- a/modules/juce_audio_devices/native/juce_win32_DirectSound.cpp +++ b/modules/juce_audio_devices/native/juce_win32_DirectSound.cpp @@ -266,6 +266,10 @@ public: pDirectSound = nullptr; pOutputBuffer = nullptr; writeOffset = 0; + xruns = 0; + + firstPlayTime = true; + lastPlayTime = 0; String error; HRESULT hr = E_NOINTERFACE; @@ -276,6 +280,7 @@ public: if (SUCCEEDED (hr)) { bytesPerBuffer = (bufferSizeSamples * (bitDepth >> 2)) & ~15; + ticksPerBuffer = bytesPerBuffer * Time::getHighResolutionTicksPerSecond() / (sampleRate * (bitDepth >> 2)); totalBytesPerBuffer = (blocksPerOverallBuffer * bytesPerBuffer) & ~15; const int numChannels = 2; @@ -397,6 +402,18 @@ public: return true; } + auto currentPlayTime = Time::getHighResolutionTicks (); + if (! firstPlayTime) + { + auto expectedBuffers = (currentPlayTime - lastPlayTime) / ticksPerBuffer; + + playCursor += static_cast (expectedBuffers * bytesPerBuffer); + } + else + firstPlayTime = false; + + lastPlayTime = currentPlayTime; + int playWriteGap = (int) (writeCursor - playCursor); if (playWriteGap < 0) playWriteGap += totalBytesPerBuffer; @@ -409,6 +426,9 @@ public: { writeOffset = writeCursor; bytesEmpty = totalBytesPerBuffer - playWriteGap; + + // buffer underflow + xruns++; } if (bytesEmpty >= bytesPerBuffer) @@ -480,7 +500,7 @@ public: } } - int bitDepth; + int bitDepth, xruns; bool doneFlag; private: @@ -496,6 +516,9 @@ private: int totalBytesPerBuffer, bytesPerBuffer; unsigned int lastPlayCursor; + bool firstPlayTime; + int64 lastPlayTime, ticksPerBuffer; + static inline int convertInputValues (const float l, const float r) noexcept { return jlimit (-32768, 32767, roundToInt (32767.0f * r)) << 16 @@ -854,6 +877,11 @@ public: bool isPlaying() override { return isStarted && isOpen_ && isThreadRunning(); } String getLastError() override { return lastError; } + int getXRunCount () const noexcept override + { + return (outChans[0] != nullptr ? outChans[0]->xruns : -1); + } + //============================================================================== StringArray inChannels, outChannels; int outputDeviceIndex, inputDeviceIndex; diff --git a/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp b/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp index 16ed54c5c0..d0380d7897 100644 --- a/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp +++ b/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp @@ -128,7 +128,12 @@ enum EDataFlow enum { - DEVICE_STATE_ACTIVE = 1, + DEVICE_STATE_ACTIVE = 1 +}; + +enum +{ + AUDCLNT_BUFFERFLAGS_DATA_DISCONTINUITY = 1, AUDCLNT_BUFFERFLAGS_SILENT = 2 }; @@ -742,6 +747,7 @@ public: reservoirMask = nextPowerOfTwo (reservoirSize) - 1; reservoir.setSize ((reservoirMask + 1) * bytesPerFrame, true); reservoirReadPos = reservoirWritePos = 0; + xruns = 0; if (! check (client->Start())) return false; @@ -774,6 +780,9 @@ public: while (check (captureClient->GetBuffer (&inputData, &numSamplesAvailable, &flags, nullptr, nullptr)) && numSamplesAvailable > 0) { + if ((flags & AUDCLNT_BUFFERFLAGS_DATA_DISCONTINUITY) != 0) + xruns++; + int samplesLeft = (int) numSamplesAvailable; while (samplesLeft > 0) @@ -838,7 +847,7 @@ public: ComSmartPtr captureClient; MemoryBlock reservoir; - int reservoirSize, reservoirMask; + int reservoirSize, reservoirMask, xruns; volatile int reservoirReadPos, reservoirWritePos; ScopedPointer converter; @@ -1075,7 +1084,7 @@ public: BigInteger getActiveOutputChannels() const override { return outputDevice != nullptr ? outputDevice->channels : BigInteger(); } BigInteger getActiveInputChannels() const override { return inputDevice != nullptr ? inputDevice->channels : BigInteger(); } String getLastError() override { return lastError; } - + int getXRunCount () const noexcept override { return inputDevice != nullptr ? inputDevice->xruns : -1; } String open (const BigInteger& inputChannels, const BigInteger& outputChannels, double sampleRate, int bufferSizeSamples) override From c309a5b2445ccabc626ce2784e7bcd2869957a51 Mon Sep 17 00:00:00 2001 From: jules Date: Thu, 21 Sep 2017 19:48:19 +0100 Subject: [PATCH 128/129] Avoided forcing TextEditor to be always opaque --- .../widgets/juce_TextEditor.cpp | 5040 ++++++++--------- .../juce_gui_basics/widgets/juce_TextEditor.h | 1548 ++--- 2 files changed, 3288 insertions(+), 3300 deletions(-) diff --git a/modules/juce_gui_basics/widgets/juce_TextEditor.cpp b/modules/juce_gui_basics/widgets/juce_TextEditor.cpp index 3e9ee97234..f3490c35b7 100644 --- a/modules/juce_gui_basics/widgets/juce_TextEditor.cpp +++ b/modules/juce_gui_basics/widgets/juce_TextEditor.cpp @@ -1,2526 +1,2514 @@ -/* - ============================================================================== - - This file is part of the JUCE library. - Copyright (c) 2017 - ROLI Ltd. - - JUCE is an open source library subject to commercial or open-source - licensing. - - By using JUCE, you agree to the terms of both the JUCE 5 End-User License - Agreement and JUCE 5 Privacy Policy (both updated and effective as of the - 27th April 2017). - - End User License Agreement: www.juce.com/juce-5-licence - Privacy Policy: www.juce.com/juce-5-privacy-policy - - Or: You may also use this code under the terms of the GPL v3 (see - www.gnu.org/licenses). - - JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER - EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE - DISCLAIMED. - - ============================================================================== -*/ - -namespace juce -{ - -// a word or space that can't be broken down any further -struct TextAtom -{ - //============================================================================== - String atomText; - float width; - int numChars; - - //============================================================================== - bool isWhitespace() const noexcept { return CharacterFunctions::isWhitespace (atomText[0]); } - bool isNewLine() const noexcept { return atomText[0] == '\r' || atomText[0] == '\n'; } - - String getText (const juce_wchar passwordCharacter) const - { - if (passwordCharacter == 0) - return atomText; - - return String::repeatedString (String::charToString (passwordCharacter), - atomText.length()); - } - - String getTrimmedText (const juce_wchar passwordCharacter) const - { - if (passwordCharacter == 0) - return atomText.substring (0, numChars); - - if (isNewLine()) - return {}; - - return String::repeatedString (String::charToString (passwordCharacter), numChars); - } - - JUCE_LEAK_DETECTOR (TextAtom) -}; - -//============================================================================== -// a run of text with a single font and colour -class TextEditor::UniformTextSection -{ -public: - UniformTextSection (const String& text, const Font& f, Colour col, juce_wchar passwordChar) - : font (f), colour (col) - { - initialiseAtoms (text, passwordChar); - } - - UniformTextSection (const UniformTextSection& other) - : font (other.font), colour (other.colour) - { - atoms.addCopiesOf (other.atoms); - } - - void append (UniformTextSection& other, const juce_wchar passwordChar) - { - if (other.atoms.size() > 0) - { - int i = 0; - - if (auto* lastAtom = atoms.getLast()) - { - if (! CharacterFunctions::isWhitespace (lastAtom->atomText.getLastCharacter())) - { - auto* first = other.atoms.getUnchecked(0); - - if (! CharacterFunctions::isWhitespace (first->atomText[0])) - { - lastAtom->atomText += first->atomText; - lastAtom->numChars = (uint16) (lastAtom->numChars + first->numChars); - lastAtom->width = font.getStringWidthFloat (lastAtom->getText (passwordChar)); - delete first; - ++i; - } - } - } - - atoms.ensureStorageAllocated (atoms.size() + other.atoms.size() - i); - - while (i < other.atoms.size()) - { - atoms.add (other.atoms.getUnchecked(i)); - ++i; - } - - other.atoms.clear (false); - } - } - - UniformTextSection* split (const int indexToBreakAt, const juce_wchar passwordChar) - { - UniformTextSection* const section2 = new UniformTextSection (String(), font, colour, passwordChar); - int index = 0; - - for (int i = 0; i < atoms.size(); ++i) - { - auto* atom = atoms.getUnchecked(i); - auto nextIndex = index + atom->numChars; - - if (index == indexToBreakAt) - { - for (int j = i; j < atoms.size(); ++j) - section2->atoms.add (atoms.getUnchecked (j)); - - atoms.removeRange (i, atoms.size(), false); - break; - } - else if (indexToBreakAt >= index && indexToBreakAt < nextIndex) - { - auto* secondAtom = new TextAtom(); - - secondAtom->atomText = atom->atomText.substring (indexToBreakAt - index); - secondAtom->width = font.getStringWidthFloat (secondAtom->getText (passwordChar)); - secondAtom->numChars = (uint16) secondAtom->atomText.length(); - - section2->atoms.add (secondAtom); - - atom->atomText = atom->atomText.substring (0, indexToBreakAt - index); - atom->width = font.getStringWidthFloat (atom->getText (passwordChar)); - atom->numChars = (uint16) (indexToBreakAt - index); - - for (int j = i + 1; j < atoms.size(); ++j) - section2->atoms.add (atoms.getUnchecked (j)); - - atoms.removeRange (i + 1, atoms.size(), false); - break; - } - - index = nextIndex; - } - - return section2; - } - - void appendAllText (MemoryOutputStream& mo) const - { - for (int i = 0; i < atoms.size(); ++i) - mo << atoms.getUnchecked(i)->atomText; - } - - void appendSubstring (MemoryOutputStream& mo, const Range range) const - { - int index = 0; - - for (auto* atom : atoms) - { - auto nextIndex = index + atom->numChars; - - if (range.getStart() < nextIndex) - { - if (range.getEnd() <= index) - break; - - auto r = (range - index).getIntersectionWith (Range (0, (int) atom->numChars)); - - if (! r.isEmpty()) - mo << atom->atomText.substring (r.getStart(), r.getEnd()); - } - - index = nextIndex; - } - } - - int getTotalLength() const noexcept - { - int total = 0; - - for (auto* atom : atoms) - total += atom->numChars; - - return total; - } - - void setFont (const Font& newFont, const juce_wchar passwordChar) - { - if (font != newFont) - { - font = newFont; - - for (auto* atom : atoms) - atom->width = newFont.getStringWidthFloat (atom->getText (passwordChar)); - } - } - - //============================================================================== - Font font; - Colour colour; - OwnedArray atoms; - -private: - void initialiseAtoms (const String& textToParse, const juce_wchar passwordChar) - { - auto text = textToParse.getCharPointer(); - - while (! text.isEmpty()) - { - size_t numChars = 0; - auto start = text; - - // create a whitespace atom unless it starts with non-ws - if (text.isWhitespace() && *text != '\r' && *text != '\n') - { - do - { - ++text; - ++numChars; - } - while (text.isWhitespace() && *text != '\r' && *text != '\n'); - } - else - { - if (*text == '\r') - { - ++text; - ++numChars; - - if (*text == '\n') - { - ++start; - ++text; - } - } - else if (*text == '\n') - { - ++text; - ++numChars; - } - else - { - while (! (text.isEmpty() || text.isWhitespace())) - { - ++text; - ++numChars; - } - } - } - - auto* atom = atoms.add (new TextAtom()); - - atom->atomText = String (start, numChars); - atom->width = font.getStringWidthFloat (atom->getText (passwordChar)); - atom->numChars = (uint16) numChars; - } - } - - UniformTextSection& operator= (const UniformTextSection&); - JUCE_LEAK_DETECTOR (UniformTextSection) -}; - -//============================================================================== -class TextEditor::Iterator -{ -public: - Iterator (const OwnedArray& sectionList, - float wrapWidth, juce_wchar passwordChar, float spacing) - : sections (sectionList), - wordWrapWidth (wrapWidth), - passwordCharacter (passwordChar), - lineSpacing (spacing) - { - jassert (wordWrapWidth > 0); - - if (sections.size() > 0) - { - currentSection = sections.getUnchecked (sectionIndex); - - if (currentSection != nullptr) - beginNewLine(); - } - } - - Iterator (const Iterator& other) - : indexInText (other.indexInText), - lineY (other.lineY), - lineHeight (other.lineHeight), - maxDescent (other.maxDescent), - atomX (other.atomX), - atomRight (other.atomRight), - atom (other.atom), - currentSection (other.currentSection), - sections (other.sections), - sectionIndex (other.sectionIndex), - atomIndex (other.atomIndex), - wordWrapWidth (other.wordWrapWidth), - passwordCharacter (other.passwordCharacter), - lineSpacing (other.lineSpacing), - tempAtom (other.tempAtom) - { - } - - //============================================================================== - bool next() - { - if (atom == &tempAtom) - { - const int numRemaining = tempAtom.atomText.length() - tempAtom.numChars; - - if (numRemaining > 0) - { - tempAtom.atomText = tempAtom.atomText.substring (tempAtom.numChars); - - atomX = 0; - - if (tempAtom.numChars > 0) - lineY += lineHeight * lineSpacing; - - indexInText += tempAtom.numChars; - - GlyphArrangement g; - g.addLineOfText (currentSection->font, atom->getText (passwordCharacter), 0.0f, 0.0f); - - int split; - for (split = 0; split < g.getNumGlyphs(); ++split) - if (shouldWrap (g.getGlyph (split).getRight())) - break; - - if (split > 0 && split <= numRemaining) - { - tempAtom.numChars = (uint16) split; - tempAtom.width = g.getGlyph (split - 1).getRight(); - atomRight = atomX + tempAtom.width; - return true; - } - } - } - - if (sectionIndex >= sections.size()) - { - moveToEndOfLastAtom(); - return false; - } - - bool forceNewLine = false; - - if (atomIndex >= currentSection->atoms.size() - 1) - { - if (atomIndex >= currentSection->atoms.size()) - { - if (++sectionIndex >= sections.size()) - { - moveToEndOfLastAtom(); - return false; - } - - atomIndex = 0; - currentSection = sections.getUnchecked (sectionIndex); - } - else - { - auto* lastAtom = currentSection->atoms.getUnchecked (atomIndex); - - if (! lastAtom->isWhitespace()) - { - // handle the case where the last atom in a section is actually part of the same - // word as the first atom of the next section... - float right = atomRight + lastAtom->width; - float lineHeight2 = lineHeight; - float maxDescent2 = maxDescent; - - for (int section = sectionIndex + 1; section < sections.size(); ++section) - { - auto* s = sections.getUnchecked (section); - - if (s->atoms.size() == 0) - break; - - auto* nextAtom = s->atoms.getUnchecked (0); - - if (nextAtom->isWhitespace()) - break; - - right += nextAtom->width; - - lineHeight2 = jmax (lineHeight2, s->font.getHeight()); - maxDescent2 = jmax (maxDescent2, s->font.getDescent()); - - if (shouldWrap (right)) - { - lineHeight = lineHeight2; - maxDescent = maxDescent2; - - forceNewLine = true; - break; - } - - if (s->atoms.size() > 1) - break; - } - } - } - } - - if (atom != nullptr) - { - atomX = atomRight; - indexInText += atom->numChars; - - if (atom->isNewLine()) - beginNewLine(); - } - - atom = currentSection->atoms.getUnchecked (atomIndex); - atomRight = atomX + atom->width; - ++atomIndex; - - if (shouldWrap (atomRight) || forceNewLine) - { - if (atom->isWhitespace()) - { - // leave whitespace at the end of a line, but truncate it to avoid scrolling - atomRight = jmin (atomRight, wordWrapWidth); - } - else - { - atomRight = atom->width; - - if (shouldWrap (atomRight)) // atom too big to fit on a line, so break it up.. - { - tempAtom = *atom; - tempAtom.width = 0; - tempAtom.numChars = 0; - atom = &tempAtom; - - if (atomX > 0) - beginNewLine(); - - return next(); - } - - beginNewLine(); - return true; - } - } - - return true; - } - - void beginNewLine() - { - atomX = 0; - lineY += lineHeight * lineSpacing; - - int tempSectionIndex = sectionIndex; - int tempAtomIndex = atomIndex; - auto* section = sections.getUnchecked (tempSectionIndex); - - lineHeight = section->font.getHeight(); - maxDescent = section->font.getDescent(); - - float x = (atom != nullptr) ? atom->width : 0; - - while (! shouldWrap (x)) - { - if (tempSectionIndex >= sections.size()) - break; - - bool checkSize = false; - - if (tempAtomIndex >= section->atoms.size()) - { - if (++tempSectionIndex >= sections.size()) - break; - - tempAtomIndex = 0; - section = sections.getUnchecked (tempSectionIndex); - checkSize = true; - } - - auto* nextAtom = section->atoms.getUnchecked (tempAtomIndex); - - if (nextAtom == nullptr) - break; - - x += nextAtom->width; - - if (shouldWrap (x) || nextAtom->isNewLine()) - break; - - if (checkSize) - { - lineHeight = jmax (lineHeight, section->font.getHeight()); - maxDescent = jmax (maxDescent, section->font.getDescent()); - } - - ++tempAtomIndex; - } - } - - //============================================================================== - void draw (Graphics& g, const UniformTextSection*& lastSection) const - { - if (passwordCharacter != 0 || ! atom->isWhitespace()) - { - if (lastSection != currentSection) - { - lastSection = currentSection; - g.setColour (currentSection->colour); - g.setFont (currentSection->font); - } - - jassert (atom->getTrimmedText (passwordCharacter).isNotEmpty()); - - GlyphArrangement ga; - ga.addLineOfText (currentSection->font, - atom->getTrimmedText (passwordCharacter), - atomX, (float) roundToInt (lineY + lineHeight - maxDescent)); - ga.draw (g); - } - } - - void addSelection (RectangleList& area, const Range selected) const - { - const float startX = indexToX (selected.getStart()); - const float endX = indexToX (selected.getEnd()); - - area.add (startX, lineY, endX - startX, lineHeight * lineSpacing); - } - - void drawUnderline (Graphics& g, const Range underline, const Colour colour) const - { - const int startX = roundToInt (indexToX (underline.getStart())); - const int endX = roundToInt (indexToX (underline.getEnd())); - const int baselineY = roundToInt (lineY + currentSection->font.getAscent() + 0.5f); - - Graphics::ScopedSaveState state (g); - g.reduceClipRegion (Rectangle (startX, baselineY, endX - startX, 1)); - g.fillCheckerBoard (Rectangle (endX, baselineY + 1), 3, 1, colour, Colours::transparentBlack); - } - - void drawSelectedText (Graphics& g, - const Range selected, - const Colour selectedTextColour) const - { - if (passwordCharacter != 0 || ! atom->isWhitespace()) - { - GlyphArrangement ga; - ga.addLineOfText (currentSection->font, - atom->getTrimmedText (passwordCharacter), - atomX, (float) roundToInt (lineY + lineHeight - maxDescent)); - - if (selected.getEnd() < indexInText + atom->numChars) - { - GlyphArrangement ga2 (ga); - ga2.removeRangeOfGlyphs (0, selected.getEnd() - indexInText); - ga.removeRangeOfGlyphs (selected.getEnd() - indexInText, -1); - - g.setColour (currentSection->colour); - ga2.draw (g); - } - - if (selected.getStart() > indexInText) - { - GlyphArrangement ga2 (ga); - ga2.removeRangeOfGlyphs (selected.getStart() - indexInText, -1); - ga.removeRangeOfGlyphs (0, selected.getStart() - indexInText); - - g.setColour (currentSection->colour); - ga2.draw (g); - } - - g.setColour (selectedTextColour); - ga.draw (g); - } - } - - //============================================================================== - float indexToX (const int indexToFind) const - { - if (indexToFind <= indexInText) - return atomX; - - if (indexToFind >= indexInText + atom->numChars) - return atomRight; - - GlyphArrangement g; - g.addLineOfText (currentSection->font, - atom->getText (passwordCharacter), - atomX, 0.0f); - - if (indexToFind - indexInText >= g.getNumGlyphs()) - return atomRight; - - return jmin (atomRight, g.getGlyph (indexToFind - indexInText).getLeft()); - } - - int xToIndex (const float xToFind) const - { - if (xToFind <= atomX || atom->isNewLine()) - return indexInText; - - if (xToFind >= atomRight) - return indexInText + atom->numChars; - - GlyphArrangement g; - g.addLineOfText (currentSection->font, - atom->getText (passwordCharacter), - atomX, 0.0f); - - const int numGlyphs = g.getNumGlyphs(); - - int j; - for (j = 0; j < numGlyphs; ++j) - { - auto& pg = g.getGlyph(j); - - if ((pg.getLeft() + pg.getRight()) / 2 > xToFind) - break; - } - - return indexInText + j; - } - - //============================================================================== - bool getCharPosition (const int index, float& cx, float& cy, float& lineHeightFound) - { - while (next()) - { - if (indexInText + atom->numChars > index) - { - cx = indexToX (index); - cy = lineY; - lineHeightFound = lineHeight; - return true; - } - } - - cx = atomX; - cy = lineY; - lineHeightFound = lineHeight; - return false; - } - - //============================================================================== - int indexInText = 0; - float lineY = 0, lineHeight = 0, maxDescent = 0; - float atomX = 0, atomRight = 0; - const TextAtom* atom = nullptr; - const UniformTextSection* currentSection = nullptr; - -private: - const OwnedArray& sections; - int sectionIndex = 0, atomIndex = 0; - const float wordWrapWidth; - const juce_wchar passwordCharacter; - const float lineSpacing; - TextAtom tempAtom; - - Iterator& operator= (const Iterator&) = delete; - - void moveToEndOfLastAtom() - { - if (atom != nullptr) - { - atomX = atomRight; - - if (atom->isNewLine()) - { - atomX = 0.0f; - lineY += lineHeight * lineSpacing; - } - } - } - - bool shouldWrap (const float x) const noexcept - { - return (x - 0.0001f) >= wordWrapWidth; - } - - JUCE_LEAK_DETECTOR (Iterator) -}; - - -//============================================================================== -class TextEditor::InsertAction : public UndoableAction -{ -public: - InsertAction (TextEditor& ed, - const String& newText, - const int insertPos, - const Font& newFont, - const Colour newColour, - const int oldCaret, - const int newCaret) - : owner (ed), - text (newText), - insertIndex (insertPos), - oldCaretPos (oldCaret), - newCaretPos (newCaret), - font (newFont), - colour (newColour) - { - } - - bool perform() override - { - owner.insert (text, insertIndex, font, colour, 0, newCaretPos); - return true; - } - - bool undo() override - { - owner.remove (Range (insertIndex, insertIndex + text.length()), 0, oldCaretPos); - return true; - } - - int getSizeInUnits() override - { - return text.length() + 16; - } - -private: - TextEditor& owner; - const String text; - const int insertIndex, oldCaretPos, newCaretPos; - const Font font; - const Colour colour; - - JUCE_DECLARE_NON_COPYABLE (InsertAction) -}; - -//============================================================================== -class TextEditor::RemoveAction : public UndoableAction -{ -public: - RemoveAction (TextEditor& ed, - const Range rangeToRemove, - const int oldCaret, - const int newCaret, - const Array& oldSections) - : owner (ed), - range (rangeToRemove), - oldCaretPos (oldCaret), - newCaretPos (newCaret) - { - removedSections.addArray (oldSections); - } - - bool perform() override - { - owner.remove (range, 0, newCaretPos); - return true; - } - - bool undo() override - { - owner.reinsert (range.getStart(), removedSections); - owner.moveCaretTo (oldCaretPos, false); - return true; - } - - int getSizeInUnits() override - { - int n = 16; - - for (auto* s : removedSections) - n += s->getTotalLength(); - - return n; - } - -private: - TextEditor& owner; - const Range range; - const int oldCaretPos, newCaretPos; - OwnedArray removedSections; - - JUCE_DECLARE_NON_COPYABLE (RemoveAction) -}; - -//============================================================================== -class TextEditor::TextHolderComponent : public Component, - public Timer, - public Value::Listener -{ -public: - TextHolderComponent (TextEditor& ed) : owner (ed) - { - setWantsKeyboardFocus (false); - setInterceptsMouseClicks (false, true); - setMouseCursor (MouseCursor::ParentCursor); - - owner.getTextValue().addListener (this); - } - - ~TextHolderComponent() - { - owner.getTextValue().removeListener (this); - } - - void paint (Graphics& g) override - { - owner.drawContent (g); - } - - void restartTimer() - { - startTimer (350); - } - - void timerCallback() override - { - owner.timerCallbackInt(); - } - - void valueChanged (Value&) override - { - owner.textWasChangedByValue(); - } - -private: - TextEditor& owner; - - JUCE_DECLARE_NON_COPYABLE (TextHolderComponent) -}; - -//============================================================================== -class TextEditorViewport : public Viewport -{ -public: - TextEditorViewport (TextEditor& ed) : owner (ed) {} - - void visibleAreaChanged (const Rectangle&) override - { - if (! rentrant) // it's rare, but possible to get into a feedback loop as the viewport's scrollbars - // appear and disappear, causing the wrap width to change. - { - const float wordWrapWidth = owner.getWordWrapWidth(); - - if (wordWrapWidth != lastWordWrapWidth) - { - lastWordWrapWidth = wordWrapWidth; - - rentrant = true; - owner.updateTextHolderSize(); - rentrant = false; - } - } - } - -private: - TextEditor& owner; - float lastWordWrapWidth = 0; - bool rentrant = false; - - JUCE_DECLARE_NON_COPYABLE (TextEditorViewport) -}; - -//============================================================================== -namespace TextEditorDefs -{ - const int textChangeMessageId = 0x10003001; - const int returnKeyMessageId = 0x10003002; - const int escapeKeyMessageId = 0x10003003; - const int focusLossMessageId = 0x10003004; - - const int maxActionsPerTransaction = 100; - - static int getCharacterCategory (const juce_wchar character) - { - return CharacterFunctions::isLetterOrDigit (character) - ? 2 : (CharacterFunctions::isWhitespace (character) ? 0 : 1); - } -} - -//============================================================================== -TextEditor::TextEditor (const String& name, - const juce_wchar passwordChar) - : Component (name), - passwordCharacter (passwordChar), - keyboardType (TextInputTarget::textKeyboard), - dragType (notDragging) -{ - setOpaque (true); - setMouseCursor (MouseCursor::IBeamCursor); - - addAndMakeVisible (viewport = new TextEditorViewport (*this)); - viewport->setViewedComponent (textHolder = new TextHolderComponent (*this)); - viewport->setWantsKeyboardFocus (false); - viewport->setScrollBarsShown (false, false); - - setWantsKeyboardFocus (true); - recreateCaret(); -} - -TextEditor::~TextEditor() -{ - if (wasFocused) - if (auto* peer = getPeer()) - peer->dismissPendingTextInput(); - - textValue.removeListener (textHolder); - textValue.referTo (Value()); - - viewport = nullptr; - textHolder = nullptr; -} - -//============================================================================== -void TextEditor::newTransaction() -{ - lastTransactionTime = Time::getApproximateMillisecondCounter(); - undoManager.beginNewTransaction(); -} - -bool TextEditor::undoOrRedo (const bool shouldUndo) -{ - if (! isReadOnly()) - { - newTransaction(); - - if (shouldUndo ? undoManager.undo() - : undoManager.redo()) - { - scrollToMakeSureCursorIsVisible(); - repaint(); - textChanged(); - return true; - } - } - - return false; -} - -bool TextEditor::undo() { return undoOrRedo (true); } -bool TextEditor::redo() { return undoOrRedo (false); } - -//============================================================================== -void TextEditor::setMultiLine (const bool shouldBeMultiLine, - const bool shouldWordWrap) -{ - if (multiline != shouldBeMultiLine - || wordWrap != (shouldWordWrap && shouldBeMultiLine)) - { - multiline = shouldBeMultiLine; - wordWrap = shouldWordWrap && shouldBeMultiLine; - - viewport->setScrollBarsShown (scrollbarVisible && multiline, - scrollbarVisible && multiline); - viewport->setViewPosition (0, 0); - resized(); - scrollToMakeSureCursorIsVisible(); - } -} - -bool TextEditor::isMultiLine() const -{ - return multiline; -} - -void TextEditor::setScrollbarsShown (bool shown) -{ - if (scrollbarVisible != shown) - { - scrollbarVisible = shown; - shown = shown && isMultiLine(); - viewport->setScrollBarsShown (shown, shown); - } -} - -void TextEditor::setReadOnly (const bool shouldBeReadOnly) -{ - if (readOnly != shouldBeReadOnly) - { - readOnly = shouldBeReadOnly; - enablementChanged(); - } -} - -bool TextEditor::isReadOnly() const noexcept -{ - return readOnly || ! isEnabled(); -} - -bool TextEditor::isTextInputActive() const -{ - return ! isReadOnly(); -} - -void TextEditor::setReturnKeyStartsNewLine (const bool shouldStartNewLine) -{ - returnKeyStartsNewLine = shouldStartNewLine; -} - -void TextEditor::setTabKeyUsedAsCharacter (const bool shouldTabKeyBeUsed) -{ - tabKeyUsed = shouldTabKeyBeUsed; -} - -void TextEditor::setPopupMenuEnabled (const bool b) -{ - popupMenuEnabled = b; -} - -void TextEditor::setSelectAllWhenFocused (const bool b) -{ - selectAllTextWhenFocused = b; -} - -//============================================================================== -void TextEditor::setFont (const Font& newFont) -{ - currentFont = newFont; - scrollToMakeSureCursorIsVisible(); -} - -void TextEditor::applyFontToAllText (const Font& newFont, bool changeCurrentFont) -{ - if (changeCurrentFont) - currentFont = newFont; - - auto overallColour = findColour (textColourId); - - for (auto* uts : sections) - { - uts->setFont (newFont, passwordCharacter); - uts->colour = overallColour; - } - - coalesceSimilarSections(); - updateTextHolderSize(); - scrollToMakeSureCursorIsVisible(); - repaint(); -} - -void TextEditor::applyColourToAllText (const Colour& newColour, bool changeCurrentTextColour) -{ - for (auto* uts : sections) - uts->colour = newColour; - - if (changeCurrentTextColour) - setColour (TextEditor::textColourId, newColour); - else - repaint(); -} - -void TextEditor::colourChanged() -{ - setOpaque (findColour (backgroundColourId).isOpaque()); - repaint(); -} - -void TextEditor::lookAndFeelChanged() -{ - colourChanged(); - - caret = nullptr; - recreateCaret(); - repaint(); -} - -void TextEditor::parentHierarchyChanged() -{ - lookAndFeelChanged(); -} - -void TextEditor::enablementChanged() -{ - recreateCaret(); - repaint(); -} - -void TextEditor::setCaretVisible (const bool shouldCaretBeVisible) -{ - if (caretVisible != shouldCaretBeVisible) - { - caretVisible = shouldCaretBeVisible; - recreateCaret(); - } -} - -void TextEditor::recreateCaret() -{ - if (isCaretVisible()) - { - if (caret == nullptr) - { - textHolder->addChildComponent (caret = getLookAndFeel().createCaretComponent (this)); - updateCaretPosition(); - } - } - else - { - caret = nullptr; - } -} - -void TextEditor::updateCaretPosition() -{ - if (caret != nullptr) - caret->setCaretPosition (getCaretRectangle().translated (leftIndent, topIndent)); -} - -TextEditor::LengthAndCharacterRestriction::LengthAndCharacterRestriction (int maxLen, const String& chars) - : allowedCharacters (chars), maxLength (maxLen) -{} - -String TextEditor::LengthAndCharacterRestriction::filterNewText (TextEditor& ed, const String& newInput) -{ - String t (newInput); - - if (allowedCharacters.isNotEmpty()) - t = t.retainCharacters (allowedCharacters); - - if (maxLength > 0) - t = t.substring (0, maxLength - (ed.getTotalNumChars() - ed.getHighlightedRegion().getLength())); - - return t; -} - -void TextEditor::setInputFilter (InputFilter* newFilter, bool takeOwnership) -{ - inputFilter.set (newFilter, takeOwnership); -} - -void TextEditor::setInputRestrictions (const int maxLen, const String& chars) -{ - setInputFilter (new LengthAndCharacterRestriction (maxLen, chars), true); -} - -void TextEditor::setTextToShowWhenEmpty (const String& text, Colour colourToUse) -{ - textToShowWhenEmpty = text; - colourForTextWhenEmpty = colourToUse; -} - -void TextEditor::setPasswordCharacter (const juce_wchar newPasswordCharacter) -{ - if (passwordCharacter != newPasswordCharacter) - { - passwordCharacter = newPasswordCharacter; - applyFontToAllText (currentFont); - } -} - -void TextEditor::setScrollBarThickness (const int newThicknessPixels) -{ - viewport->setScrollBarThickness (newThicknessPixels); -} - -//============================================================================== -void TextEditor::clear() -{ - clearInternal (nullptr); - updateTextHolderSize(); - undoManager.clearUndoHistory(); -} - -void TextEditor::setText (const String& newText, - const bool sendTextChangeMessage) -{ - const int newLength = newText.length(); - - if (newLength != getTotalNumChars() || getText() != newText) - { - if (! sendTextChangeMessage) - textValue.removeListener (textHolder); - - textValue = newText; - - auto oldCursorPos = caretPosition; - const bool cursorWasAtEnd = oldCursorPos >= getTotalNumChars(); - - clearInternal (nullptr); - insert (newText, 0, currentFont, findColour (textColourId), 0, caretPosition); - - // if you're adding text with line-feeds to a single-line text editor, it - // ain't gonna look right! - jassert (multiline || ! newText.containsAnyOf ("\r\n")); - - if (cursorWasAtEnd && ! isMultiLine()) - oldCursorPos = getTotalNumChars(); - - moveCaretTo (oldCursorPos, false); - - if (sendTextChangeMessage) - textChanged(); - else - textValue.addListener (textHolder); - - updateTextHolderSize(); - scrollToMakeSureCursorIsVisible(); - undoManager.clearUndoHistory(); - - repaint(); - } -} - -//============================================================================== -void TextEditor::updateValueFromText() -{ - if (valueTextNeedsUpdating) - { - valueTextNeedsUpdating = false; - textValue = getText(); - } -} - -Value& TextEditor::getTextValue() -{ - updateValueFromText(); - return textValue; -} - -void TextEditor::textWasChangedByValue() -{ - if (textValue.getValueSource().getReferenceCount() > 1) - setText (textValue.getValue()); -} - -//============================================================================== -void TextEditor::textChanged() -{ - updateTextHolderSize(); - - if (listeners.size() > 0) - postCommandMessage (TextEditorDefs::textChangeMessageId); - - if (textValue.getValueSource().getReferenceCount() > 1) - { - valueTextNeedsUpdating = false; - textValue = getText(); - } -} - -void TextEditor::returnPressed() { postCommandMessage (TextEditorDefs::returnKeyMessageId); } -void TextEditor::escapePressed() { postCommandMessage (TextEditorDefs::escapeKeyMessageId); } - -void TextEditor::addListener (Listener* l) { listeners.add (l); } -void TextEditor::removeListener (Listener* l) { listeners.remove (l); } - -//============================================================================== -void TextEditor::timerCallbackInt() -{ - if (hasKeyboardFocus (false) && ! isCurrentlyBlockedByAnotherModalComponent()) - wasFocused = true; - - auto now = Time::getApproximateMillisecondCounter(); - - if (now > lastTransactionTime + 200) - newTransaction(); -} - -void TextEditor::repaintText (const Range range) -{ - if (! range.isEmpty()) - { - float x = 0, y = 0, lh = currentFont.getHeight(); - - const float wordWrapWidth = getWordWrapWidth(); - - if (wordWrapWidth > 0) - { - Iterator i (sections, wordWrapWidth, passwordCharacter, lineSpacing); - - i.getCharPosition (range.getStart(), x, y, lh); - - auto y1 = (int) y; - int y2; - - if (range.getEnd() >= getTotalNumChars()) - { - y2 = textHolder->getHeight(); - } - else - { - i.getCharPosition (range.getEnd(), x, y, lh); - y2 = (int) (y + lh * 2.0f); - } - - textHolder->repaint (0, y1, textHolder->getWidth(), y2 - y1); - } - } -} - -//============================================================================== -void TextEditor::moveCaret (int newCaretPos) -{ - if (newCaretPos < 0) - newCaretPos = 0; - else - newCaretPos = jmin (newCaretPos, getTotalNumChars()); - - if (newCaretPos != getCaretPosition()) - { - caretPosition = newCaretPos; - textHolder->restartTimer(); - scrollToMakeSureCursorIsVisible(); - updateCaretPosition(); - } -} - -int TextEditor::getCaretPosition() const -{ - return caretPosition; -} - -void TextEditor::setCaretPosition (const int newIndex) -{ - moveCaretTo (newIndex, false); -} - -void TextEditor::moveCaretToEnd() -{ - moveCaretTo (std::numeric_limits::max(), false); -} - -void TextEditor::scrollEditorToPositionCaret (const int desiredCaretX, - const int desiredCaretY) - -{ - updateCaretPosition(); - auto caretPos = getCaretRectangle(); - - int vx = caretPos.getX() - desiredCaretX; - int vy = caretPos.getY() - desiredCaretY; - - if (desiredCaretX < jmax (1, proportionOfWidth (0.05f))) - vx += desiredCaretX - proportionOfWidth (0.2f); - else if (desiredCaretX > jmax (0, viewport->getMaximumVisibleWidth() - (wordWrap ? 2 : 10))) - vx += desiredCaretX + (isMultiLine() ? proportionOfWidth (0.2f) : 10) - viewport->getMaximumVisibleWidth(); - - vx = jlimit (0, jmax (0, textHolder->getWidth() + 8 - viewport->getMaximumVisibleWidth()), vx); - - if (! isMultiLine()) - { - vy = viewport->getViewPositionY(); - } - else - { - vy = jlimit (0, jmax (0, textHolder->getHeight() - viewport->getMaximumVisibleHeight()), vy); - - if (desiredCaretY < 0) - vy = jmax (0, desiredCaretY + vy); - else if (desiredCaretY > jmax (0, viewport->getMaximumVisibleHeight() - topIndent - caretPos.getHeight())) - vy += desiredCaretY + 2 + caretPos.getHeight() + topIndent - viewport->getMaximumVisibleHeight(); - } - - viewport->setViewPosition (vx, vy); -} - -Rectangle TextEditor::getCaretRectangle() -{ - float cursorX, cursorY; - float cursorHeight = currentFont.getHeight(); // (in case the text is empty and the call below doesn't set this value) - getCharPosition (caretPosition, cursorX, cursorY, cursorHeight); - - return { roundToInt (cursorX), roundToInt (cursorY), 2, roundToInt (cursorHeight) }; -} - -//============================================================================== -enum { rightEdgeSpace = 2 }; - -float TextEditor::getWordWrapWidth() const -{ - return wordWrap ? (float) (viewport->getMaximumVisibleWidth() - (leftIndent + rightEdgeSpace + 1)) - : std::numeric_limits::max(); -} - -void TextEditor::updateTextHolderSize() -{ - const float wordWrapWidth = getWordWrapWidth(); - - if (wordWrapWidth > 0) - { - float maxWidth = 0.0f; - - Iterator i (sections, wordWrapWidth, passwordCharacter, lineSpacing); - - while (i.next()) - maxWidth = jmax (maxWidth, i.atomRight); - - const int w = leftIndent + roundToInt (maxWidth); - const int h = topIndent + roundToInt (jmax (i.lineY + i.lineHeight, - currentFont.getHeight())); - - textHolder->setSize (w + rightEdgeSpace, h + 1); // (allows a bit of space for the cursor to be at the right-hand-edge) - } -} - -int TextEditor::getTextWidth() const { return textHolder->getWidth(); } -int TextEditor::getTextHeight() const { return textHolder->getHeight(); } - -void TextEditor::setIndents (const int newLeftIndent, const int newTopIndent) -{ - leftIndent = newLeftIndent; - topIndent = newTopIndent; -} - -void TextEditor::setBorder (const BorderSize& border) -{ - borderSize = border; - resized(); -} - -BorderSize TextEditor::getBorder() const -{ - return borderSize; -} - -void TextEditor::setScrollToShowCursor (const bool shouldScrollToShowCursor) -{ - keepCaretOnScreen = shouldScrollToShowCursor; -} - -void TextEditor::scrollToMakeSureCursorIsVisible() -{ - updateCaretPosition(); - - if (keepCaretOnScreen) - { - auto viewPos = viewport->getViewPosition(); - auto caretRect = getCaretRectangle(); - auto relativeCursor = caretRect.getPosition() - viewPos; - - if (relativeCursor.x < jmax (1, proportionOfWidth (0.05f))) - { - viewPos.x += relativeCursor.x - proportionOfWidth (0.2f); - } - else if (relativeCursor.x > jmax (0, viewport->getMaximumVisibleWidth() - (wordWrap ? 2 : 10))) - { - viewPos.x += relativeCursor.x + (isMultiLine() ? proportionOfWidth (0.2f) : 10) - viewport->getMaximumVisibleWidth(); - } - - viewPos.x = jlimit (0, jmax (0, textHolder->getWidth() + 8 - viewport->getMaximumVisibleWidth()), viewPos.x); - - if (! isMultiLine()) - { - viewPos.y = (getHeight() - textHolder->getHeight() - topIndent) / -2; - } - else if (relativeCursor.y < 0) - { - viewPos.y = jmax (0, relativeCursor.y + viewPos.y); - } - else if (relativeCursor.y > jmax (0, viewport->getMaximumVisibleHeight() - topIndent - caretRect.getHeight())) - { - viewPos.y += relativeCursor.y + 2 + caretRect.getHeight() + topIndent - viewport->getMaximumVisibleHeight(); - } - - viewport->setViewPosition (viewPos); - } -} - -void TextEditor::moveCaretTo (const int newPosition, const bool isSelecting) -{ - if (isSelecting) - { - moveCaret (newPosition); - - auto oldSelection = selection; - - if (dragType == notDragging) - { - if (std::abs (getCaretPosition() - selection.getStart()) < std::abs (getCaretPosition() - selection.getEnd())) - dragType = draggingSelectionStart; - else - dragType = draggingSelectionEnd; - } - - if (dragType == draggingSelectionStart) - { - if (getCaretPosition() >= selection.getEnd()) - dragType = draggingSelectionEnd; - - selection = Range::between (getCaretPosition(), selection.getEnd()); - } - else - { - if (getCaretPosition() < selection.getStart()) - dragType = draggingSelectionStart; - - selection = Range::between (getCaretPosition(), selection.getStart()); - } - - repaintText (selection.getUnionWith (oldSelection)); - } - else - { - dragType = notDragging; - - repaintText (selection); - - moveCaret (newPosition); - selection = Range::emptyRange (getCaretPosition()); - } -} - -int TextEditor::getTextIndexAt (const int x, const int y) -{ - return indexAtPosition ((float) (x + viewport->getViewPositionX() - leftIndent - borderSize.getLeft()), - (float) (y + viewport->getViewPositionY() - topIndent - borderSize.getTop())); -} - -void TextEditor::insertTextAtCaret (const String& t) -{ - String newText (inputFilter != nullptr ? inputFilter->filterNewText (*this, t) : t); - - if (isMultiLine()) - newText = newText.replace ("\r\n", "\n"); - else - newText = newText.replaceCharacters ("\r\n", " "); - - const int insertIndex = selection.getStart(); - const int newCaretPos = insertIndex + newText.length(); - - remove (selection, getUndoManager(), - newText.isNotEmpty() ? newCaretPos - 1 : newCaretPos); - - insert (newText, insertIndex, currentFont, findColour (textColourId), - getUndoManager(), newCaretPos); - - textChanged(); -} - -void TextEditor::setHighlightedRegion (const Range& newSelection) -{ - moveCaretTo (newSelection.getStart(), false); - moveCaretTo (newSelection.getEnd(), true); -} - -//============================================================================== -void TextEditor::copy() -{ - if (passwordCharacter == 0) - { - auto selectedText = getHighlightedText(); - - if (selectedText.isNotEmpty()) - SystemClipboard::copyTextToClipboard (selectedText); - } -} - -void TextEditor::paste() -{ - if (! isReadOnly()) - { - auto clip = SystemClipboard::getTextFromClipboard(); - - if (clip.isNotEmpty()) - insertTextAtCaret (clip); - } -} - -void TextEditor::cut() -{ - if (! isReadOnly()) - { - moveCaret (selection.getEnd()); - insertTextAtCaret (String()); - } -} - -//============================================================================== -void TextEditor::drawContent (Graphics& g) -{ - const float wordWrapWidth = getWordWrapWidth(); - - if (wordWrapWidth > 0) - { - g.setOrigin (leftIndent, topIndent); - auto clip = g.getClipBounds(); - Colour selectedTextColour; - - Iterator i (sections, wordWrapWidth, passwordCharacter, lineSpacing); - - if (! selection.isEmpty()) - { - Iterator i2 (i); - RectangleList selectionArea; - - while (i2.next() && i2.lineY < clip.getBottom()) - { - if (i2.lineY + i2.lineHeight >= clip.getY() - && selection.intersects (Range (i2.indexInText, i2.indexInText + i2.atom->numChars))) - { - i2.addSelection (selectionArea, selection); - } - } - - g.setColour (findColour (highlightColourId).withMultipliedAlpha (hasKeyboardFocus (true) ? 1.0f : 0.5f)); - g.fillRectList (selectionArea); - - selectedTextColour = findColour (highlightedTextColourId); - } - - const UniformTextSection* lastSection = nullptr; - - while (i.next() && i.lineY < clip.getBottom()) - { - if (i.lineY + i.lineHeight >= clip.getY()) - { - if (selection.intersects (Range (i.indexInText, i.indexInText + i.atom->numChars))) - { - i.drawSelectedText (g, selection, selectedTextColour); - lastSection = nullptr; - } - else - { - i.draw (g, lastSection); - } - } - } - - for (int j = underlinedSections.size(); --j >= 0;) - { - const Range underlinedSection = underlinedSections.getReference (j); - - Iterator i2 (sections, wordWrapWidth, passwordCharacter, lineSpacing); - - while (i2.next() && i2.lineY < clip.getBottom()) - { - if (i2.lineY + i2.lineHeight >= clip.getY() - && underlinedSection.intersects (Range (i2.indexInText, i2.indexInText + i2.atom->numChars))) - { - i2.drawUnderline (g, underlinedSection, findColour (textColourId)); - } - } - } - } -} - -void TextEditor::paint (Graphics& g) -{ - getLookAndFeel().fillTextEditorBackground (g, getWidth(), getHeight(), *this); -} - -void TextEditor::paintOverChildren (Graphics& g) -{ - if (textToShowWhenEmpty.isNotEmpty() - && (! hasKeyboardFocus (false)) - && getTotalNumChars() == 0) - { - g.setColour (colourForTextWhenEmpty); - g.setFont (getFont()); - - if (isMultiLine()) - g.drawText (textToShowWhenEmpty, getLocalBounds(), - Justification::centred, true); - else - g.drawText (textToShowWhenEmpty, - leftIndent, 0, viewport->getWidth() - leftIndent, getHeight(), - Justification::centredLeft, true); - } - - getLookAndFeel().drawTextEditorOutline (g, getWidth(), getHeight(), *this); -} - -//============================================================================== -void TextEditor::addPopupMenuItems (PopupMenu& m, const MouseEvent*) -{ - const bool writable = ! isReadOnly(); - - if (passwordCharacter == 0) - { - m.addItem (StandardApplicationCommandIDs::cut, TRANS("Cut"), writable); - m.addItem (StandardApplicationCommandIDs::copy, TRANS("Copy"), ! selection.isEmpty()); - } - - m.addItem (StandardApplicationCommandIDs::paste, TRANS("Paste"), writable); - m.addItem (StandardApplicationCommandIDs::del, TRANS("Delete"), writable); - m.addSeparator(); - m.addItem (StandardApplicationCommandIDs::selectAll, TRANS("Select All")); - m.addSeparator(); - - if (getUndoManager() != nullptr) - { - m.addItem (StandardApplicationCommandIDs::undo, TRANS("Undo"), undoManager.canUndo()); - m.addItem (StandardApplicationCommandIDs::redo, TRANS("Redo"), undoManager.canRedo()); - } -} - -void TextEditor::performPopupMenuAction (const int menuItemID) -{ - switch (menuItemID) - { - case StandardApplicationCommandIDs::cut: cutToClipboard(); break; - case StandardApplicationCommandIDs::copy: copyToClipboard(); break; - case StandardApplicationCommandIDs::paste: pasteFromClipboard(); break; - case StandardApplicationCommandIDs::del: cut(); break; - case StandardApplicationCommandIDs::selectAll: selectAll(); break; - case StandardApplicationCommandIDs::undo: undo(); break; - case StandardApplicationCommandIDs::redo: redo(); break; - default: break; - } -} - -static void textEditorMenuCallback (int menuResult, TextEditor* editor) -{ - if (editor != nullptr && menuResult != 0) - editor->performPopupMenuAction (menuResult); -} - -//============================================================================== -void TextEditor::mouseDown (const MouseEvent& e) -{ - beginDragAutoRepeat (100); - newTransaction(); - - if (wasFocused || ! selectAllTextWhenFocused) - { - if (! (popupMenuEnabled && e.mods.isPopupMenu())) - { - moveCaretTo (getTextIndexAt (e.x, e.y), - e.mods.isShiftDown()); - } - else - { - PopupMenu m; - m.setLookAndFeel (&getLookAndFeel()); - addPopupMenuItems (m, &e); - - m.showMenuAsync (PopupMenu::Options(), - ModalCallbackFunction::forComponent (textEditorMenuCallback, this)); - } - } -} - -void TextEditor::mouseDrag (const MouseEvent& e) -{ - if (wasFocused || ! selectAllTextWhenFocused) - if (! (popupMenuEnabled && e.mods.isPopupMenu())) - moveCaretTo (getTextIndexAt (e.x, e.y), true); -} - -void TextEditor::mouseUp (const MouseEvent& e) -{ - newTransaction(); - textHolder->restartTimer(); - - if (wasFocused || ! selectAllTextWhenFocused) - if (e.mouseWasClicked() && ! (popupMenuEnabled && e.mods.isPopupMenu())) - moveCaret (getTextIndexAt (e.x, e.y)); - - wasFocused = true; -} - -void TextEditor::mouseDoubleClick (const MouseEvent& e) -{ - int tokenEnd = getTextIndexAt (e.x, e.y); - int tokenStart = 0; - - if (e.getNumberOfClicks() > 3) - { - tokenEnd = getTotalNumChars(); - } - else - { - auto t = getText(); - auto totalLength = getTotalNumChars(); - - while (tokenEnd < totalLength) - { - // (note the slight bodge here - it's because iswalnum only checks for alphabetic chars in the current locale) - const juce_wchar c = t [tokenEnd]; - if (CharacterFunctions::isLetterOrDigit (c) || c > 128) - ++tokenEnd; - else - break; - } - - tokenStart = tokenEnd; - - while (tokenStart > 0) - { - // (note the slight bodge here - it's because iswalnum only checks for alphabetic chars in the current locale) - const juce_wchar c = t [tokenStart - 1]; - if (CharacterFunctions::isLetterOrDigit (c) || c > 128) - --tokenStart; - else - break; - } - - if (e.getNumberOfClicks() > 2) - { - while (tokenEnd < totalLength) - { - const juce_wchar c = t [tokenEnd]; - if (c != '\r' && c != '\n') - ++tokenEnd; - else - break; - } - - while (tokenStart > 0) - { - const juce_wchar c = t [tokenStart - 1]; - if (c != '\r' && c != '\n') - --tokenStart; - else - break; - } - } - } - - moveCaretTo (tokenEnd, false); - moveCaretTo (tokenStart, true); -} - -void TextEditor::mouseWheelMove (const MouseEvent& e, const MouseWheelDetails& wheel) -{ - if (! viewport->useMouseWheelMoveIfNeeded (e, wheel)) - Component::mouseWheelMove (e, wheel); -} - -//============================================================================== -bool TextEditor::moveCaretWithTransaction (const int newPos, const bool selecting) -{ - newTransaction(); - moveCaretTo (newPos, selecting); - return true; -} - -bool TextEditor::moveCaretLeft (bool moveInWholeWordSteps, bool selecting) -{ - int pos = getCaretPosition(); - - if (moveInWholeWordSteps) - pos = findWordBreakBefore (pos); - else - --pos; - - return moveCaretWithTransaction (pos, selecting); -} - -bool TextEditor::moveCaretRight (bool moveInWholeWordSteps, bool selecting) -{ - int pos = getCaretPosition(); - - if (moveInWholeWordSteps) - pos = findWordBreakAfter (pos); - else - ++pos; - - return moveCaretWithTransaction (pos, selecting); -} - -bool TextEditor::moveCaretUp (bool selecting) -{ - if (! isMultiLine()) - return moveCaretToStartOfLine (selecting); - - auto caretPos = getCaretRectangle().toFloat(); - return moveCaretWithTransaction (indexAtPosition (caretPos.getX(), caretPos.getY() - 1.0f), selecting); -} - -bool TextEditor::moveCaretDown (bool selecting) -{ - if (! isMultiLine()) - return moveCaretToEndOfLine (selecting); - - auto caretPos = getCaretRectangle().toFloat(); - return moveCaretWithTransaction (indexAtPosition (caretPos.getX(), caretPos.getBottom() + 1.0f), selecting); -} - -bool TextEditor::pageUp (bool selecting) -{ - if (! isMultiLine()) - return moveCaretToStartOfLine (selecting); - - auto caretPos = getCaretRectangle().toFloat(); - return moveCaretWithTransaction (indexAtPosition (caretPos.getX(), caretPos.getY() - viewport->getViewHeight()), selecting); -} - -bool TextEditor::pageDown (bool selecting) -{ - if (! isMultiLine()) - return moveCaretToEndOfLine (selecting); - - auto caretPos = getCaretRectangle().toFloat(); - return moveCaretWithTransaction (indexAtPosition (caretPos.getX(), caretPos.getBottom() + viewport->getViewHeight()), selecting); -} - -void TextEditor::scrollByLines (int deltaLines) -{ - if (auto* scrollbar = viewport->getVerticalScrollBar()) - scrollbar->moveScrollbarInSteps (deltaLines); -} - -bool TextEditor::scrollDown() -{ - scrollByLines (-1); - return true; -} - -bool TextEditor::scrollUp() -{ - scrollByLines (1); - return true; -} - -bool TextEditor::moveCaretToTop (bool selecting) -{ - return moveCaretWithTransaction (0, selecting); -} - -bool TextEditor::moveCaretToStartOfLine (bool selecting) -{ - auto caretPos = getCaretRectangle().toFloat(); - return moveCaretWithTransaction (indexAtPosition (0.0f, caretPos.getY()), selecting); -} - -bool TextEditor::moveCaretToEnd (bool selecting) -{ - return moveCaretWithTransaction (getTotalNumChars(), selecting); -} - -bool TextEditor::moveCaretToEndOfLine (bool selecting) -{ - auto caretPos = getCaretRectangle().toFloat(); - return moveCaretWithTransaction (indexAtPosition ((float) textHolder->getWidth(), caretPos.getY()), selecting); -} - -bool TextEditor::deleteBackwards (bool moveInWholeWordSteps) -{ - if (moveInWholeWordSteps) - moveCaretTo (findWordBreakBefore (getCaretPosition()), true); - else if (selection.isEmpty() && selection.getStart() > 0) - selection = Range (selection.getEnd() - 1, selection.getEnd()); - - cut(); - return true; -} - -bool TextEditor::deleteForwards (bool /*moveInWholeWordSteps*/) -{ - if (selection.isEmpty() && selection.getStart() < getTotalNumChars()) - selection = Range (selection.getStart(), selection.getStart() + 1); - - cut(); - return true; -} - -bool TextEditor::copyToClipboard() -{ - newTransaction(); - copy(); - return true; -} - -bool TextEditor::cutToClipboard() -{ - newTransaction(); - copy(); - cut(); - return true; -} - -bool TextEditor::pasteFromClipboard() -{ - newTransaction(); - paste(); - return true; -} - -bool TextEditor::selectAll() -{ - newTransaction(); - moveCaretTo (getTotalNumChars(), false); - moveCaretTo (0, true); - return true; -} - -//============================================================================== -void TextEditor::setEscapeAndReturnKeysConsumed (bool shouldBeConsumed) noexcept -{ - consumeEscAndReturnKeys = shouldBeConsumed; -} - -bool TextEditor::keyPressed (const KeyPress& key) -{ - if (isReadOnly() && key != KeyPress ('c', ModifierKeys::commandModifier, 0) - && key != KeyPress ('a', ModifierKeys::commandModifier, 0)) - return false; - - if (! TextEditorKeyMapper::invokeKeyFunction (*this, key)) - { - if (key == KeyPress::returnKey) - { - newTransaction(); - - if (returnKeyStartsNewLine) - insertTextAtCaret ("\n"); - else - { - returnPressed(); - return consumeEscAndReturnKeys; - } - } - else if (key.isKeyCode (KeyPress::escapeKey)) - { - newTransaction(); - moveCaretTo (getCaretPosition(), false); - escapePressed(); - return consumeEscAndReturnKeys; - } - else if (key.getTextCharacter() >= ' ' - || (tabKeyUsed && (key.getTextCharacter() == '\t'))) - { - insertTextAtCaret (String::charToString (key.getTextCharacter())); - - lastTransactionTime = Time::getApproximateMillisecondCounter(); - } - else - { - return false; - } - } - - return true; -} - -bool TextEditor::keyStateChanged (const bool isKeyDown) -{ - if (! isKeyDown) - return false; - - #if JUCE_WINDOWS - if (KeyPress (KeyPress::F4Key, ModifierKeys::altModifier, 0).isCurrentlyDown()) - return false; // We need to explicitly allow alt-F4 to pass through on Windows - #endif - - if ((! consumeEscAndReturnKeys) - && (KeyPress (KeyPress::escapeKey).isCurrentlyDown() - || KeyPress (KeyPress::returnKey).isCurrentlyDown())) - return false; - - // (overridden to avoid forwarding key events to the parent) - return ! ModifierKeys::getCurrentModifiers().isCommandDown(); -} - -//============================================================================== -void TextEditor::focusGained (FocusChangeType) -{ - newTransaction(); - - if (selectAllTextWhenFocused) - { - moveCaretTo (0, false); - moveCaretTo (getTotalNumChars(), true); - } - - repaint(); - updateCaretPosition(); - - if (auto* peer = getPeer()) - if (! isReadOnly()) - peer->textInputRequired (peer->globalToLocal (getScreenPosition()), *this); -} - -void TextEditor::focusLost (FocusChangeType) -{ - newTransaction(); - - wasFocused = false; - textHolder->stopTimer(); - - underlinedSections.clear(); - - if (auto* peer = getPeer()) - peer->dismissPendingTextInput(); - - updateCaretPosition(); - - postCommandMessage (TextEditorDefs::focusLossMessageId); - repaint(); -} - -//============================================================================== -void TextEditor::resized() -{ - viewport->setBoundsInset (borderSize); - viewport->setSingleStepSizes (16, roundToInt (currentFont.getHeight())); - - updateTextHolderSize(); - - if (isMultiLine()) - updateCaretPosition(); - else - scrollToMakeSureCursorIsVisible(); -} - -void TextEditor::handleCommandMessage (const int commandId) -{ - Component::BailOutChecker checker (this); - - switch (commandId) - { - case TextEditorDefs::textChangeMessageId: - listeners.callChecked (checker, &Listener::textEditorTextChanged, (TextEditor&) *this); - break; - - case TextEditorDefs::returnKeyMessageId: - listeners.callChecked (checker, &Listener::textEditorReturnKeyPressed, (TextEditor&) *this); - break; - - case TextEditorDefs::escapeKeyMessageId: - listeners.callChecked (checker, &Listener::textEditorEscapeKeyPressed, (TextEditor&) *this); - break; - - case TextEditorDefs::focusLossMessageId: - updateValueFromText(); - listeners.callChecked (checker, &Listener::textEditorFocusLost, (TextEditor&) *this); - break; - - default: - jassertfalse; - break; - } -} - -void TextEditor::setTemporaryUnderlining (const Array >& newUnderlinedSections) -{ - underlinedSections = newUnderlinedSections; - repaint(); -} - -//============================================================================== -UndoManager* TextEditor::getUndoManager() noexcept -{ - return readOnly ? nullptr : &undoManager; -} - -void TextEditor::clearInternal (UndoManager* const um) -{ - remove (Range (0, getTotalNumChars()), um, caretPosition); -} - -void TextEditor::insert (const String& text, - const int insertIndex, - const Font& font, - const Colour colour, - UndoManager* const um, - const int caretPositionToMoveTo) -{ - if (text.isNotEmpty()) - { - if (um != nullptr) - { - if (um->getNumActionsInCurrentTransaction() > TextEditorDefs::maxActionsPerTransaction) - newTransaction(); - - um->perform (new InsertAction (*this, text, insertIndex, font, colour, - caretPosition, caretPositionToMoveTo)); - } - else - { - repaintText (Range (insertIndex, getTotalNumChars())); // must do this before and after changing the data, in case - // a line gets moved due to word wrap - - int index = 0; - int nextIndex = 0; - - for (int i = 0; i < sections.size(); ++i) - { - nextIndex = index + sections.getUnchecked (i)->getTotalLength(); - - if (insertIndex == index) - { - sections.insert (i, new UniformTextSection (text, font, colour, passwordCharacter)); - break; - } - else if (insertIndex > index && insertIndex < nextIndex) - { - splitSection (i, insertIndex - index); - sections.insert (i + 1, new UniformTextSection (text, font, colour, passwordCharacter)); - break; - } - - index = nextIndex; - } - - if (nextIndex == insertIndex) - sections.add (new UniformTextSection (text, font, colour, passwordCharacter)); - - coalesceSimilarSections(); - totalNumChars = -1; - valueTextNeedsUpdating = true; - - updateTextHolderSize(); - moveCaretTo (caretPositionToMoveTo, false); - - repaintText (Range (insertIndex, getTotalNumChars())); - } - } -} - -void TextEditor::reinsert (const int insertIndex, const OwnedArray& sectionsToInsert) -{ - int index = 0; - int nextIndex = 0; - - for (int i = 0; i < sections.size(); ++i) - { - nextIndex = index + sections.getUnchecked (i)->getTotalLength(); - - if (insertIndex == index) - { - for (int j = sectionsToInsert.size(); --j >= 0;) - sections.insert (i, new UniformTextSection (*sectionsToInsert.getUnchecked(j))); - - break; - } - else if (insertIndex > index && insertIndex < nextIndex) - { - splitSection (i, insertIndex - index); - - for (int j = sectionsToInsert.size(); --j >= 0;) - sections.insert (i + 1, new UniformTextSection (*sectionsToInsert.getUnchecked(j))); - - break; - } - - index = nextIndex; - } - - if (nextIndex == insertIndex) - { - for (int j = 0; j < sectionsToInsert.size(); ++j) - sections.add (new UniformTextSection (*sectionsToInsert.getUnchecked(j))); - } - - coalesceSimilarSections(); - totalNumChars = -1; - valueTextNeedsUpdating = true; -} - -void TextEditor::remove (Range range, UndoManager* const um, const int caretPositionToMoveTo) -{ - if (! range.isEmpty()) - { - int index = 0; - - for (int i = 0; i < sections.size(); ++i) - { - const int nextIndex = index + sections.getUnchecked(i)->getTotalLength(); - - if (range.getStart() > index && range.getStart() < nextIndex) - { - splitSection (i, range.getStart() - index); - --i; - } - else if (range.getEnd() > index && range.getEnd() < nextIndex) - { - splitSection (i, range.getEnd() - index); - --i; - } - else - { - index = nextIndex; - - if (index > range.getEnd()) - break; - } - } - - index = 0; - - if (um != nullptr) - { - Array removedSections; - - for (int i = 0; i < sections.size(); ++i) - { - if (range.getEnd() <= range.getStart()) - break; - - auto* section = sections.getUnchecked (i); - auto nextIndex = index + section->getTotalLength(); - - if (range.getStart() <= index && range.getEnd() >= nextIndex) - removedSections.add (new UniformTextSection (*section)); - - index = nextIndex; - } - - if (um->getNumActionsInCurrentTransaction() > TextEditorDefs::maxActionsPerTransaction) - newTransaction(); - - um->perform (new RemoveAction (*this, range, caretPosition, - caretPositionToMoveTo, removedSections)); - } - else - { - auto remainingRange = range; - - for (int i = 0; i < sections.size(); ++i) - { - auto* section = sections.getUnchecked (i); - - const int nextIndex = index + section->getTotalLength(); - - if (remainingRange.getStart() <= index && remainingRange.getEnd() >= nextIndex) - { - sections.remove (i); - remainingRange.setEnd (remainingRange.getEnd() - (nextIndex - index)); - - if (remainingRange.isEmpty()) - break; - - --i; - } - else - { - index = nextIndex; - } - } - - coalesceSimilarSections(); - totalNumChars = -1; - valueTextNeedsUpdating = true; - - moveCaretTo (caretPositionToMoveTo, false); - - repaintText (Range (range.getStart(), getTotalNumChars())); - } - } -} - -//============================================================================== -String TextEditor::getText() const -{ - MemoryOutputStream mo; - mo.preallocate ((size_t) getTotalNumChars()); - - for (int i = 0; i < sections.size(); ++i) - sections.getUnchecked (i)->appendAllText (mo); - - return mo.toUTF8(); -} - -String TextEditor::getTextInRange (const Range& range) const -{ - if (range.isEmpty()) - return {}; - - MemoryOutputStream mo; - mo.preallocate ((size_t) jmin (getTotalNumChars(), range.getLength())); - - int index = 0; - - for (int i = 0; i < sections.size(); ++i) - { - auto* s = sections.getUnchecked (i); - auto nextIndex = index + s->getTotalLength(); - - if (range.getStart() < nextIndex) - { - if (range.getEnd() <= index) - break; - - s->appendSubstring (mo, range - index); - } - - index = nextIndex; - } - - return mo.toUTF8(); -} - -String TextEditor::getHighlightedText() const -{ - return getTextInRange (selection); -} - -int TextEditor::getTotalNumChars() const -{ - if (totalNumChars < 0) - { - totalNumChars = 0; - - for (int i = sections.size(); --i >= 0;) - totalNumChars += sections.getUnchecked (i)->getTotalLength(); - } - - return totalNumChars; -} - -bool TextEditor::isEmpty() const -{ - return getTotalNumChars() == 0; -} - -void TextEditor::getCharPosition (const int index, float& cx, float& cy, float& lineHeight) const -{ - const float wordWrapWidth = getWordWrapWidth(); - - if (wordWrapWidth > 0 && sections.size() > 0) - { - Iterator i (sections, wordWrapWidth, passwordCharacter, lineSpacing); - - i.getCharPosition (index, cx, cy, lineHeight); - } - else - { - cx = cy = 0; - lineHeight = currentFont.getHeight(); - } -} - -int TextEditor::indexAtPosition (const float x, const float y) -{ - const float wordWrapWidth = getWordWrapWidth(); - - if (wordWrapWidth > 0) - { - Iterator i (sections, wordWrapWidth, passwordCharacter, lineSpacing); - - while (i.next()) - { - if (i.lineY + i.lineHeight > y) - { - if (i.lineY > y) - return jmax (0, i.indexInText - 1); - - if (i.atomX >= x) - return i.indexInText; - - if (x < i.atomRight) - return i.xToIndex (x); - } - } - } - - return getTotalNumChars(); -} - -//============================================================================== -int TextEditor::findWordBreakAfter (const int position) const -{ - auto t = getTextInRange (Range (position, position + 512)); - auto totalLength = t.length(); - int i = 0; - - while (i < totalLength && CharacterFunctions::isWhitespace (t[i])) - ++i; - - const int type = TextEditorDefs::getCharacterCategory (t[i]); - - while (i < totalLength && type == TextEditorDefs::getCharacterCategory (t[i])) - ++i; - - while (i < totalLength && CharacterFunctions::isWhitespace (t[i])) - ++i; - - return position + i; -} - -int TextEditor::findWordBreakBefore (const int position) const -{ - if (position <= 0) - return 0; - - auto startOfBuffer = jmax (0, position - 512); - auto t = getTextInRange (Range (startOfBuffer, position)); - - int i = position - startOfBuffer; - - while (i > 0 && CharacterFunctions::isWhitespace (t [i - 1])) - --i; - - if (i > 0) - { - auto type = TextEditorDefs::getCharacterCategory (t [i - 1]); - - while (i > 0 && type == TextEditorDefs::getCharacterCategory (t [i - 1])) - --i; - } - - jassert (startOfBuffer + i >= 0); - return startOfBuffer + i; -} - - -//============================================================================== -void TextEditor::splitSection (const int sectionIndex, const int charToSplitAt) -{ - jassert (sections[sectionIndex] != nullptr); - - sections.insert (sectionIndex + 1, - sections.getUnchecked (sectionIndex)->split (charToSplitAt, passwordCharacter)); -} - -void TextEditor::coalesceSimilarSections() -{ - for (int i = 0; i < sections.size() - 1; ++i) - { - auto* s1 = sections.getUnchecked (i); - auto* s2 = sections.getUnchecked (i + 1); - - if (s1->font == s2->font - && s1->colour == s2->colour) - { - s1->append (*s2, passwordCharacter); - sections.remove (i + 1); - --i; - } - } -} - -} // namespace juce +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2017 - ROLI Ltd. + + JUCE is an open source library subject to commercial or open-source + licensing. + + By using JUCE, you agree to the terms of both the JUCE 5 End-User License + Agreement and JUCE 5 Privacy Policy (both updated and effective as of the + 27th April 2017). + + End User License Agreement: www.juce.com/juce-5-licence + Privacy Policy: www.juce.com/juce-5-privacy-policy + + Or: You may also use this code under the terms of the GPL v3 (see + www.gnu.org/licenses). + + JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER + EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE + DISCLAIMED. + + ============================================================================== +*/ + +namespace juce +{ + +// a word or space that can't be broken down any further +struct TextAtom +{ + //============================================================================== + String atomText; + float width; + int numChars; + + //============================================================================== + bool isWhitespace() const noexcept { return CharacterFunctions::isWhitespace (atomText[0]); } + bool isNewLine() const noexcept { return atomText[0] == '\r' || atomText[0] == '\n'; } + + String getText (const juce_wchar passwordCharacter) const + { + if (passwordCharacter == 0) + return atomText; + + return String::repeatedString (String::charToString (passwordCharacter), + atomText.length()); + } + + String getTrimmedText (const juce_wchar passwordCharacter) const + { + if (passwordCharacter == 0) + return atomText.substring (0, numChars); + + if (isNewLine()) + return {}; + + return String::repeatedString (String::charToString (passwordCharacter), numChars); + } + + JUCE_LEAK_DETECTOR (TextAtom) +}; + +//============================================================================== +// a run of text with a single font and colour +class TextEditor::UniformTextSection +{ +public: + UniformTextSection (const String& text, const Font& f, Colour col, juce_wchar passwordChar) + : font (f), colour (col) + { + initialiseAtoms (text, passwordChar); + } + + UniformTextSection (const UniformTextSection& other) + : font (other.font), colour (other.colour) + { + atoms.addCopiesOf (other.atoms); + } + + void append (UniformTextSection& other, const juce_wchar passwordChar) + { + if (other.atoms.size() > 0) + { + int i = 0; + + if (auto* lastAtom = atoms.getLast()) + { + if (! CharacterFunctions::isWhitespace (lastAtom->atomText.getLastCharacter())) + { + auto* first = other.atoms.getUnchecked(0); + + if (! CharacterFunctions::isWhitespace (first->atomText[0])) + { + lastAtom->atomText += first->atomText; + lastAtom->numChars = (uint16) (lastAtom->numChars + first->numChars); + lastAtom->width = font.getStringWidthFloat (lastAtom->getText (passwordChar)); + delete first; + ++i; + } + } + } + + atoms.ensureStorageAllocated (atoms.size() + other.atoms.size() - i); + + while (i < other.atoms.size()) + { + atoms.add (other.atoms.getUnchecked(i)); + ++i; + } + + other.atoms.clear (false); + } + } + + UniformTextSection* split (const int indexToBreakAt, const juce_wchar passwordChar) + { + UniformTextSection* const section2 = new UniformTextSection (String(), font, colour, passwordChar); + int index = 0; + + for (int i = 0; i < atoms.size(); ++i) + { + auto* atom = atoms.getUnchecked(i); + auto nextIndex = index + atom->numChars; + + if (index == indexToBreakAt) + { + for (int j = i; j < atoms.size(); ++j) + section2->atoms.add (atoms.getUnchecked (j)); + + atoms.removeRange (i, atoms.size(), false); + break; + } + else if (indexToBreakAt >= index && indexToBreakAt < nextIndex) + { + auto* secondAtom = new TextAtom(); + + secondAtom->atomText = atom->atomText.substring (indexToBreakAt - index); + secondAtom->width = font.getStringWidthFloat (secondAtom->getText (passwordChar)); + secondAtom->numChars = (uint16) secondAtom->atomText.length(); + + section2->atoms.add (secondAtom); + + atom->atomText = atom->atomText.substring (0, indexToBreakAt - index); + atom->width = font.getStringWidthFloat (atom->getText (passwordChar)); + atom->numChars = (uint16) (indexToBreakAt - index); + + for (int j = i + 1; j < atoms.size(); ++j) + section2->atoms.add (atoms.getUnchecked (j)); + + atoms.removeRange (i + 1, atoms.size(), false); + break; + } + + index = nextIndex; + } + + return section2; + } + + void appendAllText (MemoryOutputStream& mo) const + { + for (int i = 0; i < atoms.size(); ++i) + mo << atoms.getUnchecked(i)->atomText; + } + + void appendSubstring (MemoryOutputStream& mo, const Range range) const + { + int index = 0; + + for (auto* atom : atoms) + { + auto nextIndex = index + atom->numChars; + + if (range.getStart() < nextIndex) + { + if (range.getEnd() <= index) + break; + + auto r = (range - index).getIntersectionWith (Range (0, (int) atom->numChars)); + + if (! r.isEmpty()) + mo << atom->atomText.substring (r.getStart(), r.getEnd()); + } + + index = nextIndex; + } + } + + int getTotalLength() const noexcept + { + int total = 0; + + for (auto* atom : atoms) + total += atom->numChars; + + return total; + } + + void setFont (const Font& newFont, const juce_wchar passwordChar) + { + if (font != newFont) + { + font = newFont; + + for (auto* atom : atoms) + atom->width = newFont.getStringWidthFloat (atom->getText (passwordChar)); + } + } + + //============================================================================== + Font font; + Colour colour; + OwnedArray atoms; + +private: + void initialiseAtoms (const String& textToParse, const juce_wchar passwordChar) + { + auto text = textToParse.getCharPointer(); + + while (! text.isEmpty()) + { + size_t numChars = 0; + auto start = text; + + // create a whitespace atom unless it starts with non-ws + if (text.isWhitespace() && *text != '\r' && *text != '\n') + { + do + { + ++text; + ++numChars; + } + while (text.isWhitespace() && *text != '\r' && *text != '\n'); + } + else + { + if (*text == '\r') + { + ++text; + ++numChars; + + if (*text == '\n') + { + ++start; + ++text; + } + } + else if (*text == '\n') + { + ++text; + ++numChars; + } + else + { + while (! (text.isEmpty() || text.isWhitespace())) + { + ++text; + ++numChars; + } + } + } + + auto* atom = atoms.add (new TextAtom()); + + atom->atomText = String (start, numChars); + atom->width = font.getStringWidthFloat (atom->getText (passwordChar)); + atom->numChars = (uint16) numChars; + } + } + + UniformTextSection& operator= (const UniformTextSection&); + JUCE_LEAK_DETECTOR (UniformTextSection) +}; + +//============================================================================== +class TextEditor::Iterator +{ +public: + Iterator (const OwnedArray& sectionList, + float wrapWidth, juce_wchar passwordChar, float spacing) + : sections (sectionList), + wordWrapWidth (wrapWidth), + passwordCharacter (passwordChar), + lineSpacing (spacing) + { + jassert (wordWrapWidth > 0); + + if (sections.size() > 0) + { + currentSection = sections.getUnchecked (sectionIndex); + + if (currentSection != nullptr) + beginNewLine(); + } + } + + Iterator (const Iterator& other) + : indexInText (other.indexInText), + lineY (other.lineY), + lineHeight (other.lineHeight), + maxDescent (other.maxDescent), + atomX (other.atomX), + atomRight (other.atomRight), + atom (other.atom), + currentSection (other.currentSection), + sections (other.sections), + sectionIndex (other.sectionIndex), + atomIndex (other.atomIndex), + wordWrapWidth (other.wordWrapWidth), + passwordCharacter (other.passwordCharacter), + lineSpacing (other.lineSpacing), + tempAtom (other.tempAtom) + { + } + + //============================================================================== + bool next() + { + if (atom == &tempAtom) + { + const int numRemaining = tempAtom.atomText.length() - tempAtom.numChars; + + if (numRemaining > 0) + { + tempAtom.atomText = tempAtom.atomText.substring (tempAtom.numChars); + + atomX = 0; + + if (tempAtom.numChars > 0) + lineY += lineHeight * lineSpacing; + + indexInText += tempAtom.numChars; + + GlyphArrangement g; + g.addLineOfText (currentSection->font, atom->getText (passwordCharacter), 0.0f, 0.0f); + + int split; + for (split = 0; split < g.getNumGlyphs(); ++split) + if (shouldWrap (g.getGlyph (split).getRight())) + break; + + if (split > 0 && split <= numRemaining) + { + tempAtom.numChars = (uint16) split; + tempAtom.width = g.getGlyph (split - 1).getRight(); + atomRight = atomX + tempAtom.width; + return true; + } + } + } + + if (sectionIndex >= sections.size()) + { + moveToEndOfLastAtom(); + return false; + } + + bool forceNewLine = false; + + if (atomIndex >= currentSection->atoms.size() - 1) + { + if (atomIndex >= currentSection->atoms.size()) + { + if (++sectionIndex >= sections.size()) + { + moveToEndOfLastAtom(); + return false; + } + + atomIndex = 0; + currentSection = sections.getUnchecked (sectionIndex); + } + else + { + auto* lastAtom = currentSection->atoms.getUnchecked (atomIndex); + + if (! lastAtom->isWhitespace()) + { + // handle the case where the last atom in a section is actually part of the same + // word as the first atom of the next section... + float right = atomRight + lastAtom->width; + float lineHeight2 = lineHeight; + float maxDescent2 = maxDescent; + + for (int section = sectionIndex + 1; section < sections.size(); ++section) + { + auto* s = sections.getUnchecked (section); + + if (s->atoms.size() == 0) + break; + + auto* nextAtom = s->atoms.getUnchecked (0); + + if (nextAtom->isWhitespace()) + break; + + right += nextAtom->width; + + lineHeight2 = jmax (lineHeight2, s->font.getHeight()); + maxDescent2 = jmax (maxDescent2, s->font.getDescent()); + + if (shouldWrap (right)) + { + lineHeight = lineHeight2; + maxDescent = maxDescent2; + + forceNewLine = true; + break; + } + + if (s->atoms.size() > 1) + break; + } + } + } + } + + if (atom != nullptr) + { + atomX = atomRight; + indexInText += atom->numChars; + + if (atom->isNewLine()) + beginNewLine(); + } + + atom = currentSection->atoms.getUnchecked (atomIndex); + atomRight = atomX + atom->width; + ++atomIndex; + + if (shouldWrap (atomRight) || forceNewLine) + { + if (atom->isWhitespace()) + { + // leave whitespace at the end of a line, but truncate it to avoid scrolling + atomRight = jmin (atomRight, wordWrapWidth); + } + else + { + atomRight = atom->width; + + if (shouldWrap (atomRight)) // atom too big to fit on a line, so break it up.. + { + tempAtom = *atom; + tempAtom.width = 0; + tempAtom.numChars = 0; + atom = &tempAtom; + + if (atomX > 0) + beginNewLine(); + + return next(); + } + + beginNewLine(); + return true; + } + } + + return true; + } + + void beginNewLine() + { + atomX = 0; + lineY += lineHeight * lineSpacing; + + int tempSectionIndex = sectionIndex; + int tempAtomIndex = atomIndex; + auto* section = sections.getUnchecked (tempSectionIndex); + + lineHeight = section->font.getHeight(); + maxDescent = section->font.getDescent(); + + float x = (atom != nullptr) ? atom->width : 0; + + while (! shouldWrap (x)) + { + if (tempSectionIndex >= sections.size()) + break; + + bool checkSize = false; + + if (tempAtomIndex >= section->atoms.size()) + { + if (++tempSectionIndex >= sections.size()) + break; + + tempAtomIndex = 0; + section = sections.getUnchecked (tempSectionIndex); + checkSize = true; + } + + auto* nextAtom = section->atoms.getUnchecked (tempAtomIndex); + + if (nextAtom == nullptr) + break; + + x += nextAtom->width; + + if (shouldWrap (x) || nextAtom->isNewLine()) + break; + + if (checkSize) + { + lineHeight = jmax (lineHeight, section->font.getHeight()); + maxDescent = jmax (maxDescent, section->font.getDescent()); + } + + ++tempAtomIndex; + } + } + + //============================================================================== + void draw (Graphics& g, const UniformTextSection*& lastSection) const + { + if (passwordCharacter != 0 || ! atom->isWhitespace()) + { + if (lastSection != currentSection) + { + lastSection = currentSection; + g.setColour (currentSection->colour); + g.setFont (currentSection->font); + } + + jassert (atom->getTrimmedText (passwordCharacter).isNotEmpty()); + + GlyphArrangement ga; + ga.addLineOfText (currentSection->font, + atom->getTrimmedText (passwordCharacter), + atomX, (float) roundToInt (lineY + lineHeight - maxDescent)); + ga.draw (g); + } + } + + void addSelection (RectangleList& area, const Range selected) const + { + const float startX = indexToX (selected.getStart()); + const float endX = indexToX (selected.getEnd()); + + area.add (startX, lineY, endX - startX, lineHeight * lineSpacing); + } + + void drawUnderline (Graphics& g, const Range underline, const Colour colour) const + { + const int startX = roundToInt (indexToX (underline.getStart())); + const int endX = roundToInt (indexToX (underline.getEnd())); + const int baselineY = roundToInt (lineY + currentSection->font.getAscent() + 0.5f); + + Graphics::ScopedSaveState state (g); + g.reduceClipRegion (Rectangle (startX, baselineY, endX - startX, 1)); + g.fillCheckerBoard (Rectangle (endX, baselineY + 1), 3, 1, colour, Colours::transparentBlack); + } + + void drawSelectedText (Graphics& g, + const Range selected, + const Colour selectedTextColour) const + { + if (passwordCharacter != 0 || ! atom->isWhitespace()) + { + GlyphArrangement ga; + ga.addLineOfText (currentSection->font, + atom->getTrimmedText (passwordCharacter), + atomX, (float) roundToInt (lineY + lineHeight - maxDescent)); + + if (selected.getEnd() < indexInText + atom->numChars) + { + GlyphArrangement ga2 (ga); + ga2.removeRangeOfGlyphs (0, selected.getEnd() - indexInText); + ga.removeRangeOfGlyphs (selected.getEnd() - indexInText, -1); + + g.setColour (currentSection->colour); + ga2.draw (g); + } + + if (selected.getStart() > indexInText) + { + GlyphArrangement ga2 (ga); + ga2.removeRangeOfGlyphs (selected.getStart() - indexInText, -1); + ga.removeRangeOfGlyphs (0, selected.getStart() - indexInText); + + g.setColour (currentSection->colour); + ga2.draw (g); + } + + g.setColour (selectedTextColour); + ga.draw (g); + } + } + + //============================================================================== + float indexToX (const int indexToFind) const + { + if (indexToFind <= indexInText) + return atomX; + + if (indexToFind >= indexInText + atom->numChars) + return atomRight; + + GlyphArrangement g; + g.addLineOfText (currentSection->font, + atom->getText (passwordCharacter), + atomX, 0.0f); + + if (indexToFind - indexInText >= g.getNumGlyphs()) + return atomRight; + + return jmin (atomRight, g.getGlyph (indexToFind - indexInText).getLeft()); + } + + int xToIndex (const float xToFind) const + { + if (xToFind <= atomX || atom->isNewLine()) + return indexInText; + + if (xToFind >= atomRight) + return indexInText + atom->numChars; + + GlyphArrangement g; + g.addLineOfText (currentSection->font, + atom->getText (passwordCharacter), + atomX, 0.0f); + + const int numGlyphs = g.getNumGlyphs(); + + int j; + for (j = 0; j < numGlyphs; ++j) + { + auto& pg = g.getGlyph(j); + + if ((pg.getLeft() + pg.getRight()) / 2 > xToFind) + break; + } + + return indexInText + j; + } + + //============================================================================== + bool getCharPosition (const int index, float& cx, float& cy, float& lineHeightFound) + { + while (next()) + { + if (indexInText + atom->numChars > index) + { + cx = indexToX (index); + cy = lineY; + lineHeightFound = lineHeight; + return true; + } + } + + cx = atomX; + cy = lineY; + lineHeightFound = lineHeight; + return false; + } + + //============================================================================== + int indexInText = 0; + float lineY = 0, lineHeight = 0, maxDescent = 0; + float atomX = 0, atomRight = 0; + const TextAtom* atom = nullptr; + const UniformTextSection* currentSection = nullptr; + +private: + const OwnedArray& sections; + int sectionIndex = 0, atomIndex = 0; + const float wordWrapWidth; + const juce_wchar passwordCharacter; + const float lineSpacing; + TextAtom tempAtom; + + Iterator& operator= (const Iterator&) = delete; + + void moveToEndOfLastAtom() + { + if (atom != nullptr) + { + atomX = atomRight; + + if (atom->isNewLine()) + { + atomX = 0.0f; + lineY += lineHeight * lineSpacing; + } + } + } + + bool shouldWrap (const float x) const noexcept + { + return (x - 0.0001f) >= wordWrapWidth; + } + + JUCE_LEAK_DETECTOR (Iterator) +}; + + +//============================================================================== +class TextEditor::InsertAction : public UndoableAction +{ +public: + InsertAction (TextEditor& ed, + const String& newText, + const int insertPos, + const Font& newFont, + const Colour newColour, + const int oldCaret, + const int newCaret) + : owner (ed), + text (newText), + insertIndex (insertPos), + oldCaretPos (oldCaret), + newCaretPos (newCaret), + font (newFont), + colour (newColour) + { + } + + bool perform() override + { + owner.insert (text, insertIndex, font, colour, 0, newCaretPos); + return true; + } + + bool undo() override + { + owner.remove (Range (insertIndex, insertIndex + text.length()), 0, oldCaretPos); + return true; + } + + int getSizeInUnits() override + { + return text.length() + 16; + } + +private: + TextEditor& owner; + const String text; + const int insertIndex, oldCaretPos, newCaretPos; + const Font font; + const Colour colour; + + JUCE_DECLARE_NON_COPYABLE (InsertAction) +}; + +//============================================================================== +class TextEditor::RemoveAction : public UndoableAction +{ +public: + RemoveAction (TextEditor& ed, + const Range rangeToRemove, + const int oldCaret, + const int newCaret, + const Array& oldSections) + : owner (ed), + range (rangeToRemove), + oldCaretPos (oldCaret), + newCaretPos (newCaret) + { + removedSections.addArray (oldSections); + } + + bool perform() override + { + owner.remove (range, 0, newCaretPos); + return true; + } + + bool undo() override + { + owner.reinsert (range.getStart(), removedSections); + owner.moveCaretTo (oldCaretPos, false); + return true; + } + + int getSizeInUnits() override + { + int n = 16; + + for (auto* s : removedSections) + n += s->getTotalLength(); + + return n; + } + +private: + TextEditor& owner; + const Range range; + const int oldCaretPos, newCaretPos; + OwnedArray removedSections; + + JUCE_DECLARE_NON_COPYABLE (RemoveAction) +}; + +//============================================================================== +class TextEditor::TextHolderComponent : public Component, + public Timer, + public Value::Listener +{ +public: + TextHolderComponent (TextEditor& ed) : owner (ed) + { + setWantsKeyboardFocus (false); + setInterceptsMouseClicks (false, true); + setMouseCursor (MouseCursor::ParentCursor); + + owner.getTextValue().addListener (this); + } + + ~TextHolderComponent() + { + owner.getTextValue().removeListener (this); + } + + void paint (Graphics& g) override + { + owner.drawContent (g); + } + + void restartTimer() + { + startTimer (350); + } + + void timerCallback() override + { + owner.timerCallbackInt(); + } + + void valueChanged (Value&) override + { + owner.textWasChangedByValue(); + } + +private: + TextEditor& owner; + + JUCE_DECLARE_NON_COPYABLE (TextHolderComponent) +}; + +//============================================================================== +class TextEditorViewport : public Viewport +{ +public: + TextEditorViewport (TextEditor& ed) : owner (ed) {} + + void visibleAreaChanged (const Rectangle&) override + { + if (! rentrant) // it's rare, but possible to get into a feedback loop as the viewport's scrollbars + // appear and disappear, causing the wrap width to change. + { + const float wordWrapWidth = owner.getWordWrapWidth(); + + if (wordWrapWidth != lastWordWrapWidth) + { + lastWordWrapWidth = wordWrapWidth; + + rentrant = true; + owner.updateTextHolderSize(); + rentrant = false; + } + } + } + +private: + TextEditor& owner; + float lastWordWrapWidth = 0; + bool rentrant = false; + + JUCE_DECLARE_NON_COPYABLE (TextEditorViewport) +}; + +//============================================================================== +namespace TextEditorDefs +{ + const int textChangeMessageId = 0x10003001; + const int returnKeyMessageId = 0x10003002; + const int escapeKeyMessageId = 0x10003003; + const int focusLossMessageId = 0x10003004; + + const int maxActionsPerTransaction = 100; + + static int getCharacterCategory (const juce_wchar character) + { + return CharacterFunctions::isLetterOrDigit (character) + ? 2 : (CharacterFunctions::isWhitespace (character) ? 0 : 1); + } +} + +//============================================================================== +TextEditor::TextEditor (const String& name, juce_wchar passwordChar) + : Component (name), + passwordCharacter (passwordChar) +{ + setMouseCursor (MouseCursor::IBeamCursor); + + addAndMakeVisible (viewport = new TextEditorViewport (*this)); + viewport->setViewedComponent (textHolder = new TextHolderComponent (*this)); + viewport->setWantsKeyboardFocus (false); + viewport->setScrollBarsShown (false, false); + + setWantsKeyboardFocus (true); + recreateCaret(); +} + +TextEditor::~TextEditor() +{ + if (wasFocused) + if (auto* peer = getPeer()) + peer->dismissPendingTextInput(); + + textValue.removeListener (textHolder); + textValue.referTo (Value()); + + viewport = nullptr; + textHolder = nullptr; +} + +//============================================================================== +void TextEditor::newTransaction() +{ + lastTransactionTime = Time::getApproximateMillisecondCounter(); + undoManager.beginNewTransaction(); +} + +bool TextEditor::undoOrRedo (const bool shouldUndo) +{ + if (! isReadOnly()) + { + newTransaction(); + + if (shouldUndo ? undoManager.undo() + : undoManager.redo()) + { + scrollToMakeSureCursorIsVisible(); + repaint(); + textChanged(); + return true; + } + } + + return false; +} + +bool TextEditor::undo() { return undoOrRedo (true); } +bool TextEditor::redo() { return undoOrRedo (false); } + +//============================================================================== +void TextEditor::setMultiLine (const bool shouldBeMultiLine, + const bool shouldWordWrap) +{ + if (multiline != shouldBeMultiLine + || wordWrap != (shouldWordWrap && shouldBeMultiLine)) + { + multiline = shouldBeMultiLine; + wordWrap = shouldWordWrap && shouldBeMultiLine; + + viewport->setScrollBarsShown (scrollbarVisible && multiline, + scrollbarVisible && multiline); + viewport->setViewPosition (0, 0); + resized(); + scrollToMakeSureCursorIsVisible(); + } +} + +bool TextEditor::isMultiLine() const +{ + return multiline; +} + +void TextEditor::setScrollbarsShown (bool shown) +{ + if (scrollbarVisible != shown) + { + scrollbarVisible = shown; + shown = shown && isMultiLine(); + viewport->setScrollBarsShown (shown, shown); + } +} + +void TextEditor::setReadOnly (const bool shouldBeReadOnly) +{ + if (readOnly != shouldBeReadOnly) + { + readOnly = shouldBeReadOnly; + enablementChanged(); + } +} + +bool TextEditor::isReadOnly() const noexcept +{ + return readOnly || ! isEnabled(); +} + +bool TextEditor::isTextInputActive() const +{ + return ! isReadOnly(); +} + +void TextEditor::setReturnKeyStartsNewLine (const bool shouldStartNewLine) +{ + returnKeyStartsNewLine = shouldStartNewLine; +} + +void TextEditor::setTabKeyUsedAsCharacter (const bool shouldTabKeyBeUsed) +{ + tabKeyUsed = shouldTabKeyBeUsed; +} + +void TextEditor::setPopupMenuEnabled (const bool b) +{ + popupMenuEnabled = b; +} + +void TextEditor::setSelectAllWhenFocused (const bool b) +{ + selectAllTextWhenFocused = b; +} + +//============================================================================== +void TextEditor::setFont (const Font& newFont) +{ + currentFont = newFont; + scrollToMakeSureCursorIsVisible(); +} + +void TextEditor::applyFontToAllText (const Font& newFont, bool changeCurrentFont) +{ + if (changeCurrentFont) + currentFont = newFont; + + auto overallColour = findColour (textColourId); + + for (auto* uts : sections) + { + uts->setFont (newFont, passwordCharacter); + uts->colour = overallColour; + } + + coalesceSimilarSections(); + updateTextHolderSize(); + scrollToMakeSureCursorIsVisible(); + repaint(); +} + +void TextEditor::applyColourToAllText (const Colour& newColour, bool changeCurrentTextColour) +{ + for (auto* uts : sections) + uts->colour = newColour; + + if (changeCurrentTextColour) + setColour (TextEditor::textColourId, newColour); + else + repaint(); +} + +void TextEditor::lookAndFeelChanged() +{ + caret = nullptr; + recreateCaret(); + repaint(); +} + +void TextEditor::parentHierarchyChanged() +{ + lookAndFeelChanged(); +} + +void TextEditor::enablementChanged() +{ + recreateCaret(); + repaint(); +} + +void TextEditor::setCaretVisible (const bool shouldCaretBeVisible) +{ + if (caretVisible != shouldCaretBeVisible) + { + caretVisible = shouldCaretBeVisible; + recreateCaret(); + } +} + +void TextEditor::recreateCaret() +{ + if (isCaretVisible()) + { + if (caret == nullptr) + { + textHolder->addChildComponent (caret = getLookAndFeel().createCaretComponent (this)); + updateCaretPosition(); + } + } + else + { + caret = nullptr; + } +} + +void TextEditor::updateCaretPosition() +{ + if (caret != nullptr) + caret->setCaretPosition (getCaretRectangle().translated (leftIndent, topIndent)); +} + +TextEditor::LengthAndCharacterRestriction::LengthAndCharacterRestriction (int maxLen, const String& chars) + : allowedCharacters (chars), maxLength (maxLen) +{} + +String TextEditor::LengthAndCharacterRestriction::filterNewText (TextEditor& ed, const String& newInput) +{ + String t (newInput); + + if (allowedCharacters.isNotEmpty()) + t = t.retainCharacters (allowedCharacters); + + if (maxLength > 0) + t = t.substring (0, maxLength - (ed.getTotalNumChars() - ed.getHighlightedRegion().getLength())); + + return t; +} + +void TextEditor::setInputFilter (InputFilter* newFilter, bool takeOwnership) +{ + inputFilter.set (newFilter, takeOwnership); +} + +void TextEditor::setInputRestrictions (const int maxLen, const String& chars) +{ + setInputFilter (new LengthAndCharacterRestriction (maxLen, chars), true); +} + +void TextEditor::setTextToShowWhenEmpty (const String& text, Colour colourToUse) +{ + textToShowWhenEmpty = text; + colourForTextWhenEmpty = colourToUse; +} + +void TextEditor::setPasswordCharacter (const juce_wchar newPasswordCharacter) +{ + if (passwordCharacter != newPasswordCharacter) + { + passwordCharacter = newPasswordCharacter; + applyFontToAllText (currentFont); + } +} + +void TextEditor::setScrollBarThickness (const int newThicknessPixels) +{ + viewport->setScrollBarThickness (newThicknessPixels); +} + +//============================================================================== +void TextEditor::clear() +{ + clearInternal (nullptr); + updateTextHolderSize(); + undoManager.clearUndoHistory(); +} + +void TextEditor::setText (const String& newText, + const bool sendTextChangeMessage) +{ + const int newLength = newText.length(); + + if (newLength != getTotalNumChars() || getText() != newText) + { + if (! sendTextChangeMessage) + textValue.removeListener (textHolder); + + textValue = newText; + + auto oldCursorPos = caretPosition; + const bool cursorWasAtEnd = oldCursorPos >= getTotalNumChars(); + + clearInternal (nullptr); + insert (newText, 0, currentFont, findColour (textColourId), 0, caretPosition); + + // if you're adding text with line-feeds to a single-line text editor, it + // ain't gonna look right! + jassert (multiline || ! newText.containsAnyOf ("\r\n")); + + if (cursorWasAtEnd && ! isMultiLine()) + oldCursorPos = getTotalNumChars(); + + moveCaretTo (oldCursorPos, false); + + if (sendTextChangeMessage) + textChanged(); + else + textValue.addListener (textHolder); + + updateTextHolderSize(); + scrollToMakeSureCursorIsVisible(); + undoManager.clearUndoHistory(); + + repaint(); + } +} + +//============================================================================== +void TextEditor::updateValueFromText() +{ + if (valueTextNeedsUpdating) + { + valueTextNeedsUpdating = false; + textValue = getText(); + } +} + +Value& TextEditor::getTextValue() +{ + updateValueFromText(); + return textValue; +} + +void TextEditor::textWasChangedByValue() +{ + if (textValue.getValueSource().getReferenceCount() > 1) + setText (textValue.getValue()); +} + +//============================================================================== +void TextEditor::textChanged() +{ + updateTextHolderSize(); + + if (listeners.size() > 0) + postCommandMessage (TextEditorDefs::textChangeMessageId); + + if (textValue.getValueSource().getReferenceCount() > 1) + { + valueTextNeedsUpdating = false; + textValue = getText(); + } +} + +void TextEditor::returnPressed() { postCommandMessage (TextEditorDefs::returnKeyMessageId); } +void TextEditor::escapePressed() { postCommandMessage (TextEditorDefs::escapeKeyMessageId); } + +void TextEditor::addListener (Listener* l) { listeners.add (l); } +void TextEditor::removeListener (Listener* l) { listeners.remove (l); } + +//============================================================================== +void TextEditor::timerCallbackInt() +{ + if (hasKeyboardFocus (false) && ! isCurrentlyBlockedByAnotherModalComponent()) + wasFocused = true; + + auto now = Time::getApproximateMillisecondCounter(); + + if (now > lastTransactionTime + 200) + newTransaction(); +} + +void TextEditor::repaintText (const Range range) +{ + if (! range.isEmpty()) + { + float x = 0, y = 0, lh = currentFont.getHeight(); + + const float wordWrapWidth = getWordWrapWidth(); + + if (wordWrapWidth > 0) + { + Iterator i (sections, wordWrapWidth, passwordCharacter, lineSpacing); + + i.getCharPosition (range.getStart(), x, y, lh); + + auto y1 = (int) y; + int y2; + + if (range.getEnd() >= getTotalNumChars()) + { + y2 = textHolder->getHeight(); + } + else + { + i.getCharPosition (range.getEnd(), x, y, lh); + y2 = (int) (y + lh * 2.0f); + } + + textHolder->repaint (0, y1, textHolder->getWidth(), y2 - y1); + } + } +} + +//============================================================================== +void TextEditor::moveCaret (int newCaretPos) +{ + if (newCaretPos < 0) + newCaretPos = 0; + else + newCaretPos = jmin (newCaretPos, getTotalNumChars()); + + if (newCaretPos != getCaretPosition()) + { + caretPosition = newCaretPos; + textHolder->restartTimer(); + scrollToMakeSureCursorIsVisible(); + updateCaretPosition(); + } +} + +int TextEditor::getCaretPosition() const +{ + return caretPosition; +} + +void TextEditor::setCaretPosition (const int newIndex) +{ + moveCaretTo (newIndex, false); +} + +void TextEditor::moveCaretToEnd() +{ + moveCaretTo (std::numeric_limits::max(), false); +} + +void TextEditor::scrollEditorToPositionCaret (const int desiredCaretX, + const int desiredCaretY) + +{ + updateCaretPosition(); + auto caretPos = getCaretRectangle(); + + int vx = caretPos.getX() - desiredCaretX; + int vy = caretPos.getY() - desiredCaretY; + + if (desiredCaretX < jmax (1, proportionOfWidth (0.05f))) + vx += desiredCaretX - proportionOfWidth (0.2f); + else if (desiredCaretX > jmax (0, viewport->getMaximumVisibleWidth() - (wordWrap ? 2 : 10))) + vx += desiredCaretX + (isMultiLine() ? proportionOfWidth (0.2f) : 10) - viewport->getMaximumVisibleWidth(); + + vx = jlimit (0, jmax (0, textHolder->getWidth() + 8 - viewport->getMaximumVisibleWidth()), vx); + + if (! isMultiLine()) + { + vy = viewport->getViewPositionY(); + } + else + { + vy = jlimit (0, jmax (0, textHolder->getHeight() - viewport->getMaximumVisibleHeight()), vy); + + if (desiredCaretY < 0) + vy = jmax (0, desiredCaretY + vy); + else if (desiredCaretY > jmax (0, viewport->getMaximumVisibleHeight() - topIndent - caretPos.getHeight())) + vy += desiredCaretY + 2 + caretPos.getHeight() + topIndent - viewport->getMaximumVisibleHeight(); + } + + viewport->setViewPosition (vx, vy); +} + +Rectangle TextEditor::getCaretRectangle() +{ + float cursorX, cursorY; + float cursorHeight = currentFont.getHeight(); // (in case the text is empty and the call below doesn't set this value) + getCharPosition (caretPosition, cursorX, cursorY, cursorHeight); + + return { roundToInt (cursorX), roundToInt (cursorY), 2, roundToInt (cursorHeight) }; +} + +//============================================================================== +enum { rightEdgeSpace = 2 }; + +float TextEditor::getWordWrapWidth() const +{ + return wordWrap ? (float) (viewport->getMaximumVisibleWidth() - (leftIndent + rightEdgeSpace + 1)) + : std::numeric_limits::max(); +} + +void TextEditor::updateTextHolderSize() +{ + const float wordWrapWidth = getWordWrapWidth(); + + if (wordWrapWidth > 0) + { + float maxWidth = 0.0f; + + Iterator i (sections, wordWrapWidth, passwordCharacter, lineSpacing); + + while (i.next()) + maxWidth = jmax (maxWidth, i.atomRight); + + const int w = leftIndent + roundToInt (maxWidth); + const int h = topIndent + roundToInt (jmax (i.lineY + i.lineHeight, + currentFont.getHeight())); + + textHolder->setSize (w + rightEdgeSpace, h + 1); // (allows a bit of space for the cursor to be at the right-hand-edge) + } +} + +int TextEditor::getTextWidth() const { return textHolder->getWidth(); } +int TextEditor::getTextHeight() const { return textHolder->getHeight(); } + +void TextEditor::setIndents (const int newLeftIndent, const int newTopIndent) +{ + leftIndent = newLeftIndent; + topIndent = newTopIndent; +} + +void TextEditor::setBorder (const BorderSize& border) +{ + borderSize = border; + resized(); +} + +BorderSize TextEditor::getBorder() const +{ + return borderSize; +} + +void TextEditor::setScrollToShowCursor (const bool shouldScrollToShowCursor) +{ + keepCaretOnScreen = shouldScrollToShowCursor; +} + +void TextEditor::scrollToMakeSureCursorIsVisible() +{ + updateCaretPosition(); + + if (keepCaretOnScreen) + { + auto viewPos = viewport->getViewPosition(); + auto caretRect = getCaretRectangle(); + auto relativeCursor = caretRect.getPosition() - viewPos; + + if (relativeCursor.x < jmax (1, proportionOfWidth (0.05f))) + { + viewPos.x += relativeCursor.x - proportionOfWidth (0.2f); + } + else if (relativeCursor.x > jmax (0, viewport->getMaximumVisibleWidth() - (wordWrap ? 2 : 10))) + { + viewPos.x += relativeCursor.x + (isMultiLine() ? proportionOfWidth (0.2f) : 10) - viewport->getMaximumVisibleWidth(); + } + + viewPos.x = jlimit (0, jmax (0, textHolder->getWidth() + 8 - viewport->getMaximumVisibleWidth()), viewPos.x); + + if (! isMultiLine()) + { + viewPos.y = (getHeight() - textHolder->getHeight() - topIndent) / -2; + } + else if (relativeCursor.y < 0) + { + viewPos.y = jmax (0, relativeCursor.y + viewPos.y); + } + else if (relativeCursor.y > jmax (0, viewport->getMaximumVisibleHeight() - topIndent - caretRect.getHeight())) + { + viewPos.y += relativeCursor.y + 2 + caretRect.getHeight() + topIndent - viewport->getMaximumVisibleHeight(); + } + + viewport->setViewPosition (viewPos); + } +} + +void TextEditor::moveCaretTo (const int newPosition, const bool isSelecting) +{ + if (isSelecting) + { + moveCaret (newPosition); + + auto oldSelection = selection; + + if (dragType == notDragging) + { + if (std::abs (getCaretPosition() - selection.getStart()) < std::abs (getCaretPosition() - selection.getEnd())) + dragType = draggingSelectionStart; + else + dragType = draggingSelectionEnd; + } + + if (dragType == draggingSelectionStart) + { + if (getCaretPosition() >= selection.getEnd()) + dragType = draggingSelectionEnd; + + selection = Range::between (getCaretPosition(), selection.getEnd()); + } + else + { + if (getCaretPosition() < selection.getStart()) + dragType = draggingSelectionStart; + + selection = Range::between (getCaretPosition(), selection.getStart()); + } + + repaintText (selection.getUnionWith (oldSelection)); + } + else + { + dragType = notDragging; + + repaintText (selection); + + moveCaret (newPosition); + selection = Range::emptyRange (getCaretPosition()); + } +} + +int TextEditor::getTextIndexAt (const int x, const int y) +{ + return indexAtPosition ((float) (x + viewport->getViewPositionX() - leftIndent - borderSize.getLeft()), + (float) (y + viewport->getViewPositionY() - topIndent - borderSize.getTop())); +} + +void TextEditor::insertTextAtCaret (const String& t) +{ + String newText (inputFilter != nullptr ? inputFilter->filterNewText (*this, t) : t); + + if (isMultiLine()) + newText = newText.replace ("\r\n", "\n"); + else + newText = newText.replaceCharacters ("\r\n", " "); + + const int insertIndex = selection.getStart(); + const int newCaretPos = insertIndex + newText.length(); + + remove (selection, getUndoManager(), + newText.isNotEmpty() ? newCaretPos - 1 : newCaretPos); + + insert (newText, insertIndex, currentFont, findColour (textColourId), + getUndoManager(), newCaretPos); + + textChanged(); +} + +void TextEditor::setHighlightedRegion (const Range& newSelection) +{ + moveCaretTo (newSelection.getStart(), false); + moveCaretTo (newSelection.getEnd(), true); +} + +//============================================================================== +void TextEditor::copy() +{ + if (passwordCharacter == 0) + { + auto selectedText = getHighlightedText(); + + if (selectedText.isNotEmpty()) + SystemClipboard::copyTextToClipboard (selectedText); + } +} + +void TextEditor::paste() +{ + if (! isReadOnly()) + { + auto clip = SystemClipboard::getTextFromClipboard(); + + if (clip.isNotEmpty()) + insertTextAtCaret (clip); + } +} + +void TextEditor::cut() +{ + if (! isReadOnly()) + { + moveCaret (selection.getEnd()); + insertTextAtCaret (String()); + } +} + +//============================================================================== +void TextEditor::drawContent (Graphics& g) +{ + const float wordWrapWidth = getWordWrapWidth(); + + if (wordWrapWidth > 0) + { + g.setOrigin (leftIndent, topIndent); + auto clip = g.getClipBounds(); + Colour selectedTextColour; + + Iterator i (sections, wordWrapWidth, passwordCharacter, lineSpacing); + + if (! selection.isEmpty()) + { + Iterator i2 (i); + RectangleList selectionArea; + + while (i2.next() && i2.lineY < clip.getBottom()) + { + if (i2.lineY + i2.lineHeight >= clip.getY() + && selection.intersects (Range (i2.indexInText, i2.indexInText + i2.atom->numChars))) + { + i2.addSelection (selectionArea, selection); + } + } + + g.setColour (findColour (highlightColourId).withMultipliedAlpha (hasKeyboardFocus (true) ? 1.0f : 0.5f)); + g.fillRectList (selectionArea); + + selectedTextColour = findColour (highlightedTextColourId); + } + + const UniformTextSection* lastSection = nullptr; + + while (i.next() && i.lineY < clip.getBottom()) + { + if (i.lineY + i.lineHeight >= clip.getY()) + { + if (selection.intersects (Range (i.indexInText, i.indexInText + i.atom->numChars))) + { + i.drawSelectedText (g, selection, selectedTextColour); + lastSection = nullptr; + } + else + { + i.draw (g, lastSection); + } + } + } + + for (int j = underlinedSections.size(); --j >= 0;) + { + const Range underlinedSection = underlinedSections.getReference (j); + + Iterator i2 (sections, wordWrapWidth, passwordCharacter, lineSpacing); + + while (i2.next() && i2.lineY < clip.getBottom()) + { + if (i2.lineY + i2.lineHeight >= clip.getY() + && underlinedSection.intersects (Range (i2.indexInText, i2.indexInText + i2.atom->numChars))) + { + i2.drawUnderline (g, underlinedSection, findColour (textColourId)); + } + } + } + } +} + +void TextEditor::paint (Graphics& g) +{ + getLookAndFeel().fillTextEditorBackground (g, getWidth(), getHeight(), *this); +} + +void TextEditor::paintOverChildren (Graphics& g) +{ + if (textToShowWhenEmpty.isNotEmpty() + && (! hasKeyboardFocus (false)) + && getTotalNumChars() == 0) + { + g.setColour (colourForTextWhenEmpty); + g.setFont (getFont()); + + if (isMultiLine()) + g.drawText (textToShowWhenEmpty, getLocalBounds(), + Justification::centred, true); + else + g.drawText (textToShowWhenEmpty, + leftIndent, 0, viewport->getWidth() - leftIndent, getHeight(), + Justification::centredLeft, true); + } + + getLookAndFeel().drawTextEditorOutline (g, getWidth(), getHeight(), *this); +} + +//============================================================================== +void TextEditor::addPopupMenuItems (PopupMenu& m, const MouseEvent*) +{ + const bool writable = ! isReadOnly(); + + if (passwordCharacter == 0) + { + m.addItem (StandardApplicationCommandIDs::cut, TRANS("Cut"), writable); + m.addItem (StandardApplicationCommandIDs::copy, TRANS("Copy"), ! selection.isEmpty()); + } + + m.addItem (StandardApplicationCommandIDs::paste, TRANS("Paste"), writable); + m.addItem (StandardApplicationCommandIDs::del, TRANS("Delete"), writable); + m.addSeparator(); + m.addItem (StandardApplicationCommandIDs::selectAll, TRANS("Select All")); + m.addSeparator(); + + if (getUndoManager() != nullptr) + { + m.addItem (StandardApplicationCommandIDs::undo, TRANS("Undo"), undoManager.canUndo()); + m.addItem (StandardApplicationCommandIDs::redo, TRANS("Redo"), undoManager.canRedo()); + } +} + +void TextEditor::performPopupMenuAction (const int menuItemID) +{ + switch (menuItemID) + { + case StandardApplicationCommandIDs::cut: cutToClipboard(); break; + case StandardApplicationCommandIDs::copy: copyToClipboard(); break; + case StandardApplicationCommandIDs::paste: pasteFromClipboard(); break; + case StandardApplicationCommandIDs::del: cut(); break; + case StandardApplicationCommandIDs::selectAll: selectAll(); break; + case StandardApplicationCommandIDs::undo: undo(); break; + case StandardApplicationCommandIDs::redo: redo(); break; + default: break; + } +} + +static void textEditorMenuCallback (int menuResult, TextEditor* editor) +{ + if (editor != nullptr && menuResult != 0) + editor->performPopupMenuAction (menuResult); +} + +//============================================================================== +void TextEditor::mouseDown (const MouseEvent& e) +{ + beginDragAutoRepeat (100); + newTransaction(); + + if (wasFocused || ! selectAllTextWhenFocused) + { + if (! (popupMenuEnabled && e.mods.isPopupMenu())) + { + moveCaretTo (getTextIndexAt (e.x, e.y), + e.mods.isShiftDown()); + } + else + { + PopupMenu m; + m.setLookAndFeel (&getLookAndFeel()); + addPopupMenuItems (m, &e); + + m.showMenuAsync (PopupMenu::Options(), + ModalCallbackFunction::forComponent (textEditorMenuCallback, this)); + } + } +} + +void TextEditor::mouseDrag (const MouseEvent& e) +{ + if (wasFocused || ! selectAllTextWhenFocused) + if (! (popupMenuEnabled && e.mods.isPopupMenu())) + moveCaretTo (getTextIndexAt (e.x, e.y), true); +} + +void TextEditor::mouseUp (const MouseEvent& e) +{ + newTransaction(); + textHolder->restartTimer(); + + if (wasFocused || ! selectAllTextWhenFocused) + if (e.mouseWasClicked() && ! (popupMenuEnabled && e.mods.isPopupMenu())) + moveCaret (getTextIndexAt (e.x, e.y)); + + wasFocused = true; +} + +void TextEditor::mouseDoubleClick (const MouseEvent& e) +{ + int tokenEnd = getTextIndexAt (e.x, e.y); + int tokenStart = 0; + + if (e.getNumberOfClicks() > 3) + { + tokenEnd = getTotalNumChars(); + } + else + { + auto t = getText(); + auto totalLength = getTotalNumChars(); + + while (tokenEnd < totalLength) + { + // (note the slight bodge here - it's because iswalnum only checks for alphabetic chars in the current locale) + const juce_wchar c = t [tokenEnd]; + if (CharacterFunctions::isLetterOrDigit (c) || c > 128) + ++tokenEnd; + else + break; + } + + tokenStart = tokenEnd; + + while (tokenStart > 0) + { + // (note the slight bodge here - it's because iswalnum only checks for alphabetic chars in the current locale) + const juce_wchar c = t [tokenStart - 1]; + if (CharacterFunctions::isLetterOrDigit (c) || c > 128) + --tokenStart; + else + break; + } + + if (e.getNumberOfClicks() > 2) + { + while (tokenEnd < totalLength) + { + const juce_wchar c = t [tokenEnd]; + if (c != '\r' && c != '\n') + ++tokenEnd; + else + break; + } + + while (tokenStart > 0) + { + const juce_wchar c = t [tokenStart - 1]; + if (c != '\r' && c != '\n') + --tokenStart; + else + break; + } + } + } + + moveCaretTo (tokenEnd, false); + moveCaretTo (tokenStart, true); +} + +void TextEditor::mouseWheelMove (const MouseEvent& e, const MouseWheelDetails& wheel) +{ + if (! viewport->useMouseWheelMoveIfNeeded (e, wheel)) + Component::mouseWheelMove (e, wheel); +} + +//============================================================================== +bool TextEditor::moveCaretWithTransaction (const int newPos, const bool selecting) +{ + newTransaction(); + moveCaretTo (newPos, selecting); + return true; +} + +bool TextEditor::moveCaretLeft (bool moveInWholeWordSteps, bool selecting) +{ + int pos = getCaretPosition(); + + if (moveInWholeWordSteps) + pos = findWordBreakBefore (pos); + else + --pos; + + return moveCaretWithTransaction (pos, selecting); +} + +bool TextEditor::moveCaretRight (bool moveInWholeWordSteps, bool selecting) +{ + int pos = getCaretPosition(); + + if (moveInWholeWordSteps) + pos = findWordBreakAfter (pos); + else + ++pos; + + return moveCaretWithTransaction (pos, selecting); +} + +bool TextEditor::moveCaretUp (bool selecting) +{ + if (! isMultiLine()) + return moveCaretToStartOfLine (selecting); + + auto caretPos = getCaretRectangle().toFloat(); + return moveCaretWithTransaction (indexAtPosition (caretPos.getX(), caretPos.getY() - 1.0f), selecting); +} + +bool TextEditor::moveCaretDown (bool selecting) +{ + if (! isMultiLine()) + return moveCaretToEndOfLine (selecting); + + auto caretPos = getCaretRectangle().toFloat(); + return moveCaretWithTransaction (indexAtPosition (caretPos.getX(), caretPos.getBottom() + 1.0f), selecting); +} + +bool TextEditor::pageUp (bool selecting) +{ + if (! isMultiLine()) + return moveCaretToStartOfLine (selecting); + + auto caretPos = getCaretRectangle().toFloat(); + return moveCaretWithTransaction (indexAtPosition (caretPos.getX(), caretPos.getY() - viewport->getViewHeight()), selecting); +} + +bool TextEditor::pageDown (bool selecting) +{ + if (! isMultiLine()) + return moveCaretToEndOfLine (selecting); + + auto caretPos = getCaretRectangle().toFloat(); + return moveCaretWithTransaction (indexAtPosition (caretPos.getX(), caretPos.getBottom() + viewport->getViewHeight()), selecting); +} + +void TextEditor::scrollByLines (int deltaLines) +{ + if (auto* scrollbar = viewport->getVerticalScrollBar()) + scrollbar->moveScrollbarInSteps (deltaLines); +} + +bool TextEditor::scrollDown() +{ + scrollByLines (-1); + return true; +} + +bool TextEditor::scrollUp() +{ + scrollByLines (1); + return true; +} + +bool TextEditor::moveCaretToTop (bool selecting) +{ + return moveCaretWithTransaction (0, selecting); +} + +bool TextEditor::moveCaretToStartOfLine (bool selecting) +{ + auto caretPos = getCaretRectangle().toFloat(); + return moveCaretWithTransaction (indexAtPosition (0.0f, caretPos.getY()), selecting); +} + +bool TextEditor::moveCaretToEnd (bool selecting) +{ + return moveCaretWithTransaction (getTotalNumChars(), selecting); +} + +bool TextEditor::moveCaretToEndOfLine (bool selecting) +{ + auto caretPos = getCaretRectangle().toFloat(); + return moveCaretWithTransaction (indexAtPosition ((float) textHolder->getWidth(), caretPos.getY()), selecting); +} + +bool TextEditor::deleteBackwards (bool moveInWholeWordSteps) +{ + if (moveInWholeWordSteps) + moveCaretTo (findWordBreakBefore (getCaretPosition()), true); + else if (selection.isEmpty() && selection.getStart() > 0) + selection = Range (selection.getEnd() - 1, selection.getEnd()); + + cut(); + return true; +} + +bool TextEditor::deleteForwards (bool /*moveInWholeWordSteps*/) +{ + if (selection.isEmpty() && selection.getStart() < getTotalNumChars()) + selection = Range (selection.getStart(), selection.getStart() + 1); + + cut(); + return true; +} + +bool TextEditor::copyToClipboard() +{ + newTransaction(); + copy(); + return true; +} + +bool TextEditor::cutToClipboard() +{ + newTransaction(); + copy(); + cut(); + return true; +} + +bool TextEditor::pasteFromClipboard() +{ + newTransaction(); + paste(); + return true; +} + +bool TextEditor::selectAll() +{ + newTransaction(); + moveCaretTo (getTotalNumChars(), false); + moveCaretTo (0, true); + return true; +} + +//============================================================================== +void TextEditor::setEscapeAndReturnKeysConsumed (bool shouldBeConsumed) noexcept +{ + consumeEscAndReturnKeys = shouldBeConsumed; +} + +bool TextEditor::keyPressed (const KeyPress& key) +{ + if (isReadOnly() && key != KeyPress ('c', ModifierKeys::commandModifier, 0) + && key != KeyPress ('a', ModifierKeys::commandModifier, 0)) + return false; + + if (! TextEditorKeyMapper::invokeKeyFunction (*this, key)) + { + if (key == KeyPress::returnKey) + { + newTransaction(); + + if (returnKeyStartsNewLine) + insertTextAtCaret ("\n"); + else + { + returnPressed(); + return consumeEscAndReturnKeys; + } + } + else if (key.isKeyCode (KeyPress::escapeKey)) + { + newTransaction(); + moveCaretTo (getCaretPosition(), false); + escapePressed(); + return consumeEscAndReturnKeys; + } + else if (key.getTextCharacter() >= ' ' + || (tabKeyUsed && (key.getTextCharacter() == '\t'))) + { + insertTextAtCaret (String::charToString (key.getTextCharacter())); + + lastTransactionTime = Time::getApproximateMillisecondCounter(); + } + else + { + return false; + } + } + + return true; +} + +bool TextEditor::keyStateChanged (const bool isKeyDown) +{ + if (! isKeyDown) + return false; + + #if JUCE_WINDOWS + if (KeyPress (KeyPress::F4Key, ModifierKeys::altModifier, 0).isCurrentlyDown()) + return false; // We need to explicitly allow alt-F4 to pass through on Windows + #endif + + if ((! consumeEscAndReturnKeys) + && (KeyPress (KeyPress::escapeKey).isCurrentlyDown() + || KeyPress (KeyPress::returnKey).isCurrentlyDown())) + return false; + + // (overridden to avoid forwarding key events to the parent) + return ! ModifierKeys::getCurrentModifiers().isCommandDown(); +} + +//============================================================================== +void TextEditor::focusGained (FocusChangeType) +{ + newTransaction(); + + if (selectAllTextWhenFocused) + { + moveCaretTo (0, false); + moveCaretTo (getTotalNumChars(), true); + } + + repaint(); + updateCaretPosition(); + + if (auto* peer = getPeer()) + if (! isReadOnly()) + peer->textInputRequired (peer->globalToLocal (getScreenPosition()), *this); +} + +void TextEditor::focusLost (FocusChangeType) +{ + newTransaction(); + + wasFocused = false; + textHolder->stopTimer(); + + underlinedSections.clear(); + + if (auto* peer = getPeer()) + peer->dismissPendingTextInput(); + + updateCaretPosition(); + + postCommandMessage (TextEditorDefs::focusLossMessageId); + repaint(); +} + +//============================================================================== +void TextEditor::resized() +{ + viewport->setBoundsInset (borderSize); + viewport->setSingleStepSizes (16, roundToInt (currentFont.getHeight())); + + updateTextHolderSize(); + + if (isMultiLine()) + updateCaretPosition(); + else + scrollToMakeSureCursorIsVisible(); +} + +void TextEditor::handleCommandMessage (const int commandId) +{ + Component::BailOutChecker checker (this); + + switch (commandId) + { + case TextEditorDefs::textChangeMessageId: + listeners.callChecked (checker, &Listener::textEditorTextChanged, (TextEditor&) *this); + break; + + case TextEditorDefs::returnKeyMessageId: + listeners.callChecked (checker, &Listener::textEditorReturnKeyPressed, (TextEditor&) *this); + break; + + case TextEditorDefs::escapeKeyMessageId: + listeners.callChecked (checker, &Listener::textEditorEscapeKeyPressed, (TextEditor&) *this); + break; + + case TextEditorDefs::focusLossMessageId: + updateValueFromText(); + listeners.callChecked (checker, &Listener::textEditorFocusLost, (TextEditor&) *this); + break; + + default: + jassertfalse; + break; + } +} + +void TextEditor::setTemporaryUnderlining (const Array >& newUnderlinedSections) +{ + underlinedSections = newUnderlinedSections; + repaint(); +} + +//============================================================================== +UndoManager* TextEditor::getUndoManager() noexcept +{ + return readOnly ? nullptr : &undoManager; +} + +void TextEditor::clearInternal (UndoManager* const um) +{ + remove (Range (0, getTotalNumChars()), um, caretPosition); +} + +void TextEditor::insert (const String& text, + const int insertIndex, + const Font& font, + const Colour colour, + UndoManager* const um, + const int caretPositionToMoveTo) +{ + if (text.isNotEmpty()) + { + if (um != nullptr) + { + if (um->getNumActionsInCurrentTransaction() > TextEditorDefs::maxActionsPerTransaction) + newTransaction(); + + um->perform (new InsertAction (*this, text, insertIndex, font, colour, + caretPosition, caretPositionToMoveTo)); + } + else + { + repaintText (Range (insertIndex, getTotalNumChars())); // must do this before and after changing the data, in case + // a line gets moved due to word wrap + + int index = 0; + int nextIndex = 0; + + for (int i = 0; i < sections.size(); ++i) + { + nextIndex = index + sections.getUnchecked (i)->getTotalLength(); + + if (insertIndex == index) + { + sections.insert (i, new UniformTextSection (text, font, colour, passwordCharacter)); + break; + } + else if (insertIndex > index && insertIndex < nextIndex) + { + splitSection (i, insertIndex - index); + sections.insert (i + 1, new UniformTextSection (text, font, colour, passwordCharacter)); + break; + } + + index = nextIndex; + } + + if (nextIndex == insertIndex) + sections.add (new UniformTextSection (text, font, colour, passwordCharacter)); + + coalesceSimilarSections(); + totalNumChars = -1; + valueTextNeedsUpdating = true; + + updateTextHolderSize(); + moveCaretTo (caretPositionToMoveTo, false); + + repaintText (Range (insertIndex, getTotalNumChars())); + } + } +} + +void TextEditor::reinsert (const int insertIndex, const OwnedArray& sectionsToInsert) +{ + int index = 0; + int nextIndex = 0; + + for (int i = 0; i < sections.size(); ++i) + { + nextIndex = index + sections.getUnchecked (i)->getTotalLength(); + + if (insertIndex == index) + { + for (int j = sectionsToInsert.size(); --j >= 0;) + sections.insert (i, new UniformTextSection (*sectionsToInsert.getUnchecked(j))); + + break; + } + else if (insertIndex > index && insertIndex < nextIndex) + { + splitSection (i, insertIndex - index); + + for (int j = sectionsToInsert.size(); --j >= 0;) + sections.insert (i + 1, new UniformTextSection (*sectionsToInsert.getUnchecked(j))); + + break; + } + + index = nextIndex; + } + + if (nextIndex == insertIndex) + { + for (int j = 0; j < sectionsToInsert.size(); ++j) + sections.add (new UniformTextSection (*sectionsToInsert.getUnchecked(j))); + } + + coalesceSimilarSections(); + totalNumChars = -1; + valueTextNeedsUpdating = true; +} + +void TextEditor::remove (Range range, UndoManager* const um, const int caretPositionToMoveTo) +{ + if (! range.isEmpty()) + { + int index = 0; + + for (int i = 0; i < sections.size(); ++i) + { + const int nextIndex = index + sections.getUnchecked(i)->getTotalLength(); + + if (range.getStart() > index && range.getStart() < nextIndex) + { + splitSection (i, range.getStart() - index); + --i; + } + else if (range.getEnd() > index && range.getEnd() < nextIndex) + { + splitSection (i, range.getEnd() - index); + --i; + } + else + { + index = nextIndex; + + if (index > range.getEnd()) + break; + } + } + + index = 0; + + if (um != nullptr) + { + Array removedSections; + + for (int i = 0; i < sections.size(); ++i) + { + if (range.getEnd() <= range.getStart()) + break; + + auto* section = sections.getUnchecked (i); + auto nextIndex = index + section->getTotalLength(); + + if (range.getStart() <= index && range.getEnd() >= nextIndex) + removedSections.add (new UniformTextSection (*section)); + + index = nextIndex; + } + + if (um->getNumActionsInCurrentTransaction() > TextEditorDefs::maxActionsPerTransaction) + newTransaction(); + + um->perform (new RemoveAction (*this, range, caretPosition, + caretPositionToMoveTo, removedSections)); + } + else + { + auto remainingRange = range; + + for (int i = 0; i < sections.size(); ++i) + { + auto* section = sections.getUnchecked (i); + + const int nextIndex = index + section->getTotalLength(); + + if (remainingRange.getStart() <= index && remainingRange.getEnd() >= nextIndex) + { + sections.remove (i); + remainingRange.setEnd (remainingRange.getEnd() - (nextIndex - index)); + + if (remainingRange.isEmpty()) + break; + + --i; + } + else + { + index = nextIndex; + } + } + + coalesceSimilarSections(); + totalNumChars = -1; + valueTextNeedsUpdating = true; + + moveCaretTo (caretPositionToMoveTo, false); + + repaintText (Range (range.getStart(), getTotalNumChars())); + } + } +} + +//============================================================================== +String TextEditor::getText() const +{ + MemoryOutputStream mo; + mo.preallocate ((size_t) getTotalNumChars()); + + for (int i = 0; i < sections.size(); ++i) + sections.getUnchecked (i)->appendAllText (mo); + + return mo.toUTF8(); +} + +String TextEditor::getTextInRange (const Range& range) const +{ + if (range.isEmpty()) + return {}; + + MemoryOutputStream mo; + mo.preallocate ((size_t) jmin (getTotalNumChars(), range.getLength())); + + int index = 0; + + for (int i = 0; i < sections.size(); ++i) + { + auto* s = sections.getUnchecked (i); + auto nextIndex = index + s->getTotalLength(); + + if (range.getStart() < nextIndex) + { + if (range.getEnd() <= index) + break; + + s->appendSubstring (mo, range - index); + } + + index = nextIndex; + } + + return mo.toUTF8(); +} + +String TextEditor::getHighlightedText() const +{ + return getTextInRange (selection); +} + +int TextEditor::getTotalNumChars() const +{ + if (totalNumChars < 0) + { + totalNumChars = 0; + + for (int i = sections.size(); --i >= 0;) + totalNumChars += sections.getUnchecked (i)->getTotalLength(); + } + + return totalNumChars; +} + +bool TextEditor::isEmpty() const +{ + return getTotalNumChars() == 0; +} + +void TextEditor::getCharPosition (const int index, float& cx, float& cy, float& lineHeight) const +{ + const float wordWrapWidth = getWordWrapWidth(); + + if (wordWrapWidth > 0 && sections.size() > 0) + { + Iterator i (sections, wordWrapWidth, passwordCharacter, lineSpacing); + + i.getCharPosition (index, cx, cy, lineHeight); + } + else + { + cx = cy = 0; + lineHeight = currentFont.getHeight(); + } +} + +int TextEditor::indexAtPosition (const float x, const float y) +{ + const float wordWrapWidth = getWordWrapWidth(); + + if (wordWrapWidth > 0) + { + Iterator i (sections, wordWrapWidth, passwordCharacter, lineSpacing); + + while (i.next()) + { + if (i.lineY + i.lineHeight > y) + { + if (i.lineY > y) + return jmax (0, i.indexInText - 1); + + if (i.atomX >= x) + return i.indexInText; + + if (x < i.atomRight) + return i.xToIndex (x); + } + } + } + + return getTotalNumChars(); +} + +//============================================================================== +int TextEditor::findWordBreakAfter (const int position) const +{ + auto t = getTextInRange (Range (position, position + 512)); + auto totalLength = t.length(); + int i = 0; + + while (i < totalLength && CharacterFunctions::isWhitespace (t[i])) + ++i; + + const int type = TextEditorDefs::getCharacterCategory (t[i]); + + while (i < totalLength && type == TextEditorDefs::getCharacterCategory (t[i])) + ++i; + + while (i < totalLength && CharacterFunctions::isWhitespace (t[i])) + ++i; + + return position + i; +} + +int TextEditor::findWordBreakBefore (const int position) const +{ + if (position <= 0) + return 0; + + auto startOfBuffer = jmax (0, position - 512); + auto t = getTextInRange (Range (startOfBuffer, position)); + + int i = position - startOfBuffer; + + while (i > 0 && CharacterFunctions::isWhitespace (t [i - 1])) + --i; + + if (i > 0) + { + auto type = TextEditorDefs::getCharacterCategory (t [i - 1]); + + while (i > 0 && type == TextEditorDefs::getCharacterCategory (t [i - 1])) + --i; + } + + jassert (startOfBuffer + i >= 0); + return startOfBuffer + i; +} + + +//============================================================================== +void TextEditor::splitSection (const int sectionIndex, const int charToSplitAt) +{ + jassert (sections[sectionIndex] != nullptr); + + sections.insert (sectionIndex + 1, + sections.getUnchecked (sectionIndex)->split (charToSplitAt, passwordCharacter)); +} + +void TextEditor::coalesceSimilarSections() +{ + for (int i = 0; i < sections.size() - 1; ++i) + { + auto* s1 = sections.getUnchecked (i); + auto* s2 = sections.getUnchecked (i + 1); + + if (s1->font == s2->font + && s1->colour == s2->colour) + { + s1->append (*s2, passwordCharacter); + sections.remove (i + 1); + --i; + } + } +} + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_TextEditor.h b/modules/juce_gui_basics/widgets/juce_TextEditor.h index 9a3960eb24..fff11dcbea 100644 --- a/modules/juce_gui_basics/widgets/juce_TextEditor.h +++ b/modules/juce_gui_basics/widgets/juce_TextEditor.h @@ -1,774 +1,774 @@ -/* - ============================================================================== - - This file is part of the JUCE library. - Copyright (c) 2017 - ROLI Ltd. - - JUCE is an open source library subject to commercial or open-source - licensing. - - By using JUCE, you agree to the terms of both the JUCE 5 End-User License - Agreement and JUCE 5 Privacy Policy (both updated and effective as of the - 27th April 2017). - - End User License Agreement: www.juce.com/juce-5-licence - Privacy Policy: www.juce.com/juce-5-privacy-policy - - Or: You may also use this code under the terms of the GPL v3 (see - www.gnu.org/licenses). - - JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER - EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE - DISCLAIMED. - - ============================================================================== -*/ - -namespace juce -{ - -//============================================================================== -/** - An editable text box. - - A TextEditor can either be in single- or multi-line mode, and supports mixed - fonts and colours. - - @see TextEditor::Listener, Label -*/ -class JUCE_API TextEditor : public Component, - public TextInputTarget, - public SettableTooltipClient -{ -public: - //============================================================================== - /** Creates a new, empty text editor. - - @param componentName the name to pass to the component for it to use as its name - @param passwordCharacter if this is not zero, this character will be used as a replacement - for all characters that are drawn on screen - e.g. to create - a password-style textbox containing circular blobs instead of text, - you could set this value to 0x25cf, which is the unicode character - for a black splodge (not all fonts include this, though), or 0x2022, - which is a bullet (probably the best choice for linux). - */ - explicit TextEditor (const String& componentName = String(), - juce_wchar passwordCharacter = 0); - - /** Destructor. */ - ~TextEditor(); - - //============================================================================== - /** Puts the editor into either multi- or single-line mode. - - By default, the editor will be in single-line mode, so use this if you need a multi-line - editor. - - See also the setReturnKeyStartsNewLine() method, which will also need to be turned - on if you want a multi-line editor with line-breaks. - - @see isMultiLine, setReturnKeyStartsNewLine - */ - void setMultiLine (bool shouldBeMultiLine, - bool shouldWordWrap = true); - - /** Returns true if the editor is in multi-line mode. */ - bool isMultiLine() const; - - //============================================================================== - /** Changes the behaviour of the return key. - - If set to true, the return key will insert a new-line into the text; if false - it will trigger a call to the TextEditor::Listener::textEditorReturnKeyPressed() - method. By default this is set to false, and when true it will only insert - new-lines when in multi-line mode (see setMultiLine()). - */ - void setReturnKeyStartsNewLine (bool shouldStartNewLine); - - /** Returns the value set by setReturnKeyStartsNewLine(). - See setReturnKeyStartsNewLine() for more info. - */ - bool getReturnKeyStartsNewLine() const { return returnKeyStartsNewLine; } - - /** Indicates whether the tab key should be accepted and used to input a tab character, - or whether it gets ignored. - - By default the tab key is ignored, so that it can be used to switch keyboard focus - between components. - */ - void setTabKeyUsedAsCharacter (bool shouldTabKeyBeUsed); - - /** Returns true if the tab key is being used for input. - @see setTabKeyUsedAsCharacter - */ - bool isTabKeyUsedAsCharacter() const { return tabKeyUsed; } - - /** This can be used to change whether escape and return keypress events are - propagated up to the parent component. - The default here is true, meaning that these events are not allowed to reach the - parent, but you may want to allow them through so that they can trigger other - actions, e.g. closing a dialog box, etc. - */ - void setEscapeAndReturnKeysConsumed (bool shouldBeConsumed) noexcept; - - //============================================================================== - /** Changes the editor to read-only mode. - - By default, the text editor is not read-only. If you're making it read-only, you - might also want to call setCaretVisible (false) to get rid of the caret. - - The text can still be highlighted and copied when in read-only mode. - - @see isReadOnly, setCaretVisible - */ - void setReadOnly (bool shouldBeReadOnly); - - /** Returns true if the editor is in read-only mode. */ - bool isReadOnly() const noexcept; - - //============================================================================== - /** Makes the caret visible or invisible. - By default the caret is visible. - @see setCaretColour, setCaretPosition - */ - void setCaretVisible (bool shouldBeVisible); - - /** Returns true if the caret is enabled. - @see setCaretVisible - */ - bool isCaretVisible() const noexcept { return caretVisible && ! isReadOnly(); } - - //============================================================================== - /** Enables/disables a vertical scrollbar. - - (This only applies when in multi-line mode). When the text gets too long to fit - in the component, a scrollbar can appear to allow it to be scrolled. Even when - this is enabled, the scrollbar will be hidden unless it's needed. - - By default the scrollbar is enabled. - */ - void setScrollbarsShown (bool shouldBeEnabled); - - /** Returns true if scrollbars are enabled. - @see setScrollbarsShown - */ - bool areScrollbarsShown() const noexcept { return scrollbarVisible; } - - - /** Changes the password character used to disguise the text. - - @param passwordCharacter if this is not zero, this character will be used as a replacement - for all characters that are drawn on screen - e.g. to create - a password-style textbox containing circular blobs instead of text, - you could set this value to 0x25cf, which is the unicode character - for a black splodge (not all fonts include this, though), or 0x2022, - which is a bullet (probably the best choice for linux). - */ - void setPasswordCharacter (juce_wchar passwordCharacter); - - /** Returns the current password character. - @see setPasswordCharacter - */ - juce_wchar getPasswordCharacter() const noexcept { return passwordCharacter; } - - - //============================================================================== - /** Allows a right-click menu to appear for the editor. - - (This defaults to being enabled). - - If enabled, right-clicking (or command-clicking on the Mac) will pop up a menu - of options such as cut/copy/paste, undo/redo, etc. - */ - void setPopupMenuEnabled (bool menuEnabled); - - /** Returns true if the right-click menu is enabled. - @see setPopupMenuEnabled - */ - bool isPopupMenuEnabled() const noexcept { return popupMenuEnabled; } - - /** Returns true if a popup-menu is currently being displayed. */ - bool isPopupMenuCurrentlyActive() const noexcept { return menuActive; } - - //============================================================================== - /** A set of colour IDs to use to change the colour of various aspects of the editor. - - These constants can be used either via the Component::setColour(), or LookAndFeel::setColour() - methods. - - NB: You can also set the caret colour using CaretComponent::caretColourId - - @see Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour - */ - enum ColourIds - { - backgroundColourId = 0x1000200, /**< The colour to use for the text component's background - this can be - transparent if necessary. */ - - textColourId = 0x1000201, /**< The colour that will be used when text is added to the editor. Note - that because the editor can contain multiple colours, calling this - method won't change the colour of existing text - to do that, use - the applyColourToAllText() method */ - - highlightColourId = 0x1000202, /**< The colour with which to fill the background of highlighted sections of - the text - this can be transparent if you don't want to show any - highlighting.*/ - - highlightedTextColourId = 0x1000203, /**< The colour with which to draw the text in highlighted sections. */ - - outlineColourId = 0x1000205, /**< If this is non-transparent, it will be used to draw a box around - the edge of the component. */ - - focusedOutlineColourId = 0x1000206, /**< If this is non-transparent, it will be used to draw a box around - the edge of the component when it has focus. */ - - shadowColourId = 0x1000207, /**< If this is non-transparent, it'll be used to draw an inner shadow - around the edge of the editor. */ - }; - - //============================================================================== - /** Sets the font to use for newly added text. - - This will change the font that will be used next time any text is added or entered - into the editor. It won't change the font of any existing text - to do that, use - applyFontToAllText() instead. - - @see applyFontToAllText - */ - void setFont (const Font& newFont); - - /** Applies a font to all the text in the editor. - - If the changeCurrentFont argument is true then this will also set the - new font as the font to be used for any new text that's added. - - @see setFont - */ - void applyFontToAllText (const Font& newFont, bool changeCurrentFont = true); - - /** Returns the font that's currently being used for new text. - - @see setFont - */ - const Font& getFont() const noexcept { return currentFont; } - - /** Applies a colour to all the text in the editor. - - If the changeCurrentTextColour argument is true then this will also set the - new colour as the colour to be used for any new text that's added. - */ - void applyColourToAllText (const Colour& newColour, bool changeCurrentTextColour = true); - - //============================================================================== - /** If set to true, focusing on the editor will highlight all its text. - - (Set to false by default). - - This is useful for boxes where you expect the user to re-enter all the - text when they focus on the component, rather than editing what's already there. - */ - void setSelectAllWhenFocused (bool shouldSelectAll); - - /** When the text editor is empty, it can be set to display a message. - - This is handy for things like telling the user what to type in the box - the - string is only displayed, it's not taken to actually be the contents of - the editor. - */ - void setTextToShowWhenEmpty (const String& text, Colour colourToUse); - - //============================================================================== - /** Changes the size of the scrollbars that are used. - Handy if you need smaller scrollbars for a small text box. - */ - void setScrollBarThickness (int newThicknessPixels); - - //============================================================================== - /** - Receives callbacks from a TextEditor component when it changes. - - @see TextEditor::addListener - */ - class JUCE_API Listener - { - public: - /** Destructor. */ - virtual ~Listener() {} - - /** Called when the user changes the text in some way. */ - virtual void textEditorTextChanged (TextEditor&) {} - - /** Called when the user presses the return key. */ - virtual void textEditorReturnKeyPressed (TextEditor&) {} - - /** Called when the user presses the escape key. */ - virtual void textEditorEscapeKeyPressed (TextEditor&) {} - - /** Called when the text editor loses focus. */ - virtual void textEditorFocusLost (TextEditor&) {} - }; - - /** Registers a listener to be told when things happen to the text. - @see removeListener - */ - void addListener (Listener* newListener); - - /** Deregisters a listener. - @see addListener - */ - void removeListener (Listener* listenerToRemove); - - //============================================================================== - /** Returns the entire contents of the editor. */ - String getText() const; - - /** Returns a section of the contents of the editor. */ - String getTextInRange (const Range& textRange) const override; - - /** Returns true if there are no characters in the editor. - This is far more efficient than calling getText().isEmpty(). - */ - bool isEmpty() const; - - /** Sets the entire content of the editor. - - This will clear the editor and insert the given text (using the current text colour - and font). You can set the current text colour using - @code setColour (TextEditor::textColourId, ...); - @endcode - - @param newText the text to add - @param sendTextChangeMessage if true, this will cause a change message to - be sent to all the listeners. - @see insertTextAtCaret - */ - void setText (const String& newText, - bool sendTextChangeMessage = true); - - /** Returns a Value object that can be used to get or set the text. - - Bear in mind that this operate quite slowly if your text box contains large - amounts of text, as it needs to dynamically build the string that's involved. - It's best used for small text boxes. - */ - Value& getTextValue(); - - /** Inserts some text at the current caret position. - - If a section of the text is highlighted, it will be replaced by - this string, otherwise it will be inserted. - - To delete a section of text, you can use setHighlightedRegion() to - highlight it, and call insertTextAtCaret (String()). - - @see setCaretPosition, getCaretPosition, setHighlightedRegion - */ - void insertTextAtCaret (const String& textToInsert) override; - - /** Deletes all the text from the editor. */ - void clear(); - - /** Deletes the currently selected region. - This doesn't copy the deleted section to the clipboard - if you need to do that, call copy() first. - @see copy, paste, SystemClipboard - */ - void cut(); - - /** Copies the currently selected region to the clipboard. - @see cut, paste, SystemClipboard - */ - void copy(); - - /** Pastes the contents of the clipboard into the editor at the caret position. - @see cut, copy, SystemClipboard - */ - void paste(); - - //============================================================================== - /** Returns the current index of the caret. - @see setCaretPosition - */ - int getCaretPosition() const; - - /** Moves the caret to be in front of a given character. - @see getCaretPosition, moveCaretToEnd - */ - void setCaretPosition (int newIndex); - - /** Attempts to scroll the text editor so that the caret ends up at - a specified position. - - This won't affect the caret's position within the text, it tries to scroll - the entire editor vertically and horizontally so that the caret is sitting - at the given position (relative to the top-left of this component). - - Depending on the amount of text available, it might not be possible to - scroll far enough for the caret to reach this exact position, but it - will go as far as it can in that direction. - */ - void scrollEditorToPositionCaret (int desiredCaretX, int desiredCaretY); - - /** Get the graphical position of the caret. - - The rectangle returned is relative to the component's top-left corner. - @see scrollEditorToPositionCaret - */ - Rectangle getCaretRectangle() override; - - /** Selects a section of the text. */ - void setHighlightedRegion (const Range& newSelection) override; - - /** Returns the range of characters that are selected. - If nothing is selected, this will return an empty range. - @see setHighlightedRegion - */ - Range getHighlightedRegion() const override { return selection; } - - /** Returns the section of text that is currently selected. */ - String getHighlightedText() const; - - /** Finds the index of the character at a given position. - The coordinates are relative to the component's top-left. - */ - int getTextIndexAt (int x, int y); - - /** Counts the number of characters in the text. - - This is quicker than getting the text as a string if you just need to know - the length. - */ - int getTotalNumChars() const; - - /** Returns the total width of the text, as it is currently laid-out. - - This may be larger than the size of the TextEditor, and can change when - the TextEditor is resized or the text changes. - */ - int getTextWidth() const; - - /** Returns the maximum height of the text, as it is currently laid-out. - - This may be larger than the size of the TextEditor, and can change when - the TextEditor is resized or the text changes. - */ - int getTextHeight() const; - - /** Changes the size of the gap at the top and left-edge of the editor. - By default there's a gap of 4 pixels. - */ - void setIndents (int newLeftIndent, int newTopIndent); - - /** Changes the size of border left around the edge of the component. - @see getBorder - */ - void setBorder (const BorderSize& border); - - /** Returns the size of border around the edge of the component. - @see setBorder - */ - BorderSize getBorder() const; - - /** Used to disable the auto-scrolling which keeps the caret visible. - - If true (the default), the editor will scroll when the caret moves offscreen. If - set to false, it won't. - */ - void setScrollToShowCursor (bool shouldScrollToShowCaret); - - /** Sets the line spacing of the TextEditor. - - The default (and minimum) value is 1.0 and values > 1.0 will increase the line spacing as a - multiple of the line height e.g. for double-spacing call this method with an argument of 2.0. - */ - void setLineSpacing (float newLineSpacing) noexcept { lineSpacing = jmax (1.0f, newLineSpacing); } - - /** Returns the current line spacing of the TextEditor. */ - float getLineSpacing() const noexcept { return lineSpacing; } - - //============================================================================== - void moveCaretToEnd(); - bool moveCaretLeft (bool moveInWholeWordSteps, bool selecting); - bool moveCaretRight (bool moveInWholeWordSteps, bool selecting); - bool moveCaretUp (bool selecting); - bool moveCaretDown (bool selecting); - bool pageUp (bool selecting); - bool pageDown (bool selecting); - bool scrollDown(); - bool scrollUp(); - bool moveCaretToTop (bool selecting); - bool moveCaretToStartOfLine (bool selecting); - bool moveCaretToEnd (bool selecting); - bool moveCaretToEndOfLine (bool selecting); - bool deleteBackwards (bool moveInWholeWordSteps); - bool deleteForwards (bool moveInWholeWordSteps); - bool copyToClipboard(); - bool cutToClipboard(); - bool pasteFromClipboard(); - bool selectAll(); - bool undo(); - bool redo(); - - //============================================================================== - /** This adds the items to the popup menu. - - By default it adds the cut/copy/paste items, but you can override this if - you need to replace these with your own items. - - If you want to add your own items to the existing ones, you can override this, - call the base class's addPopupMenuItems() method, then append your own items. - - When the menu has been shown, performPopupMenuAction() will be called to - perform the item that the user has chosen. - - The default menu items will be added using item IDs from the - StandardApplicationCommandIDs namespace. - - If this was triggered by a mouse-click, the mouseClickEvent parameter will be - a pointer to the info about it, or may be null if the menu is being triggered - by some other means. - - @see performPopupMenuAction, setPopupMenuEnabled, isPopupMenuEnabled - */ - virtual void addPopupMenuItems (PopupMenu& menuToAddTo, - const MouseEvent* mouseClickEvent); - - /** This is called to perform one of the items that was shown on the popup menu. - - If you've overridden addPopupMenuItems(), you should also override this - to perform the actions that you've added. - - If you've overridden addPopupMenuItems() but have still left the default items - on the menu, remember to call the superclass's performPopupMenuAction() - so that it can perform the default actions if that's what the user clicked on. - - @see addPopupMenuItems, setPopupMenuEnabled, isPopupMenuEnabled - */ - virtual void performPopupMenuAction (int menuItemID); - - //============================================================================== - /** Base class for input filters that can be applied to a TextEditor to restrict - the text that can be entered. - */ - class JUCE_API InputFilter - { - public: - InputFilter() {} - virtual ~InputFilter() {} - - /** This method is called whenever text is entered into the editor. - An implementation of this class should should check the input string, - and return an edited version of it that should be used. - */ - virtual String filterNewText (TextEditor&, const String& newInput) = 0; - }; - - /** An input filter for a TextEditor that limits the length of text and/or the - characters that it may contain. - */ - class JUCE_API LengthAndCharacterRestriction : public InputFilter - { - public: - /** Creates a filter that limits the length of text, and/or the characters that it can contain. - @param maxNumChars if this is > 0, it sets a maximum length limit; if <= 0, no - limit is set - @param allowedCharacters if this is non-empty, then only characters that occur in - this string are allowed to be entered into the editor. - */ - LengthAndCharacterRestriction (int maxNumChars, const String& allowedCharacters); - - String filterNewText (TextEditor&, const String&) override; - - private: - String allowedCharacters; - int maxLength; - - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LengthAndCharacterRestriction) - }; - - /** Sets an input filter that should be applied to this editor. - The filter can be nullptr, to remove any existing filters. - If takeOwnership is true, then the filter will be owned and deleted by the editor - when no longer needed. - */ - void setInputFilter (InputFilter* newFilter, bool takeOwnership); - - /** Returns the current InputFilter, as set by setInputFilter(). */ - InputFilter* getInputFilter() const noexcept { return inputFilter; } - - /** Sets limits on the characters that can be entered. - This is just a shortcut that passes an instance of the LengthAndCharacterRestriction - class to setInputFilter(). - - @param maxTextLength if this is > 0, it sets a maximum length limit; if 0, no - limit is set - @param allowedCharacters if this is non-empty, then only characters that occur in - this string are allowed to be entered into the editor. - */ - void setInputRestrictions (int maxTextLength, - const String& allowedCharacters = String()); - - void setKeyboardType (VirtualKeyboardType type) noexcept { keyboardType = type; } - - //============================================================================== - /** This abstract base class is implemented by LookAndFeel classes to provide - TextEditor drawing functionality. - */ - struct JUCE_API LookAndFeelMethods - { - virtual ~LookAndFeelMethods() {} - - virtual void fillTextEditorBackground (Graphics&, int width, int height, TextEditor&) = 0; - virtual void drawTextEditorOutline (Graphics&, int width, int height, TextEditor&) = 0; - - virtual CaretComponent* createCaretComponent (Component* keyFocusOwner) = 0; - }; - - //============================================================================== - /** @internal */ - void paint (Graphics&) override; - /** @internal */ - void paintOverChildren (Graphics&) override; - /** @internal */ - void mouseDown (const MouseEvent&) override; - /** @internal */ - void mouseUp (const MouseEvent&) override; - /** @internal */ - void mouseDrag (const MouseEvent&) override; - /** @internal */ - void mouseDoubleClick (const MouseEvent&) override; - /** @internal */ - void mouseWheelMove (const MouseEvent&, const MouseWheelDetails&) override; - /** @internal */ - bool keyPressed (const KeyPress&) override; - /** @internal */ - bool keyStateChanged (bool) override; - /** @internal */ - void focusGained (FocusChangeType) override; - /** @internal */ - void focusLost (FocusChangeType) override; - /** @internal */ - void resized() override; - /** @internal */ - void enablementChanged() override; - /** @internal */ - void colourChanged() override; - /** @internal */ - void lookAndFeelChanged() override; - /** @internal */ - void parentHierarchyChanged() override; - /** @internal */ - bool isTextInputActive() const override; - /** @internal */ - void setTemporaryUnderlining (const Array >&) override; - /** @internal */ - VirtualKeyboardType getKeyboardType() override { return keyboardType; } - -protected: - //============================================================================== - /** Scrolls the minimum distance needed to get the caret into view. */ - void scrollToMakeSureCursorIsVisible(); - - /** Used internally to dispatch a text-change message. */ - void textChanged(); - - /** Begins a new transaction in the UndoManager. */ - void newTransaction(); - - /** Can be overridden to intercept return key presses directly */ - virtual void returnPressed(); - - /** Can be overridden to intercept escape key presses directly */ - virtual void escapePressed(); - -private: - //============================================================================== - class Iterator; - JUCE_PUBLIC_IN_DLL_BUILD (class UniformTextSection) - class TextHolderComponent; - class InsertAction; - class RemoveAction; - friend class InsertAction; - friend class RemoveAction; - - ScopedPointer viewport; - TextHolderComponent* textHolder; - BorderSize borderSize { 1, 1, 1, 3 }; - - bool readOnly = false; - bool caretVisible = true; - bool multiline = false; - bool wordWrap = false; - bool returnKeyStartsNewLine = false; - bool popupMenuEnabled = true; - bool selectAllTextWhenFocused = false; - bool scrollbarVisible = true; - bool wasFocused = false; - bool keepCaretOnScreen = true; - bool tabKeyUsed = false; - bool menuActive = false; - bool valueTextNeedsUpdating = false; - bool consumeEscAndReturnKeys = true; - - UndoManager undoManager; - ScopedPointer caret; - Range selection; - int leftIndent = 4, topIndent = 4; - unsigned int lastTransactionTime = 0; - Font currentFont { 14.0f }; - mutable int totalNumChars = 0; - int caretPosition = 0; - OwnedArray sections; - String textToShowWhenEmpty; - Colour colourForTextWhenEmpty; - juce_wchar passwordCharacter; - OptionalScopedPointer inputFilter; - Value textValue; - VirtualKeyboardType keyboardType; - float lineSpacing = 1.0f; - - enum - { - notDragging, - draggingSelectionStart, - draggingSelectionEnd - } dragType; - - ListenerList listeners; - Array > underlinedSections; - - void moveCaret (int newCaretPos); - void moveCaretTo (int newPosition, bool isSelecting); - void recreateCaret(); - void handleCommandMessage (int) override; - void coalesceSimilarSections(); - void splitSection (int sectionIndex, int charToSplitAt); - void clearInternal (UndoManager*); - void insert (const String&, int insertIndex, const Font&, const Colour, UndoManager*, int newCaretPos); - void reinsert (int insertIndex, const OwnedArray&); - void remove (Range range, UndoManager*, int caretPositionToMoveTo); - void getCharPosition (int index, float& x, float& y, float& lineHeight) const; - void updateCaretPosition(); - void updateValueFromText(); - void textWasChangedByValue(); - int indexAtPosition (float x, float y); - int findWordBreakAfter (int position) const; - int findWordBreakBefore (int position) const; - bool moveCaretWithTransaction (int newPos, bool selecting); - friend class TextHolderComponent; - friend class TextEditorViewport; - void drawContent (Graphics&); - void updateTextHolderSize(); - float getWordWrapWidth() const; - void timerCallbackInt(); - void repaintText (Range); - void scrollByLines (int deltaLines); - bool undoOrRedo (bool shouldUndo); - UndoManager* getUndoManager() noexcept; - - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TextEditor) -}; - -/** This typedef is just for compatibility with old code - newer code should use the TextEditor::Listener class directly. */ -typedef TextEditor::Listener TextEditorListener; - -} // namespace juce +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2017 - ROLI Ltd. + + JUCE is an open source library subject to commercial or open-source + licensing. + + By using JUCE, you agree to the terms of both the JUCE 5 End-User License + Agreement and JUCE 5 Privacy Policy (both updated and effective as of the + 27th April 2017). + + End User License Agreement: www.juce.com/juce-5-licence + Privacy Policy: www.juce.com/juce-5-privacy-policy + + Or: You may also use this code under the terms of the GPL v3 (see + www.gnu.org/licenses). + + JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER + EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE + DISCLAIMED. + + ============================================================================== +*/ + +namespace juce +{ + +//============================================================================== +/** + An editable text box. + + A TextEditor can either be in single- or multi-line mode, and supports mixed + fonts and colours. + + @see TextEditor::Listener, Label +*/ +class JUCE_API TextEditor : public Component, + public TextInputTarget, + public SettableTooltipClient +{ +public: + //============================================================================== + /** Creates a new, empty text editor. + + @param componentName the name to pass to the component for it to use as its name + @param passwordCharacter if this is not zero, this character will be used as a replacement + for all characters that are drawn on screen - e.g. to create + a password-style textbox containing circular blobs instead of text, + you could set this value to 0x25cf, which is the unicode character + for a black splodge (not all fonts include this, though), or 0x2022, + which is a bullet (probably the best choice for linux). + */ + explicit TextEditor (const String& componentName = String(), + juce_wchar passwordCharacter = 0); + + /** Destructor. */ + ~TextEditor(); + + //============================================================================== + /** Puts the editor into either multi- or single-line mode. + + By default, the editor will be in single-line mode, so use this if you need a multi-line + editor. + + See also the setReturnKeyStartsNewLine() method, which will also need to be turned + on if you want a multi-line editor with line-breaks. + + @see isMultiLine, setReturnKeyStartsNewLine + */ + void setMultiLine (bool shouldBeMultiLine, + bool shouldWordWrap = true); + + /** Returns true if the editor is in multi-line mode. */ + bool isMultiLine() const; + + //============================================================================== + /** Changes the behaviour of the return key. + + If set to true, the return key will insert a new-line into the text; if false + it will trigger a call to the TextEditor::Listener::textEditorReturnKeyPressed() + method. By default this is set to false, and when true it will only insert + new-lines when in multi-line mode (see setMultiLine()). + */ + void setReturnKeyStartsNewLine (bool shouldStartNewLine); + + /** Returns the value set by setReturnKeyStartsNewLine(). + See setReturnKeyStartsNewLine() for more info. + */ + bool getReturnKeyStartsNewLine() const { return returnKeyStartsNewLine; } + + /** Indicates whether the tab key should be accepted and used to input a tab character, + or whether it gets ignored. + + By default the tab key is ignored, so that it can be used to switch keyboard focus + between components. + */ + void setTabKeyUsedAsCharacter (bool shouldTabKeyBeUsed); + + /** Returns true if the tab key is being used for input. + @see setTabKeyUsedAsCharacter + */ + bool isTabKeyUsedAsCharacter() const { return tabKeyUsed; } + + /** This can be used to change whether escape and return keypress events are + propagated up to the parent component. + The default here is true, meaning that these events are not allowed to reach the + parent, but you may want to allow them through so that they can trigger other + actions, e.g. closing a dialog box, etc. + */ + void setEscapeAndReturnKeysConsumed (bool shouldBeConsumed) noexcept; + + //============================================================================== + /** Changes the editor to read-only mode. + + By default, the text editor is not read-only. If you're making it read-only, you + might also want to call setCaretVisible (false) to get rid of the caret. + + The text can still be highlighted and copied when in read-only mode. + + @see isReadOnly, setCaretVisible + */ + void setReadOnly (bool shouldBeReadOnly); + + /** Returns true if the editor is in read-only mode. */ + bool isReadOnly() const noexcept; + + //============================================================================== + /** Makes the caret visible or invisible. + By default the caret is visible. + @see setCaretColour, setCaretPosition + */ + void setCaretVisible (bool shouldBeVisible); + + /** Returns true if the caret is enabled. + @see setCaretVisible + */ + bool isCaretVisible() const noexcept { return caretVisible && ! isReadOnly(); } + + //============================================================================== + /** Enables/disables a vertical scrollbar. + + (This only applies when in multi-line mode). When the text gets too long to fit + in the component, a scrollbar can appear to allow it to be scrolled. Even when + this is enabled, the scrollbar will be hidden unless it's needed. + + By default the scrollbar is enabled. + */ + void setScrollbarsShown (bool shouldBeEnabled); + + /** Returns true if scrollbars are enabled. + @see setScrollbarsShown + */ + bool areScrollbarsShown() const noexcept { return scrollbarVisible; } + + + /** Changes the password character used to disguise the text. + + @param passwordCharacter if this is not zero, this character will be used as a replacement + for all characters that are drawn on screen - e.g. to create + a password-style textbox containing circular blobs instead of text, + you could set this value to 0x25cf, which is the unicode character + for a black splodge (not all fonts include this, though), or 0x2022, + which is a bullet (probably the best choice for linux). + */ + void setPasswordCharacter (juce_wchar passwordCharacter); + + /** Returns the current password character. + @see setPasswordCharacter + */ + juce_wchar getPasswordCharacter() const noexcept { return passwordCharacter; } + + + //============================================================================== + /** Allows a right-click menu to appear for the editor. + + (This defaults to being enabled). + + If enabled, right-clicking (or command-clicking on the Mac) will pop up a menu + of options such as cut/copy/paste, undo/redo, etc. + */ + void setPopupMenuEnabled (bool menuEnabled); + + /** Returns true if the right-click menu is enabled. + @see setPopupMenuEnabled + */ + bool isPopupMenuEnabled() const noexcept { return popupMenuEnabled; } + + /** Returns true if a popup-menu is currently being displayed. */ + bool isPopupMenuCurrentlyActive() const noexcept { return menuActive; } + + //============================================================================== + /** A set of colour IDs to use to change the colour of various aspects of the editor. + + These constants can be used either via the Component::setColour(), or LookAndFeel::setColour() + methods. + + NB: You can also set the caret colour using CaretComponent::caretColourId + + @see Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour + */ + enum ColourIds + { + backgroundColourId = 0x1000200, /**< The colour to use for the text component's background - this can be + transparent if necessary. */ + + textColourId = 0x1000201, /**< The colour that will be used when text is added to the editor. Note + that because the editor can contain multiple colours, calling this + method won't change the colour of existing text - to do that, use + the applyColourToAllText() method */ + + highlightColourId = 0x1000202, /**< The colour with which to fill the background of highlighted sections of + the text - this can be transparent if you don't want to show any + highlighting.*/ + + highlightedTextColourId = 0x1000203, /**< The colour with which to draw the text in highlighted sections. */ + + outlineColourId = 0x1000205, /**< If this is non-transparent, it will be used to draw a box around + the edge of the component. */ + + focusedOutlineColourId = 0x1000206, /**< If this is non-transparent, it will be used to draw a box around + the edge of the component when it has focus. */ + + shadowColourId = 0x1000207, /**< If this is non-transparent, it'll be used to draw an inner shadow + around the edge of the editor. */ + }; + + //============================================================================== + /** Sets the font to use for newly added text. + + This will change the font that will be used next time any text is added or entered + into the editor. It won't change the font of any existing text - to do that, use + applyFontToAllText() instead. + + @see applyFontToAllText + */ + void setFont (const Font& newFont); + + /** Applies a font to all the text in the editor. + + If the changeCurrentFont argument is true then this will also set the + new font as the font to be used for any new text that's added. + + @see setFont + */ + void applyFontToAllText (const Font& newFont, bool changeCurrentFont = true); + + /** Returns the font that's currently being used for new text. + + @see setFont + */ + const Font& getFont() const noexcept { return currentFont; } + + /** Applies a colour to all the text in the editor. + + If the changeCurrentTextColour argument is true then this will also set the + new colour as the colour to be used for any new text that's added. + */ + void applyColourToAllText (const Colour& newColour, bool changeCurrentTextColour = true); + + //============================================================================== + /** If set to true, focusing on the editor will highlight all its text. + + (Set to false by default). + + This is useful for boxes where you expect the user to re-enter all the + text when they focus on the component, rather than editing what's already there. + */ + void setSelectAllWhenFocused (bool shouldSelectAll); + + /** When the text editor is empty, it can be set to display a message. + + This is handy for things like telling the user what to type in the box - the + string is only displayed, it's not taken to actually be the contents of + the editor. + */ + void setTextToShowWhenEmpty (const String& text, Colour colourToUse); + + //============================================================================== + /** Changes the size of the scrollbars that are used. + Handy if you need smaller scrollbars for a small text box. + */ + void setScrollBarThickness (int newThicknessPixels); + + //============================================================================== + /** + Receives callbacks from a TextEditor component when it changes. + + @see TextEditor::addListener + */ + class JUCE_API Listener + { + public: + /** Destructor. */ + virtual ~Listener() {} + + /** Called when the user changes the text in some way. */ + virtual void textEditorTextChanged (TextEditor&) {} + + /** Called when the user presses the return key. */ + virtual void textEditorReturnKeyPressed (TextEditor&) {} + + /** Called when the user presses the escape key. */ + virtual void textEditorEscapeKeyPressed (TextEditor&) {} + + /** Called when the text editor loses focus. */ + virtual void textEditorFocusLost (TextEditor&) {} + }; + + /** Registers a listener to be told when things happen to the text. + @see removeListener + */ + void addListener (Listener* newListener); + + /** Deregisters a listener. + @see addListener + */ + void removeListener (Listener* listenerToRemove); + + //============================================================================== + /** Returns the entire contents of the editor. */ + String getText() const; + + /** Returns a section of the contents of the editor. */ + String getTextInRange (const Range& textRange) const override; + + /** Returns true if there are no characters in the editor. + This is far more efficient than calling getText().isEmpty(). + */ + bool isEmpty() const; + + /** Sets the entire content of the editor. + + This will clear the editor and insert the given text (using the current text colour + and font). You can set the current text colour using + @code setColour (TextEditor::textColourId, ...); + @endcode + + @param newText the text to add + @param sendTextChangeMessage if true, this will cause a change message to + be sent to all the listeners. + @see insertTextAtCaret + */ + void setText (const String& newText, + bool sendTextChangeMessage = true); + + /** Returns a Value object that can be used to get or set the text. + + Bear in mind that this operate quite slowly if your text box contains large + amounts of text, as it needs to dynamically build the string that's involved. + It's best used for small text boxes. + */ + Value& getTextValue(); + + /** Inserts some text at the current caret position. + + If a section of the text is highlighted, it will be replaced by + this string, otherwise it will be inserted. + + To delete a section of text, you can use setHighlightedRegion() to + highlight it, and call insertTextAtCaret (String()). + + @see setCaretPosition, getCaretPosition, setHighlightedRegion + */ + void insertTextAtCaret (const String& textToInsert) override; + + /** Deletes all the text from the editor. */ + void clear(); + + /** Deletes the currently selected region. + This doesn't copy the deleted section to the clipboard - if you need to do that, call copy() first. + @see copy, paste, SystemClipboard + */ + void cut(); + + /** Copies the currently selected region to the clipboard. + @see cut, paste, SystemClipboard + */ + void copy(); + + /** Pastes the contents of the clipboard into the editor at the caret position. + @see cut, copy, SystemClipboard + */ + void paste(); + + //============================================================================== + /** Returns the current index of the caret. + @see setCaretPosition + */ + int getCaretPosition() const; + + /** Moves the caret to be in front of a given character. + @see getCaretPosition, moveCaretToEnd + */ + void setCaretPosition (int newIndex); + + /** Attempts to scroll the text editor so that the caret ends up at + a specified position. + + This won't affect the caret's position within the text, it tries to scroll + the entire editor vertically and horizontally so that the caret is sitting + at the given position (relative to the top-left of this component). + + Depending on the amount of text available, it might not be possible to + scroll far enough for the caret to reach this exact position, but it + will go as far as it can in that direction. + */ + void scrollEditorToPositionCaret (int desiredCaretX, int desiredCaretY); + + /** Get the graphical position of the caret. + + The rectangle returned is relative to the component's top-left corner. + @see scrollEditorToPositionCaret + */ + Rectangle getCaretRectangle() override; + + /** Selects a section of the text. */ + void setHighlightedRegion (const Range& newSelection) override; + + /** Returns the range of characters that are selected. + If nothing is selected, this will return an empty range. + @see setHighlightedRegion + */ + Range getHighlightedRegion() const override { return selection; } + + /** Returns the section of text that is currently selected. */ + String getHighlightedText() const; + + /** Finds the index of the character at a given position. + The coordinates are relative to the component's top-left. + */ + int getTextIndexAt (int x, int y); + + /** Counts the number of characters in the text. + + This is quicker than getting the text as a string if you just need to know + the length. + */ + int getTotalNumChars() const; + + /** Returns the total width of the text, as it is currently laid-out. + + This may be larger than the size of the TextEditor, and can change when + the TextEditor is resized or the text changes. + */ + int getTextWidth() const; + + /** Returns the maximum height of the text, as it is currently laid-out. + + This may be larger than the size of the TextEditor, and can change when + the TextEditor is resized or the text changes. + */ + int getTextHeight() const; + + /** Changes the size of the gap at the top and left-edge of the editor. + By default there's a gap of 4 pixels. + */ + void setIndents (int newLeftIndent, int newTopIndent); + + /** Changes the size of border left around the edge of the component. + @see getBorder + */ + void setBorder (const BorderSize& border); + + /** Returns the size of border around the edge of the component. + @see setBorder + */ + BorderSize getBorder() const; + + /** Used to disable the auto-scrolling which keeps the caret visible. + + If true (the default), the editor will scroll when the caret moves offscreen. If + set to false, it won't. + */ + void setScrollToShowCursor (bool shouldScrollToShowCaret); + + /** Sets the line spacing of the TextEditor. + + The default (and minimum) value is 1.0 and values > 1.0 will increase the line spacing as a + multiple of the line height e.g. for double-spacing call this method with an argument of 2.0. + */ + void setLineSpacing (float newLineSpacing) noexcept { lineSpacing = jmax (1.0f, newLineSpacing); } + + /** Returns the current line spacing of the TextEditor. */ + float getLineSpacing() const noexcept { return lineSpacing; } + + //============================================================================== + void moveCaretToEnd(); + bool moveCaretLeft (bool moveInWholeWordSteps, bool selecting); + bool moveCaretRight (bool moveInWholeWordSteps, bool selecting); + bool moveCaretUp (bool selecting); + bool moveCaretDown (bool selecting); + bool pageUp (bool selecting); + bool pageDown (bool selecting); + bool scrollDown(); + bool scrollUp(); + bool moveCaretToTop (bool selecting); + bool moveCaretToStartOfLine (bool selecting); + bool moveCaretToEnd (bool selecting); + bool moveCaretToEndOfLine (bool selecting); + bool deleteBackwards (bool moveInWholeWordSteps); + bool deleteForwards (bool moveInWholeWordSteps); + bool copyToClipboard(); + bool cutToClipboard(); + bool pasteFromClipboard(); + bool selectAll(); + bool undo(); + bool redo(); + + //============================================================================== + /** This adds the items to the popup menu. + + By default it adds the cut/copy/paste items, but you can override this if + you need to replace these with your own items. + + If you want to add your own items to the existing ones, you can override this, + call the base class's addPopupMenuItems() method, then append your own items. + + When the menu has been shown, performPopupMenuAction() will be called to + perform the item that the user has chosen. + + The default menu items will be added using item IDs from the + StandardApplicationCommandIDs namespace. + + If this was triggered by a mouse-click, the mouseClickEvent parameter will be + a pointer to the info about it, or may be null if the menu is being triggered + by some other means. + + @see performPopupMenuAction, setPopupMenuEnabled, isPopupMenuEnabled + */ + virtual void addPopupMenuItems (PopupMenu& menuToAddTo, + const MouseEvent* mouseClickEvent); + + /** This is called to perform one of the items that was shown on the popup menu. + + If you've overridden addPopupMenuItems(), you should also override this + to perform the actions that you've added. + + If you've overridden addPopupMenuItems() but have still left the default items + on the menu, remember to call the superclass's performPopupMenuAction() + so that it can perform the default actions if that's what the user clicked on. + + @see addPopupMenuItems, setPopupMenuEnabled, isPopupMenuEnabled + */ + virtual void performPopupMenuAction (int menuItemID); + + //============================================================================== + /** Base class for input filters that can be applied to a TextEditor to restrict + the text that can be entered. + */ + class JUCE_API InputFilter + { + public: + InputFilter() {} + virtual ~InputFilter() {} + + /** This method is called whenever text is entered into the editor. + An implementation of this class should should check the input string, + and return an edited version of it that should be used. + */ + virtual String filterNewText (TextEditor&, const String& newInput) = 0; + }; + + /** An input filter for a TextEditor that limits the length of text and/or the + characters that it may contain. + */ + class JUCE_API LengthAndCharacterRestriction : public InputFilter + { + public: + /** Creates a filter that limits the length of text, and/or the characters that it can contain. + @param maxNumChars if this is > 0, it sets a maximum length limit; if <= 0, no + limit is set + @param allowedCharacters if this is non-empty, then only characters that occur in + this string are allowed to be entered into the editor. + */ + LengthAndCharacterRestriction (int maxNumChars, const String& allowedCharacters); + + String filterNewText (TextEditor&, const String&) override; + + private: + String allowedCharacters; + int maxLength; + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LengthAndCharacterRestriction) + }; + + /** Sets an input filter that should be applied to this editor. + The filter can be nullptr, to remove any existing filters. + If takeOwnership is true, then the filter will be owned and deleted by the editor + when no longer needed. + */ + void setInputFilter (InputFilter* newFilter, bool takeOwnership); + + /** Returns the current InputFilter, as set by setInputFilter(). */ + InputFilter* getInputFilter() const noexcept { return inputFilter; } + + /** Sets limits on the characters that can be entered. + This is just a shortcut that passes an instance of the LengthAndCharacterRestriction + class to setInputFilter(). + + @param maxTextLength if this is > 0, it sets a maximum length limit; if 0, no + limit is set + @param allowedCharacters if this is non-empty, then only characters that occur in + this string are allowed to be entered into the editor. + */ + void setInputRestrictions (int maxTextLength, + const String& allowedCharacters = String()); + + void setKeyboardType (VirtualKeyboardType type) noexcept { keyboardType = type; } + + //============================================================================== + /** This abstract base class is implemented by LookAndFeel classes to provide + TextEditor drawing functionality. + */ + struct JUCE_API LookAndFeelMethods + { + virtual ~LookAndFeelMethods() {} + + virtual void fillTextEditorBackground (Graphics&, int width, int height, TextEditor&) = 0; + virtual void drawTextEditorOutline (Graphics&, int width, int height, TextEditor&) = 0; + + virtual CaretComponent* createCaretComponent (Component* keyFocusOwner) = 0; + }; + + //============================================================================== + /** @internal */ + void paint (Graphics&) override; + /** @internal */ + void paintOverChildren (Graphics&) override; + /** @internal */ + void mouseDown (const MouseEvent&) override; + /** @internal */ + void mouseUp (const MouseEvent&) override; + /** @internal */ + void mouseDrag (const MouseEvent&) override; + /** @internal */ + void mouseDoubleClick (const MouseEvent&) override; + /** @internal */ + void mouseWheelMove (const MouseEvent&, const MouseWheelDetails&) override; + /** @internal */ + bool keyPressed (const KeyPress&) override; + /** @internal */ + bool keyStateChanged (bool) override; + /** @internal */ + void focusGained (FocusChangeType) override; + /** @internal */ + void focusLost (FocusChangeType) override; + /** @internal */ + void resized() override; + /** @internal */ + void enablementChanged() override; + /** @internal */ + void lookAndFeelChanged() override; + /** @internal */ + void parentHierarchyChanged() override; + /** @internal */ + bool isTextInputActive() const override; + /** @internal */ + void setTemporaryUnderlining (const Array >&) override; + /** @internal */ + VirtualKeyboardType getKeyboardType() override { return keyboardType; } + +protected: + //============================================================================== + /** Scrolls the minimum distance needed to get the caret into view. */ + void scrollToMakeSureCursorIsVisible(); + + /** Used internally to dispatch a text-change message. */ + void textChanged(); + + /** Begins a new transaction in the UndoManager. */ + void newTransaction(); + + /** Can be overridden to intercept return key presses directly */ + virtual void returnPressed(); + + /** Can be overridden to intercept escape key presses directly */ + virtual void escapePressed(); + +private: + //============================================================================== + class Iterator; + JUCE_PUBLIC_IN_DLL_BUILD (class UniformTextSection) + class TextHolderComponent; + class InsertAction; + class RemoveAction; + friend class InsertAction; + friend class RemoveAction; + + ScopedPointer viewport; + TextHolderComponent* textHolder; + BorderSize borderSize { 1, 1, 1, 3 }; + + bool readOnly = false; + bool caretVisible = true; + bool multiline = false; + bool wordWrap = false; + bool returnKeyStartsNewLine = false; + bool popupMenuEnabled = true; + bool selectAllTextWhenFocused = false; + bool scrollbarVisible = true; + bool wasFocused = false; + bool keepCaretOnScreen = true; + bool tabKeyUsed = false; + bool menuActive = false; + bool valueTextNeedsUpdating = false; + bool consumeEscAndReturnKeys = true; + + UndoManager undoManager; + ScopedPointer caret; + Range selection; + int leftIndent = 4, topIndent = 4; + unsigned int lastTransactionTime = 0; + Font currentFont { 14.0f }; + mutable int totalNumChars = 0; + int caretPosition = 0; + OwnedArray sections; + String textToShowWhenEmpty; + Colour colourForTextWhenEmpty; + juce_wchar passwordCharacter; + OptionalScopedPointer inputFilter; + Value textValue; + VirtualKeyboardType keyboardType = TextInputTarget::textKeyboard; + float lineSpacing = 1.0f; + + enum DragType + { + notDragging, + draggingSelectionStart, + draggingSelectionEnd + }; + + DragType dragType = notDragging; + + ListenerList listeners; + Array> underlinedSections; + + void moveCaret (int newCaretPos); + void moveCaretTo (int newPosition, bool isSelecting); + void recreateCaret(); + void handleCommandMessage (int) override; + void coalesceSimilarSections(); + void splitSection (int sectionIndex, int charToSplitAt); + void clearInternal (UndoManager*); + void insert (const String&, int insertIndex, const Font&, const Colour, UndoManager*, int newCaretPos); + void reinsert (int insertIndex, const OwnedArray&); + void remove (Range range, UndoManager*, int caretPositionToMoveTo); + void getCharPosition (int index, float& x, float& y, float& lineHeight) const; + void updateCaretPosition(); + void updateValueFromText(); + void textWasChangedByValue(); + int indexAtPosition (float x, float y); + int findWordBreakAfter (int position) const; + int findWordBreakBefore (int position) const; + bool moveCaretWithTransaction (int newPos, bool selecting); + friend class TextHolderComponent; + friend class TextEditorViewport; + void drawContent (Graphics&); + void updateTextHolderSize(); + float getWordWrapWidth() const; + void timerCallbackInt(); + void repaintText (Range); + void scrollByLines (int deltaLines); + bool undoOrRedo (bool shouldUndo); + UndoManager* getUndoManager() noexcept; + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TextEditor) +}; + +/** This typedef is just for compatibility with old code - newer code should use the TextEditor::Listener class directly. */ +typedef TextEditor::Listener TextEditorListener; + +} // namespace juce From 6290e95152f548d5c08d7be16a59812aa1716994 Mon Sep 17 00:00:00 2001 From: jules Date: Thu, 21 Sep 2017 19:49:18 +0100 Subject: [PATCH 129/129] Whitespace --- .../widgets/juce_TextEditor.cpp | 5028 ++++++++--------- .../juce_gui_basics/widgets/juce_TextEditor.h | 1548 ++--- 2 files changed, 3288 insertions(+), 3288 deletions(-) diff --git a/modules/juce_gui_basics/widgets/juce_TextEditor.cpp b/modules/juce_gui_basics/widgets/juce_TextEditor.cpp index f3490c35b7..c40956cfe8 100644 --- a/modules/juce_gui_basics/widgets/juce_TextEditor.cpp +++ b/modules/juce_gui_basics/widgets/juce_TextEditor.cpp @@ -1,2514 +1,2514 @@ -/* - ============================================================================== - - This file is part of the JUCE library. - Copyright (c) 2017 - ROLI Ltd. - - JUCE is an open source library subject to commercial or open-source - licensing. - - By using JUCE, you agree to the terms of both the JUCE 5 End-User License - Agreement and JUCE 5 Privacy Policy (both updated and effective as of the - 27th April 2017). - - End User License Agreement: www.juce.com/juce-5-licence - Privacy Policy: www.juce.com/juce-5-privacy-policy - - Or: You may also use this code under the terms of the GPL v3 (see - www.gnu.org/licenses). - - JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER - EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE - DISCLAIMED. - - ============================================================================== -*/ - -namespace juce -{ - -// a word or space that can't be broken down any further -struct TextAtom -{ - //============================================================================== - String atomText; - float width; - int numChars; - - //============================================================================== - bool isWhitespace() const noexcept { return CharacterFunctions::isWhitespace (atomText[0]); } - bool isNewLine() const noexcept { return atomText[0] == '\r' || atomText[0] == '\n'; } - - String getText (const juce_wchar passwordCharacter) const - { - if (passwordCharacter == 0) - return atomText; - - return String::repeatedString (String::charToString (passwordCharacter), - atomText.length()); - } - - String getTrimmedText (const juce_wchar passwordCharacter) const - { - if (passwordCharacter == 0) - return atomText.substring (0, numChars); - - if (isNewLine()) - return {}; - - return String::repeatedString (String::charToString (passwordCharacter), numChars); - } - - JUCE_LEAK_DETECTOR (TextAtom) -}; - -//============================================================================== -// a run of text with a single font and colour -class TextEditor::UniformTextSection -{ -public: - UniformTextSection (const String& text, const Font& f, Colour col, juce_wchar passwordChar) - : font (f), colour (col) - { - initialiseAtoms (text, passwordChar); - } - - UniformTextSection (const UniformTextSection& other) - : font (other.font), colour (other.colour) - { - atoms.addCopiesOf (other.atoms); - } - - void append (UniformTextSection& other, const juce_wchar passwordChar) - { - if (other.atoms.size() > 0) - { - int i = 0; - - if (auto* lastAtom = atoms.getLast()) - { - if (! CharacterFunctions::isWhitespace (lastAtom->atomText.getLastCharacter())) - { - auto* first = other.atoms.getUnchecked(0); - - if (! CharacterFunctions::isWhitespace (first->atomText[0])) - { - lastAtom->atomText += first->atomText; - lastAtom->numChars = (uint16) (lastAtom->numChars + first->numChars); - lastAtom->width = font.getStringWidthFloat (lastAtom->getText (passwordChar)); - delete first; - ++i; - } - } - } - - atoms.ensureStorageAllocated (atoms.size() + other.atoms.size() - i); - - while (i < other.atoms.size()) - { - atoms.add (other.atoms.getUnchecked(i)); - ++i; - } - - other.atoms.clear (false); - } - } - - UniformTextSection* split (const int indexToBreakAt, const juce_wchar passwordChar) - { - UniformTextSection* const section2 = new UniformTextSection (String(), font, colour, passwordChar); - int index = 0; - - for (int i = 0; i < atoms.size(); ++i) - { - auto* atom = atoms.getUnchecked(i); - auto nextIndex = index + atom->numChars; - - if (index == indexToBreakAt) - { - for (int j = i; j < atoms.size(); ++j) - section2->atoms.add (atoms.getUnchecked (j)); - - atoms.removeRange (i, atoms.size(), false); - break; - } - else if (indexToBreakAt >= index && indexToBreakAt < nextIndex) - { - auto* secondAtom = new TextAtom(); - - secondAtom->atomText = atom->atomText.substring (indexToBreakAt - index); - secondAtom->width = font.getStringWidthFloat (secondAtom->getText (passwordChar)); - secondAtom->numChars = (uint16) secondAtom->atomText.length(); - - section2->atoms.add (secondAtom); - - atom->atomText = atom->atomText.substring (0, indexToBreakAt - index); - atom->width = font.getStringWidthFloat (atom->getText (passwordChar)); - atom->numChars = (uint16) (indexToBreakAt - index); - - for (int j = i + 1; j < atoms.size(); ++j) - section2->atoms.add (atoms.getUnchecked (j)); - - atoms.removeRange (i + 1, atoms.size(), false); - break; - } - - index = nextIndex; - } - - return section2; - } - - void appendAllText (MemoryOutputStream& mo) const - { - for (int i = 0; i < atoms.size(); ++i) - mo << atoms.getUnchecked(i)->atomText; - } - - void appendSubstring (MemoryOutputStream& mo, const Range range) const - { - int index = 0; - - for (auto* atom : atoms) - { - auto nextIndex = index + atom->numChars; - - if (range.getStart() < nextIndex) - { - if (range.getEnd() <= index) - break; - - auto r = (range - index).getIntersectionWith (Range (0, (int) atom->numChars)); - - if (! r.isEmpty()) - mo << atom->atomText.substring (r.getStart(), r.getEnd()); - } - - index = nextIndex; - } - } - - int getTotalLength() const noexcept - { - int total = 0; - - for (auto* atom : atoms) - total += atom->numChars; - - return total; - } - - void setFont (const Font& newFont, const juce_wchar passwordChar) - { - if (font != newFont) - { - font = newFont; - - for (auto* atom : atoms) - atom->width = newFont.getStringWidthFloat (atom->getText (passwordChar)); - } - } - - //============================================================================== - Font font; - Colour colour; - OwnedArray atoms; - -private: - void initialiseAtoms (const String& textToParse, const juce_wchar passwordChar) - { - auto text = textToParse.getCharPointer(); - - while (! text.isEmpty()) - { - size_t numChars = 0; - auto start = text; - - // create a whitespace atom unless it starts with non-ws - if (text.isWhitespace() && *text != '\r' && *text != '\n') - { - do - { - ++text; - ++numChars; - } - while (text.isWhitespace() && *text != '\r' && *text != '\n'); - } - else - { - if (*text == '\r') - { - ++text; - ++numChars; - - if (*text == '\n') - { - ++start; - ++text; - } - } - else if (*text == '\n') - { - ++text; - ++numChars; - } - else - { - while (! (text.isEmpty() || text.isWhitespace())) - { - ++text; - ++numChars; - } - } - } - - auto* atom = atoms.add (new TextAtom()); - - atom->atomText = String (start, numChars); - atom->width = font.getStringWidthFloat (atom->getText (passwordChar)); - atom->numChars = (uint16) numChars; - } - } - - UniformTextSection& operator= (const UniformTextSection&); - JUCE_LEAK_DETECTOR (UniformTextSection) -}; - -//============================================================================== -class TextEditor::Iterator -{ -public: - Iterator (const OwnedArray& sectionList, - float wrapWidth, juce_wchar passwordChar, float spacing) - : sections (sectionList), - wordWrapWidth (wrapWidth), - passwordCharacter (passwordChar), - lineSpacing (spacing) - { - jassert (wordWrapWidth > 0); - - if (sections.size() > 0) - { - currentSection = sections.getUnchecked (sectionIndex); - - if (currentSection != nullptr) - beginNewLine(); - } - } - - Iterator (const Iterator& other) - : indexInText (other.indexInText), - lineY (other.lineY), - lineHeight (other.lineHeight), - maxDescent (other.maxDescent), - atomX (other.atomX), - atomRight (other.atomRight), - atom (other.atom), - currentSection (other.currentSection), - sections (other.sections), - sectionIndex (other.sectionIndex), - atomIndex (other.atomIndex), - wordWrapWidth (other.wordWrapWidth), - passwordCharacter (other.passwordCharacter), - lineSpacing (other.lineSpacing), - tempAtom (other.tempAtom) - { - } - - //============================================================================== - bool next() - { - if (atom == &tempAtom) - { - const int numRemaining = tempAtom.atomText.length() - tempAtom.numChars; - - if (numRemaining > 0) - { - tempAtom.atomText = tempAtom.atomText.substring (tempAtom.numChars); - - atomX = 0; - - if (tempAtom.numChars > 0) - lineY += lineHeight * lineSpacing; - - indexInText += tempAtom.numChars; - - GlyphArrangement g; - g.addLineOfText (currentSection->font, atom->getText (passwordCharacter), 0.0f, 0.0f); - - int split; - for (split = 0; split < g.getNumGlyphs(); ++split) - if (shouldWrap (g.getGlyph (split).getRight())) - break; - - if (split > 0 && split <= numRemaining) - { - tempAtom.numChars = (uint16) split; - tempAtom.width = g.getGlyph (split - 1).getRight(); - atomRight = atomX + tempAtom.width; - return true; - } - } - } - - if (sectionIndex >= sections.size()) - { - moveToEndOfLastAtom(); - return false; - } - - bool forceNewLine = false; - - if (atomIndex >= currentSection->atoms.size() - 1) - { - if (atomIndex >= currentSection->atoms.size()) - { - if (++sectionIndex >= sections.size()) - { - moveToEndOfLastAtom(); - return false; - } - - atomIndex = 0; - currentSection = sections.getUnchecked (sectionIndex); - } - else - { - auto* lastAtom = currentSection->atoms.getUnchecked (atomIndex); - - if (! lastAtom->isWhitespace()) - { - // handle the case where the last atom in a section is actually part of the same - // word as the first atom of the next section... - float right = atomRight + lastAtom->width; - float lineHeight2 = lineHeight; - float maxDescent2 = maxDescent; - - for (int section = sectionIndex + 1; section < sections.size(); ++section) - { - auto* s = sections.getUnchecked (section); - - if (s->atoms.size() == 0) - break; - - auto* nextAtom = s->atoms.getUnchecked (0); - - if (nextAtom->isWhitespace()) - break; - - right += nextAtom->width; - - lineHeight2 = jmax (lineHeight2, s->font.getHeight()); - maxDescent2 = jmax (maxDescent2, s->font.getDescent()); - - if (shouldWrap (right)) - { - lineHeight = lineHeight2; - maxDescent = maxDescent2; - - forceNewLine = true; - break; - } - - if (s->atoms.size() > 1) - break; - } - } - } - } - - if (atom != nullptr) - { - atomX = atomRight; - indexInText += atom->numChars; - - if (atom->isNewLine()) - beginNewLine(); - } - - atom = currentSection->atoms.getUnchecked (atomIndex); - atomRight = atomX + atom->width; - ++atomIndex; - - if (shouldWrap (atomRight) || forceNewLine) - { - if (atom->isWhitespace()) - { - // leave whitespace at the end of a line, but truncate it to avoid scrolling - atomRight = jmin (atomRight, wordWrapWidth); - } - else - { - atomRight = atom->width; - - if (shouldWrap (atomRight)) // atom too big to fit on a line, so break it up.. - { - tempAtom = *atom; - tempAtom.width = 0; - tempAtom.numChars = 0; - atom = &tempAtom; - - if (atomX > 0) - beginNewLine(); - - return next(); - } - - beginNewLine(); - return true; - } - } - - return true; - } - - void beginNewLine() - { - atomX = 0; - lineY += lineHeight * lineSpacing; - - int tempSectionIndex = sectionIndex; - int tempAtomIndex = atomIndex; - auto* section = sections.getUnchecked (tempSectionIndex); - - lineHeight = section->font.getHeight(); - maxDescent = section->font.getDescent(); - - float x = (atom != nullptr) ? atom->width : 0; - - while (! shouldWrap (x)) - { - if (tempSectionIndex >= sections.size()) - break; - - bool checkSize = false; - - if (tempAtomIndex >= section->atoms.size()) - { - if (++tempSectionIndex >= sections.size()) - break; - - tempAtomIndex = 0; - section = sections.getUnchecked (tempSectionIndex); - checkSize = true; - } - - auto* nextAtom = section->atoms.getUnchecked (tempAtomIndex); - - if (nextAtom == nullptr) - break; - - x += nextAtom->width; - - if (shouldWrap (x) || nextAtom->isNewLine()) - break; - - if (checkSize) - { - lineHeight = jmax (lineHeight, section->font.getHeight()); - maxDescent = jmax (maxDescent, section->font.getDescent()); - } - - ++tempAtomIndex; - } - } - - //============================================================================== - void draw (Graphics& g, const UniformTextSection*& lastSection) const - { - if (passwordCharacter != 0 || ! atom->isWhitespace()) - { - if (lastSection != currentSection) - { - lastSection = currentSection; - g.setColour (currentSection->colour); - g.setFont (currentSection->font); - } - - jassert (atom->getTrimmedText (passwordCharacter).isNotEmpty()); - - GlyphArrangement ga; - ga.addLineOfText (currentSection->font, - atom->getTrimmedText (passwordCharacter), - atomX, (float) roundToInt (lineY + lineHeight - maxDescent)); - ga.draw (g); - } - } - - void addSelection (RectangleList& area, const Range selected) const - { - const float startX = indexToX (selected.getStart()); - const float endX = indexToX (selected.getEnd()); - - area.add (startX, lineY, endX - startX, lineHeight * lineSpacing); - } - - void drawUnderline (Graphics& g, const Range underline, const Colour colour) const - { - const int startX = roundToInt (indexToX (underline.getStart())); - const int endX = roundToInt (indexToX (underline.getEnd())); - const int baselineY = roundToInt (lineY + currentSection->font.getAscent() + 0.5f); - - Graphics::ScopedSaveState state (g); - g.reduceClipRegion (Rectangle (startX, baselineY, endX - startX, 1)); - g.fillCheckerBoard (Rectangle (endX, baselineY + 1), 3, 1, colour, Colours::transparentBlack); - } - - void drawSelectedText (Graphics& g, - const Range selected, - const Colour selectedTextColour) const - { - if (passwordCharacter != 0 || ! atom->isWhitespace()) - { - GlyphArrangement ga; - ga.addLineOfText (currentSection->font, - atom->getTrimmedText (passwordCharacter), - atomX, (float) roundToInt (lineY + lineHeight - maxDescent)); - - if (selected.getEnd() < indexInText + atom->numChars) - { - GlyphArrangement ga2 (ga); - ga2.removeRangeOfGlyphs (0, selected.getEnd() - indexInText); - ga.removeRangeOfGlyphs (selected.getEnd() - indexInText, -1); - - g.setColour (currentSection->colour); - ga2.draw (g); - } - - if (selected.getStart() > indexInText) - { - GlyphArrangement ga2 (ga); - ga2.removeRangeOfGlyphs (selected.getStart() - indexInText, -1); - ga.removeRangeOfGlyphs (0, selected.getStart() - indexInText); - - g.setColour (currentSection->colour); - ga2.draw (g); - } - - g.setColour (selectedTextColour); - ga.draw (g); - } - } - - //============================================================================== - float indexToX (const int indexToFind) const - { - if (indexToFind <= indexInText) - return atomX; - - if (indexToFind >= indexInText + atom->numChars) - return atomRight; - - GlyphArrangement g; - g.addLineOfText (currentSection->font, - atom->getText (passwordCharacter), - atomX, 0.0f); - - if (indexToFind - indexInText >= g.getNumGlyphs()) - return atomRight; - - return jmin (atomRight, g.getGlyph (indexToFind - indexInText).getLeft()); - } - - int xToIndex (const float xToFind) const - { - if (xToFind <= atomX || atom->isNewLine()) - return indexInText; - - if (xToFind >= atomRight) - return indexInText + atom->numChars; - - GlyphArrangement g; - g.addLineOfText (currentSection->font, - atom->getText (passwordCharacter), - atomX, 0.0f); - - const int numGlyphs = g.getNumGlyphs(); - - int j; - for (j = 0; j < numGlyphs; ++j) - { - auto& pg = g.getGlyph(j); - - if ((pg.getLeft() + pg.getRight()) / 2 > xToFind) - break; - } - - return indexInText + j; - } - - //============================================================================== - bool getCharPosition (const int index, float& cx, float& cy, float& lineHeightFound) - { - while (next()) - { - if (indexInText + atom->numChars > index) - { - cx = indexToX (index); - cy = lineY; - lineHeightFound = lineHeight; - return true; - } - } - - cx = atomX; - cy = lineY; - lineHeightFound = lineHeight; - return false; - } - - //============================================================================== - int indexInText = 0; - float lineY = 0, lineHeight = 0, maxDescent = 0; - float atomX = 0, atomRight = 0; - const TextAtom* atom = nullptr; - const UniformTextSection* currentSection = nullptr; - -private: - const OwnedArray& sections; - int sectionIndex = 0, atomIndex = 0; - const float wordWrapWidth; - const juce_wchar passwordCharacter; - const float lineSpacing; - TextAtom tempAtom; - - Iterator& operator= (const Iterator&) = delete; - - void moveToEndOfLastAtom() - { - if (atom != nullptr) - { - atomX = atomRight; - - if (atom->isNewLine()) - { - atomX = 0.0f; - lineY += lineHeight * lineSpacing; - } - } - } - - bool shouldWrap (const float x) const noexcept - { - return (x - 0.0001f) >= wordWrapWidth; - } - - JUCE_LEAK_DETECTOR (Iterator) -}; - - -//============================================================================== -class TextEditor::InsertAction : public UndoableAction -{ -public: - InsertAction (TextEditor& ed, - const String& newText, - const int insertPos, - const Font& newFont, - const Colour newColour, - const int oldCaret, - const int newCaret) - : owner (ed), - text (newText), - insertIndex (insertPos), - oldCaretPos (oldCaret), - newCaretPos (newCaret), - font (newFont), - colour (newColour) - { - } - - bool perform() override - { - owner.insert (text, insertIndex, font, colour, 0, newCaretPos); - return true; - } - - bool undo() override - { - owner.remove (Range (insertIndex, insertIndex + text.length()), 0, oldCaretPos); - return true; - } - - int getSizeInUnits() override - { - return text.length() + 16; - } - -private: - TextEditor& owner; - const String text; - const int insertIndex, oldCaretPos, newCaretPos; - const Font font; - const Colour colour; - - JUCE_DECLARE_NON_COPYABLE (InsertAction) -}; - -//============================================================================== -class TextEditor::RemoveAction : public UndoableAction -{ -public: - RemoveAction (TextEditor& ed, - const Range rangeToRemove, - const int oldCaret, - const int newCaret, - const Array& oldSections) - : owner (ed), - range (rangeToRemove), - oldCaretPos (oldCaret), - newCaretPos (newCaret) - { - removedSections.addArray (oldSections); - } - - bool perform() override - { - owner.remove (range, 0, newCaretPos); - return true; - } - - bool undo() override - { - owner.reinsert (range.getStart(), removedSections); - owner.moveCaretTo (oldCaretPos, false); - return true; - } - - int getSizeInUnits() override - { - int n = 16; - - for (auto* s : removedSections) - n += s->getTotalLength(); - - return n; - } - -private: - TextEditor& owner; - const Range range; - const int oldCaretPos, newCaretPos; - OwnedArray removedSections; - - JUCE_DECLARE_NON_COPYABLE (RemoveAction) -}; - -//============================================================================== -class TextEditor::TextHolderComponent : public Component, - public Timer, - public Value::Listener -{ -public: - TextHolderComponent (TextEditor& ed) : owner (ed) - { - setWantsKeyboardFocus (false); - setInterceptsMouseClicks (false, true); - setMouseCursor (MouseCursor::ParentCursor); - - owner.getTextValue().addListener (this); - } - - ~TextHolderComponent() - { - owner.getTextValue().removeListener (this); - } - - void paint (Graphics& g) override - { - owner.drawContent (g); - } - - void restartTimer() - { - startTimer (350); - } - - void timerCallback() override - { - owner.timerCallbackInt(); - } - - void valueChanged (Value&) override - { - owner.textWasChangedByValue(); - } - -private: - TextEditor& owner; - - JUCE_DECLARE_NON_COPYABLE (TextHolderComponent) -}; - -//============================================================================== -class TextEditorViewport : public Viewport -{ -public: - TextEditorViewport (TextEditor& ed) : owner (ed) {} - - void visibleAreaChanged (const Rectangle&) override - { - if (! rentrant) // it's rare, but possible to get into a feedback loop as the viewport's scrollbars - // appear and disappear, causing the wrap width to change. - { - const float wordWrapWidth = owner.getWordWrapWidth(); - - if (wordWrapWidth != lastWordWrapWidth) - { - lastWordWrapWidth = wordWrapWidth; - - rentrant = true; - owner.updateTextHolderSize(); - rentrant = false; - } - } - } - -private: - TextEditor& owner; - float lastWordWrapWidth = 0; - bool rentrant = false; - - JUCE_DECLARE_NON_COPYABLE (TextEditorViewport) -}; - -//============================================================================== -namespace TextEditorDefs -{ - const int textChangeMessageId = 0x10003001; - const int returnKeyMessageId = 0x10003002; - const int escapeKeyMessageId = 0x10003003; - const int focusLossMessageId = 0x10003004; - - const int maxActionsPerTransaction = 100; - - static int getCharacterCategory (const juce_wchar character) - { - return CharacterFunctions::isLetterOrDigit (character) - ? 2 : (CharacterFunctions::isWhitespace (character) ? 0 : 1); - } -} - -//============================================================================== -TextEditor::TextEditor (const String& name, juce_wchar passwordChar) - : Component (name), - passwordCharacter (passwordChar) -{ - setMouseCursor (MouseCursor::IBeamCursor); - - addAndMakeVisible (viewport = new TextEditorViewport (*this)); - viewport->setViewedComponent (textHolder = new TextHolderComponent (*this)); - viewport->setWantsKeyboardFocus (false); - viewport->setScrollBarsShown (false, false); - - setWantsKeyboardFocus (true); - recreateCaret(); -} - -TextEditor::~TextEditor() -{ - if (wasFocused) - if (auto* peer = getPeer()) - peer->dismissPendingTextInput(); - - textValue.removeListener (textHolder); - textValue.referTo (Value()); - - viewport = nullptr; - textHolder = nullptr; -} - -//============================================================================== -void TextEditor::newTransaction() -{ - lastTransactionTime = Time::getApproximateMillisecondCounter(); - undoManager.beginNewTransaction(); -} - -bool TextEditor::undoOrRedo (const bool shouldUndo) -{ - if (! isReadOnly()) - { - newTransaction(); - - if (shouldUndo ? undoManager.undo() - : undoManager.redo()) - { - scrollToMakeSureCursorIsVisible(); - repaint(); - textChanged(); - return true; - } - } - - return false; -} - -bool TextEditor::undo() { return undoOrRedo (true); } -bool TextEditor::redo() { return undoOrRedo (false); } - -//============================================================================== -void TextEditor::setMultiLine (const bool shouldBeMultiLine, - const bool shouldWordWrap) -{ - if (multiline != shouldBeMultiLine - || wordWrap != (shouldWordWrap && shouldBeMultiLine)) - { - multiline = shouldBeMultiLine; - wordWrap = shouldWordWrap && shouldBeMultiLine; - - viewport->setScrollBarsShown (scrollbarVisible && multiline, - scrollbarVisible && multiline); - viewport->setViewPosition (0, 0); - resized(); - scrollToMakeSureCursorIsVisible(); - } -} - -bool TextEditor::isMultiLine() const -{ - return multiline; -} - -void TextEditor::setScrollbarsShown (bool shown) -{ - if (scrollbarVisible != shown) - { - scrollbarVisible = shown; - shown = shown && isMultiLine(); - viewport->setScrollBarsShown (shown, shown); - } -} - -void TextEditor::setReadOnly (const bool shouldBeReadOnly) -{ - if (readOnly != shouldBeReadOnly) - { - readOnly = shouldBeReadOnly; - enablementChanged(); - } -} - -bool TextEditor::isReadOnly() const noexcept -{ - return readOnly || ! isEnabled(); -} - -bool TextEditor::isTextInputActive() const -{ - return ! isReadOnly(); -} - -void TextEditor::setReturnKeyStartsNewLine (const bool shouldStartNewLine) -{ - returnKeyStartsNewLine = shouldStartNewLine; -} - -void TextEditor::setTabKeyUsedAsCharacter (const bool shouldTabKeyBeUsed) -{ - tabKeyUsed = shouldTabKeyBeUsed; -} - -void TextEditor::setPopupMenuEnabled (const bool b) -{ - popupMenuEnabled = b; -} - -void TextEditor::setSelectAllWhenFocused (const bool b) -{ - selectAllTextWhenFocused = b; -} - -//============================================================================== -void TextEditor::setFont (const Font& newFont) -{ - currentFont = newFont; - scrollToMakeSureCursorIsVisible(); -} - -void TextEditor::applyFontToAllText (const Font& newFont, bool changeCurrentFont) -{ - if (changeCurrentFont) - currentFont = newFont; - - auto overallColour = findColour (textColourId); - - for (auto* uts : sections) - { - uts->setFont (newFont, passwordCharacter); - uts->colour = overallColour; - } - - coalesceSimilarSections(); - updateTextHolderSize(); - scrollToMakeSureCursorIsVisible(); - repaint(); -} - -void TextEditor::applyColourToAllText (const Colour& newColour, bool changeCurrentTextColour) -{ - for (auto* uts : sections) - uts->colour = newColour; - - if (changeCurrentTextColour) - setColour (TextEditor::textColourId, newColour); - else - repaint(); -} - -void TextEditor::lookAndFeelChanged() -{ - caret = nullptr; - recreateCaret(); - repaint(); -} - -void TextEditor::parentHierarchyChanged() -{ - lookAndFeelChanged(); -} - -void TextEditor::enablementChanged() -{ - recreateCaret(); - repaint(); -} - -void TextEditor::setCaretVisible (const bool shouldCaretBeVisible) -{ - if (caretVisible != shouldCaretBeVisible) - { - caretVisible = shouldCaretBeVisible; - recreateCaret(); - } -} - -void TextEditor::recreateCaret() -{ - if (isCaretVisible()) - { - if (caret == nullptr) - { - textHolder->addChildComponent (caret = getLookAndFeel().createCaretComponent (this)); - updateCaretPosition(); - } - } - else - { - caret = nullptr; - } -} - -void TextEditor::updateCaretPosition() -{ - if (caret != nullptr) - caret->setCaretPosition (getCaretRectangle().translated (leftIndent, topIndent)); -} - -TextEditor::LengthAndCharacterRestriction::LengthAndCharacterRestriction (int maxLen, const String& chars) - : allowedCharacters (chars), maxLength (maxLen) -{} - -String TextEditor::LengthAndCharacterRestriction::filterNewText (TextEditor& ed, const String& newInput) -{ - String t (newInput); - - if (allowedCharacters.isNotEmpty()) - t = t.retainCharacters (allowedCharacters); - - if (maxLength > 0) - t = t.substring (0, maxLength - (ed.getTotalNumChars() - ed.getHighlightedRegion().getLength())); - - return t; -} - -void TextEditor::setInputFilter (InputFilter* newFilter, bool takeOwnership) -{ - inputFilter.set (newFilter, takeOwnership); -} - -void TextEditor::setInputRestrictions (const int maxLen, const String& chars) -{ - setInputFilter (new LengthAndCharacterRestriction (maxLen, chars), true); -} - -void TextEditor::setTextToShowWhenEmpty (const String& text, Colour colourToUse) -{ - textToShowWhenEmpty = text; - colourForTextWhenEmpty = colourToUse; -} - -void TextEditor::setPasswordCharacter (const juce_wchar newPasswordCharacter) -{ - if (passwordCharacter != newPasswordCharacter) - { - passwordCharacter = newPasswordCharacter; - applyFontToAllText (currentFont); - } -} - -void TextEditor::setScrollBarThickness (const int newThicknessPixels) -{ - viewport->setScrollBarThickness (newThicknessPixels); -} - -//============================================================================== -void TextEditor::clear() -{ - clearInternal (nullptr); - updateTextHolderSize(); - undoManager.clearUndoHistory(); -} - -void TextEditor::setText (const String& newText, - const bool sendTextChangeMessage) -{ - const int newLength = newText.length(); - - if (newLength != getTotalNumChars() || getText() != newText) - { - if (! sendTextChangeMessage) - textValue.removeListener (textHolder); - - textValue = newText; - - auto oldCursorPos = caretPosition; - const bool cursorWasAtEnd = oldCursorPos >= getTotalNumChars(); - - clearInternal (nullptr); - insert (newText, 0, currentFont, findColour (textColourId), 0, caretPosition); - - // if you're adding text with line-feeds to a single-line text editor, it - // ain't gonna look right! - jassert (multiline || ! newText.containsAnyOf ("\r\n")); - - if (cursorWasAtEnd && ! isMultiLine()) - oldCursorPos = getTotalNumChars(); - - moveCaretTo (oldCursorPos, false); - - if (sendTextChangeMessage) - textChanged(); - else - textValue.addListener (textHolder); - - updateTextHolderSize(); - scrollToMakeSureCursorIsVisible(); - undoManager.clearUndoHistory(); - - repaint(); - } -} - -//============================================================================== -void TextEditor::updateValueFromText() -{ - if (valueTextNeedsUpdating) - { - valueTextNeedsUpdating = false; - textValue = getText(); - } -} - -Value& TextEditor::getTextValue() -{ - updateValueFromText(); - return textValue; -} - -void TextEditor::textWasChangedByValue() -{ - if (textValue.getValueSource().getReferenceCount() > 1) - setText (textValue.getValue()); -} - -//============================================================================== -void TextEditor::textChanged() -{ - updateTextHolderSize(); - - if (listeners.size() > 0) - postCommandMessage (TextEditorDefs::textChangeMessageId); - - if (textValue.getValueSource().getReferenceCount() > 1) - { - valueTextNeedsUpdating = false; - textValue = getText(); - } -} - -void TextEditor::returnPressed() { postCommandMessage (TextEditorDefs::returnKeyMessageId); } -void TextEditor::escapePressed() { postCommandMessage (TextEditorDefs::escapeKeyMessageId); } - -void TextEditor::addListener (Listener* l) { listeners.add (l); } -void TextEditor::removeListener (Listener* l) { listeners.remove (l); } - -//============================================================================== -void TextEditor::timerCallbackInt() -{ - if (hasKeyboardFocus (false) && ! isCurrentlyBlockedByAnotherModalComponent()) - wasFocused = true; - - auto now = Time::getApproximateMillisecondCounter(); - - if (now > lastTransactionTime + 200) - newTransaction(); -} - -void TextEditor::repaintText (const Range range) -{ - if (! range.isEmpty()) - { - float x = 0, y = 0, lh = currentFont.getHeight(); - - const float wordWrapWidth = getWordWrapWidth(); - - if (wordWrapWidth > 0) - { - Iterator i (sections, wordWrapWidth, passwordCharacter, lineSpacing); - - i.getCharPosition (range.getStart(), x, y, lh); - - auto y1 = (int) y; - int y2; - - if (range.getEnd() >= getTotalNumChars()) - { - y2 = textHolder->getHeight(); - } - else - { - i.getCharPosition (range.getEnd(), x, y, lh); - y2 = (int) (y + lh * 2.0f); - } - - textHolder->repaint (0, y1, textHolder->getWidth(), y2 - y1); - } - } -} - -//============================================================================== -void TextEditor::moveCaret (int newCaretPos) -{ - if (newCaretPos < 0) - newCaretPos = 0; - else - newCaretPos = jmin (newCaretPos, getTotalNumChars()); - - if (newCaretPos != getCaretPosition()) - { - caretPosition = newCaretPos; - textHolder->restartTimer(); - scrollToMakeSureCursorIsVisible(); - updateCaretPosition(); - } -} - -int TextEditor::getCaretPosition() const -{ - return caretPosition; -} - -void TextEditor::setCaretPosition (const int newIndex) -{ - moveCaretTo (newIndex, false); -} - -void TextEditor::moveCaretToEnd() -{ - moveCaretTo (std::numeric_limits::max(), false); -} - -void TextEditor::scrollEditorToPositionCaret (const int desiredCaretX, - const int desiredCaretY) - -{ - updateCaretPosition(); - auto caretPos = getCaretRectangle(); - - int vx = caretPos.getX() - desiredCaretX; - int vy = caretPos.getY() - desiredCaretY; - - if (desiredCaretX < jmax (1, proportionOfWidth (0.05f))) - vx += desiredCaretX - proportionOfWidth (0.2f); - else if (desiredCaretX > jmax (0, viewport->getMaximumVisibleWidth() - (wordWrap ? 2 : 10))) - vx += desiredCaretX + (isMultiLine() ? proportionOfWidth (0.2f) : 10) - viewport->getMaximumVisibleWidth(); - - vx = jlimit (0, jmax (0, textHolder->getWidth() + 8 - viewport->getMaximumVisibleWidth()), vx); - - if (! isMultiLine()) - { - vy = viewport->getViewPositionY(); - } - else - { - vy = jlimit (0, jmax (0, textHolder->getHeight() - viewport->getMaximumVisibleHeight()), vy); - - if (desiredCaretY < 0) - vy = jmax (0, desiredCaretY + vy); - else if (desiredCaretY > jmax (0, viewport->getMaximumVisibleHeight() - topIndent - caretPos.getHeight())) - vy += desiredCaretY + 2 + caretPos.getHeight() + topIndent - viewport->getMaximumVisibleHeight(); - } - - viewport->setViewPosition (vx, vy); -} - -Rectangle TextEditor::getCaretRectangle() -{ - float cursorX, cursorY; - float cursorHeight = currentFont.getHeight(); // (in case the text is empty and the call below doesn't set this value) - getCharPosition (caretPosition, cursorX, cursorY, cursorHeight); - - return { roundToInt (cursorX), roundToInt (cursorY), 2, roundToInt (cursorHeight) }; -} - -//============================================================================== -enum { rightEdgeSpace = 2 }; - -float TextEditor::getWordWrapWidth() const -{ - return wordWrap ? (float) (viewport->getMaximumVisibleWidth() - (leftIndent + rightEdgeSpace + 1)) - : std::numeric_limits::max(); -} - -void TextEditor::updateTextHolderSize() -{ - const float wordWrapWidth = getWordWrapWidth(); - - if (wordWrapWidth > 0) - { - float maxWidth = 0.0f; - - Iterator i (sections, wordWrapWidth, passwordCharacter, lineSpacing); - - while (i.next()) - maxWidth = jmax (maxWidth, i.atomRight); - - const int w = leftIndent + roundToInt (maxWidth); - const int h = topIndent + roundToInt (jmax (i.lineY + i.lineHeight, - currentFont.getHeight())); - - textHolder->setSize (w + rightEdgeSpace, h + 1); // (allows a bit of space for the cursor to be at the right-hand-edge) - } -} - -int TextEditor::getTextWidth() const { return textHolder->getWidth(); } -int TextEditor::getTextHeight() const { return textHolder->getHeight(); } - -void TextEditor::setIndents (const int newLeftIndent, const int newTopIndent) -{ - leftIndent = newLeftIndent; - topIndent = newTopIndent; -} - -void TextEditor::setBorder (const BorderSize& border) -{ - borderSize = border; - resized(); -} - -BorderSize TextEditor::getBorder() const -{ - return borderSize; -} - -void TextEditor::setScrollToShowCursor (const bool shouldScrollToShowCursor) -{ - keepCaretOnScreen = shouldScrollToShowCursor; -} - -void TextEditor::scrollToMakeSureCursorIsVisible() -{ - updateCaretPosition(); - - if (keepCaretOnScreen) - { - auto viewPos = viewport->getViewPosition(); - auto caretRect = getCaretRectangle(); - auto relativeCursor = caretRect.getPosition() - viewPos; - - if (relativeCursor.x < jmax (1, proportionOfWidth (0.05f))) - { - viewPos.x += relativeCursor.x - proportionOfWidth (0.2f); - } - else if (relativeCursor.x > jmax (0, viewport->getMaximumVisibleWidth() - (wordWrap ? 2 : 10))) - { - viewPos.x += relativeCursor.x + (isMultiLine() ? proportionOfWidth (0.2f) : 10) - viewport->getMaximumVisibleWidth(); - } - - viewPos.x = jlimit (0, jmax (0, textHolder->getWidth() + 8 - viewport->getMaximumVisibleWidth()), viewPos.x); - - if (! isMultiLine()) - { - viewPos.y = (getHeight() - textHolder->getHeight() - topIndent) / -2; - } - else if (relativeCursor.y < 0) - { - viewPos.y = jmax (0, relativeCursor.y + viewPos.y); - } - else if (relativeCursor.y > jmax (0, viewport->getMaximumVisibleHeight() - topIndent - caretRect.getHeight())) - { - viewPos.y += relativeCursor.y + 2 + caretRect.getHeight() + topIndent - viewport->getMaximumVisibleHeight(); - } - - viewport->setViewPosition (viewPos); - } -} - -void TextEditor::moveCaretTo (const int newPosition, const bool isSelecting) -{ - if (isSelecting) - { - moveCaret (newPosition); - - auto oldSelection = selection; - - if (dragType == notDragging) - { - if (std::abs (getCaretPosition() - selection.getStart()) < std::abs (getCaretPosition() - selection.getEnd())) - dragType = draggingSelectionStart; - else - dragType = draggingSelectionEnd; - } - - if (dragType == draggingSelectionStart) - { - if (getCaretPosition() >= selection.getEnd()) - dragType = draggingSelectionEnd; - - selection = Range::between (getCaretPosition(), selection.getEnd()); - } - else - { - if (getCaretPosition() < selection.getStart()) - dragType = draggingSelectionStart; - - selection = Range::between (getCaretPosition(), selection.getStart()); - } - - repaintText (selection.getUnionWith (oldSelection)); - } - else - { - dragType = notDragging; - - repaintText (selection); - - moveCaret (newPosition); - selection = Range::emptyRange (getCaretPosition()); - } -} - -int TextEditor::getTextIndexAt (const int x, const int y) -{ - return indexAtPosition ((float) (x + viewport->getViewPositionX() - leftIndent - borderSize.getLeft()), - (float) (y + viewport->getViewPositionY() - topIndent - borderSize.getTop())); -} - -void TextEditor::insertTextAtCaret (const String& t) -{ - String newText (inputFilter != nullptr ? inputFilter->filterNewText (*this, t) : t); - - if (isMultiLine()) - newText = newText.replace ("\r\n", "\n"); - else - newText = newText.replaceCharacters ("\r\n", " "); - - const int insertIndex = selection.getStart(); - const int newCaretPos = insertIndex + newText.length(); - - remove (selection, getUndoManager(), - newText.isNotEmpty() ? newCaretPos - 1 : newCaretPos); - - insert (newText, insertIndex, currentFont, findColour (textColourId), - getUndoManager(), newCaretPos); - - textChanged(); -} - -void TextEditor::setHighlightedRegion (const Range& newSelection) -{ - moveCaretTo (newSelection.getStart(), false); - moveCaretTo (newSelection.getEnd(), true); -} - -//============================================================================== -void TextEditor::copy() -{ - if (passwordCharacter == 0) - { - auto selectedText = getHighlightedText(); - - if (selectedText.isNotEmpty()) - SystemClipboard::copyTextToClipboard (selectedText); - } -} - -void TextEditor::paste() -{ - if (! isReadOnly()) - { - auto clip = SystemClipboard::getTextFromClipboard(); - - if (clip.isNotEmpty()) - insertTextAtCaret (clip); - } -} - -void TextEditor::cut() -{ - if (! isReadOnly()) - { - moveCaret (selection.getEnd()); - insertTextAtCaret (String()); - } -} - -//============================================================================== -void TextEditor::drawContent (Graphics& g) -{ - const float wordWrapWidth = getWordWrapWidth(); - - if (wordWrapWidth > 0) - { - g.setOrigin (leftIndent, topIndent); - auto clip = g.getClipBounds(); - Colour selectedTextColour; - - Iterator i (sections, wordWrapWidth, passwordCharacter, lineSpacing); - - if (! selection.isEmpty()) - { - Iterator i2 (i); - RectangleList selectionArea; - - while (i2.next() && i2.lineY < clip.getBottom()) - { - if (i2.lineY + i2.lineHeight >= clip.getY() - && selection.intersects (Range (i2.indexInText, i2.indexInText + i2.atom->numChars))) - { - i2.addSelection (selectionArea, selection); - } - } - - g.setColour (findColour (highlightColourId).withMultipliedAlpha (hasKeyboardFocus (true) ? 1.0f : 0.5f)); - g.fillRectList (selectionArea); - - selectedTextColour = findColour (highlightedTextColourId); - } - - const UniformTextSection* lastSection = nullptr; - - while (i.next() && i.lineY < clip.getBottom()) - { - if (i.lineY + i.lineHeight >= clip.getY()) - { - if (selection.intersects (Range (i.indexInText, i.indexInText + i.atom->numChars))) - { - i.drawSelectedText (g, selection, selectedTextColour); - lastSection = nullptr; - } - else - { - i.draw (g, lastSection); - } - } - } - - for (int j = underlinedSections.size(); --j >= 0;) - { - const Range underlinedSection = underlinedSections.getReference (j); - - Iterator i2 (sections, wordWrapWidth, passwordCharacter, lineSpacing); - - while (i2.next() && i2.lineY < clip.getBottom()) - { - if (i2.lineY + i2.lineHeight >= clip.getY() - && underlinedSection.intersects (Range (i2.indexInText, i2.indexInText + i2.atom->numChars))) - { - i2.drawUnderline (g, underlinedSection, findColour (textColourId)); - } - } - } - } -} - -void TextEditor::paint (Graphics& g) -{ - getLookAndFeel().fillTextEditorBackground (g, getWidth(), getHeight(), *this); -} - -void TextEditor::paintOverChildren (Graphics& g) -{ - if (textToShowWhenEmpty.isNotEmpty() - && (! hasKeyboardFocus (false)) - && getTotalNumChars() == 0) - { - g.setColour (colourForTextWhenEmpty); - g.setFont (getFont()); - - if (isMultiLine()) - g.drawText (textToShowWhenEmpty, getLocalBounds(), - Justification::centred, true); - else - g.drawText (textToShowWhenEmpty, - leftIndent, 0, viewport->getWidth() - leftIndent, getHeight(), - Justification::centredLeft, true); - } - - getLookAndFeel().drawTextEditorOutline (g, getWidth(), getHeight(), *this); -} - -//============================================================================== -void TextEditor::addPopupMenuItems (PopupMenu& m, const MouseEvent*) -{ - const bool writable = ! isReadOnly(); - - if (passwordCharacter == 0) - { - m.addItem (StandardApplicationCommandIDs::cut, TRANS("Cut"), writable); - m.addItem (StandardApplicationCommandIDs::copy, TRANS("Copy"), ! selection.isEmpty()); - } - - m.addItem (StandardApplicationCommandIDs::paste, TRANS("Paste"), writable); - m.addItem (StandardApplicationCommandIDs::del, TRANS("Delete"), writable); - m.addSeparator(); - m.addItem (StandardApplicationCommandIDs::selectAll, TRANS("Select All")); - m.addSeparator(); - - if (getUndoManager() != nullptr) - { - m.addItem (StandardApplicationCommandIDs::undo, TRANS("Undo"), undoManager.canUndo()); - m.addItem (StandardApplicationCommandIDs::redo, TRANS("Redo"), undoManager.canRedo()); - } -} - -void TextEditor::performPopupMenuAction (const int menuItemID) -{ - switch (menuItemID) - { - case StandardApplicationCommandIDs::cut: cutToClipboard(); break; - case StandardApplicationCommandIDs::copy: copyToClipboard(); break; - case StandardApplicationCommandIDs::paste: pasteFromClipboard(); break; - case StandardApplicationCommandIDs::del: cut(); break; - case StandardApplicationCommandIDs::selectAll: selectAll(); break; - case StandardApplicationCommandIDs::undo: undo(); break; - case StandardApplicationCommandIDs::redo: redo(); break; - default: break; - } -} - -static void textEditorMenuCallback (int menuResult, TextEditor* editor) -{ - if (editor != nullptr && menuResult != 0) - editor->performPopupMenuAction (menuResult); -} - -//============================================================================== -void TextEditor::mouseDown (const MouseEvent& e) -{ - beginDragAutoRepeat (100); - newTransaction(); - - if (wasFocused || ! selectAllTextWhenFocused) - { - if (! (popupMenuEnabled && e.mods.isPopupMenu())) - { - moveCaretTo (getTextIndexAt (e.x, e.y), - e.mods.isShiftDown()); - } - else - { - PopupMenu m; - m.setLookAndFeel (&getLookAndFeel()); - addPopupMenuItems (m, &e); - - m.showMenuAsync (PopupMenu::Options(), - ModalCallbackFunction::forComponent (textEditorMenuCallback, this)); - } - } -} - -void TextEditor::mouseDrag (const MouseEvent& e) -{ - if (wasFocused || ! selectAllTextWhenFocused) - if (! (popupMenuEnabled && e.mods.isPopupMenu())) - moveCaretTo (getTextIndexAt (e.x, e.y), true); -} - -void TextEditor::mouseUp (const MouseEvent& e) -{ - newTransaction(); - textHolder->restartTimer(); - - if (wasFocused || ! selectAllTextWhenFocused) - if (e.mouseWasClicked() && ! (popupMenuEnabled && e.mods.isPopupMenu())) - moveCaret (getTextIndexAt (e.x, e.y)); - - wasFocused = true; -} - -void TextEditor::mouseDoubleClick (const MouseEvent& e) -{ - int tokenEnd = getTextIndexAt (e.x, e.y); - int tokenStart = 0; - - if (e.getNumberOfClicks() > 3) - { - tokenEnd = getTotalNumChars(); - } - else - { - auto t = getText(); - auto totalLength = getTotalNumChars(); - - while (tokenEnd < totalLength) - { - // (note the slight bodge here - it's because iswalnum only checks for alphabetic chars in the current locale) - const juce_wchar c = t [tokenEnd]; - if (CharacterFunctions::isLetterOrDigit (c) || c > 128) - ++tokenEnd; - else - break; - } - - tokenStart = tokenEnd; - - while (tokenStart > 0) - { - // (note the slight bodge here - it's because iswalnum only checks for alphabetic chars in the current locale) - const juce_wchar c = t [tokenStart - 1]; - if (CharacterFunctions::isLetterOrDigit (c) || c > 128) - --tokenStart; - else - break; - } - - if (e.getNumberOfClicks() > 2) - { - while (tokenEnd < totalLength) - { - const juce_wchar c = t [tokenEnd]; - if (c != '\r' && c != '\n') - ++tokenEnd; - else - break; - } - - while (tokenStart > 0) - { - const juce_wchar c = t [tokenStart - 1]; - if (c != '\r' && c != '\n') - --tokenStart; - else - break; - } - } - } - - moveCaretTo (tokenEnd, false); - moveCaretTo (tokenStart, true); -} - -void TextEditor::mouseWheelMove (const MouseEvent& e, const MouseWheelDetails& wheel) -{ - if (! viewport->useMouseWheelMoveIfNeeded (e, wheel)) - Component::mouseWheelMove (e, wheel); -} - -//============================================================================== -bool TextEditor::moveCaretWithTransaction (const int newPos, const bool selecting) -{ - newTransaction(); - moveCaretTo (newPos, selecting); - return true; -} - -bool TextEditor::moveCaretLeft (bool moveInWholeWordSteps, bool selecting) -{ - int pos = getCaretPosition(); - - if (moveInWholeWordSteps) - pos = findWordBreakBefore (pos); - else - --pos; - - return moveCaretWithTransaction (pos, selecting); -} - -bool TextEditor::moveCaretRight (bool moveInWholeWordSteps, bool selecting) -{ - int pos = getCaretPosition(); - - if (moveInWholeWordSteps) - pos = findWordBreakAfter (pos); - else - ++pos; - - return moveCaretWithTransaction (pos, selecting); -} - -bool TextEditor::moveCaretUp (bool selecting) -{ - if (! isMultiLine()) - return moveCaretToStartOfLine (selecting); - - auto caretPos = getCaretRectangle().toFloat(); - return moveCaretWithTransaction (indexAtPosition (caretPos.getX(), caretPos.getY() - 1.0f), selecting); -} - -bool TextEditor::moveCaretDown (bool selecting) -{ - if (! isMultiLine()) - return moveCaretToEndOfLine (selecting); - - auto caretPos = getCaretRectangle().toFloat(); - return moveCaretWithTransaction (indexAtPosition (caretPos.getX(), caretPos.getBottom() + 1.0f), selecting); -} - -bool TextEditor::pageUp (bool selecting) -{ - if (! isMultiLine()) - return moveCaretToStartOfLine (selecting); - - auto caretPos = getCaretRectangle().toFloat(); - return moveCaretWithTransaction (indexAtPosition (caretPos.getX(), caretPos.getY() - viewport->getViewHeight()), selecting); -} - -bool TextEditor::pageDown (bool selecting) -{ - if (! isMultiLine()) - return moveCaretToEndOfLine (selecting); - - auto caretPos = getCaretRectangle().toFloat(); - return moveCaretWithTransaction (indexAtPosition (caretPos.getX(), caretPos.getBottom() + viewport->getViewHeight()), selecting); -} - -void TextEditor::scrollByLines (int deltaLines) -{ - if (auto* scrollbar = viewport->getVerticalScrollBar()) - scrollbar->moveScrollbarInSteps (deltaLines); -} - -bool TextEditor::scrollDown() -{ - scrollByLines (-1); - return true; -} - -bool TextEditor::scrollUp() -{ - scrollByLines (1); - return true; -} - -bool TextEditor::moveCaretToTop (bool selecting) -{ - return moveCaretWithTransaction (0, selecting); -} - -bool TextEditor::moveCaretToStartOfLine (bool selecting) -{ - auto caretPos = getCaretRectangle().toFloat(); - return moveCaretWithTransaction (indexAtPosition (0.0f, caretPos.getY()), selecting); -} - -bool TextEditor::moveCaretToEnd (bool selecting) -{ - return moveCaretWithTransaction (getTotalNumChars(), selecting); -} - -bool TextEditor::moveCaretToEndOfLine (bool selecting) -{ - auto caretPos = getCaretRectangle().toFloat(); - return moveCaretWithTransaction (indexAtPosition ((float) textHolder->getWidth(), caretPos.getY()), selecting); -} - -bool TextEditor::deleteBackwards (bool moveInWholeWordSteps) -{ - if (moveInWholeWordSteps) - moveCaretTo (findWordBreakBefore (getCaretPosition()), true); - else if (selection.isEmpty() && selection.getStart() > 0) - selection = Range (selection.getEnd() - 1, selection.getEnd()); - - cut(); - return true; -} - -bool TextEditor::deleteForwards (bool /*moveInWholeWordSteps*/) -{ - if (selection.isEmpty() && selection.getStart() < getTotalNumChars()) - selection = Range (selection.getStart(), selection.getStart() + 1); - - cut(); - return true; -} - -bool TextEditor::copyToClipboard() -{ - newTransaction(); - copy(); - return true; -} - -bool TextEditor::cutToClipboard() -{ - newTransaction(); - copy(); - cut(); - return true; -} - -bool TextEditor::pasteFromClipboard() -{ - newTransaction(); - paste(); - return true; -} - -bool TextEditor::selectAll() -{ - newTransaction(); - moveCaretTo (getTotalNumChars(), false); - moveCaretTo (0, true); - return true; -} - -//============================================================================== -void TextEditor::setEscapeAndReturnKeysConsumed (bool shouldBeConsumed) noexcept -{ - consumeEscAndReturnKeys = shouldBeConsumed; -} - -bool TextEditor::keyPressed (const KeyPress& key) -{ - if (isReadOnly() && key != KeyPress ('c', ModifierKeys::commandModifier, 0) - && key != KeyPress ('a', ModifierKeys::commandModifier, 0)) - return false; - - if (! TextEditorKeyMapper::invokeKeyFunction (*this, key)) - { - if (key == KeyPress::returnKey) - { - newTransaction(); - - if (returnKeyStartsNewLine) - insertTextAtCaret ("\n"); - else - { - returnPressed(); - return consumeEscAndReturnKeys; - } - } - else if (key.isKeyCode (KeyPress::escapeKey)) - { - newTransaction(); - moveCaretTo (getCaretPosition(), false); - escapePressed(); - return consumeEscAndReturnKeys; - } - else if (key.getTextCharacter() >= ' ' - || (tabKeyUsed && (key.getTextCharacter() == '\t'))) - { - insertTextAtCaret (String::charToString (key.getTextCharacter())); - - lastTransactionTime = Time::getApproximateMillisecondCounter(); - } - else - { - return false; - } - } - - return true; -} - -bool TextEditor::keyStateChanged (const bool isKeyDown) -{ - if (! isKeyDown) - return false; - - #if JUCE_WINDOWS - if (KeyPress (KeyPress::F4Key, ModifierKeys::altModifier, 0).isCurrentlyDown()) - return false; // We need to explicitly allow alt-F4 to pass through on Windows - #endif - - if ((! consumeEscAndReturnKeys) - && (KeyPress (KeyPress::escapeKey).isCurrentlyDown() - || KeyPress (KeyPress::returnKey).isCurrentlyDown())) - return false; - - // (overridden to avoid forwarding key events to the parent) - return ! ModifierKeys::getCurrentModifiers().isCommandDown(); -} - -//============================================================================== -void TextEditor::focusGained (FocusChangeType) -{ - newTransaction(); - - if (selectAllTextWhenFocused) - { - moveCaretTo (0, false); - moveCaretTo (getTotalNumChars(), true); - } - - repaint(); - updateCaretPosition(); - - if (auto* peer = getPeer()) - if (! isReadOnly()) - peer->textInputRequired (peer->globalToLocal (getScreenPosition()), *this); -} - -void TextEditor::focusLost (FocusChangeType) -{ - newTransaction(); - - wasFocused = false; - textHolder->stopTimer(); - - underlinedSections.clear(); - - if (auto* peer = getPeer()) - peer->dismissPendingTextInput(); - - updateCaretPosition(); - - postCommandMessage (TextEditorDefs::focusLossMessageId); - repaint(); -} - -//============================================================================== -void TextEditor::resized() -{ - viewport->setBoundsInset (borderSize); - viewport->setSingleStepSizes (16, roundToInt (currentFont.getHeight())); - - updateTextHolderSize(); - - if (isMultiLine()) - updateCaretPosition(); - else - scrollToMakeSureCursorIsVisible(); -} - -void TextEditor::handleCommandMessage (const int commandId) -{ - Component::BailOutChecker checker (this); - - switch (commandId) - { - case TextEditorDefs::textChangeMessageId: - listeners.callChecked (checker, &Listener::textEditorTextChanged, (TextEditor&) *this); - break; - - case TextEditorDefs::returnKeyMessageId: - listeners.callChecked (checker, &Listener::textEditorReturnKeyPressed, (TextEditor&) *this); - break; - - case TextEditorDefs::escapeKeyMessageId: - listeners.callChecked (checker, &Listener::textEditorEscapeKeyPressed, (TextEditor&) *this); - break; - - case TextEditorDefs::focusLossMessageId: - updateValueFromText(); - listeners.callChecked (checker, &Listener::textEditorFocusLost, (TextEditor&) *this); - break; - - default: - jassertfalse; - break; - } -} - -void TextEditor::setTemporaryUnderlining (const Array >& newUnderlinedSections) -{ - underlinedSections = newUnderlinedSections; - repaint(); -} - -//============================================================================== -UndoManager* TextEditor::getUndoManager() noexcept -{ - return readOnly ? nullptr : &undoManager; -} - -void TextEditor::clearInternal (UndoManager* const um) -{ - remove (Range (0, getTotalNumChars()), um, caretPosition); -} - -void TextEditor::insert (const String& text, - const int insertIndex, - const Font& font, - const Colour colour, - UndoManager* const um, - const int caretPositionToMoveTo) -{ - if (text.isNotEmpty()) - { - if (um != nullptr) - { - if (um->getNumActionsInCurrentTransaction() > TextEditorDefs::maxActionsPerTransaction) - newTransaction(); - - um->perform (new InsertAction (*this, text, insertIndex, font, colour, - caretPosition, caretPositionToMoveTo)); - } - else - { - repaintText (Range (insertIndex, getTotalNumChars())); // must do this before and after changing the data, in case - // a line gets moved due to word wrap - - int index = 0; - int nextIndex = 0; - - for (int i = 0; i < sections.size(); ++i) - { - nextIndex = index + sections.getUnchecked (i)->getTotalLength(); - - if (insertIndex == index) - { - sections.insert (i, new UniformTextSection (text, font, colour, passwordCharacter)); - break; - } - else if (insertIndex > index && insertIndex < nextIndex) - { - splitSection (i, insertIndex - index); - sections.insert (i + 1, new UniformTextSection (text, font, colour, passwordCharacter)); - break; - } - - index = nextIndex; - } - - if (nextIndex == insertIndex) - sections.add (new UniformTextSection (text, font, colour, passwordCharacter)); - - coalesceSimilarSections(); - totalNumChars = -1; - valueTextNeedsUpdating = true; - - updateTextHolderSize(); - moveCaretTo (caretPositionToMoveTo, false); - - repaintText (Range (insertIndex, getTotalNumChars())); - } - } -} - -void TextEditor::reinsert (const int insertIndex, const OwnedArray& sectionsToInsert) -{ - int index = 0; - int nextIndex = 0; - - for (int i = 0; i < sections.size(); ++i) - { - nextIndex = index + sections.getUnchecked (i)->getTotalLength(); - - if (insertIndex == index) - { - for (int j = sectionsToInsert.size(); --j >= 0;) - sections.insert (i, new UniformTextSection (*sectionsToInsert.getUnchecked(j))); - - break; - } - else if (insertIndex > index && insertIndex < nextIndex) - { - splitSection (i, insertIndex - index); - - for (int j = sectionsToInsert.size(); --j >= 0;) - sections.insert (i + 1, new UniformTextSection (*sectionsToInsert.getUnchecked(j))); - - break; - } - - index = nextIndex; - } - - if (nextIndex == insertIndex) - { - for (int j = 0; j < sectionsToInsert.size(); ++j) - sections.add (new UniformTextSection (*sectionsToInsert.getUnchecked(j))); - } - - coalesceSimilarSections(); - totalNumChars = -1; - valueTextNeedsUpdating = true; -} - -void TextEditor::remove (Range range, UndoManager* const um, const int caretPositionToMoveTo) -{ - if (! range.isEmpty()) - { - int index = 0; - - for (int i = 0; i < sections.size(); ++i) - { - const int nextIndex = index + sections.getUnchecked(i)->getTotalLength(); - - if (range.getStart() > index && range.getStart() < nextIndex) - { - splitSection (i, range.getStart() - index); - --i; - } - else if (range.getEnd() > index && range.getEnd() < nextIndex) - { - splitSection (i, range.getEnd() - index); - --i; - } - else - { - index = nextIndex; - - if (index > range.getEnd()) - break; - } - } - - index = 0; - - if (um != nullptr) - { - Array removedSections; - - for (int i = 0; i < sections.size(); ++i) - { - if (range.getEnd() <= range.getStart()) - break; - - auto* section = sections.getUnchecked (i); - auto nextIndex = index + section->getTotalLength(); - - if (range.getStart() <= index && range.getEnd() >= nextIndex) - removedSections.add (new UniformTextSection (*section)); - - index = nextIndex; - } - - if (um->getNumActionsInCurrentTransaction() > TextEditorDefs::maxActionsPerTransaction) - newTransaction(); - - um->perform (new RemoveAction (*this, range, caretPosition, - caretPositionToMoveTo, removedSections)); - } - else - { - auto remainingRange = range; - - for (int i = 0; i < sections.size(); ++i) - { - auto* section = sections.getUnchecked (i); - - const int nextIndex = index + section->getTotalLength(); - - if (remainingRange.getStart() <= index && remainingRange.getEnd() >= nextIndex) - { - sections.remove (i); - remainingRange.setEnd (remainingRange.getEnd() - (nextIndex - index)); - - if (remainingRange.isEmpty()) - break; - - --i; - } - else - { - index = nextIndex; - } - } - - coalesceSimilarSections(); - totalNumChars = -1; - valueTextNeedsUpdating = true; - - moveCaretTo (caretPositionToMoveTo, false); - - repaintText (Range (range.getStart(), getTotalNumChars())); - } - } -} - -//============================================================================== -String TextEditor::getText() const -{ - MemoryOutputStream mo; - mo.preallocate ((size_t) getTotalNumChars()); - - for (int i = 0; i < sections.size(); ++i) - sections.getUnchecked (i)->appendAllText (mo); - - return mo.toUTF8(); -} - -String TextEditor::getTextInRange (const Range& range) const -{ - if (range.isEmpty()) - return {}; - - MemoryOutputStream mo; - mo.preallocate ((size_t) jmin (getTotalNumChars(), range.getLength())); - - int index = 0; - - for (int i = 0; i < sections.size(); ++i) - { - auto* s = sections.getUnchecked (i); - auto nextIndex = index + s->getTotalLength(); - - if (range.getStart() < nextIndex) - { - if (range.getEnd() <= index) - break; - - s->appendSubstring (mo, range - index); - } - - index = nextIndex; - } - - return mo.toUTF8(); -} - -String TextEditor::getHighlightedText() const -{ - return getTextInRange (selection); -} - -int TextEditor::getTotalNumChars() const -{ - if (totalNumChars < 0) - { - totalNumChars = 0; - - for (int i = sections.size(); --i >= 0;) - totalNumChars += sections.getUnchecked (i)->getTotalLength(); - } - - return totalNumChars; -} - -bool TextEditor::isEmpty() const -{ - return getTotalNumChars() == 0; -} - -void TextEditor::getCharPosition (const int index, float& cx, float& cy, float& lineHeight) const -{ - const float wordWrapWidth = getWordWrapWidth(); - - if (wordWrapWidth > 0 && sections.size() > 0) - { - Iterator i (sections, wordWrapWidth, passwordCharacter, lineSpacing); - - i.getCharPosition (index, cx, cy, lineHeight); - } - else - { - cx = cy = 0; - lineHeight = currentFont.getHeight(); - } -} - -int TextEditor::indexAtPosition (const float x, const float y) -{ - const float wordWrapWidth = getWordWrapWidth(); - - if (wordWrapWidth > 0) - { - Iterator i (sections, wordWrapWidth, passwordCharacter, lineSpacing); - - while (i.next()) - { - if (i.lineY + i.lineHeight > y) - { - if (i.lineY > y) - return jmax (0, i.indexInText - 1); - - if (i.atomX >= x) - return i.indexInText; - - if (x < i.atomRight) - return i.xToIndex (x); - } - } - } - - return getTotalNumChars(); -} - -//============================================================================== -int TextEditor::findWordBreakAfter (const int position) const -{ - auto t = getTextInRange (Range (position, position + 512)); - auto totalLength = t.length(); - int i = 0; - - while (i < totalLength && CharacterFunctions::isWhitespace (t[i])) - ++i; - - const int type = TextEditorDefs::getCharacterCategory (t[i]); - - while (i < totalLength && type == TextEditorDefs::getCharacterCategory (t[i])) - ++i; - - while (i < totalLength && CharacterFunctions::isWhitespace (t[i])) - ++i; - - return position + i; -} - -int TextEditor::findWordBreakBefore (const int position) const -{ - if (position <= 0) - return 0; - - auto startOfBuffer = jmax (0, position - 512); - auto t = getTextInRange (Range (startOfBuffer, position)); - - int i = position - startOfBuffer; - - while (i > 0 && CharacterFunctions::isWhitespace (t [i - 1])) - --i; - - if (i > 0) - { - auto type = TextEditorDefs::getCharacterCategory (t [i - 1]); - - while (i > 0 && type == TextEditorDefs::getCharacterCategory (t [i - 1])) - --i; - } - - jassert (startOfBuffer + i >= 0); - return startOfBuffer + i; -} - - -//============================================================================== -void TextEditor::splitSection (const int sectionIndex, const int charToSplitAt) -{ - jassert (sections[sectionIndex] != nullptr); - - sections.insert (sectionIndex + 1, - sections.getUnchecked (sectionIndex)->split (charToSplitAt, passwordCharacter)); -} - -void TextEditor::coalesceSimilarSections() -{ - for (int i = 0; i < sections.size() - 1; ++i) - { - auto* s1 = sections.getUnchecked (i); - auto* s2 = sections.getUnchecked (i + 1); - - if (s1->font == s2->font - && s1->colour == s2->colour) - { - s1->append (*s2, passwordCharacter); - sections.remove (i + 1); - --i; - } - } -} - -} // namespace juce +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2017 - ROLI Ltd. + + JUCE is an open source library subject to commercial or open-source + licensing. + + By using JUCE, you agree to the terms of both the JUCE 5 End-User License + Agreement and JUCE 5 Privacy Policy (both updated and effective as of the + 27th April 2017). + + End User License Agreement: www.juce.com/juce-5-licence + Privacy Policy: www.juce.com/juce-5-privacy-policy + + Or: You may also use this code under the terms of the GPL v3 (see + www.gnu.org/licenses). + + JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER + EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE + DISCLAIMED. + + ============================================================================== +*/ + +namespace juce +{ + +// a word or space that can't be broken down any further +struct TextAtom +{ + //============================================================================== + String atomText; + float width; + int numChars; + + //============================================================================== + bool isWhitespace() const noexcept { return CharacterFunctions::isWhitespace (atomText[0]); } + bool isNewLine() const noexcept { return atomText[0] == '\r' || atomText[0] == '\n'; } + + String getText (const juce_wchar passwordCharacter) const + { + if (passwordCharacter == 0) + return atomText; + + return String::repeatedString (String::charToString (passwordCharacter), + atomText.length()); + } + + String getTrimmedText (const juce_wchar passwordCharacter) const + { + if (passwordCharacter == 0) + return atomText.substring (0, numChars); + + if (isNewLine()) + return {}; + + return String::repeatedString (String::charToString (passwordCharacter), numChars); + } + + JUCE_LEAK_DETECTOR (TextAtom) +}; + +//============================================================================== +// a run of text with a single font and colour +class TextEditor::UniformTextSection +{ +public: + UniformTextSection (const String& text, const Font& f, Colour col, juce_wchar passwordChar) + : font (f), colour (col) + { + initialiseAtoms (text, passwordChar); + } + + UniformTextSection (const UniformTextSection& other) + : font (other.font), colour (other.colour) + { + atoms.addCopiesOf (other.atoms); + } + + void append (UniformTextSection& other, const juce_wchar passwordChar) + { + if (other.atoms.size() > 0) + { + int i = 0; + + if (auto* lastAtom = atoms.getLast()) + { + if (! CharacterFunctions::isWhitespace (lastAtom->atomText.getLastCharacter())) + { + auto* first = other.atoms.getUnchecked(0); + + if (! CharacterFunctions::isWhitespace (first->atomText[0])) + { + lastAtom->atomText += first->atomText; + lastAtom->numChars = (uint16) (lastAtom->numChars + first->numChars); + lastAtom->width = font.getStringWidthFloat (lastAtom->getText (passwordChar)); + delete first; + ++i; + } + } + } + + atoms.ensureStorageAllocated (atoms.size() + other.atoms.size() - i); + + while (i < other.atoms.size()) + { + atoms.add (other.atoms.getUnchecked(i)); + ++i; + } + + other.atoms.clear (false); + } + } + + UniformTextSection* split (const int indexToBreakAt, const juce_wchar passwordChar) + { + UniformTextSection* const section2 = new UniformTextSection (String(), font, colour, passwordChar); + int index = 0; + + for (int i = 0; i < atoms.size(); ++i) + { + auto* atom = atoms.getUnchecked(i); + auto nextIndex = index + atom->numChars; + + if (index == indexToBreakAt) + { + for (int j = i; j < atoms.size(); ++j) + section2->atoms.add (atoms.getUnchecked (j)); + + atoms.removeRange (i, atoms.size(), false); + break; + } + else if (indexToBreakAt >= index && indexToBreakAt < nextIndex) + { + auto* secondAtom = new TextAtom(); + + secondAtom->atomText = atom->atomText.substring (indexToBreakAt - index); + secondAtom->width = font.getStringWidthFloat (secondAtom->getText (passwordChar)); + secondAtom->numChars = (uint16) secondAtom->atomText.length(); + + section2->atoms.add (secondAtom); + + atom->atomText = atom->atomText.substring (0, indexToBreakAt - index); + atom->width = font.getStringWidthFloat (atom->getText (passwordChar)); + atom->numChars = (uint16) (indexToBreakAt - index); + + for (int j = i + 1; j < atoms.size(); ++j) + section2->atoms.add (atoms.getUnchecked (j)); + + atoms.removeRange (i + 1, atoms.size(), false); + break; + } + + index = nextIndex; + } + + return section2; + } + + void appendAllText (MemoryOutputStream& mo) const + { + for (int i = 0; i < atoms.size(); ++i) + mo << atoms.getUnchecked(i)->atomText; + } + + void appendSubstring (MemoryOutputStream& mo, const Range range) const + { + int index = 0; + + for (auto* atom : atoms) + { + auto nextIndex = index + atom->numChars; + + if (range.getStart() < nextIndex) + { + if (range.getEnd() <= index) + break; + + auto r = (range - index).getIntersectionWith (Range (0, (int) atom->numChars)); + + if (! r.isEmpty()) + mo << atom->atomText.substring (r.getStart(), r.getEnd()); + } + + index = nextIndex; + } + } + + int getTotalLength() const noexcept + { + int total = 0; + + for (auto* atom : atoms) + total += atom->numChars; + + return total; + } + + void setFont (const Font& newFont, const juce_wchar passwordChar) + { + if (font != newFont) + { + font = newFont; + + for (auto* atom : atoms) + atom->width = newFont.getStringWidthFloat (atom->getText (passwordChar)); + } + } + + //============================================================================== + Font font; + Colour colour; + OwnedArray atoms; + +private: + void initialiseAtoms (const String& textToParse, const juce_wchar passwordChar) + { + auto text = textToParse.getCharPointer(); + + while (! text.isEmpty()) + { + size_t numChars = 0; + auto start = text; + + // create a whitespace atom unless it starts with non-ws + if (text.isWhitespace() && *text != '\r' && *text != '\n') + { + do + { + ++text; + ++numChars; + } + while (text.isWhitespace() && *text != '\r' && *text != '\n'); + } + else + { + if (*text == '\r') + { + ++text; + ++numChars; + + if (*text == '\n') + { + ++start; + ++text; + } + } + else if (*text == '\n') + { + ++text; + ++numChars; + } + else + { + while (! (text.isEmpty() || text.isWhitespace())) + { + ++text; + ++numChars; + } + } + } + + auto* atom = atoms.add (new TextAtom()); + + atom->atomText = String (start, numChars); + atom->width = font.getStringWidthFloat (atom->getText (passwordChar)); + atom->numChars = (uint16) numChars; + } + } + + UniformTextSection& operator= (const UniformTextSection&); + JUCE_LEAK_DETECTOR (UniformTextSection) +}; + +//============================================================================== +class TextEditor::Iterator +{ +public: + Iterator (const OwnedArray& sectionList, + float wrapWidth, juce_wchar passwordChar, float spacing) + : sections (sectionList), + wordWrapWidth (wrapWidth), + passwordCharacter (passwordChar), + lineSpacing (spacing) + { + jassert (wordWrapWidth > 0); + + if (sections.size() > 0) + { + currentSection = sections.getUnchecked (sectionIndex); + + if (currentSection != nullptr) + beginNewLine(); + } + } + + Iterator (const Iterator& other) + : indexInText (other.indexInText), + lineY (other.lineY), + lineHeight (other.lineHeight), + maxDescent (other.maxDescent), + atomX (other.atomX), + atomRight (other.atomRight), + atom (other.atom), + currentSection (other.currentSection), + sections (other.sections), + sectionIndex (other.sectionIndex), + atomIndex (other.atomIndex), + wordWrapWidth (other.wordWrapWidth), + passwordCharacter (other.passwordCharacter), + lineSpacing (other.lineSpacing), + tempAtom (other.tempAtom) + { + } + + //============================================================================== + bool next() + { + if (atom == &tempAtom) + { + const int numRemaining = tempAtom.atomText.length() - tempAtom.numChars; + + if (numRemaining > 0) + { + tempAtom.atomText = tempAtom.atomText.substring (tempAtom.numChars); + + atomX = 0; + + if (tempAtom.numChars > 0) + lineY += lineHeight * lineSpacing; + + indexInText += tempAtom.numChars; + + GlyphArrangement g; + g.addLineOfText (currentSection->font, atom->getText (passwordCharacter), 0.0f, 0.0f); + + int split; + for (split = 0; split < g.getNumGlyphs(); ++split) + if (shouldWrap (g.getGlyph (split).getRight())) + break; + + if (split > 0 && split <= numRemaining) + { + tempAtom.numChars = (uint16) split; + tempAtom.width = g.getGlyph (split - 1).getRight(); + atomRight = atomX + tempAtom.width; + return true; + } + } + } + + if (sectionIndex >= sections.size()) + { + moveToEndOfLastAtom(); + return false; + } + + bool forceNewLine = false; + + if (atomIndex >= currentSection->atoms.size() - 1) + { + if (atomIndex >= currentSection->atoms.size()) + { + if (++sectionIndex >= sections.size()) + { + moveToEndOfLastAtom(); + return false; + } + + atomIndex = 0; + currentSection = sections.getUnchecked (sectionIndex); + } + else + { + auto* lastAtom = currentSection->atoms.getUnchecked (atomIndex); + + if (! lastAtom->isWhitespace()) + { + // handle the case where the last atom in a section is actually part of the same + // word as the first atom of the next section... + float right = atomRight + lastAtom->width; + float lineHeight2 = lineHeight; + float maxDescent2 = maxDescent; + + for (int section = sectionIndex + 1; section < sections.size(); ++section) + { + auto* s = sections.getUnchecked (section); + + if (s->atoms.size() == 0) + break; + + auto* nextAtom = s->atoms.getUnchecked (0); + + if (nextAtom->isWhitespace()) + break; + + right += nextAtom->width; + + lineHeight2 = jmax (lineHeight2, s->font.getHeight()); + maxDescent2 = jmax (maxDescent2, s->font.getDescent()); + + if (shouldWrap (right)) + { + lineHeight = lineHeight2; + maxDescent = maxDescent2; + + forceNewLine = true; + break; + } + + if (s->atoms.size() > 1) + break; + } + } + } + } + + if (atom != nullptr) + { + atomX = atomRight; + indexInText += atom->numChars; + + if (atom->isNewLine()) + beginNewLine(); + } + + atom = currentSection->atoms.getUnchecked (atomIndex); + atomRight = atomX + atom->width; + ++atomIndex; + + if (shouldWrap (atomRight) || forceNewLine) + { + if (atom->isWhitespace()) + { + // leave whitespace at the end of a line, but truncate it to avoid scrolling + atomRight = jmin (atomRight, wordWrapWidth); + } + else + { + atomRight = atom->width; + + if (shouldWrap (atomRight)) // atom too big to fit on a line, so break it up.. + { + tempAtom = *atom; + tempAtom.width = 0; + tempAtom.numChars = 0; + atom = &tempAtom; + + if (atomX > 0) + beginNewLine(); + + return next(); + } + + beginNewLine(); + return true; + } + } + + return true; + } + + void beginNewLine() + { + atomX = 0; + lineY += lineHeight * lineSpacing; + + int tempSectionIndex = sectionIndex; + int tempAtomIndex = atomIndex; + auto* section = sections.getUnchecked (tempSectionIndex); + + lineHeight = section->font.getHeight(); + maxDescent = section->font.getDescent(); + + float x = (atom != nullptr) ? atom->width : 0; + + while (! shouldWrap (x)) + { + if (tempSectionIndex >= sections.size()) + break; + + bool checkSize = false; + + if (tempAtomIndex >= section->atoms.size()) + { + if (++tempSectionIndex >= sections.size()) + break; + + tempAtomIndex = 0; + section = sections.getUnchecked (tempSectionIndex); + checkSize = true; + } + + auto* nextAtom = section->atoms.getUnchecked (tempAtomIndex); + + if (nextAtom == nullptr) + break; + + x += nextAtom->width; + + if (shouldWrap (x) || nextAtom->isNewLine()) + break; + + if (checkSize) + { + lineHeight = jmax (lineHeight, section->font.getHeight()); + maxDescent = jmax (maxDescent, section->font.getDescent()); + } + + ++tempAtomIndex; + } + } + + //============================================================================== + void draw (Graphics& g, const UniformTextSection*& lastSection) const + { + if (passwordCharacter != 0 || ! atom->isWhitespace()) + { + if (lastSection != currentSection) + { + lastSection = currentSection; + g.setColour (currentSection->colour); + g.setFont (currentSection->font); + } + + jassert (atom->getTrimmedText (passwordCharacter).isNotEmpty()); + + GlyphArrangement ga; + ga.addLineOfText (currentSection->font, + atom->getTrimmedText (passwordCharacter), + atomX, (float) roundToInt (lineY + lineHeight - maxDescent)); + ga.draw (g); + } + } + + void addSelection (RectangleList& area, const Range selected) const + { + const float startX = indexToX (selected.getStart()); + const float endX = indexToX (selected.getEnd()); + + area.add (startX, lineY, endX - startX, lineHeight * lineSpacing); + } + + void drawUnderline (Graphics& g, const Range underline, const Colour colour) const + { + const int startX = roundToInt (indexToX (underline.getStart())); + const int endX = roundToInt (indexToX (underline.getEnd())); + const int baselineY = roundToInt (lineY + currentSection->font.getAscent() + 0.5f); + + Graphics::ScopedSaveState state (g); + g.reduceClipRegion (Rectangle (startX, baselineY, endX - startX, 1)); + g.fillCheckerBoard (Rectangle (endX, baselineY + 1), 3, 1, colour, Colours::transparentBlack); + } + + void drawSelectedText (Graphics& g, + const Range selected, + const Colour selectedTextColour) const + { + if (passwordCharacter != 0 || ! atom->isWhitespace()) + { + GlyphArrangement ga; + ga.addLineOfText (currentSection->font, + atom->getTrimmedText (passwordCharacter), + atomX, (float) roundToInt (lineY + lineHeight - maxDescent)); + + if (selected.getEnd() < indexInText + atom->numChars) + { + GlyphArrangement ga2 (ga); + ga2.removeRangeOfGlyphs (0, selected.getEnd() - indexInText); + ga.removeRangeOfGlyphs (selected.getEnd() - indexInText, -1); + + g.setColour (currentSection->colour); + ga2.draw (g); + } + + if (selected.getStart() > indexInText) + { + GlyphArrangement ga2 (ga); + ga2.removeRangeOfGlyphs (selected.getStart() - indexInText, -1); + ga.removeRangeOfGlyphs (0, selected.getStart() - indexInText); + + g.setColour (currentSection->colour); + ga2.draw (g); + } + + g.setColour (selectedTextColour); + ga.draw (g); + } + } + + //============================================================================== + float indexToX (const int indexToFind) const + { + if (indexToFind <= indexInText) + return atomX; + + if (indexToFind >= indexInText + atom->numChars) + return atomRight; + + GlyphArrangement g; + g.addLineOfText (currentSection->font, + atom->getText (passwordCharacter), + atomX, 0.0f); + + if (indexToFind - indexInText >= g.getNumGlyphs()) + return atomRight; + + return jmin (atomRight, g.getGlyph (indexToFind - indexInText).getLeft()); + } + + int xToIndex (const float xToFind) const + { + if (xToFind <= atomX || atom->isNewLine()) + return indexInText; + + if (xToFind >= atomRight) + return indexInText + atom->numChars; + + GlyphArrangement g; + g.addLineOfText (currentSection->font, + atom->getText (passwordCharacter), + atomX, 0.0f); + + const int numGlyphs = g.getNumGlyphs(); + + int j; + for (j = 0; j < numGlyphs; ++j) + { + auto& pg = g.getGlyph(j); + + if ((pg.getLeft() + pg.getRight()) / 2 > xToFind) + break; + } + + return indexInText + j; + } + + //============================================================================== + bool getCharPosition (const int index, float& cx, float& cy, float& lineHeightFound) + { + while (next()) + { + if (indexInText + atom->numChars > index) + { + cx = indexToX (index); + cy = lineY; + lineHeightFound = lineHeight; + return true; + } + } + + cx = atomX; + cy = lineY; + lineHeightFound = lineHeight; + return false; + } + + //============================================================================== + int indexInText = 0; + float lineY = 0, lineHeight = 0, maxDescent = 0; + float atomX = 0, atomRight = 0; + const TextAtom* atom = nullptr; + const UniformTextSection* currentSection = nullptr; + +private: + const OwnedArray& sections; + int sectionIndex = 0, atomIndex = 0; + const float wordWrapWidth; + const juce_wchar passwordCharacter; + const float lineSpacing; + TextAtom tempAtom; + + Iterator& operator= (const Iterator&) = delete; + + void moveToEndOfLastAtom() + { + if (atom != nullptr) + { + atomX = atomRight; + + if (atom->isNewLine()) + { + atomX = 0.0f; + lineY += lineHeight * lineSpacing; + } + } + } + + bool shouldWrap (const float x) const noexcept + { + return (x - 0.0001f) >= wordWrapWidth; + } + + JUCE_LEAK_DETECTOR (Iterator) +}; + + +//============================================================================== +class TextEditor::InsertAction : public UndoableAction +{ +public: + InsertAction (TextEditor& ed, + const String& newText, + const int insertPos, + const Font& newFont, + const Colour newColour, + const int oldCaret, + const int newCaret) + : owner (ed), + text (newText), + insertIndex (insertPos), + oldCaretPos (oldCaret), + newCaretPos (newCaret), + font (newFont), + colour (newColour) + { + } + + bool perform() override + { + owner.insert (text, insertIndex, font, colour, 0, newCaretPos); + return true; + } + + bool undo() override + { + owner.remove (Range (insertIndex, insertIndex + text.length()), 0, oldCaretPos); + return true; + } + + int getSizeInUnits() override + { + return text.length() + 16; + } + +private: + TextEditor& owner; + const String text; + const int insertIndex, oldCaretPos, newCaretPos; + const Font font; + const Colour colour; + + JUCE_DECLARE_NON_COPYABLE (InsertAction) +}; + +//============================================================================== +class TextEditor::RemoveAction : public UndoableAction +{ +public: + RemoveAction (TextEditor& ed, + const Range rangeToRemove, + const int oldCaret, + const int newCaret, + const Array& oldSections) + : owner (ed), + range (rangeToRemove), + oldCaretPos (oldCaret), + newCaretPos (newCaret) + { + removedSections.addArray (oldSections); + } + + bool perform() override + { + owner.remove (range, 0, newCaretPos); + return true; + } + + bool undo() override + { + owner.reinsert (range.getStart(), removedSections); + owner.moveCaretTo (oldCaretPos, false); + return true; + } + + int getSizeInUnits() override + { + int n = 16; + + for (auto* s : removedSections) + n += s->getTotalLength(); + + return n; + } + +private: + TextEditor& owner; + const Range range; + const int oldCaretPos, newCaretPos; + OwnedArray removedSections; + + JUCE_DECLARE_NON_COPYABLE (RemoveAction) +}; + +//============================================================================== +class TextEditor::TextHolderComponent : public Component, + public Timer, + public Value::Listener +{ +public: + TextHolderComponent (TextEditor& ed) : owner (ed) + { + setWantsKeyboardFocus (false); + setInterceptsMouseClicks (false, true); + setMouseCursor (MouseCursor::ParentCursor); + + owner.getTextValue().addListener (this); + } + + ~TextHolderComponent() + { + owner.getTextValue().removeListener (this); + } + + void paint (Graphics& g) override + { + owner.drawContent (g); + } + + void restartTimer() + { + startTimer (350); + } + + void timerCallback() override + { + owner.timerCallbackInt(); + } + + void valueChanged (Value&) override + { + owner.textWasChangedByValue(); + } + +private: + TextEditor& owner; + + JUCE_DECLARE_NON_COPYABLE (TextHolderComponent) +}; + +//============================================================================== +class TextEditorViewport : public Viewport +{ +public: + TextEditorViewport (TextEditor& ed) : owner (ed) {} + + void visibleAreaChanged (const Rectangle&) override + { + if (! rentrant) // it's rare, but possible to get into a feedback loop as the viewport's scrollbars + // appear and disappear, causing the wrap width to change. + { + const float wordWrapWidth = owner.getWordWrapWidth(); + + if (wordWrapWidth != lastWordWrapWidth) + { + lastWordWrapWidth = wordWrapWidth; + + rentrant = true; + owner.updateTextHolderSize(); + rentrant = false; + } + } + } + +private: + TextEditor& owner; + float lastWordWrapWidth = 0; + bool rentrant = false; + + JUCE_DECLARE_NON_COPYABLE (TextEditorViewport) +}; + +//============================================================================== +namespace TextEditorDefs +{ + const int textChangeMessageId = 0x10003001; + const int returnKeyMessageId = 0x10003002; + const int escapeKeyMessageId = 0x10003003; + const int focusLossMessageId = 0x10003004; + + const int maxActionsPerTransaction = 100; + + static int getCharacterCategory (const juce_wchar character) + { + return CharacterFunctions::isLetterOrDigit (character) + ? 2 : (CharacterFunctions::isWhitespace (character) ? 0 : 1); + } +} + +//============================================================================== +TextEditor::TextEditor (const String& name, juce_wchar passwordChar) + : Component (name), + passwordCharacter (passwordChar) +{ + setMouseCursor (MouseCursor::IBeamCursor); + + addAndMakeVisible (viewport = new TextEditorViewport (*this)); + viewport->setViewedComponent (textHolder = new TextHolderComponent (*this)); + viewport->setWantsKeyboardFocus (false); + viewport->setScrollBarsShown (false, false); + + setWantsKeyboardFocus (true); + recreateCaret(); +} + +TextEditor::~TextEditor() +{ + if (wasFocused) + if (auto* peer = getPeer()) + peer->dismissPendingTextInput(); + + textValue.removeListener (textHolder); + textValue.referTo (Value()); + + viewport = nullptr; + textHolder = nullptr; +} + +//============================================================================== +void TextEditor::newTransaction() +{ + lastTransactionTime = Time::getApproximateMillisecondCounter(); + undoManager.beginNewTransaction(); +} + +bool TextEditor::undoOrRedo (const bool shouldUndo) +{ + if (! isReadOnly()) + { + newTransaction(); + + if (shouldUndo ? undoManager.undo() + : undoManager.redo()) + { + scrollToMakeSureCursorIsVisible(); + repaint(); + textChanged(); + return true; + } + } + + return false; +} + +bool TextEditor::undo() { return undoOrRedo (true); } +bool TextEditor::redo() { return undoOrRedo (false); } + +//============================================================================== +void TextEditor::setMultiLine (const bool shouldBeMultiLine, + const bool shouldWordWrap) +{ + if (multiline != shouldBeMultiLine + || wordWrap != (shouldWordWrap && shouldBeMultiLine)) + { + multiline = shouldBeMultiLine; + wordWrap = shouldWordWrap && shouldBeMultiLine; + + viewport->setScrollBarsShown (scrollbarVisible && multiline, + scrollbarVisible && multiline); + viewport->setViewPosition (0, 0); + resized(); + scrollToMakeSureCursorIsVisible(); + } +} + +bool TextEditor::isMultiLine() const +{ + return multiline; +} + +void TextEditor::setScrollbarsShown (bool shown) +{ + if (scrollbarVisible != shown) + { + scrollbarVisible = shown; + shown = shown && isMultiLine(); + viewport->setScrollBarsShown (shown, shown); + } +} + +void TextEditor::setReadOnly (const bool shouldBeReadOnly) +{ + if (readOnly != shouldBeReadOnly) + { + readOnly = shouldBeReadOnly; + enablementChanged(); + } +} + +bool TextEditor::isReadOnly() const noexcept +{ + return readOnly || ! isEnabled(); +} + +bool TextEditor::isTextInputActive() const +{ + return ! isReadOnly(); +} + +void TextEditor::setReturnKeyStartsNewLine (const bool shouldStartNewLine) +{ + returnKeyStartsNewLine = shouldStartNewLine; +} + +void TextEditor::setTabKeyUsedAsCharacter (const bool shouldTabKeyBeUsed) +{ + tabKeyUsed = shouldTabKeyBeUsed; +} + +void TextEditor::setPopupMenuEnabled (const bool b) +{ + popupMenuEnabled = b; +} + +void TextEditor::setSelectAllWhenFocused (const bool b) +{ + selectAllTextWhenFocused = b; +} + +//============================================================================== +void TextEditor::setFont (const Font& newFont) +{ + currentFont = newFont; + scrollToMakeSureCursorIsVisible(); +} + +void TextEditor::applyFontToAllText (const Font& newFont, bool changeCurrentFont) +{ + if (changeCurrentFont) + currentFont = newFont; + + auto overallColour = findColour (textColourId); + + for (auto* uts : sections) + { + uts->setFont (newFont, passwordCharacter); + uts->colour = overallColour; + } + + coalesceSimilarSections(); + updateTextHolderSize(); + scrollToMakeSureCursorIsVisible(); + repaint(); +} + +void TextEditor::applyColourToAllText (const Colour& newColour, bool changeCurrentTextColour) +{ + for (auto* uts : sections) + uts->colour = newColour; + + if (changeCurrentTextColour) + setColour (TextEditor::textColourId, newColour); + else + repaint(); +} + +void TextEditor::lookAndFeelChanged() +{ + caret = nullptr; + recreateCaret(); + repaint(); +} + +void TextEditor::parentHierarchyChanged() +{ + lookAndFeelChanged(); +} + +void TextEditor::enablementChanged() +{ + recreateCaret(); + repaint(); +} + +void TextEditor::setCaretVisible (const bool shouldCaretBeVisible) +{ + if (caretVisible != shouldCaretBeVisible) + { + caretVisible = shouldCaretBeVisible; + recreateCaret(); + } +} + +void TextEditor::recreateCaret() +{ + if (isCaretVisible()) + { + if (caret == nullptr) + { + textHolder->addChildComponent (caret = getLookAndFeel().createCaretComponent (this)); + updateCaretPosition(); + } + } + else + { + caret = nullptr; + } +} + +void TextEditor::updateCaretPosition() +{ + if (caret != nullptr) + caret->setCaretPosition (getCaretRectangle().translated (leftIndent, topIndent)); +} + +TextEditor::LengthAndCharacterRestriction::LengthAndCharacterRestriction (int maxLen, const String& chars) + : allowedCharacters (chars), maxLength (maxLen) +{} + +String TextEditor::LengthAndCharacterRestriction::filterNewText (TextEditor& ed, const String& newInput) +{ + String t (newInput); + + if (allowedCharacters.isNotEmpty()) + t = t.retainCharacters (allowedCharacters); + + if (maxLength > 0) + t = t.substring (0, maxLength - (ed.getTotalNumChars() - ed.getHighlightedRegion().getLength())); + + return t; +} + +void TextEditor::setInputFilter (InputFilter* newFilter, bool takeOwnership) +{ + inputFilter.set (newFilter, takeOwnership); +} + +void TextEditor::setInputRestrictions (const int maxLen, const String& chars) +{ + setInputFilter (new LengthAndCharacterRestriction (maxLen, chars), true); +} + +void TextEditor::setTextToShowWhenEmpty (const String& text, Colour colourToUse) +{ + textToShowWhenEmpty = text; + colourForTextWhenEmpty = colourToUse; +} + +void TextEditor::setPasswordCharacter (const juce_wchar newPasswordCharacter) +{ + if (passwordCharacter != newPasswordCharacter) + { + passwordCharacter = newPasswordCharacter; + applyFontToAllText (currentFont); + } +} + +void TextEditor::setScrollBarThickness (const int newThicknessPixels) +{ + viewport->setScrollBarThickness (newThicknessPixels); +} + +//============================================================================== +void TextEditor::clear() +{ + clearInternal (nullptr); + updateTextHolderSize(); + undoManager.clearUndoHistory(); +} + +void TextEditor::setText (const String& newText, + const bool sendTextChangeMessage) +{ + const int newLength = newText.length(); + + if (newLength != getTotalNumChars() || getText() != newText) + { + if (! sendTextChangeMessage) + textValue.removeListener (textHolder); + + textValue = newText; + + auto oldCursorPos = caretPosition; + const bool cursorWasAtEnd = oldCursorPos >= getTotalNumChars(); + + clearInternal (nullptr); + insert (newText, 0, currentFont, findColour (textColourId), 0, caretPosition); + + // if you're adding text with line-feeds to a single-line text editor, it + // ain't gonna look right! + jassert (multiline || ! newText.containsAnyOf ("\r\n")); + + if (cursorWasAtEnd && ! isMultiLine()) + oldCursorPos = getTotalNumChars(); + + moveCaretTo (oldCursorPos, false); + + if (sendTextChangeMessage) + textChanged(); + else + textValue.addListener (textHolder); + + updateTextHolderSize(); + scrollToMakeSureCursorIsVisible(); + undoManager.clearUndoHistory(); + + repaint(); + } +} + +//============================================================================== +void TextEditor::updateValueFromText() +{ + if (valueTextNeedsUpdating) + { + valueTextNeedsUpdating = false; + textValue = getText(); + } +} + +Value& TextEditor::getTextValue() +{ + updateValueFromText(); + return textValue; +} + +void TextEditor::textWasChangedByValue() +{ + if (textValue.getValueSource().getReferenceCount() > 1) + setText (textValue.getValue()); +} + +//============================================================================== +void TextEditor::textChanged() +{ + updateTextHolderSize(); + + if (listeners.size() > 0) + postCommandMessage (TextEditorDefs::textChangeMessageId); + + if (textValue.getValueSource().getReferenceCount() > 1) + { + valueTextNeedsUpdating = false; + textValue = getText(); + } +} + +void TextEditor::returnPressed() { postCommandMessage (TextEditorDefs::returnKeyMessageId); } +void TextEditor::escapePressed() { postCommandMessage (TextEditorDefs::escapeKeyMessageId); } + +void TextEditor::addListener (Listener* l) { listeners.add (l); } +void TextEditor::removeListener (Listener* l) { listeners.remove (l); } + +//============================================================================== +void TextEditor::timerCallbackInt() +{ + if (hasKeyboardFocus (false) && ! isCurrentlyBlockedByAnotherModalComponent()) + wasFocused = true; + + auto now = Time::getApproximateMillisecondCounter(); + + if (now > lastTransactionTime + 200) + newTransaction(); +} + +void TextEditor::repaintText (const Range range) +{ + if (! range.isEmpty()) + { + float x = 0, y = 0, lh = currentFont.getHeight(); + + const float wordWrapWidth = getWordWrapWidth(); + + if (wordWrapWidth > 0) + { + Iterator i (sections, wordWrapWidth, passwordCharacter, lineSpacing); + + i.getCharPosition (range.getStart(), x, y, lh); + + auto y1 = (int) y; + int y2; + + if (range.getEnd() >= getTotalNumChars()) + { + y2 = textHolder->getHeight(); + } + else + { + i.getCharPosition (range.getEnd(), x, y, lh); + y2 = (int) (y + lh * 2.0f); + } + + textHolder->repaint (0, y1, textHolder->getWidth(), y2 - y1); + } + } +} + +//============================================================================== +void TextEditor::moveCaret (int newCaretPos) +{ + if (newCaretPos < 0) + newCaretPos = 0; + else + newCaretPos = jmin (newCaretPos, getTotalNumChars()); + + if (newCaretPos != getCaretPosition()) + { + caretPosition = newCaretPos; + textHolder->restartTimer(); + scrollToMakeSureCursorIsVisible(); + updateCaretPosition(); + } +} + +int TextEditor::getCaretPosition() const +{ + return caretPosition; +} + +void TextEditor::setCaretPosition (const int newIndex) +{ + moveCaretTo (newIndex, false); +} + +void TextEditor::moveCaretToEnd() +{ + moveCaretTo (std::numeric_limits::max(), false); +} + +void TextEditor::scrollEditorToPositionCaret (const int desiredCaretX, + const int desiredCaretY) + +{ + updateCaretPosition(); + auto caretPos = getCaretRectangle(); + + int vx = caretPos.getX() - desiredCaretX; + int vy = caretPos.getY() - desiredCaretY; + + if (desiredCaretX < jmax (1, proportionOfWidth (0.05f))) + vx += desiredCaretX - proportionOfWidth (0.2f); + else if (desiredCaretX > jmax (0, viewport->getMaximumVisibleWidth() - (wordWrap ? 2 : 10))) + vx += desiredCaretX + (isMultiLine() ? proportionOfWidth (0.2f) : 10) - viewport->getMaximumVisibleWidth(); + + vx = jlimit (0, jmax (0, textHolder->getWidth() + 8 - viewport->getMaximumVisibleWidth()), vx); + + if (! isMultiLine()) + { + vy = viewport->getViewPositionY(); + } + else + { + vy = jlimit (0, jmax (0, textHolder->getHeight() - viewport->getMaximumVisibleHeight()), vy); + + if (desiredCaretY < 0) + vy = jmax (0, desiredCaretY + vy); + else if (desiredCaretY > jmax (0, viewport->getMaximumVisibleHeight() - topIndent - caretPos.getHeight())) + vy += desiredCaretY + 2 + caretPos.getHeight() + topIndent - viewport->getMaximumVisibleHeight(); + } + + viewport->setViewPosition (vx, vy); +} + +Rectangle TextEditor::getCaretRectangle() +{ + float cursorX, cursorY; + float cursorHeight = currentFont.getHeight(); // (in case the text is empty and the call below doesn't set this value) + getCharPosition (caretPosition, cursorX, cursorY, cursorHeight); + + return { roundToInt (cursorX), roundToInt (cursorY), 2, roundToInt (cursorHeight) }; +} + +//============================================================================== +enum { rightEdgeSpace = 2 }; + +float TextEditor::getWordWrapWidth() const +{ + return wordWrap ? (float) (viewport->getMaximumVisibleWidth() - (leftIndent + rightEdgeSpace + 1)) + : std::numeric_limits::max(); +} + +void TextEditor::updateTextHolderSize() +{ + const float wordWrapWidth = getWordWrapWidth(); + + if (wordWrapWidth > 0) + { + float maxWidth = 0.0f; + + Iterator i (sections, wordWrapWidth, passwordCharacter, lineSpacing); + + while (i.next()) + maxWidth = jmax (maxWidth, i.atomRight); + + const int w = leftIndent + roundToInt (maxWidth); + const int h = topIndent + roundToInt (jmax (i.lineY + i.lineHeight, + currentFont.getHeight())); + + textHolder->setSize (w + rightEdgeSpace, h + 1); // (allows a bit of space for the cursor to be at the right-hand-edge) + } +} + +int TextEditor::getTextWidth() const { return textHolder->getWidth(); } +int TextEditor::getTextHeight() const { return textHolder->getHeight(); } + +void TextEditor::setIndents (const int newLeftIndent, const int newTopIndent) +{ + leftIndent = newLeftIndent; + topIndent = newTopIndent; +} + +void TextEditor::setBorder (const BorderSize& border) +{ + borderSize = border; + resized(); +} + +BorderSize TextEditor::getBorder() const +{ + return borderSize; +} + +void TextEditor::setScrollToShowCursor (const bool shouldScrollToShowCursor) +{ + keepCaretOnScreen = shouldScrollToShowCursor; +} + +void TextEditor::scrollToMakeSureCursorIsVisible() +{ + updateCaretPosition(); + + if (keepCaretOnScreen) + { + auto viewPos = viewport->getViewPosition(); + auto caretRect = getCaretRectangle(); + auto relativeCursor = caretRect.getPosition() - viewPos; + + if (relativeCursor.x < jmax (1, proportionOfWidth (0.05f))) + { + viewPos.x += relativeCursor.x - proportionOfWidth (0.2f); + } + else if (relativeCursor.x > jmax (0, viewport->getMaximumVisibleWidth() - (wordWrap ? 2 : 10))) + { + viewPos.x += relativeCursor.x + (isMultiLine() ? proportionOfWidth (0.2f) : 10) - viewport->getMaximumVisibleWidth(); + } + + viewPos.x = jlimit (0, jmax (0, textHolder->getWidth() + 8 - viewport->getMaximumVisibleWidth()), viewPos.x); + + if (! isMultiLine()) + { + viewPos.y = (getHeight() - textHolder->getHeight() - topIndent) / -2; + } + else if (relativeCursor.y < 0) + { + viewPos.y = jmax (0, relativeCursor.y + viewPos.y); + } + else if (relativeCursor.y > jmax (0, viewport->getMaximumVisibleHeight() - topIndent - caretRect.getHeight())) + { + viewPos.y += relativeCursor.y + 2 + caretRect.getHeight() + topIndent - viewport->getMaximumVisibleHeight(); + } + + viewport->setViewPosition (viewPos); + } +} + +void TextEditor::moveCaretTo (const int newPosition, const bool isSelecting) +{ + if (isSelecting) + { + moveCaret (newPosition); + + auto oldSelection = selection; + + if (dragType == notDragging) + { + if (std::abs (getCaretPosition() - selection.getStart()) < std::abs (getCaretPosition() - selection.getEnd())) + dragType = draggingSelectionStart; + else + dragType = draggingSelectionEnd; + } + + if (dragType == draggingSelectionStart) + { + if (getCaretPosition() >= selection.getEnd()) + dragType = draggingSelectionEnd; + + selection = Range::between (getCaretPosition(), selection.getEnd()); + } + else + { + if (getCaretPosition() < selection.getStart()) + dragType = draggingSelectionStart; + + selection = Range::between (getCaretPosition(), selection.getStart()); + } + + repaintText (selection.getUnionWith (oldSelection)); + } + else + { + dragType = notDragging; + + repaintText (selection); + + moveCaret (newPosition); + selection = Range::emptyRange (getCaretPosition()); + } +} + +int TextEditor::getTextIndexAt (const int x, const int y) +{ + return indexAtPosition ((float) (x + viewport->getViewPositionX() - leftIndent - borderSize.getLeft()), + (float) (y + viewport->getViewPositionY() - topIndent - borderSize.getTop())); +} + +void TextEditor::insertTextAtCaret (const String& t) +{ + String newText (inputFilter != nullptr ? inputFilter->filterNewText (*this, t) : t); + + if (isMultiLine()) + newText = newText.replace ("\r\n", "\n"); + else + newText = newText.replaceCharacters ("\r\n", " "); + + const int insertIndex = selection.getStart(); + const int newCaretPos = insertIndex + newText.length(); + + remove (selection, getUndoManager(), + newText.isNotEmpty() ? newCaretPos - 1 : newCaretPos); + + insert (newText, insertIndex, currentFont, findColour (textColourId), + getUndoManager(), newCaretPos); + + textChanged(); +} + +void TextEditor::setHighlightedRegion (const Range& newSelection) +{ + moveCaretTo (newSelection.getStart(), false); + moveCaretTo (newSelection.getEnd(), true); +} + +//============================================================================== +void TextEditor::copy() +{ + if (passwordCharacter == 0) + { + auto selectedText = getHighlightedText(); + + if (selectedText.isNotEmpty()) + SystemClipboard::copyTextToClipboard (selectedText); + } +} + +void TextEditor::paste() +{ + if (! isReadOnly()) + { + auto clip = SystemClipboard::getTextFromClipboard(); + + if (clip.isNotEmpty()) + insertTextAtCaret (clip); + } +} + +void TextEditor::cut() +{ + if (! isReadOnly()) + { + moveCaret (selection.getEnd()); + insertTextAtCaret (String()); + } +} + +//============================================================================== +void TextEditor::drawContent (Graphics& g) +{ + const float wordWrapWidth = getWordWrapWidth(); + + if (wordWrapWidth > 0) + { + g.setOrigin (leftIndent, topIndent); + auto clip = g.getClipBounds(); + Colour selectedTextColour; + + Iterator i (sections, wordWrapWidth, passwordCharacter, lineSpacing); + + if (! selection.isEmpty()) + { + Iterator i2 (i); + RectangleList selectionArea; + + while (i2.next() && i2.lineY < clip.getBottom()) + { + if (i2.lineY + i2.lineHeight >= clip.getY() + && selection.intersects (Range (i2.indexInText, i2.indexInText + i2.atom->numChars))) + { + i2.addSelection (selectionArea, selection); + } + } + + g.setColour (findColour (highlightColourId).withMultipliedAlpha (hasKeyboardFocus (true) ? 1.0f : 0.5f)); + g.fillRectList (selectionArea); + + selectedTextColour = findColour (highlightedTextColourId); + } + + const UniformTextSection* lastSection = nullptr; + + while (i.next() && i.lineY < clip.getBottom()) + { + if (i.lineY + i.lineHeight >= clip.getY()) + { + if (selection.intersects (Range (i.indexInText, i.indexInText + i.atom->numChars))) + { + i.drawSelectedText (g, selection, selectedTextColour); + lastSection = nullptr; + } + else + { + i.draw (g, lastSection); + } + } + } + + for (int j = underlinedSections.size(); --j >= 0;) + { + const Range underlinedSection = underlinedSections.getReference (j); + + Iterator i2 (sections, wordWrapWidth, passwordCharacter, lineSpacing); + + while (i2.next() && i2.lineY < clip.getBottom()) + { + if (i2.lineY + i2.lineHeight >= clip.getY() + && underlinedSection.intersects (Range (i2.indexInText, i2.indexInText + i2.atom->numChars))) + { + i2.drawUnderline (g, underlinedSection, findColour (textColourId)); + } + } + } + } +} + +void TextEditor::paint (Graphics& g) +{ + getLookAndFeel().fillTextEditorBackground (g, getWidth(), getHeight(), *this); +} + +void TextEditor::paintOverChildren (Graphics& g) +{ + if (textToShowWhenEmpty.isNotEmpty() + && (! hasKeyboardFocus (false)) + && getTotalNumChars() == 0) + { + g.setColour (colourForTextWhenEmpty); + g.setFont (getFont()); + + if (isMultiLine()) + g.drawText (textToShowWhenEmpty, getLocalBounds(), + Justification::centred, true); + else + g.drawText (textToShowWhenEmpty, + leftIndent, 0, viewport->getWidth() - leftIndent, getHeight(), + Justification::centredLeft, true); + } + + getLookAndFeel().drawTextEditorOutline (g, getWidth(), getHeight(), *this); +} + +//============================================================================== +void TextEditor::addPopupMenuItems (PopupMenu& m, const MouseEvent*) +{ + const bool writable = ! isReadOnly(); + + if (passwordCharacter == 0) + { + m.addItem (StandardApplicationCommandIDs::cut, TRANS("Cut"), writable); + m.addItem (StandardApplicationCommandIDs::copy, TRANS("Copy"), ! selection.isEmpty()); + } + + m.addItem (StandardApplicationCommandIDs::paste, TRANS("Paste"), writable); + m.addItem (StandardApplicationCommandIDs::del, TRANS("Delete"), writable); + m.addSeparator(); + m.addItem (StandardApplicationCommandIDs::selectAll, TRANS("Select All")); + m.addSeparator(); + + if (getUndoManager() != nullptr) + { + m.addItem (StandardApplicationCommandIDs::undo, TRANS("Undo"), undoManager.canUndo()); + m.addItem (StandardApplicationCommandIDs::redo, TRANS("Redo"), undoManager.canRedo()); + } +} + +void TextEditor::performPopupMenuAction (const int menuItemID) +{ + switch (menuItemID) + { + case StandardApplicationCommandIDs::cut: cutToClipboard(); break; + case StandardApplicationCommandIDs::copy: copyToClipboard(); break; + case StandardApplicationCommandIDs::paste: pasteFromClipboard(); break; + case StandardApplicationCommandIDs::del: cut(); break; + case StandardApplicationCommandIDs::selectAll: selectAll(); break; + case StandardApplicationCommandIDs::undo: undo(); break; + case StandardApplicationCommandIDs::redo: redo(); break; + default: break; + } +} + +static void textEditorMenuCallback (int menuResult, TextEditor* editor) +{ + if (editor != nullptr && menuResult != 0) + editor->performPopupMenuAction (menuResult); +} + +//============================================================================== +void TextEditor::mouseDown (const MouseEvent& e) +{ + beginDragAutoRepeat (100); + newTransaction(); + + if (wasFocused || ! selectAllTextWhenFocused) + { + if (! (popupMenuEnabled && e.mods.isPopupMenu())) + { + moveCaretTo (getTextIndexAt (e.x, e.y), + e.mods.isShiftDown()); + } + else + { + PopupMenu m; + m.setLookAndFeel (&getLookAndFeel()); + addPopupMenuItems (m, &e); + + m.showMenuAsync (PopupMenu::Options(), + ModalCallbackFunction::forComponent (textEditorMenuCallback, this)); + } + } +} + +void TextEditor::mouseDrag (const MouseEvent& e) +{ + if (wasFocused || ! selectAllTextWhenFocused) + if (! (popupMenuEnabled && e.mods.isPopupMenu())) + moveCaretTo (getTextIndexAt (e.x, e.y), true); +} + +void TextEditor::mouseUp (const MouseEvent& e) +{ + newTransaction(); + textHolder->restartTimer(); + + if (wasFocused || ! selectAllTextWhenFocused) + if (e.mouseWasClicked() && ! (popupMenuEnabled && e.mods.isPopupMenu())) + moveCaret (getTextIndexAt (e.x, e.y)); + + wasFocused = true; +} + +void TextEditor::mouseDoubleClick (const MouseEvent& e) +{ + int tokenEnd = getTextIndexAt (e.x, e.y); + int tokenStart = 0; + + if (e.getNumberOfClicks() > 3) + { + tokenEnd = getTotalNumChars(); + } + else + { + auto t = getText(); + auto totalLength = getTotalNumChars(); + + while (tokenEnd < totalLength) + { + // (note the slight bodge here - it's because iswalnum only checks for alphabetic chars in the current locale) + const juce_wchar c = t [tokenEnd]; + if (CharacterFunctions::isLetterOrDigit (c) || c > 128) + ++tokenEnd; + else + break; + } + + tokenStart = tokenEnd; + + while (tokenStart > 0) + { + // (note the slight bodge here - it's because iswalnum only checks for alphabetic chars in the current locale) + const juce_wchar c = t [tokenStart - 1]; + if (CharacterFunctions::isLetterOrDigit (c) || c > 128) + --tokenStart; + else + break; + } + + if (e.getNumberOfClicks() > 2) + { + while (tokenEnd < totalLength) + { + const juce_wchar c = t [tokenEnd]; + if (c != '\r' && c != '\n') + ++tokenEnd; + else + break; + } + + while (tokenStart > 0) + { + const juce_wchar c = t [tokenStart - 1]; + if (c != '\r' && c != '\n') + --tokenStart; + else + break; + } + } + } + + moveCaretTo (tokenEnd, false); + moveCaretTo (tokenStart, true); +} + +void TextEditor::mouseWheelMove (const MouseEvent& e, const MouseWheelDetails& wheel) +{ + if (! viewport->useMouseWheelMoveIfNeeded (e, wheel)) + Component::mouseWheelMove (e, wheel); +} + +//============================================================================== +bool TextEditor::moveCaretWithTransaction (const int newPos, const bool selecting) +{ + newTransaction(); + moveCaretTo (newPos, selecting); + return true; +} + +bool TextEditor::moveCaretLeft (bool moveInWholeWordSteps, bool selecting) +{ + int pos = getCaretPosition(); + + if (moveInWholeWordSteps) + pos = findWordBreakBefore (pos); + else + --pos; + + return moveCaretWithTransaction (pos, selecting); +} + +bool TextEditor::moveCaretRight (bool moveInWholeWordSteps, bool selecting) +{ + int pos = getCaretPosition(); + + if (moveInWholeWordSteps) + pos = findWordBreakAfter (pos); + else + ++pos; + + return moveCaretWithTransaction (pos, selecting); +} + +bool TextEditor::moveCaretUp (bool selecting) +{ + if (! isMultiLine()) + return moveCaretToStartOfLine (selecting); + + auto caretPos = getCaretRectangle().toFloat(); + return moveCaretWithTransaction (indexAtPosition (caretPos.getX(), caretPos.getY() - 1.0f), selecting); +} + +bool TextEditor::moveCaretDown (bool selecting) +{ + if (! isMultiLine()) + return moveCaretToEndOfLine (selecting); + + auto caretPos = getCaretRectangle().toFloat(); + return moveCaretWithTransaction (indexAtPosition (caretPos.getX(), caretPos.getBottom() + 1.0f), selecting); +} + +bool TextEditor::pageUp (bool selecting) +{ + if (! isMultiLine()) + return moveCaretToStartOfLine (selecting); + + auto caretPos = getCaretRectangle().toFloat(); + return moveCaretWithTransaction (indexAtPosition (caretPos.getX(), caretPos.getY() - viewport->getViewHeight()), selecting); +} + +bool TextEditor::pageDown (bool selecting) +{ + if (! isMultiLine()) + return moveCaretToEndOfLine (selecting); + + auto caretPos = getCaretRectangle().toFloat(); + return moveCaretWithTransaction (indexAtPosition (caretPos.getX(), caretPos.getBottom() + viewport->getViewHeight()), selecting); +} + +void TextEditor::scrollByLines (int deltaLines) +{ + if (auto* scrollbar = viewport->getVerticalScrollBar()) + scrollbar->moveScrollbarInSteps (deltaLines); +} + +bool TextEditor::scrollDown() +{ + scrollByLines (-1); + return true; +} + +bool TextEditor::scrollUp() +{ + scrollByLines (1); + return true; +} + +bool TextEditor::moveCaretToTop (bool selecting) +{ + return moveCaretWithTransaction (0, selecting); +} + +bool TextEditor::moveCaretToStartOfLine (bool selecting) +{ + auto caretPos = getCaretRectangle().toFloat(); + return moveCaretWithTransaction (indexAtPosition (0.0f, caretPos.getY()), selecting); +} + +bool TextEditor::moveCaretToEnd (bool selecting) +{ + return moveCaretWithTransaction (getTotalNumChars(), selecting); +} + +bool TextEditor::moveCaretToEndOfLine (bool selecting) +{ + auto caretPos = getCaretRectangle().toFloat(); + return moveCaretWithTransaction (indexAtPosition ((float) textHolder->getWidth(), caretPos.getY()), selecting); +} + +bool TextEditor::deleteBackwards (bool moveInWholeWordSteps) +{ + if (moveInWholeWordSteps) + moveCaretTo (findWordBreakBefore (getCaretPosition()), true); + else if (selection.isEmpty() && selection.getStart() > 0) + selection = Range (selection.getEnd() - 1, selection.getEnd()); + + cut(); + return true; +} + +bool TextEditor::deleteForwards (bool /*moveInWholeWordSteps*/) +{ + if (selection.isEmpty() && selection.getStart() < getTotalNumChars()) + selection = Range (selection.getStart(), selection.getStart() + 1); + + cut(); + return true; +} + +bool TextEditor::copyToClipboard() +{ + newTransaction(); + copy(); + return true; +} + +bool TextEditor::cutToClipboard() +{ + newTransaction(); + copy(); + cut(); + return true; +} + +bool TextEditor::pasteFromClipboard() +{ + newTransaction(); + paste(); + return true; +} + +bool TextEditor::selectAll() +{ + newTransaction(); + moveCaretTo (getTotalNumChars(), false); + moveCaretTo (0, true); + return true; +} + +//============================================================================== +void TextEditor::setEscapeAndReturnKeysConsumed (bool shouldBeConsumed) noexcept +{ + consumeEscAndReturnKeys = shouldBeConsumed; +} + +bool TextEditor::keyPressed (const KeyPress& key) +{ + if (isReadOnly() && key != KeyPress ('c', ModifierKeys::commandModifier, 0) + && key != KeyPress ('a', ModifierKeys::commandModifier, 0)) + return false; + + if (! TextEditorKeyMapper::invokeKeyFunction (*this, key)) + { + if (key == KeyPress::returnKey) + { + newTransaction(); + + if (returnKeyStartsNewLine) + insertTextAtCaret ("\n"); + else + { + returnPressed(); + return consumeEscAndReturnKeys; + } + } + else if (key.isKeyCode (KeyPress::escapeKey)) + { + newTransaction(); + moveCaretTo (getCaretPosition(), false); + escapePressed(); + return consumeEscAndReturnKeys; + } + else if (key.getTextCharacter() >= ' ' + || (tabKeyUsed && (key.getTextCharacter() == '\t'))) + { + insertTextAtCaret (String::charToString (key.getTextCharacter())); + + lastTransactionTime = Time::getApproximateMillisecondCounter(); + } + else + { + return false; + } + } + + return true; +} + +bool TextEditor::keyStateChanged (const bool isKeyDown) +{ + if (! isKeyDown) + return false; + + #if JUCE_WINDOWS + if (KeyPress (KeyPress::F4Key, ModifierKeys::altModifier, 0).isCurrentlyDown()) + return false; // We need to explicitly allow alt-F4 to pass through on Windows + #endif + + if ((! consumeEscAndReturnKeys) + && (KeyPress (KeyPress::escapeKey).isCurrentlyDown() + || KeyPress (KeyPress::returnKey).isCurrentlyDown())) + return false; + + // (overridden to avoid forwarding key events to the parent) + return ! ModifierKeys::getCurrentModifiers().isCommandDown(); +} + +//============================================================================== +void TextEditor::focusGained (FocusChangeType) +{ + newTransaction(); + + if (selectAllTextWhenFocused) + { + moveCaretTo (0, false); + moveCaretTo (getTotalNumChars(), true); + } + + repaint(); + updateCaretPosition(); + + if (auto* peer = getPeer()) + if (! isReadOnly()) + peer->textInputRequired (peer->globalToLocal (getScreenPosition()), *this); +} + +void TextEditor::focusLost (FocusChangeType) +{ + newTransaction(); + + wasFocused = false; + textHolder->stopTimer(); + + underlinedSections.clear(); + + if (auto* peer = getPeer()) + peer->dismissPendingTextInput(); + + updateCaretPosition(); + + postCommandMessage (TextEditorDefs::focusLossMessageId); + repaint(); +} + +//============================================================================== +void TextEditor::resized() +{ + viewport->setBoundsInset (borderSize); + viewport->setSingleStepSizes (16, roundToInt (currentFont.getHeight())); + + updateTextHolderSize(); + + if (isMultiLine()) + updateCaretPosition(); + else + scrollToMakeSureCursorIsVisible(); +} + +void TextEditor::handleCommandMessage (const int commandId) +{ + Component::BailOutChecker checker (this); + + switch (commandId) + { + case TextEditorDefs::textChangeMessageId: + listeners.callChecked (checker, &Listener::textEditorTextChanged, (TextEditor&) *this); + break; + + case TextEditorDefs::returnKeyMessageId: + listeners.callChecked (checker, &Listener::textEditorReturnKeyPressed, (TextEditor&) *this); + break; + + case TextEditorDefs::escapeKeyMessageId: + listeners.callChecked (checker, &Listener::textEditorEscapeKeyPressed, (TextEditor&) *this); + break; + + case TextEditorDefs::focusLossMessageId: + updateValueFromText(); + listeners.callChecked (checker, &Listener::textEditorFocusLost, (TextEditor&) *this); + break; + + default: + jassertfalse; + break; + } +} + +void TextEditor::setTemporaryUnderlining (const Array >& newUnderlinedSections) +{ + underlinedSections = newUnderlinedSections; + repaint(); +} + +//============================================================================== +UndoManager* TextEditor::getUndoManager() noexcept +{ + return readOnly ? nullptr : &undoManager; +} + +void TextEditor::clearInternal (UndoManager* const um) +{ + remove (Range (0, getTotalNumChars()), um, caretPosition); +} + +void TextEditor::insert (const String& text, + const int insertIndex, + const Font& font, + const Colour colour, + UndoManager* const um, + const int caretPositionToMoveTo) +{ + if (text.isNotEmpty()) + { + if (um != nullptr) + { + if (um->getNumActionsInCurrentTransaction() > TextEditorDefs::maxActionsPerTransaction) + newTransaction(); + + um->perform (new InsertAction (*this, text, insertIndex, font, colour, + caretPosition, caretPositionToMoveTo)); + } + else + { + repaintText (Range (insertIndex, getTotalNumChars())); // must do this before and after changing the data, in case + // a line gets moved due to word wrap + + int index = 0; + int nextIndex = 0; + + for (int i = 0; i < sections.size(); ++i) + { + nextIndex = index + sections.getUnchecked (i)->getTotalLength(); + + if (insertIndex == index) + { + sections.insert (i, new UniformTextSection (text, font, colour, passwordCharacter)); + break; + } + else if (insertIndex > index && insertIndex < nextIndex) + { + splitSection (i, insertIndex - index); + sections.insert (i + 1, new UniformTextSection (text, font, colour, passwordCharacter)); + break; + } + + index = nextIndex; + } + + if (nextIndex == insertIndex) + sections.add (new UniformTextSection (text, font, colour, passwordCharacter)); + + coalesceSimilarSections(); + totalNumChars = -1; + valueTextNeedsUpdating = true; + + updateTextHolderSize(); + moveCaretTo (caretPositionToMoveTo, false); + + repaintText (Range (insertIndex, getTotalNumChars())); + } + } +} + +void TextEditor::reinsert (const int insertIndex, const OwnedArray& sectionsToInsert) +{ + int index = 0; + int nextIndex = 0; + + for (int i = 0; i < sections.size(); ++i) + { + nextIndex = index + sections.getUnchecked (i)->getTotalLength(); + + if (insertIndex == index) + { + for (int j = sectionsToInsert.size(); --j >= 0;) + sections.insert (i, new UniformTextSection (*sectionsToInsert.getUnchecked(j))); + + break; + } + else if (insertIndex > index && insertIndex < nextIndex) + { + splitSection (i, insertIndex - index); + + for (int j = sectionsToInsert.size(); --j >= 0;) + sections.insert (i + 1, new UniformTextSection (*sectionsToInsert.getUnchecked(j))); + + break; + } + + index = nextIndex; + } + + if (nextIndex == insertIndex) + { + for (int j = 0; j < sectionsToInsert.size(); ++j) + sections.add (new UniformTextSection (*sectionsToInsert.getUnchecked(j))); + } + + coalesceSimilarSections(); + totalNumChars = -1; + valueTextNeedsUpdating = true; +} + +void TextEditor::remove (Range range, UndoManager* const um, const int caretPositionToMoveTo) +{ + if (! range.isEmpty()) + { + int index = 0; + + for (int i = 0; i < sections.size(); ++i) + { + const int nextIndex = index + sections.getUnchecked(i)->getTotalLength(); + + if (range.getStart() > index && range.getStart() < nextIndex) + { + splitSection (i, range.getStart() - index); + --i; + } + else if (range.getEnd() > index && range.getEnd() < nextIndex) + { + splitSection (i, range.getEnd() - index); + --i; + } + else + { + index = nextIndex; + + if (index > range.getEnd()) + break; + } + } + + index = 0; + + if (um != nullptr) + { + Array removedSections; + + for (int i = 0; i < sections.size(); ++i) + { + if (range.getEnd() <= range.getStart()) + break; + + auto* section = sections.getUnchecked (i); + auto nextIndex = index + section->getTotalLength(); + + if (range.getStart() <= index && range.getEnd() >= nextIndex) + removedSections.add (new UniformTextSection (*section)); + + index = nextIndex; + } + + if (um->getNumActionsInCurrentTransaction() > TextEditorDefs::maxActionsPerTransaction) + newTransaction(); + + um->perform (new RemoveAction (*this, range, caretPosition, + caretPositionToMoveTo, removedSections)); + } + else + { + auto remainingRange = range; + + for (int i = 0; i < sections.size(); ++i) + { + auto* section = sections.getUnchecked (i); + + const int nextIndex = index + section->getTotalLength(); + + if (remainingRange.getStart() <= index && remainingRange.getEnd() >= nextIndex) + { + sections.remove (i); + remainingRange.setEnd (remainingRange.getEnd() - (nextIndex - index)); + + if (remainingRange.isEmpty()) + break; + + --i; + } + else + { + index = nextIndex; + } + } + + coalesceSimilarSections(); + totalNumChars = -1; + valueTextNeedsUpdating = true; + + moveCaretTo (caretPositionToMoveTo, false); + + repaintText (Range (range.getStart(), getTotalNumChars())); + } + } +} + +//============================================================================== +String TextEditor::getText() const +{ + MemoryOutputStream mo; + mo.preallocate ((size_t) getTotalNumChars()); + + for (int i = 0; i < sections.size(); ++i) + sections.getUnchecked (i)->appendAllText (mo); + + return mo.toUTF8(); +} + +String TextEditor::getTextInRange (const Range& range) const +{ + if (range.isEmpty()) + return {}; + + MemoryOutputStream mo; + mo.preallocate ((size_t) jmin (getTotalNumChars(), range.getLength())); + + int index = 0; + + for (int i = 0; i < sections.size(); ++i) + { + auto* s = sections.getUnchecked (i); + auto nextIndex = index + s->getTotalLength(); + + if (range.getStart() < nextIndex) + { + if (range.getEnd() <= index) + break; + + s->appendSubstring (mo, range - index); + } + + index = nextIndex; + } + + return mo.toUTF8(); +} + +String TextEditor::getHighlightedText() const +{ + return getTextInRange (selection); +} + +int TextEditor::getTotalNumChars() const +{ + if (totalNumChars < 0) + { + totalNumChars = 0; + + for (int i = sections.size(); --i >= 0;) + totalNumChars += sections.getUnchecked (i)->getTotalLength(); + } + + return totalNumChars; +} + +bool TextEditor::isEmpty() const +{ + return getTotalNumChars() == 0; +} + +void TextEditor::getCharPosition (const int index, float& cx, float& cy, float& lineHeight) const +{ + const float wordWrapWidth = getWordWrapWidth(); + + if (wordWrapWidth > 0 && sections.size() > 0) + { + Iterator i (sections, wordWrapWidth, passwordCharacter, lineSpacing); + + i.getCharPosition (index, cx, cy, lineHeight); + } + else + { + cx = cy = 0; + lineHeight = currentFont.getHeight(); + } +} + +int TextEditor::indexAtPosition (const float x, const float y) +{ + const float wordWrapWidth = getWordWrapWidth(); + + if (wordWrapWidth > 0) + { + Iterator i (sections, wordWrapWidth, passwordCharacter, lineSpacing); + + while (i.next()) + { + if (i.lineY + i.lineHeight > y) + { + if (i.lineY > y) + return jmax (0, i.indexInText - 1); + + if (i.atomX >= x) + return i.indexInText; + + if (x < i.atomRight) + return i.xToIndex (x); + } + } + } + + return getTotalNumChars(); +} + +//============================================================================== +int TextEditor::findWordBreakAfter (const int position) const +{ + auto t = getTextInRange (Range (position, position + 512)); + auto totalLength = t.length(); + int i = 0; + + while (i < totalLength && CharacterFunctions::isWhitespace (t[i])) + ++i; + + const int type = TextEditorDefs::getCharacterCategory (t[i]); + + while (i < totalLength && type == TextEditorDefs::getCharacterCategory (t[i])) + ++i; + + while (i < totalLength && CharacterFunctions::isWhitespace (t[i])) + ++i; + + return position + i; +} + +int TextEditor::findWordBreakBefore (const int position) const +{ + if (position <= 0) + return 0; + + auto startOfBuffer = jmax (0, position - 512); + auto t = getTextInRange (Range (startOfBuffer, position)); + + int i = position - startOfBuffer; + + while (i > 0 && CharacterFunctions::isWhitespace (t [i - 1])) + --i; + + if (i > 0) + { + auto type = TextEditorDefs::getCharacterCategory (t [i - 1]); + + while (i > 0 && type == TextEditorDefs::getCharacterCategory (t [i - 1])) + --i; + } + + jassert (startOfBuffer + i >= 0); + return startOfBuffer + i; +} + + +//============================================================================== +void TextEditor::splitSection (const int sectionIndex, const int charToSplitAt) +{ + jassert (sections[sectionIndex] != nullptr); + + sections.insert (sectionIndex + 1, + sections.getUnchecked (sectionIndex)->split (charToSplitAt, passwordCharacter)); +} + +void TextEditor::coalesceSimilarSections() +{ + for (int i = 0; i < sections.size() - 1; ++i) + { + auto* s1 = sections.getUnchecked (i); + auto* s2 = sections.getUnchecked (i + 1); + + if (s1->font == s2->font + && s1->colour == s2->colour) + { + s1->append (*s2, passwordCharacter); + sections.remove (i + 1); + --i; + } + } +} + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_TextEditor.h b/modules/juce_gui_basics/widgets/juce_TextEditor.h index fff11dcbea..7077d57c04 100644 --- a/modules/juce_gui_basics/widgets/juce_TextEditor.h +++ b/modules/juce_gui_basics/widgets/juce_TextEditor.h @@ -1,774 +1,774 @@ -/* - ============================================================================== - - This file is part of the JUCE library. - Copyright (c) 2017 - ROLI Ltd. - - JUCE is an open source library subject to commercial or open-source - licensing. - - By using JUCE, you agree to the terms of both the JUCE 5 End-User License - Agreement and JUCE 5 Privacy Policy (both updated and effective as of the - 27th April 2017). - - End User License Agreement: www.juce.com/juce-5-licence - Privacy Policy: www.juce.com/juce-5-privacy-policy - - Or: You may also use this code under the terms of the GPL v3 (see - www.gnu.org/licenses). - - JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER - EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE - DISCLAIMED. - - ============================================================================== -*/ - -namespace juce -{ - -//============================================================================== -/** - An editable text box. - - A TextEditor can either be in single- or multi-line mode, and supports mixed - fonts and colours. - - @see TextEditor::Listener, Label -*/ -class JUCE_API TextEditor : public Component, - public TextInputTarget, - public SettableTooltipClient -{ -public: - //============================================================================== - /** Creates a new, empty text editor. - - @param componentName the name to pass to the component for it to use as its name - @param passwordCharacter if this is not zero, this character will be used as a replacement - for all characters that are drawn on screen - e.g. to create - a password-style textbox containing circular blobs instead of text, - you could set this value to 0x25cf, which is the unicode character - for a black splodge (not all fonts include this, though), or 0x2022, - which is a bullet (probably the best choice for linux). - */ - explicit TextEditor (const String& componentName = String(), - juce_wchar passwordCharacter = 0); - - /** Destructor. */ - ~TextEditor(); - - //============================================================================== - /** Puts the editor into either multi- or single-line mode. - - By default, the editor will be in single-line mode, so use this if you need a multi-line - editor. - - See also the setReturnKeyStartsNewLine() method, which will also need to be turned - on if you want a multi-line editor with line-breaks. - - @see isMultiLine, setReturnKeyStartsNewLine - */ - void setMultiLine (bool shouldBeMultiLine, - bool shouldWordWrap = true); - - /** Returns true if the editor is in multi-line mode. */ - bool isMultiLine() const; - - //============================================================================== - /** Changes the behaviour of the return key. - - If set to true, the return key will insert a new-line into the text; if false - it will trigger a call to the TextEditor::Listener::textEditorReturnKeyPressed() - method. By default this is set to false, and when true it will only insert - new-lines when in multi-line mode (see setMultiLine()). - */ - void setReturnKeyStartsNewLine (bool shouldStartNewLine); - - /** Returns the value set by setReturnKeyStartsNewLine(). - See setReturnKeyStartsNewLine() for more info. - */ - bool getReturnKeyStartsNewLine() const { return returnKeyStartsNewLine; } - - /** Indicates whether the tab key should be accepted and used to input a tab character, - or whether it gets ignored. - - By default the tab key is ignored, so that it can be used to switch keyboard focus - between components. - */ - void setTabKeyUsedAsCharacter (bool shouldTabKeyBeUsed); - - /** Returns true if the tab key is being used for input. - @see setTabKeyUsedAsCharacter - */ - bool isTabKeyUsedAsCharacter() const { return tabKeyUsed; } - - /** This can be used to change whether escape and return keypress events are - propagated up to the parent component. - The default here is true, meaning that these events are not allowed to reach the - parent, but you may want to allow them through so that they can trigger other - actions, e.g. closing a dialog box, etc. - */ - void setEscapeAndReturnKeysConsumed (bool shouldBeConsumed) noexcept; - - //============================================================================== - /** Changes the editor to read-only mode. - - By default, the text editor is not read-only. If you're making it read-only, you - might also want to call setCaretVisible (false) to get rid of the caret. - - The text can still be highlighted and copied when in read-only mode. - - @see isReadOnly, setCaretVisible - */ - void setReadOnly (bool shouldBeReadOnly); - - /** Returns true if the editor is in read-only mode. */ - bool isReadOnly() const noexcept; - - //============================================================================== - /** Makes the caret visible or invisible. - By default the caret is visible. - @see setCaretColour, setCaretPosition - */ - void setCaretVisible (bool shouldBeVisible); - - /** Returns true if the caret is enabled. - @see setCaretVisible - */ - bool isCaretVisible() const noexcept { return caretVisible && ! isReadOnly(); } - - //============================================================================== - /** Enables/disables a vertical scrollbar. - - (This only applies when in multi-line mode). When the text gets too long to fit - in the component, a scrollbar can appear to allow it to be scrolled. Even when - this is enabled, the scrollbar will be hidden unless it's needed. - - By default the scrollbar is enabled. - */ - void setScrollbarsShown (bool shouldBeEnabled); - - /** Returns true if scrollbars are enabled. - @see setScrollbarsShown - */ - bool areScrollbarsShown() const noexcept { return scrollbarVisible; } - - - /** Changes the password character used to disguise the text. - - @param passwordCharacter if this is not zero, this character will be used as a replacement - for all characters that are drawn on screen - e.g. to create - a password-style textbox containing circular blobs instead of text, - you could set this value to 0x25cf, which is the unicode character - for a black splodge (not all fonts include this, though), or 0x2022, - which is a bullet (probably the best choice for linux). - */ - void setPasswordCharacter (juce_wchar passwordCharacter); - - /** Returns the current password character. - @see setPasswordCharacter - */ - juce_wchar getPasswordCharacter() const noexcept { return passwordCharacter; } - - - //============================================================================== - /** Allows a right-click menu to appear for the editor. - - (This defaults to being enabled). - - If enabled, right-clicking (or command-clicking on the Mac) will pop up a menu - of options such as cut/copy/paste, undo/redo, etc. - */ - void setPopupMenuEnabled (bool menuEnabled); - - /** Returns true if the right-click menu is enabled. - @see setPopupMenuEnabled - */ - bool isPopupMenuEnabled() const noexcept { return popupMenuEnabled; } - - /** Returns true if a popup-menu is currently being displayed. */ - bool isPopupMenuCurrentlyActive() const noexcept { return menuActive; } - - //============================================================================== - /** A set of colour IDs to use to change the colour of various aspects of the editor. - - These constants can be used either via the Component::setColour(), or LookAndFeel::setColour() - methods. - - NB: You can also set the caret colour using CaretComponent::caretColourId - - @see Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour - */ - enum ColourIds - { - backgroundColourId = 0x1000200, /**< The colour to use for the text component's background - this can be - transparent if necessary. */ - - textColourId = 0x1000201, /**< The colour that will be used when text is added to the editor. Note - that because the editor can contain multiple colours, calling this - method won't change the colour of existing text - to do that, use - the applyColourToAllText() method */ - - highlightColourId = 0x1000202, /**< The colour with which to fill the background of highlighted sections of - the text - this can be transparent if you don't want to show any - highlighting.*/ - - highlightedTextColourId = 0x1000203, /**< The colour with which to draw the text in highlighted sections. */ - - outlineColourId = 0x1000205, /**< If this is non-transparent, it will be used to draw a box around - the edge of the component. */ - - focusedOutlineColourId = 0x1000206, /**< If this is non-transparent, it will be used to draw a box around - the edge of the component when it has focus. */ - - shadowColourId = 0x1000207, /**< If this is non-transparent, it'll be used to draw an inner shadow - around the edge of the editor. */ - }; - - //============================================================================== - /** Sets the font to use for newly added text. - - This will change the font that will be used next time any text is added or entered - into the editor. It won't change the font of any existing text - to do that, use - applyFontToAllText() instead. - - @see applyFontToAllText - */ - void setFont (const Font& newFont); - - /** Applies a font to all the text in the editor. - - If the changeCurrentFont argument is true then this will also set the - new font as the font to be used for any new text that's added. - - @see setFont - */ - void applyFontToAllText (const Font& newFont, bool changeCurrentFont = true); - - /** Returns the font that's currently being used for new text. - - @see setFont - */ - const Font& getFont() const noexcept { return currentFont; } - - /** Applies a colour to all the text in the editor. - - If the changeCurrentTextColour argument is true then this will also set the - new colour as the colour to be used for any new text that's added. - */ - void applyColourToAllText (const Colour& newColour, bool changeCurrentTextColour = true); - - //============================================================================== - /** If set to true, focusing on the editor will highlight all its text. - - (Set to false by default). - - This is useful for boxes where you expect the user to re-enter all the - text when they focus on the component, rather than editing what's already there. - */ - void setSelectAllWhenFocused (bool shouldSelectAll); - - /** When the text editor is empty, it can be set to display a message. - - This is handy for things like telling the user what to type in the box - the - string is only displayed, it's not taken to actually be the contents of - the editor. - */ - void setTextToShowWhenEmpty (const String& text, Colour colourToUse); - - //============================================================================== - /** Changes the size of the scrollbars that are used. - Handy if you need smaller scrollbars for a small text box. - */ - void setScrollBarThickness (int newThicknessPixels); - - //============================================================================== - /** - Receives callbacks from a TextEditor component when it changes. - - @see TextEditor::addListener - */ - class JUCE_API Listener - { - public: - /** Destructor. */ - virtual ~Listener() {} - - /** Called when the user changes the text in some way. */ - virtual void textEditorTextChanged (TextEditor&) {} - - /** Called when the user presses the return key. */ - virtual void textEditorReturnKeyPressed (TextEditor&) {} - - /** Called when the user presses the escape key. */ - virtual void textEditorEscapeKeyPressed (TextEditor&) {} - - /** Called when the text editor loses focus. */ - virtual void textEditorFocusLost (TextEditor&) {} - }; - - /** Registers a listener to be told when things happen to the text. - @see removeListener - */ - void addListener (Listener* newListener); - - /** Deregisters a listener. - @see addListener - */ - void removeListener (Listener* listenerToRemove); - - //============================================================================== - /** Returns the entire contents of the editor. */ - String getText() const; - - /** Returns a section of the contents of the editor. */ - String getTextInRange (const Range& textRange) const override; - - /** Returns true if there are no characters in the editor. - This is far more efficient than calling getText().isEmpty(). - */ - bool isEmpty() const; - - /** Sets the entire content of the editor. - - This will clear the editor and insert the given text (using the current text colour - and font). You can set the current text colour using - @code setColour (TextEditor::textColourId, ...); - @endcode - - @param newText the text to add - @param sendTextChangeMessage if true, this will cause a change message to - be sent to all the listeners. - @see insertTextAtCaret - */ - void setText (const String& newText, - bool sendTextChangeMessage = true); - - /** Returns a Value object that can be used to get or set the text. - - Bear in mind that this operate quite slowly if your text box contains large - amounts of text, as it needs to dynamically build the string that's involved. - It's best used for small text boxes. - */ - Value& getTextValue(); - - /** Inserts some text at the current caret position. - - If a section of the text is highlighted, it will be replaced by - this string, otherwise it will be inserted. - - To delete a section of text, you can use setHighlightedRegion() to - highlight it, and call insertTextAtCaret (String()). - - @see setCaretPosition, getCaretPosition, setHighlightedRegion - */ - void insertTextAtCaret (const String& textToInsert) override; - - /** Deletes all the text from the editor. */ - void clear(); - - /** Deletes the currently selected region. - This doesn't copy the deleted section to the clipboard - if you need to do that, call copy() first. - @see copy, paste, SystemClipboard - */ - void cut(); - - /** Copies the currently selected region to the clipboard. - @see cut, paste, SystemClipboard - */ - void copy(); - - /** Pastes the contents of the clipboard into the editor at the caret position. - @see cut, copy, SystemClipboard - */ - void paste(); - - //============================================================================== - /** Returns the current index of the caret. - @see setCaretPosition - */ - int getCaretPosition() const; - - /** Moves the caret to be in front of a given character. - @see getCaretPosition, moveCaretToEnd - */ - void setCaretPosition (int newIndex); - - /** Attempts to scroll the text editor so that the caret ends up at - a specified position. - - This won't affect the caret's position within the text, it tries to scroll - the entire editor vertically and horizontally so that the caret is sitting - at the given position (relative to the top-left of this component). - - Depending on the amount of text available, it might not be possible to - scroll far enough for the caret to reach this exact position, but it - will go as far as it can in that direction. - */ - void scrollEditorToPositionCaret (int desiredCaretX, int desiredCaretY); - - /** Get the graphical position of the caret. - - The rectangle returned is relative to the component's top-left corner. - @see scrollEditorToPositionCaret - */ - Rectangle getCaretRectangle() override; - - /** Selects a section of the text. */ - void setHighlightedRegion (const Range& newSelection) override; - - /** Returns the range of characters that are selected. - If nothing is selected, this will return an empty range. - @see setHighlightedRegion - */ - Range getHighlightedRegion() const override { return selection; } - - /** Returns the section of text that is currently selected. */ - String getHighlightedText() const; - - /** Finds the index of the character at a given position. - The coordinates are relative to the component's top-left. - */ - int getTextIndexAt (int x, int y); - - /** Counts the number of characters in the text. - - This is quicker than getting the text as a string if you just need to know - the length. - */ - int getTotalNumChars() const; - - /** Returns the total width of the text, as it is currently laid-out. - - This may be larger than the size of the TextEditor, and can change when - the TextEditor is resized or the text changes. - */ - int getTextWidth() const; - - /** Returns the maximum height of the text, as it is currently laid-out. - - This may be larger than the size of the TextEditor, and can change when - the TextEditor is resized or the text changes. - */ - int getTextHeight() const; - - /** Changes the size of the gap at the top and left-edge of the editor. - By default there's a gap of 4 pixels. - */ - void setIndents (int newLeftIndent, int newTopIndent); - - /** Changes the size of border left around the edge of the component. - @see getBorder - */ - void setBorder (const BorderSize& border); - - /** Returns the size of border around the edge of the component. - @see setBorder - */ - BorderSize getBorder() const; - - /** Used to disable the auto-scrolling which keeps the caret visible. - - If true (the default), the editor will scroll when the caret moves offscreen. If - set to false, it won't. - */ - void setScrollToShowCursor (bool shouldScrollToShowCaret); - - /** Sets the line spacing of the TextEditor. - - The default (and minimum) value is 1.0 and values > 1.0 will increase the line spacing as a - multiple of the line height e.g. for double-spacing call this method with an argument of 2.0. - */ - void setLineSpacing (float newLineSpacing) noexcept { lineSpacing = jmax (1.0f, newLineSpacing); } - - /** Returns the current line spacing of the TextEditor. */ - float getLineSpacing() const noexcept { return lineSpacing; } - - //============================================================================== - void moveCaretToEnd(); - bool moveCaretLeft (bool moveInWholeWordSteps, bool selecting); - bool moveCaretRight (bool moveInWholeWordSteps, bool selecting); - bool moveCaretUp (bool selecting); - bool moveCaretDown (bool selecting); - bool pageUp (bool selecting); - bool pageDown (bool selecting); - bool scrollDown(); - bool scrollUp(); - bool moveCaretToTop (bool selecting); - bool moveCaretToStartOfLine (bool selecting); - bool moveCaretToEnd (bool selecting); - bool moveCaretToEndOfLine (bool selecting); - bool deleteBackwards (bool moveInWholeWordSteps); - bool deleteForwards (bool moveInWholeWordSteps); - bool copyToClipboard(); - bool cutToClipboard(); - bool pasteFromClipboard(); - bool selectAll(); - bool undo(); - bool redo(); - - //============================================================================== - /** This adds the items to the popup menu. - - By default it adds the cut/copy/paste items, but you can override this if - you need to replace these with your own items. - - If you want to add your own items to the existing ones, you can override this, - call the base class's addPopupMenuItems() method, then append your own items. - - When the menu has been shown, performPopupMenuAction() will be called to - perform the item that the user has chosen. - - The default menu items will be added using item IDs from the - StandardApplicationCommandIDs namespace. - - If this was triggered by a mouse-click, the mouseClickEvent parameter will be - a pointer to the info about it, or may be null if the menu is being triggered - by some other means. - - @see performPopupMenuAction, setPopupMenuEnabled, isPopupMenuEnabled - */ - virtual void addPopupMenuItems (PopupMenu& menuToAddTo, - const MouseEvent* mouseClickEvent); - - /** This is called to perform one of the items that was shown on the popup menu. - - If you've overridden addPopupMenuItems(), you should also override this - to perform the actions that you've added. - - If you've overridden addPopupMenuItems() but have still left the default items - on the menu, remember to call the superclass's performPopupMenuAction() - so that it can perform the default actions if that's what the user clicked on. - - @see addPopupMenuItems, setPopupMenuEnabled, isPopupMenuEnabled - */ - virtual void performPopupMenuAction (int menuItemID); - - //============================================================================== - /** Base class for input filters that can be applied to a TextEditor to restrict - the text that can be entered. - */ - class JUCE_API InputFilter - { - public: - InputFilter() {} - virtual ~InputFilter() {} - - /** This method is called whenever text is entered into the editor. - An implementation of this class should should check the input string, - and return an edited version of it that should be used. - */ - virtual String filterNewText (TextEditor&, const String& newInput) = 0; - }; - - /** An input filter for a TextEditor that limits the length of text and/or the - characters that it may contain. - */ - class JUCE_API LengthAndCharacterRestriction : public InputFilter - { - public: - /** Creates a filter that limits the length of text, and/or the characters that it can contain. - @param maxNumChars if this is > 0, it sets a maximum length limit; if <= 0, no - limit is set - @param allowedCharacters if this is non-empty, then only characters that occur in - this string are allowed to be entered into the editor. - */ - LengthAndCharacterRestriction (int maxNumChars, const String& allowedCharacters); - - String filterNewText (TextEditor&, const String&) override; - - private: - String allowedCharacters; - int maxLength; - - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LengthAndCharacterRestriction) - }; - - /** Sets an input filter that should be applied to this editor. - The filter can be nullptr, to remove any existing filters. - If takeOwnership is true, then the filter will be owned and deleted by the editor - when no longer needed. - */ - void setInputFilter (InputFilter* newFilter, bool takeOwnership); - - /** Returns the current InputFilter, as set by setInputFilter(). */ - InputFilter* getInputFilter() const noexcept { return inputFilter; } - - /** Sets limits on the characters that can be entered. - This is just a shortcut that passes an instance of the LengthAndCharacterRestriction - class to setInputFilter(). - - @param maxTextLength if this is > 0, it sets a maximum length limit; if 0, no - limit is set - @param allowedCharacters if this is non-empty, then only characters that occur in - this string are allowed to be entered into the editor. - */ - void setInputRestrictions (int maxTextLength, - const String& allowedCharacters = String()); - - void setKeyboardType (VirtualKeyboardType type) noexcept { keyboardType = type; } - - //============================================================================== - /** This abstract base class is implemented by LookAndFeel classes to provide - TextEditor drawing functionality. - */ - struct JUCE_API LookAndFeelMethods - { - virtual ~LookAndFeelMethods() {} - - virtual void fillTextEditorBackground (Graphics&, int width, int height, TextEditor&) = 0; - virtual void drawTextEditorOutline (Graphics&, int width, int height, TextEditor&) = 0; - - virtual CaretComponent* createCaretComponent (Component* keyFocusOwner) = 0; - }; - - //============================================================================== - /** @internal */ - void paint (Graphics&) override; - /** @internal */ - void paintOverChildren (Graphics&) override; - /** @internal */ - void mouseDown (const MouseEvent&) override; - /** @internal */ - void mouseUp (const MouseEvent&) override; - /** @internal */ - void mouseDrag (const MouseEvent&) override; - /** @internal */ - void mouseDoubleClick (const MouseEvent&) override; - /** @internal */ - void mouseWheelMove (const MouseEvent&, const MouseWheelDetails&) override; - /** @internal */ - bool keyPressed (const KeyPress&) override; - /** @internal */ - bool keyStateChanged (bool) override; - /** @internal */ - void focusGained (FocusChangeType) override; - /** @internal */ - void focusLost (FocusChangeType) override; - /** @internal */ - void resized() override; - /** @internal */ - void enablementChanged() override; - /** @internal */ - void lookAndFeelChanged() override; - /** @internal */ - void parentHierarchyChanged() override; - /** @internal */ - bool isTextInputActive() const override; - /** @internal */ - void setTemporaryUnderlining (const Array >&) override; - /** @internal */ - VirtualKeyboardType getKeyboardType() override { return keyboardType; } - -protected: - //============================================================================== - /** Scrolls the minimum distance needed to get the caret into view. */ - void scrollToMakeSureCursorIsVisible(); - - /** Used internally to dispatch a text-change message. */ - void textChanged(); - - /** Begins a new transaction in the UndoManager. */ - void newTransaction(); - - /** Can be overridden to intercept return key presses directly */ - virtual void returnPressed(); - - /** Can be overridden to intercept escape key presses directly */ - virtual void escapePressed(); - -private: - //============================================================================== - class Iterator; - JUCE_PUBLIC_IN_DLL_BUILD (class UniformTextSection) - class TextHolderComponent; - class InsertAction; - class RemoveAction; - friend class InsertAction; - friend class RemoveAction; - - ScopedPointer viewport; - TextHolderComponent* textHolder; - BorderSize borderSize { 1, 1, 1, 3 }; - - bool readOnly = false; - bool caretVisible = true; - bool multiline = false; - bool wordWrap = false; - bool returnKeyStartsNewLine = false; - bool popupMenuEnabled = true; - bool selectAllTextWhenFocused = false; - bool scrollbarVisible = true; - bool wasFocused = false; - bool keepCaretOnScreen = true; - bool tabKeyUsed = false; - bool menuActive = false; - bool valueTextNeedsUpdating = false; - bool consumeEscAndReturnKeys = true; - - UndoManager undoManager; - ScopedPointer caret; - Range selection; - int leftIndent = 4, topIndent = 4; - unsigned int lastTransactionTime = 0; - Font currentFont { 14.0f }; - mutable int totalNumChars = 0; - int caretPosition = 0; - OwnedArray sections; - String textToShowWhenEmpty; - Colour colourForTextWhenEmpty; - juce_wchar passwordCharacter; - OptionalScopedPointer inputFilter; - Value textValue; - VirtualKeyboardType keyboardType = TextInputTarget::textKeyboard; - float lineSpacing = 1.0f; - - enum DragType - { - notDragging, - draggingSelectionStart, - draggingSelectionEnd - }; - - DragType dragType = notDragging; - - ListenerList listeners; - Array> underlinedSections; - - void moveCaret (int newCaretPos); - void moveCaretTo (int newPosition, bool isSelecting); - void recreateCaret(); - void handleCommandMessage (int) override; - void coalesceSimilarSections(); - void splitSection (int sectionIndex, int charToSplitAt); - void clearInternal (UndoManager*); - void insert (const String&, int insertIndex, const Font&, const Colour, UndoManager*, int newCaretPos); - void reinsert (int insertIndex, const OwnedArray&); - void remove (Range range, UndoManager*, int caretPositionToMoveTo); - void getCharPosition (int index, float& x, float& y, float& lineHeight) const; - void updateCaretPosition(); - void updateValueFromText(); - void textWasChangedByValue(); - int indexAtPosition (float x, float y); - int findWordBreakAfter (int position) const; - int findWordBreakBefore (int position) const; - bool moveCaretWithTransaction (int newPos, bool selecting); - friend class TextHolderComponent; - friend class TextEditorViewport; - void drawContent (Graphics&); - void updateTextHolderSize(); - float getWordWrapWidth() const; - void timerCallbackInt(); - void repaintText (Range); - void scrollByLines (int deltaLines); - bool undoOrRedo (bool shouldUndo); - UndoManager* getUndoManager() noexcept; - - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TextEditor) -}; - -/** This typedef is just for compatibility with old code - newer code should use the TextEditor::Listener class directly. */ -typedef TextEditor::Listener TextEditorListener; - -} // namespace juce +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2017 - ROLI Ltd. + + JUCE is an open source library subject to commercial or open-source + licensing. + + By using JUCE, you agree to the terms of both the JUCE 5 End-User License + Agreement and JUCE 5 Privacy Policy (both updated and effective as of the + 27th April 2017). + + End User License Agreement: www.juce.com/juce-5-licence + Privacy Policy: www.juce.com/juce-5-privacy-policy + + Or: You may also use this code under the terms of the GPL v3 (see + www.gnu.org/licenses). + + JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER + EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE + DISCLAIMED. + + ============================================================================== +*/ + +namespace juce +{ + +//============================================================================== +/** + An editable text box. + + A TextEditor can either be in single- or multi-line mode, and supports mixed + fonts and colours. + + @see TextEditor::Listener, Label +*/ +class JUCE_API TextEditor : public Component, + public TextInputTarget, + public SettableTooltipClient +{ +public: + //============================================================================== + /** Creates a new, empty text editor. + + @param componentName the name to pass to the component for it to use as its name + @param passwordCharacter if this is not zero, this character will be used as a replacement + for all characters that are drawn on screen - e.g. to create + a password-style textbox containing circular blobs instead of text, + you could set this value to 0x25cf, which is the unicode character + for a black splodge (not all fonts include this, though), or 0x2022, + which is a bullet (probably the best choice for linux). + */ + explicit TextEditor (const String& componentName = String(), + juce_wchar passwordCharacter = 0); + + /** Destructor. */ + ~TextEditor(); + + //============================================================================== + /** Puts the editor into either multi- or single-line mode. + + By default, the editor will be in single-line mode, so use this if you need a multi-line + editor. + + See also the setReturnKeyStartsNewLine() method, which will also need to be turned + on if you want a multi-line editor with line-breaks. + + @see isMultiLine, setReturnKeyStartsNewLine + */ + void setMultiLine (bool shouldBeMultiLine, + bool shouldWordWrap = true); + + /** Returns true if the editor is in multi-line mode. */ + bool isMultiLine() const; + + //============================================================================== + /** Changes the behaviour of the return key. + + If set to true, the return key will insert a new-line into the text; if false + it will trigger a call to the TextEditor::Listener::textEditorReturnKeyPressed() + method. By default this is set to false, and when true it will only insert + new-lines when in multi-line mode (see setMultiLine()). + */ + void setReturnKeyStartsNewLine (bool shouldStartNewLine); + + /** Returns the value set by setReturnKeyStartsNewLine(). + See setReturnKeyStartsNewLine() for more info. + */ + bool getReturnKeyStartsNewLine() const { return returnKeyStartsNewLine; } + + /** Indicates whether the tab key should be accepted and used to input a tab character, + or whether it gets ignored. + + By default the tab key is ignored, so that it can be used to switch keyboard focus + between components. + */ + void setTabKeyUsedAsCharacter (bool shouldTabKeyBeUsed); + + /** Returns true if the tab key is being used for input. + @see setTabKeyUsedAsCharacter + */ + bool isTabKeyUsedAsCharacter() const { return tabKeyUsed; } + + /** This can be used to change whether escape and return keypress events are + propagated up to the parent component. + The default here is true, meaning that these events are not allowed to reach the + parent, but you may want to allow them through so that they can trigger other + actions, e.g. closing a dialog box, etc. + */ + void setEscapeAndReturnKeysConsumed (bool shouldBeConsumed) noexcept; + + //============================================================================== + /** Changes the editor to read-only mode. + + By default, the text editor is not read-only. If you're making it read-only, you + might also want to call setCaretVisible (false) to get rid of the caret. + + The text can still be highlighted and copied when in read-only mode. + + @see isReadOnly, setCaretVisible + */ + void setReadOnly (bool shouldBeReadOnly); + + /** Returns true if the editor is in read-only mode. */ + bool isReadOnly() const noexcept; + + //============================================================================== + /** Makes the caret visible or invisible. + By default the caret is visible. + @see setCaretColour, setCaretPosition + */ + void setCaretVisible (bool shouldBeVisible); + + /** Returns true if the caret is enabled. + @see setCaretVisible + */ + bool isCaretVisible() const noexcept { return caretVisible && ! isReadOnly(); } + + //============================================================================== + /** Enables/disables a vertical scrollbar. + + (This only applies when in multi-line mode). When the text gets too long to fit + in the component, a scrollbar can appear to allow it to be scrolled. Even when + this is enabled, the scrollbar will be hidden unless it's needed. + + By default the scrollbar is enabled. + */ + void setScrollbarsShown (bool shouldBeEnabled); + + /** Returns true if scrollbars are enabled. + @see setScrollbarsShown + */ + bool areScrollbarsShown() const noexcept { return scrollbarVisible; } + + + /** Changes the password character used to disguise the text. + + @param passwordCharacter if this is not zero, this character will be used as a replacement + for all characters that are drawn on screen - e.g. to create + a password-style textbox containing circular blobs instead of text, + you could set this value to 0x25cf, which is the unicode character + for a black splodge (not all fonts include this, though), or 0x2022, + which is a bullet (probably the best choice for linux). + */ + void setPasswordCharacter (juce_wchar passwordCharacter); + + /** Returns the current password character. + @see setPasswordCharacter + */ + juce_wchar getPasswordCharacter() const noexcept { return passwordCharacter; } + + + //============================================================================== + /** Allows a right-click menu to appear for the editor. + + (This defaults to being enabled). + + If enabled, right-clicking (or command-clicking on the Mac) will pop up a menu + of options such as cut/copy/paste, undo/redo, etc. + */ + void setPopupMenuEnabled (bool menuEnabled); + + /** Returns true if the right-click menu is enabled. + @see setPopupMenuEnabled + */ + bool isPopupMenuEnabled() const noexcept { return popupMenuEnabled; } + + /** Returns true if a popup-menu is currently being displayed. */ + bool isPopupMenuCurrentlyActive() const noexcept { return menuActive; } + + //============================================================================== + /** A set of colour IDs to use to change the colour of various aspects of the editor. + + These constants can be used either via the Component::setColour(), or LookAndFeel::setColour() + methods. + + NB: You can also set the caret colour using CaretComponent::caretColourId + + @see Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour + */ + enum ColourIds + { + backgroundColourId = 0x1000200, /**< The colour to use for the text component's background - this can be + transparent if necessary. */ + + textColourId = 0x1000201, /**< The colour that will be used when text is added to the editor. Note + that because the editor can contain multiple colours, calling this + method won't change the colour of existing text - to do that, use + the applyColourToAllText() method */ + + highlightColourId = 0x1000202, /**< The colour with which to fill the background of highlighted sections of + the text - this can be transparent if you don't want to show any + highlighting.*/ + + highlightedTextColourId = 0x1000203, /**< The colour with which to draw the text in highlighted sections. */ + + outlineColourId = 0x1000205, /**< If this is non-transparent, it will be used to draw a box around + the edge of the component. */ + + focusedOutlineColourId = 0x1000206, /**< If this is non-transparent, it will be used to draw a box around + the edge of the component when it has focus. */ + + shadowColourId = 0x1000207, /**< If this is non-transparent, it'll be used to draw an inner shadow + around the edge of the editor. */ + }; + + //============================================================================== + /** Sets the font to use for newly added text. + + This will change the font that will be used next time any text is added or entered + into the editor. It won't change the font of any existing text - to do that, use + applyFontToAllText() instead. + + @see applyFontToAllText + */ + void setFont (const Font& newFont); + + /** Applies a font to all the text in the editor. + + If the changeCurrentFont argument is true then this will also set the + new font as the font to be used for any new text that's added. + + @see setFont + */ + void applyFontToAllText (const Font& newFont, bool changeCurrentFont = true); + + /** Returns the font that's currently being used for new text. + + @see setFont + */ + const Font& getFont() const noexcept { return currentFont; } + + /** Applies a colour to all the text in the editor. + + If the changeCurrentTextColour argument is true then this will also set the + new colour as the colour to be used for any new text that's added. + */ + void applyColourToAllText (const Colour& newColour, bool changeCurrentTextColour = true); + + //============================================================================== + /** If set to true, focusing on the editor will highlight all its text. + + (Set to false by default). + + This is useful for boxes where you expect the user to re-enter all the + text when they focus on the component, rather than editing what's already there. + */ + void setSelectAllWhenFocused (bool shouldSelectAll); + + /** When the text editor is empty, it can be set to display a message. + + This is handy for things like telling the user what to type in the box - the + string is only displayed, it's not taken to actually be the contents of + the editor. + */ + void setTextToShowWhenEmpty (const String& text, Colour colourToUse); + + //============================================================================== + /** Changes the size of the scrollbars that are used. + Handy if you need smaller scrollbars for a small text box. + */ + void setScrollBarThickness (int newThicknessPixels); + + //============================================================================== + /** + Receives callbacks from a TextEditor component when it changes. + + @see TextEditor::addListener + */ + class JUCE_API Listener + { + public: + /** Destructor. */ + virtual ~Listener() {} + + /** Called when the user changes the text in some way. */ + virtual void textEditorTextChanged (TextEditor&) {} + + /** Called when the user presses the return key. */ + virtual void textEditorReturnKeyPressed (TextEditor&) {} + + /** Called when the user presses the escape key. */ + virtual void textEditorEscapeKeyPressed (TextEditor&) {} + + /** Called when the text editor loses focus. */ + virtual void textEditorFocusLost (TextEditor&) {} + }; + + /** Registers a listener to be told when things happen to the text. + @see removeListener + */ + void addListener (Listener* newListener); + + /** Deregisters a listener. + @see addListener + */ + void removeListener (Listener* listenerToRemove); + + //============================================================================== + /** Returns the entire contents of the editor. */ + String getText() const; + + /** Returns a section of the contents of the editor. */ + String getTextInRange (const Range& textRange) const override; + + /** Returns true if there are no characters in the editor. + This is far more efficient than calling getText().isEmpty(). + */ + bool isEmpty() const; + + /** Sets the entire content of the editor. + + This will clear the editor and insert the given text (using the current text colour + and font). You can set the current text colour using + @code setColour (TextEditor::textColourId, ...); + @endcode + + @param newText the text to add + @param sendTextChangeMessage if true, this will cause a change message to + be sent to all the listeners. + @see insertTextAtCaret + */ + void setText (const String& newText, + bool sendTextChangeMessage = true); + + /** Returns a Value object that can be used to get or set the text. + + Bear in mind that this operate quite slowly if your text box contains large + amounts of text, as it needs to dynamically build the string that's involved. + It's best used for small text boxes. + */ + Value& getTextValue(); + + /** Inserts some text at the current caret position. + + If a section of the text is highlighted, it will be replaced by + this string, otherwise it will be inserted. + + To delete a section of text, you can use setHighlightedRegion() to + highlight it, and call insertTextAtCaret (String()). + + @see setCaretPosition, getCaretPosition, setHighlightedRegion + */ + void insertTextAtCaret (const String& textToInsert) override; + + /** Deletes all the text from the editor. */ + void clear(); + + /** Deletes the currently selected region. + This doesn't copy the deleted section to the clipboard - if you need to do that, call copy() first. + @see copy, paste, SystemClipboard + */ + void cut(); + + /** Copies the currently selected region to the clipboard. + @see cut, paste, SystemClipboard + */ + void copy(); + + /** Pastes the contents of the clipboard into the editor at the caret position. + @see cut, copy, SystemClipboard + */ + void paste(); + + //============================================================================== + /** Returns the current index of the caret. + @see setCaretPosition + */ + int getCaretPosition() const; + + /** Moves the caret to be in front of a given character. + @see getCaretPosition, moveCaretToEnd + */ + void setCaretPosition (int newIndex); + + /** Attempts to scroll the text editor so that the caret ends up at + a specified position. + + This won't affect the caret's position within the text, it tries to scroll + the entire editor vertically and horizontally so that the caret is sitting + at the given position (relative to the top-left of this component). + + Depending on the amount of text available, it might not be possible to + scroll far enough for the caret to reach this exact position, but it + will go as far as it can in that direction. + */ + void scrollEditorToPositionCaret (int desiredCaretX, int desiredCaretY); + + /** Get the graphical position of the caret. + + The rectangle returned is relative to the component's top-left corner. + @see scrollEditorToPositionCaret + */ + Rectangle getCaretRectangle() override; + + /** Selects a section of the text. */ + void setHighlightedRegion (const Range& newSelection) override; + + /** Returns the range of characters that are selected. + If nothing is selected, this will return an empty range. + @see setHighlightedRegion + */ + Range getHighlightedRegion() const override { return selection; } + + /** Returns the section of text that is currently selected. */ + String getHighlightedText() const; + + /** Finds the index of the character at a given position. + The coordinates are relative to the component's top-left. + */ + int getTextIndexAt (int x, int y); + + /** Counts the number of characters in the text. + + This is quicker than getting the text as a string if you just need to know + the length. + */ + int getTotalNumChars() const; + + /** Returns the total width of the text, as it is currently laid-out. + + This may be larger than the size of the TextEditor, and can change when + the TextEditor is resized or the text changes. + */ + int getTextWidth() const; + + /** Returns the maximum height of the text, as it is currently laid-out. + + This may be larger than the size of the TextEditor, and can change when + the TextEditor is resized or the text changes. + */ + int getTextHeight() const; + + /** Changes the size of the gap at the top and left-edge of the editor. + By default there's a gap of 4 pixels. + */ + void setIndents (int newLeftIndent, int newTopIndent); + + /** Changes the size of border left around the edge of the component. + @see getBorder + */ + void setBorder (const BorderSize& border); + + /** Returns the size of border around the edge of the component. + @see setBorder + */ + BorderSize getBorder() const; + + /** Used to disable the auto-scrolling which keeps the caret visible. + + If true (the default), the editor will scroll when the caret moves offscreen. If + set to false, it won't. + */ + void setScrollToShowCursor (bool shouldScrollToShowCaret); + + /** Sets the line spacing of the TextEditor. + + The default (and minimum) value is 1.0 and values > 1.0 will increase the line spacing as a + multiple of the line height e.g. for double-spacing call this method with an argument of 2.0. + */ + void setLineSpacing (float newLineSpacing) noexcept { lineSpacing = jmax (1.0f, newLineSpacing); } + + /** Returns the current line spacing of the TextEditor. */ + float getLineSpacing() const noexcept { return lineSpacing; } + + //============================================================================== + void moveCaretToEnd(); + bool moveCaretLeft (bool moveInWholeWordSteps, bool selecting); + bool moveCaretRight (bool moveInWholeWordSteps, bool selecting); + bool moveCaretUp (bool selecting); + bool moveCaretDown (bool selecting); + bool pageUp (bool selecting); + bool pageDown (bool selecting); + bool scrollDown(); + bool scrollUp(); + bool moveCaretToTop (bool selecting); + bool moveCaretToStartOfLine (bool selecting); + bool moveCaretToEnd (bool selecting); + bool moveCaretToEndOfLine (bool selecting); + bool deleteBackwards (bool moveInWholeWordSteps); + bool deleteForwards (bool moveInWholeWordSteps); + bool copyToClipboard(); + bool cutToClipboard(); + bool pasteFromClipboard(); + bool selectAll(); + bool undo(); + bool redo(); + + //============================================================================== + /** This adds the items to the popup menu. + + By default it adds the cut/copy/paste items, but you can override this if + you need to replace these with your own items. + + If you want to add your own items to the existing ones, you can override this, + call the base class's addPopupMenuItems() method, then append your own items. + + When the menu has been shown, performPopupMenuAction() will be called to + perform the item that the user has chosen. + + The default menu items will be added using item IDs from the + StandardApplicationCommandIDs namespace. + + If this was triggered by a mouse-click, the mouseClickEvent parameter will be + a pointer to the info about it, or may be null if the menu is being triggered + by some other means. + + @see performPopupMenuAction, setPopupMenuEnabled, isPopupMenuEnabled + */ + virtual void addPopupMenuItems (PopupMenu& menuToAddTo, + const MouseEvent* mouseClickEvent); + + /** This is called to perform one of the items that was shown on the popup menu. + + If you've overridden addPopupMenuItems(), you should also override this + to perform the actions that you've added. + + If you've overridden addPopupMenuItems() but have still left the default items + on the menu, remember to call the superclass's performPopupMenuAction() + so that it can perform the default actions if that's what the user clicked on. + + @see addPopupMenuItems, setPopupMenuEnabled, isPopupMenuEnabled + */ + virtual void performPopupMenuAction (int menuItemID); + + //============================================================================== + /** Base class for input filters that can be applied to a TextEditor to restrict + the text that can be entered. + */ + class JUCE_API InputFilter + { + public: + InputFilter() {} + virtual ~InputFilter() {} + + /** This method is called whenever text is entered into the editor. + An implementation of this class should should check the input string, + and return an edited version of it that should be used. + */ + virtual String filterNewText (TextEditor&, const String& newInput) = 0; + }; + + /** An input filter for a TextEditor that limits the length of text and/or the + characters that it may contain. + */ + class JUCE_API LengthAndCharacterRestriction : public InputFilter + { + public: + /** Creates a filter that limits the length of text, and/or the characters that it can contain. + @param maxNumChars if this is > 0, it sets a maximum length limit; if <= 0, no + limit is set + @param allowedCharacters if this is non-empty, then only characters that occur in + this string are allowed to be entered into the editor. + */ + LengthAndCharacterRestriction (int maxNumChars, const String& allowedCharacters); + + String filterNewText (TextEditor&, const String&) override; + + private: + String allowedCharacters; + int maxLength; + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LengthAndCharacterRestriction) + }; + + /** Sets an input filter that should be applied to this editor. + The filter can be nullptr, to remove any existing filters. + If takeOwnership is true, then the filter will be owned and deleted by the editor + when no longer needed. + */ + void setInputFilter (InputFilter* newFilter, bool takeOwnership); + + /** Returns the current InputFilter, as set by setInputFilter(). */ + InputFilter* getInputFilter() const noexcept { return inputFilter; } + + /** Sets limits on the characters that can be entered. + This is just a shortcut that passes an instance of the LengthAndCharacterRestriction + class to setInputFilter(). + + @param maxTextLength if this is > 0, it sets a maximum length limit; if 0, no + limit is set + @param allowedCharacters if this is non-empty, then only characters that occur in + this string are allowed to be entered into the editor. + */ + void setInputRestrictions (int maxTextLength, + const String& allowedCharacters = String()); + + void setKeyboardType (VirtualKeyboardType type) noexcept { keyboardType = type; } + + //============================================================================== + /** This abstract base class is implemented by LookAndFeel classes to provide + TextEditor drawing functionality. + */ + struct JUCE_API LookAndFeelMethods + { + virtual ~LookAndFeelMethods() {} + + virtual void fillTextEditorBackground (Graphics&, int width, int height, TextEditor&) = 0; + virtual void drawTextEditorOutline (Graphics&, int width, int height, TextEditor&) = 0; + + virtual CaretComponent* createCaretComponent (Component* keyFocusOwner) = 0; + }; + + //============================================================================== + /** @internal */ + void paint (Graphics&) override; + /** @internal */ + void paintOverChildren (Graphics&) override; + /** @internal */ + void mouseDown (const MouseEvent&) override; + /** @internal */ + void mouseUp (const MouseEvent&) override; + /** @internal */ + void mouseDrag (const MouseEvent&) override; + /** @internal */ + void mouseDoubleClick (const MouseEvent&) override; + /** @internal */ + void mouseWheelMove (const MouseEvent&, const MouseWheelDetails&) override; + /** @internal */ + bool keyPressed (const KeyPress&) override; + /** @internal */ + bool keyStateChanged (bool) override; + /** @internal */ + void focusGained (FocusChangeType) override; + /** @internal */ + void focusLost (FocusChangeType) override; + /** @internal */ + void resized() override; + /** @internal */ + void enablementChanged() override; + /** @internal */ + void lookAndFeelChanged() override; + /** @internal */ + void parentHierarchyChanged() override; + /** @internal */ + bool isTextInputActive() const override; + /** @internal */ + void setTemporaryUnderlining (const Array >&) override; + /** @internal */ + VirtualKeyboardType getKeyboardType() override { return keyboardType; } + +protected: + //============================================================================== + /** Scrolls the minimum distance needed to get the caret into view. */ + void scrollToMakeSureCursorIsVisible(); + + /** Used internally to dispatch a text-change message. */ + void textChanged(); + + /** Begins a new transaction in the UndoManager. */ + void newTransaction(); + + /** Can be overridden to intercept return key presses directly */ + virtual void returnPressed(); + + /** Can be overridden to intercept escape key presses directly */ + virtual void escapePressed(); + +private: + //============================================================================== + class Iterator; + JUCE_PUBLIC_IN_DLL_BUILD (class UniformTextSection) + class TextHolderComponent; + class InsertAction; + class RemoveAction; + friend class InsertAction; + friend class RemoveAction; + + ScopedPointer viewport; + TextHolderComponent* textHolder; + BorderSize borderSize { 1, 1, 1, 3 }; + + bool readOnly = false; + bool caretVisible = true; + bool multiline = false; + bool wordWrap = false; + bool returnKeyStartsNewLine = false; + bool popupMenuEnabled = true; + bool selectAllTextWhenFocused = false; + bool scrollbarVisible = true; + bool wasFocused = false; + bool keepCaretOnScreen = true; + bool tabKeyUsed = false; + bool menuActive = false; + bool valueTextNeedsUpdating = false; + bool consumeEscAndReturnKeys = true; + + UndoManager undoManager; + ScopedPointer caret; + Range selection; + int leftIndent = 4, topIndent = 4; + unsigned int lastTransactionTime = 0; + Font currentFont { 14.0f }; + mutable int totalNumChars = 0; + int caretPosition = 0; + OwnedArray sections; + String textToShowWhenEmpty; + Colour colourForTextWhenEmpty; + juce_wchar passwordCharacter; + OptionalScopedPointer inputFilter; + Value textValue; + VirtualKeyboardType keyboardType = TextInputTarget::textKeyboard; + float lineSpacing = 1.0f; + + enum DragType + { + notDragging, + draggingSelectionStart, + draggingSelectionEnd + }; + + DragType dragType = notDragging; + + ListenerList listeners; + Array> underlinedSections; + + void moveCaret (int newCaretPos); + void moveCaretTo (int newPosition, bool isSelecting); + void recreateCaret(); + void handleCommandMessage (int) override; + void coalesceSimilarSections(); + void splitSection (int sectionIndex, int charToSplitAt); + void clearInternal (UndoManager*); + void insert (const String&, int insertIndex, const Font&, const Colour, UndoManager*, int newCaretPos); + void reinsert (int insertIndex, const OwnedArray&); + void remove (Range range, UndoManager*, int caretPositionToMoveTo); + void getCharPosition (int index, float& x, float& y, float& lineHeight) const; + void updateCaretPosition(); + void updateValueFromText(); + void textWasChangedByValue(); + int indexAtPosition (float x, float y); + int findWordBreakAfter (int position) const; + int findWordBreakBefore (int position) const; + bool moveCaretWithTransaction (int newPos, bool selecting); + friend class TextHolderComponent; + friend class TextEditorViewport; + void drawContent (Graphics&); + void updateTextHolderSize(); + float getWordWrapWidth() const; + void timerCallbackInt(); + void repaintText (Range); + void scrollByLines (int deltaLines); + bool undoOrRedo (bool shouldUndo); + UndoManager* getUndoManager() noexcept; + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TextEditor) +}; + +/** This typedef is just for compatibility with old code - newer code should use the TextEditor::Listener class directly. */ +typedef TextEditor::Listener TextEditorListener; + +} // namespace juce