Browse Source

Finally turned off the T wide-char string macro by default. If you've used it in your code, I'd recommend just skimming through and simply removing it. Any ascii strings will work fine without it; any strings containing extended chars are NOT PORTABLE and shouldn't be embedded anyway, but will work just as well if you replace the T with an 'L' prefix (much better to re-encode them as escaped UTF-8 though). If you really must keep using the macro, you can set the JUCE_DEFINE_T_MACRO flag to 1, and it will still be available as before.

tags/2021-05-28
jules 13 years ago
parent
commit
6b07bfb51b
15 changed files with 62 additions and 159 deletions
  1. +0
    -1
      modules/juce_audio_devices/juce_audio_devices.cpp
  2. +0
    -1
      modules/juce_audio_formats/juce_audio_formats.cpp
  3. +0
    -1
      modules/juce_audio_processors/juce_audio_processors.cpp
  4. +0
    -1
      modules/juce_audio_utils/juce_audio_utils.cpp
  5. +0
    -1
      modules/juce_browser_plugin/juce_browser_plugin.cpp
  6. +0
    -1
      modules/juce_core/juce_core.cpp
  7. +8
    -11
      modules/juce_core/text/juce_CharacterFunctions.h
  8. +0
    -1
      modules/juce_events/juce_events.cpp
  9. +46
    -136
      modules/juce_graphics/colour/juce_Colour.cpp
  10. +8
    -0
      modules/juce_graphics/colour/juce_PixelFormats.h
  11. +0
    -1
      modules/juce_graphics/juce_graphics.cpp
  12. +0
    -1
      modules/juce_gui_basics/juce_gui_basics.cpp
  13. +0
    -1
      modules/juce_gui_extra/juce_gui_extra.cpp
  14. +0
    -1
      modules/juce_opengl/juce_opengl.cpp
  15. +0
    -1
      modules/juce_video/juce_video.cpp

+ 0
- 1
modules/juce_audio_devices/juce_audio_devices.cpp View File

@@ -36,7 +36,6 @@
// and your header search path must make it accessible to the module's files. // and your header search path must make it accessible to the module's files.
#include "AppConfig.h" #include "AppConfig.h"
#define JUCE_DONT_DEFINE_MACROS 1
#include "../juce_core/native/juce_BasicNativeHeaders.h" #include "../juce_core/native/juce_BasicNativeHeaders.h"
#include "juce_audio_devices.h" #include "juce_audio_devices.h"


+ 0
- 1
modules/juce_audio_formats/juce_audio_formats.cpp View File

@@ -36,7 +36,6 @@
// and your header search path must make it accessible to the module's files. // and your header search path must make it accessible to the module's files.
#include "AppConfig.h" #include "AppConfig.h"
#define JUCE_DONT_DEFINE_MACROS 1
#include "../juce_core/native/juce_BasicNativeHeaders.h" #include "../juce_core/native/juce_BasicNativeHeaders.h"
#include "juce_audio_formats.h" #include "juce_audio_formats.h"


+ 0
- 1
modules/juce_audio_processors/juce_audio_processors.cpp View File

@@ -36,7 +36,6 @@
// and your header search path must make it accessible to the module's files. // and your header search path must make it accessible to the module's files.
#include "AppConfig.h" #include "AppConfig.h"
#define JUCE_DONT_DEFINE_MACROS 1
#include "../juce_core/native/juce_BasicNativeHeaders.h" #include "../juce_core/native/juce_BasicNativeHeaders.h"
#include "juce_audio_processors.h" #include "juce_audio_processors.h"
#include "../juce_gui_extra/juce_gui_extra.h" #include "../juce_gui_extra/juce_gui_extra.h"


+ 0
- 1
modules/juce_audio_utils/juce_audio_utils.cpp View File

@@ -36,7 +36,6 @@
// and your header search path must make it accessible to the module's files. // and your header search path must make it accessible to the module's files.
#include "AppConfig.h" #include "AppConfig.h"
#define JUCE_DONT_DEFINE_MACROS 1
#include "../juce_core/native/juce_BasicNativeHeaders.h" #include "../juce_core/native/juce_BasicNativeHeaders.h"
#include "juce_audio_utils.h" #include "juce_audio_utils.h"


+ 0
- 1
modules/juce_browser_plugin/juce_browser_plugin.cpp View File

@@ -36,7 +36,6 @@
// and your header search path must make it accessible to the module's files. // and your header search path must make it accessible to the module's files.
#include "AppConfig.h" #include "AppConfig.h"
#define JUCE_DONT_DEFINE_MACROS 1
#include "../juce_core/native/juce_BasicNativeHeaders.h" #include "../juce_core/native/juce_BasicNativeHeaders.h"
#if _MSC_VER #if _MSC_VER


+ 0
- 1
modules/juce_core/juce_core.cpp View File

@@ -37,7 +37,6 @@
#include "AppConfig.h" #include "AppConfig.h"
//============================================================================== //==============================================================================
#define JUCE_DONT_DEFINE_MACROS 1
#include "native/juce_BasicNativeHeaders.h" #include "native/juce_BasicNativeHeaders.h"
#include "juce_core.h" #include "juce_core.h"


+ 8
- 11
modules/juce_core/text/juce_CharacterFunctions.h View File

@@ -48,21 +48,18 @@
typedef uint32 juce_wchar; typedef uint32 juce_wchar;
#endif #endif
/** This macro is deprecated, but preserved for compatibility with old code.*/
#define JUCE_T(stringLiteral) (L##stringLiteral)
/** This macro is deprecated, but preserved for compatibility with old code. */
#define JUCE_T(stringLiteral) (L##stringLiteral)
#if ! JUCE_DONT_DEFINE_MACROS
#if JUCE_DEFINE_T_MACRO
/** The 'T' macro is an alternative for using the "L" prefix in front of a string literal. /** The 'T' macro is an alternative for using the "L" prefix in front of a string literal.
This macro is deprectated, but kept here for compatibility with old code. The best (i.e.
most portable) way to encode your string literals is just as standard 8-bit strings, but
using escaped utf-8 character codes for extended characters.
Because the 'T' symbol is occasionally used inside 3rd-party library headers which you
may need to include after juce.h, you can set the JUCE_DONT_DEFINE_MACROS flag to avoid
defining it.
This macro is deprecated, but available for compatibility with old code if you set
JUCE_DEFINE_T_MACRO = 1. The fastest, most portable and best way to write your string
literals is as standard char strings, using escaped utf-8 character sequences for extended
characters, rather than trying to store them as wide-char strings.
*/ */
#define T(stringLiteral) JUCE_T(stringLiteral)
#define T(stringLiteral) JUCE_T(stringLiteral)
#endif #endif
#undef max #undef max


+ 0
- 1
modules/juce_events/juce_events.cpp View File

@@ -36,7 +36,6 @@
// and your header search path must make it accessible to the module's files. // and your header search path must make it accessible to the module's files.
#include "AppConfig.h" #include "AppConfig.h"
#define JUCE_DONT_DEFINE_MACROS 1
#include "../juce_core/native/juce_BasicNativeHeaders.h" #include "../juce_core/native/juce_BasicNativeHeaders.h"
#include "juce_events.h" #include "juce_events.h"


+ 46
- 136
modules/juce_graphics/colour/juce_Colour.cpp View File

@@ -28,9 +28,9 @@ BEGIN_JUCE_NAMESPACE
//============================================================================== //==============================================================================
namespace ColourHelpers namespace ColourHelpers
{ {
uint8 floatAlphaToInt (const float alpha) noexcept
uint8 floatToUInt8 (const float n) noexcept
{ {
return (uint8) jlimit (0, 0xff, roundToInt (alpha * 255.0f));
return (uint8) jlimit (0, 255, roundToInt (n * 255.0f));
} }
// This is an adjusted brightness value, based on the way the human eye responds to // This is an adjusted brightness value, based on the way the human eye responds to
@@ -97,63 +97,25 @@ struct HSB
return Colour (hue, saturation, brightness, original.getAlpha()); return Colour (hue, saturation, brightness, original.getAlpha());
} }
static void convertHSBtoRGB (float h, float s, float v,
uint8& r, uint8& g, uint8& b) noexcept
static PixelARGB convertHSBtoRGB (float h, float s, float v, const uint8 alpha) noexcept
{ {
v = jlimit (0.0f, 1.0f, v);
v *= 255.0f;
v = jlimit (0.0f, 255.0f, v * 255.0f);
const uint8 intV = (uint8) roundToInt (v); const uint8 intV = (uint8) roundToInt (v);
if (s <= 0) if (s <= 0)
{
r = intV;
g = intV;
b = intV;
}
else
{
s = jmin (1.0f, s);
h = (h - std::floor (h)) * 6.0f + 0.00001f; // need a small adjustment to compensate for rounding errors
const float f = h - std::floor (h);
const uint8 x = (uint8) roundToInt (v * (1.0f - s));
if (h < 1.0f)
{
r = intV;
g = (uint8) roundToInt (v * (1.0f - (s * (1.0f - f))));
b = x;
}
else if (h < 2.0f)
{
r = (uint8) roundToInt (v * (1.0f - s * f));
g = intV;
b = x;
}
else if (h < 3.0f)
{
r = x;
g = intV;
b = (uint8) roundToInt (v * (1.0f - (s * (1.0f - f))));
}
else if (h < 4.0f)
{
r = x;
g = (uint8) roundToInt (v * (1.0f - s * f));
b = intV;
}
else if (h < 5.0f)
{
r = (uint8) roundToInt (v * (1.0f - (s * (1.0f - f))));
g = x;
b = intV;
}
else
{
r = intV;
g = x;
b = (uint8) roundToInt (v * (1.0f - s * f));
}
}
return PixelARGB (alpha, intV, intV, intV);
s = jmin (1.0f, s);
h = (h - std::floor (h)) * 6.0f + 0.00001f; // need a small adjustment to compensate for rounding errors
const float f = h - std::floor (h);
const uint8 x = (uint8) roundToInt (v * (1.0f - s));
if (h < 1.0f) return PixelARGB (alpha, intV, (uint8) roundToInt (v * (1.0f - (s * (1.0f - f)))), x);
if (h < 2.0f) return PixelARGB (alpha, (uint8) roundToInt (v * (1.0f - s * f)), intV, x);
if (h < 3.0f) return PixelARGB (alpha, x, intV, (uint8) roundToInt (v * (1.0f - (s * (1.0f - f)))));
if (h < 4.0f) return PixelARGB (alpha, x, (uint8) roundToInt (v * (1.0f - s * f)), intV);
if (h < 5.0f) return PixelARGB (alpha, (uint8) roundToInt (v * (1.0f - (s * (1.0f - f)))), x, intV);
else return PixelARGB (alpha, intV, x, (uint8) roundToInt (v * (1.0f - s * f)));
} }
float hue, saturation, brightness; float hue, saturation, brightness;
@@ -176,15 +138,8 @@ Colour& Colour::operator= (const Colour& other) noexcept
return *this; return *this;
} }
bool Colour::operator== (const Colour& other) const noexcept
{
return argb.getARGB() == other.argb.getARGB();
}
bool Colour::operator!= (const Colour& other) const noexcept
{
return argb.getARGB() != other.argb.getARGB();
}
bool Colour::operator== (const Colour& other) const noexcept { return argb.getARGB() == other.argb.getARGB(); }
bool Colour::operator!= (const Colour& other) const noexcept { return argb.getARGB() != other.argb.getARGB(); }
//============================================================================== //==============================================================================
Colour::Colour (const uint32 argb_) noexcept Colour::Colour (const uint32 argb_) noexcept
@@ -192,80 +147,49 @@ Colour::Colour (const uint32 argb_) noexcept
{ {
} }
Colour::Colour (const uint8 red,
const uint8 green,
const uint8 blue) noexcept
Colour::Colour (const uint8 red, const uint8 green, const uint8 blue) noexcept
{ {
argb.setARGB (0xff, red, green, blue); argb.setARGB (0xff, red, green, blue);
} }
Colour Colour::fromRGB (const uint8 red,
const uint8 green,
const uint8 blue) noexcept
Colour Colour::fromRGB (const uint8 red, const uint8 green, const uint8 blue) noexcept
{ {
return Colour (red, green, blue); return Colour (red, green, blue);
} }
Colour::Colour (const uint8 red,
const uint8 green,
const uint8 blue,
const uint8 alpha) noexcept
Colour::Colour (const uint8 red, const uint8 green, const uint8 blue, const uint8 alpha) noexcept
{ {
argb.setARGB (alpha, red, green, blue); argb.setARGB (alpha, red, green, blue);
} }
Colour Colour::fromRGBA (const uint8 red,
const uint8 green,
const uint8 blue,
const uint8 alpha) noexcept
Colour Colour::fromRGBA (const uint8 red, const uint8 green, const uint8 blue, const uint8 alpha) noexcept
{ {
return Colour (red, green, blue, alpha); return Colour (red, green, blue, alpha);
} }
Colour::Colour (const uint8 red,
const uint8 green,
const uint8 blue,
const float alpha) noexcept
Colour::Colour (const uint8 red, const uint8 green, const uint8 blue, const float alpha) noexcept
{ {
argb.setARGB (ColourHelpers::floatAlphaToInt (alpha), red, green, blue);
argb.setARGB (ColourHelpers::floatToUInt8 (alpha), red, green, blue);
} }
Colour Colour::fromRGBAFloat (const uint8 red,
const uint8 green,
const uint8 blue,
const float alpha) noexcept
Colour Colour::fromRGBAFloat (const uint8 red, const uint8 green, const uint8 blue, const float alpha) noexcept
{ {
return Colour (red, green, blue, alpha); return Colour (red, green, blue, alpha);
} }
Colour::Colour (const float hue,
const float saturation,
const float brightness,
const float alpha) noexcept
Colour::Colour (const float hue, const float saturation, const float brightness, const float alpha) noexcept
: argb (HSB::convertHSBtoRGB (hue, saturation, brightness, ColourHelpers::floatToUInt8 (alpha)))
{ {
uint8 r, g, b;
HSB::convertHSBtoRGB (hue, saturation, brightness, r, g, b);
argb.setARGB (ColourHelpers::floatAlphaToInt (alpha), r, g, b);
} }
Colour Colour::fromHSV (const float hue,
const float saturation,
const float brightness,
const float alpha) noexcept
Colour Colour::fromHSV (const float hue, const float saturation, const float brightness, const float alpha) noexcept
{ {
return Colour (hue, saturation, brightness, alpha); return Colour (hue, saturation, brightness, alpha);
} }
Colour::Colour (const float hue,
const float saturation,
const float brightness,
const uint8 alpha) noexcept
Colour::Colour (const float hue, const float saturation, const float brightness, const uint8 alpha) noexcept
: argb (HSB::convertHSBtoRGB (hue, saturation, brightness, alpha))
{ {
uint8 r, g, b;
HSB::convertHSBtoRGB (hue, saturation, brightness, r, g, b);
argb.setARGB (alpha, r, g, b);
} }
Colour::~Colour() noexcept Colour::~Colour() noexcept
@@ -308,7 +232,7 @@ Colour Colour::withAlpha (const float newAlpha) const noexcept
jassert (newAlpha >= 0 && newAlpha <= 1.0f); jassert (newAlpha >= 0 && newAlpha <= 1.0f);
PixelARGB newCol (argb); PixelARGB newCol (argb);
newCol.setAlpha (ColourHelpers::floatAlphaToInt (newAlpha));
newCol.setAlpha (ColourHelpers::floatToUInt8 (newAlpha));
return Colour (newCol.getARGB()); return Colour (newCol.getARGB());
} }
@@ -326,27 +250,21 @@ Colour Colour::overlaidWith (const Colour& src) const noexcept
{ {
const int destAlpha = getAlpha(); const int destAlpha = getAlpha();
if (destAlpha > 0)
{
const int invA = 0xff - (int) src.getAlpha();
const int resA = 0xff - (((0xff - destAlpha) * invA) >> 8);
if (destAlpha <= 0)
return src;
if (resA > 0)
{
const int da = (invA * destAlpha) / resA;
return Colour ((uint8) (src.getRed() + ((((int) getRed() - src.getRed()) * da) >> 8)),
(uint8) (src.getGreen() + ((((int) getGreen() - src.getGreen()) * da) >> 8)),
(uint8) (src.getBlue() + ((((int) getBlue() - src.getBlue()) * da) >> 8)),
(uint8) resA);
}
const int invA = 0xff - (int) src.getAlpha();
const int resA = 0xff - (((0xff - destAlpha) * invA) >> 8);
if (resA <= 0)
return *this; return *this;
}
else
{
return src;
}
const int da = (invA * destAlpha) / resA;
return Colour ((uint8) (src.getRed() + ((((int) getRed() - src.getRed()) * da) >> 8)),
(uint8) (src.getGreen() + ((((int) getGreen() - src.getGreen()) * da) >> 8)),
(uint8) (src.getBlue() + ((((int) getBlue() - src.getBlue()) * da) >> 8)),
(uint8) resA);
} }
Colour Colour::interpolatedWith (const Colour& other, float proportionOfOther) const noexcept Colour Colour::interpolatedWith (const Colour& other, float proportionOfOther) const noexcept
@@ -380,7 +298,6 @@ void Colour::getHSB (float& h, float& s, float& v) const noexcept
v = hsb.brightness; v = hsb.brightness;
} }
//==============================================================================
float Colour::getHue() const noexcept { return HSB (*this).hue; } float Colour::getHue() const noexcept { return HSB (*this).hue; }
float Colour::getSaturation() const noexcept { return HSB (*this).saturation; } float Colour::getSaturation() const noexcept { return HSB (*this).saturation; }
float Colour::getBrightness() const noexcept { return HSB (*this).brightness; } float Colour::getBrightness() const noexcept { return HSB (*this).brightness; }
@@ -397,7 +314,6 @@ Colour Colour::withRotatedHue (const float amountToRotate) const noexcept
return hsb.toColour (*this); return hsb.toColour (*this);
} }
//==============================================================================
Colour Colour::withMultipliedSaturation (const float amount) const noexcept Colour Colour::withMultipliedSaturation (const float amount) const noexcept
{ {
HSB hsb (*this); HSB hsb (*this);
@@ -405,14 +321,10 @@ Colour Colour::withMultipliedSaturation (const float amount) const noexcept
return hsb.toColour (*this); return hsb.toColour (*this);
} }
//==============================================================================
Colour Colour::withMultipliedBrightness (const float amount) const noexcept Colour Colour::withMultipliedBrightness (const float amount) const noexcept
{ {
HSB hsb (*this); HSB hsb (*this);
hsb.brightness *= amount;
if (hsb.brightness > 1.0f)
hsb.brightness = 1.0f;
hsb.brightness = jmin (1.0f, hsb.brightness * amount);
return hsb.toColour (*this); return hsb.toColour (*this);
} }
@@ -440,9 +352,7 @@ Colour Colour::darker (float amount) const noexcept
//============================================================================== //==============================================================================
Colour Colour::greyLevel (const float brightness) noexcept Colour Colour::greyLevel (const float brightness) noexcept
{ {
const uint8 level
= (uint8) jlimit (0x00, 0xff, roundToInt (brightness * 255.0f));
const uint8 level = ColourHelpers::floatToUInt8 (brightness);
return Colour (level, level, level); return Colour (level, level, level);
} }


+ 8
- 0
modules/juce_graphics/colour/juce_PixelFormats.h View File

@@ -65,6 +65,14 @@ public:
{ {
} }
PixelARGB (const uint8 a, const uint8 r, const uint8 g, const uint8 b) noexcept
{
components.b = b;
components.g = g;
components.r = r;
components.a = a;
}
forcedinline uint32 getARGB() const noexcept { return argb; } forcedinline uint32 getARGB() const noexcept { return argb; }
forcedinline uint32 getUnpremultipliedARGB() const noexcept { PixelARGB p (argb); p.unpremultiply(); return p.getARGB(); } forcedinline uint32 getUnpremultipliedARGB() const noexcept { PixelARGB p (argb); p.unpremultiply(); return p.getARGB(); }


+ 0
- 1
modules/juce_graphics/juce_graphics.cpp View File

@@ -37,7 +37,6 @@
#include "AppConfig.h" #include "AppConfig.h"
#include "../juce_core/native/juce_BasicNativeHeaders.h" #include "../juce_core/native/juce_BasicNativeHeaders.h"
#define JUCE_DONT_DEFINE_MACROS 1
#include "juce_graphics.h" #include "juce_graphics.h"
//============================================================================== //==============================================================================


+ 0
- 1
modules/juce_gui_basics/juce_gui_basics.cpp View File

@@ -36,7 +36,6 @@
// and your header search path must make it accessible to the module's files. // and your header search path must make it accessible to the module's files.
#include "AppConfig.h" #include "AppConfig.h"
#define JUCE_DONT_DEFINE_MACROS 1
#include "../juce_core/native/juce_BasicNativeHeaders.h" #include "../juce_core/native/juce_BasicNativeHeaders.h"
#include "juce_gui_basics.h" #include "juce_gui_basics.h"


+ 0
- 1
modules/juce_gui_extra/juce_gui_extra.cpp View File

@@ -36,7 +36,6 @@
// and your header search path must make it accessible to the module's files. // and your header search path must make it accessible to the module's files.
#include "AppConfig.h" #include "AppConfig.h"
#define JUCE_DONT_DEFINE_MACROS 1
#include "../juce_core/native/juce_BasicNativeHeaders.h" #include "../juce_core/native/juce_BasicNativeHeaders.h"
#include "juce_gui_extra.h" #include "juce_gui_extra.h"


+ 0
- 1
modules/juce_opengl/juce_opengl.cpp View File

@@ -36,7 +36,6 @@
// and your header search path must make it accessible to the module's files. // and your header search path must make it accessible to the module's files.
#include "AppConfig.h" #include "AppConfig.h"
#define JUCE_DONT_DEFINE_MACROS 1
#include "../juce_core/native/juce_BasicNativeHeaders.h" #include "../juce_core/native/juce_BasicNativeHeaders.h"
#include "juce_opengl.h" #include "juce_opengl.h"


+ 0
- 1
modules/juce_video/juce_video.cpp View File

@@ -36,7 +36,6 @@
// and your header search path must make it accessible to the module's files. // and your header search path must make it accessible to the module's files.
#include "AppConfig.h" #include "AppConfig.h"
#define JUCE_DONT_DEFINE_MACROS 1
#include "../juce_core/native/juce_BasicNativeHeaders.h" #include "../juce_core/native/juce_BasicNativeHeaders.h"
#include "../juce_gui_extra/juce_gui_extra.h" #include "../juce_gui_extra/juce_gui_extra.h"
#include "juce_video.h" #include "juce_video.h"


Loading…
Cancel
Save