Browse Source

Update juce

tags/1.9.4
falkTX 10 years ago
parent
commit
d92d36b108
15 changed files with 108 additions and 108 deletions
  1. +2
    -2
      data/copy-juce-carla
  2. +11
    -8
      source/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp
  3. +1
    -1
      source/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp
  4. +1
    -0
      source/modules/juce_core/juce_core.h
  5. +3
    -3
      source/modules/juce_core/memory/juce_ReferenceCountedObject.h
  6. +1
    -1
      source/modules/juce_core/native/juce_win32_ComSmartPtr.h
  7. +8
    -6
      source/modules/juce_graphics/native/juce_RenderingHelpers.h
  8. +7
    -8
      source/modules/juce_graphics/native/juce_win32_Direct2DGraphicsContext.cpp
  9. +6
    -6
      source/modules/juce_graphics/native/juce_win32_DirectWriteTypeLayout.cpp
  10. +4
    -9
      source/modules/juce_graphics/native/juce_win32_DirectWriteTypeface.cpp
  11. +11
    -11
      source/modules/juce_graphics/native/juce_win32_Fonts.cpp
  12. +42
    -46
      source/modules/juce_gui_basics/layout/juce_Viewport.cpp
  13. +9
    -3
      source/modules/juce_gui_basics/layout/juce_Viewport.h
  14. +2
    -3
      source/modules/juce_gui_extra/misc/juce_ColourSelector.h
  15. +0
    -1
      source/modules/juce_gui_extra/native/juce_mac_NSViewComponent.mm

+ 2
- 2
data/copy-juce-carla View File

@@ -2,8 +2,8 @@


set -e set -e


JUCE_MODULES_DIR="/home/falktx/FOSS/GIT-mine/DISTRHO/libs/juce/source/modules/"
CARLA_MODULES_DIR="/home/falktx/FOSS/GIT-mine/Carla/source/modules/"
JUCE_MODULES_DIR="/home/falktx/Personal/FOSS/GIT/distrho/DISTRHO/libs/juce/source/modules/"
CARLA_MODULES_DIR="/home/falktx/Personal/FOSS/GIT/falktx/Carla/source/modules/"


MODULES=("juce_audio_basics juce_audio_devices juce_audio_formats juce_audio_processors juce_core juce_data_structures juce_events juce_graphics juce_gui_basics juce_gui_extra") MODULES=("juce_audio_basics juce_audio_devices juce_audio_formats juce_audio_processors juce_core juce_data_structures juce_events juce_graphics juce_gui_basics juce_gui_extra")




+ 11
- 8
source/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp View File

@@ -229,7 +229,7 @@ namespace FloatVectorHelpers
static Type findMinOrMax (const Type* src, int num, const bool isMinimum) noexcept static Type findMinOrMax (const Type* src, int num, const bool isMinimum) noexcept
{ {
const int numLongOps = num / Mode::numParallel;
int numLongOps = num / Mode::numParallel;
#if JUCE_USE_SSE_INTRINSICS #if JUCE_USE_SSE_INTRINSICS
if (numLongOps > 1 && isSSE2Available()) if (numLongOps > 1 && isSSE2Available())
@@ -246,7 +246,7 @@ namespace FloatVectorHelpers
if (isMinimum) if (isMinimum)
{ {
for (int i = 1; i < numLongOps; ++i)
while (--numLongOps > 0)
{ {
src += Mode::numParallel; src += Mode::numParallel;
val = Mode::min (val, Mode::loadA (src)); val = Mode::min (val, Mode::loadA (src));
@@ -254,7 +254,7 @@ namespace FloatVectorHelpers
} }
else else
{ {
for (int i = 1; i < numLongOps; ++i)
while (--numLongOps > 0)
{ {
src += Mode::numParallel; src += Mode::numParallel;
val = Mode::max (val, Mode::loadA (src)); val = Mode::max (val, Mode::loadA (src));
@@ -268,7 +268,7 @@ namespace FloatVectorHelpers
if (isMinimum) if (isMinimum)
{ {
for (int i = 1; i < numLongOps; ++i)
while (--numLongOps > 0)
{ {
src += Mode::numParallel; src += Mode::numParallel;
val = Mode::min (val, Mode::loadU (src)); val = Mode::min (val, Mode::loadU (src));
@@ -276,7 +276,7 @@ namespace FloatVectorHelpers
} }
else else
{ {
for (int i = 1; i < numLongOps; ++i)
while (--numLongOps > 0)
{ {
src += Mode::numParallel; src += Mode::numParallel;
val = Mode::max (val, Mode::loadU (src)); val = Mode::max (val, Mode::loadU (src));
@@ -288,6 +288,7 @@ namespace FloatVectorHelpers
: Mode::max (val); : Mode::max (val);
num &= (Mode::numParallel - 1); num &= (Mode::numParallel - 1);
src += Mode::numParallel;
for (int i = 0; i < num; ++i) for (int i = 0; i < num; ++i)
result = isMinimum ? jmin (result, src[i]) result = isMinimum ? jmin (result, src[i])
@@ -302,7 +303,7 @@ namespace FloatVectorHelpers
static Range<Type> findMinAndMax (const Type* src, int num) noexcept static Range<Type> findMinAndMax (const Type* src, int num) noexcept
{ {
const int numLongOps = num / Mode::numParallel;
int numLongOps = num / Mode::numParallel;
#if JUCE_USE_SSE_INTRINSICS #if JUCE_USE_SSE_INTRINSICS
if (numLongOps > 1 && isSSE2Available()) if (numLongOps > 1 && isSSE2Available())
@@ -318,7 +319,7 @@ namespace FloatVectorHelpers
mn = Mode::loadA (src); mn = Mode::loadA (src);
mx = mn; mx = mn;
for (int i = 1; i < numLongOps; ++i)
while (--numLongOps > 0)
{ {
src += Mode::numParallel; src += Mode::numParallel;
const ParallelType v = Mode::loadA (src); const ParallelType v = Mode::loadA (src);
@@ -332,7 +333,7 @@ namespace FloatVectorHelpers
mn = Mode::loadU (src); mn = Mode::loadU (src);
mx = mn; mx = mn;
for (int i = 1; i < numLongOps; ++i)
while (--numLongOps > 0)
{ {
src += Mode::numParallel; src += Mode::numParallel;
const ParallelType v = Mode::loadU (src); const ParallelType v = Mode::loadU (src);
@@ -345,6 +346,8 @@ namespace FloatVectorHelpers
Mode::max (mx)); Mode::max (mx));
num &= 3; num &= 3;
src += Mode::numParallel;
for (int i = 0; i < num; ++i) for (int i = 0; i < num; ++i)
result = result.getUnionWith (src[i]); result = result.getUnionWith (src[i]);


+ 1
- 1
source/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp View File

@@ -1758,7 +1758,7 @@ private:
//============================================================================== //==============================================================================
VST3ModuleHandle::Ptr module; VST3ModuleHandle::Ptr module;
friend class VST3HostContext;
friend VST3HostContext;
ComSmartPtr<VST3HostContext> host; ComSmartPtr<VST3HostContext> host;
// Information objects: // Information objects:


+ 1
- 0
source/modules/juce_core/juce_core.h View File

@@ -272,6 +272,7 @@ extern JUCE_API void JUCE_CALLTYPE logAssertion (const char* file, int line) noe
#include "zip/juce_GZIPDecompressorInputStream.h" #include "zip/juce_GZIPDecompressorInputStream.h"
#include "zip/juce_ZipFile.h" #include "zip/juce_ZipFile.h"
#include "containers/juce_PropertySet.h" #include "containers/juce_PropertySet.h"
#include "memory/juce_SharedResourcePointer.h"
} }


+ 3
- 3
source/modules/juce_core/memory/juce_ReferenceCountedObject.h View File

@@ -329,17 +329,17 @@ public:
//============================================================================== //==============================================================================
/** Returns the object that this pointer references. /** Returns the object that this pointer references.
The pointer returned may be zero, of course.
The pointer returned may be null, of course.
*/ */
operator ReferencedType*() const noexcept { return referencedObject; } operator ReferencedType*() const noexcept { return referencedObject; }
/** Returns the object that this pointer references. /** Returns the object that this pointer references.
The pointer returned may be zero, of course.
The pointer returned may be null, of course.
*/ */
ReferencedType* get() const noexcept { return referencedObject; } ReferencedType* get() const noexcept { return referencedObject; }
/** Returns the object that this pointer references. /** Returns the object that this pointer references.
The pointer returned may be zero, of course.
The pointer returned may be null, of course.
*/ */
ReferencedType* getObject() const noexcept { return referencedObject; } ReferencedType* getObject() const noexcept { return referencedObject; }


+ 1
- 1
source/modules/juce_core/native/juce_win32_ComSmartPtr.h View File

@@ -29,7 +29,7 @@
#ifndef JUCE_WIN32_COMSMARTPTR_H_INCLUDED #ifndef JUCE_WIN32_COMSMARTPTR_H_INCLUDED
#define JUCE_WIN32_COMSMARTPTR_H_INCLUDED #define JUCE_WIN32_COMSMARTPTR_H_INCLUDED
#if ! defined (_MSC_VER) //|| defined (__uuidof))
#if ! (defined (_MSC_VER) || defined (__uuidof))
template<typename Type> struct UUIDGetter { static CLSID get() { jassertfalse; return CLSID(); } }; template<typename Type> struct UUIDGetter { static CLSID get() { jassertfalse; return CLSID(); } };
#define __uuidof(x) UUIDGetter<x>::get() #define __uuidof(x) UUIDGetter<x>::get()
#endif #endif


+ 8
- 6
source/modules/juce_graphics/native/juce_RenderingHelpers.h View File

@@ -890,20 +890,22 @@ namespace EdgeTableFillers
forcedinline void copyRow (DestPixelType* dest, SrcPixelType const* src, int width) const noexcept forcedinline void copyRow (DestPixelType* dest, SrcPixelType const* src, int width) const noexcept
{ {
if (srcData.pixelStride == 3 && destData.pixelStride == 3)
const int destStride = destData.pixelStride;
const int srcStride = srcData.pixelStride;
if (destStride == srcStride
&& srcData.pixelFormat == Image::RGB
&& destData.pixelFormat == Image::RGB)
{ {
memcpy (dest, src, sizeof (PixelRGB) * (size_t) width);
memcpy (dest, src, (size_t) (width * srcStride));
} }
else else
{ {
const int destStride = destData.pixelStride;
const int srcStride = srcData.pixelStride;
do do
{ {
dest->blend (*src); dest->blend (*src);
dest = addBytesToPointer (dest, destStride); dest = addBytesToPointer (dest, destStride);
src = addBytesToPointer (src, srcStride);
src = addBytesToPointer (src, srcStride);
} while (--width > 0); } while (--width > 0);
} }
} }


+ 7
- 8
source/modules/juce_graphics/native/juce_win32_Direct2DGraphicsContext.cpp View File

@@ -37,10 +37,9 @@ public:
D2D1_RENDER_TARGET_PROPERTIES props = D2D1::RenderTargetProperties(); D2D1_RENDER_TARGET_PROPERTIES props = D2D1::RenderTargetProperties();
D2D1_HWND_RENDER_TARGET_PROPERTIES propsHwnd = D2D1::HwndRenderTargetProperties (hwnd, size); D2D1_HWND_RENDER_TARGET_PROPERTIES propsHwnd = D2D1::HwndRenderTargetProperties (hwnd, size);
const Direct2DFactories& factories = Direct2DFactories::getInstance();
if (factories.d2dFactory != nullptr)
if (factories->d2dFactory != nullptr)
{ {
HRESULT hr = factories.d2dFactory->CreateHwndRenderTarget (props, propsHwnd, renderingTarget.resetAndGetPointerAddress());
HRESULT hr = factories->d2dFactory->CreateHwndRenderTarget (props, propsHwnd, renderingTarget.resetAndGetPointerAddress());
jassert (SUCCEEDED (hr)); (void) hr; jassert (SUCCEEDED (hr)); (void) hr;
hr = renderingTarget->CreateSolidColorBrush (D2D1::ColorF::ColorF (0.0f, 0.0f, 0.0f, 1.0f), colourBrush.resetAndGetPointerAddress()); hr = renderingTarget->CreateSolidColorBrush (D2D1::ColorF::ColorF (0.0f, 0.0f, 0.0f, 1.0f), colourBrush.resetAndGetPointerAddress());
} }
@@ -287,9 +286,8 @@ public:
{ {
renderingTarget->SetTransform (transformToMatrix (currentState->transform)); renderingTarget->SetTransform (transformToMatrix (currentState->transform));
const Direct2DFactories& factories = Direct2DFactories::getInstance();
DirectWriteTypeLayout::drawToD2DContext (text, area, renderingTarget, factories.directWriteFactory,
factories.d2dFactory, factories.systemFonts);
DirectWriteTypeLayout::drawToD2DContext (text, area, renderingTarget, factories->directWriteFactory,
factories->d2dFactory, factories->systemFonts);
renderingTarget->SetTransform (D2D1::IdentityMatrix()); renderingTarget->SetTransform (D2D1::IdentityMatrix());
return true; return true;
@@ -695,6 +693,7 @@ public:
//============================================================================== //==============================================================================
private: private:
SharedResourcePointer<Direct2DFactories> factories;
HWND hwnd; HWND hwnd;
ComSmartPtr <ID2D1HwndRenderTarget> renderingTarget; ComSmartPtr <ID2D1HwndRenderTarget> renderingTarget;
ComSmartPtr <ID2D1SolidColorBrush> colourBrush; ComSmartPtr <ID2D1SolidColorBrush> colourBrush;
@@ -733,7 +732,7 @@ private:
static ID2D1PathGeometry* rectListToPathGeometry (const RectangleList<int>& clipRegion) static ID2D1PathGeometry* rectListToPathGeometry (const RectangleList<int>& clipRegion)
{ {
ID2D1PathGeometry* p = nullptr; ID2D1PathGeometry* p = nullptr;
Direct2DFactories::getInstance().d2dFactory->CreatePathGeometry (&p);
factories->d2dFactory->CreatePathGeometry (&p);
ComSmartPtr <ID2D1GeometrySink> sink; ComSmartPtr <ID2D1GeometrySink> sink;
HRESULT hr = p->Open (sink.resetAndGetPointerAddress()); // xxx handle error HRESULT hr = p->Open (sink.resetAndGetPointerAddress()); // xxx handle error
@@ -811,7 +810,7 @@ private:
static ID2D1PathGeometry* pathToPathGeometry (const Path& path, const AffineTransform& transform) static ID2D1PathGeometry* pathToPathGeometry (const Path& path, const AffineTransform& transform)
{ {
ID2D1PathGeometry* p = nullptr; ID2D1PathGeometry* p = nullptr;
Direct2DFactories::getInstance().d2dFactory->CreatePathGeometry (&p);
factories->d2dFactory->CreatePathGeometry (&p);
ComSmartPtr <ID2D1GeometrySink> sink; ComSmartPtr <ID2D1GeometrySink> sink;
HRESULT hr = p->Open (sink.resetAndGetPointerAddress()); HRESULT hr = p->Open (sink.resetAndGetPointerAddress());


+ 6
- 6
source/modules/juce_graphics/native/juce_win32_DirectWriteTypeLayout.cpp View File

@@ -389,9 +389,9 @@ namespace DirectWriteTypeLayout
bool TextLayout::createNativeLayout (const AttributedString& text) bool TextLayout::createNativeLayout (const AttributedString& text)
{ {
#if JUCE_USE_DIRECTWRITE #if JUCE_USE_DIRECTWRITE
const Direct2DFactories& factories = Direct2DFactories::getInstance();
SharedResourcePointer<Direct2DFactories> factories;
if (factories.d2dFactory != nullptr && factories.systemFonts != nullptr)
if (factories->d2dFactory != nullptr && factories->systemFonts != nullptr)
{ {
#if JUCE_64BIT #if JUCE_64BIT
// There's a mysterious bug in 64-bit Windows that causes garbage floating-point // There's a mysterious bug in 64-bit Windows that causes garbage floating-point
@@ -402,13 +402,13 @@ bool TextLayout::createNativeLayout (const AttributedString& text)
{ {
hasBeenCalled = true; hasBeenCalled = true;
TextLayout dummy; TextLayout dummy;
DirectWriteTypeLayout::createLayout (dummy, text, factories.directWriteFactory,
factories.d2dFactory, factories.systemFonts);
DirectWriteTypeLayout::createLayout (dummy, text, factories->directWriteFactory,
factories->d2dFactory, factories->systemFonts);
} }
#endif #endif
DirectWriteTypeLayout::createLayout (*this, text, factories.directWriteFactory,
factories.d2dFactory, factories.systemFonts);
DirectWriteTypeLayout::createLayout (*this, text, factories->directWriteFactory,
factories->d2dFactory, factories->systemFonts);
return true; return true;
} }
#else #else


+ 4
- 9
source/modules/juce_graphics/native/juce_win32_DirectWriteTypeface.cpp View File

@@ -107,15 +107,9 @@ public:
systemFonts = nullptr; systemFonts = nullptr;
} }
static const Direct2DFactories& getInstance()
{
static Direct2DFactories instance;
return instance;
}
ComSmartPtr <ID2D1Factory> d2dFactory;
ComSmartPtr <IDWriteFactory> directWriteFactory;
ComSmartPtr <IDWriteFontCollection> systemFonts;
ComSmartPtr<ID2D1Factory> d2dFactory;
ComSmartPtr<IDWriteFactory> directWriteFactory;
ComSmartPtr<IDWriteFontCollection> systemFonts;
private: private:
DynamicLibrary direct2dDll, directWriteDll; DynamicLibrary direct2dDll, directWriteDll;
@@ -255,6 +249,7 @@ public:
IDWriteFontFace* getIDWriteFontFace() const noexcept { return dwFontFace; } IDWriteFontFace* getIDWriteFontFace() const noexcept { return dwFontFace; }
private: private:
SharedResourcePointer<Direct2DFactories> factories;
ComSmartPtr<IDWriteFontFace> dwFontFace; ComSmartPtr<IDWriteFontFace> dwFontFace;
float unitsToHeightScaleFactor, heightToPointsFactor, ascent; float unitsToHeightScaleFactor, heightToPointsFactor, ascent;
int designUnitsPerEm; int designUnitsPerEm;


+ 11
- 11
source/modules/juce_graphics/native/juce_win32_Fonts.cpp View File

@@ -176,17 +176,17 @@ StringArray Font::findAllTypefaceNames()
StringArray results; StringArray results;
#if JUCE_USE_DIRECTWRITE #if JUCE_USE_DIRECTWRITE
const Direct2DFactories& factories = Direct2DFactories::getInstance();
SharedResourcePointer<Direct2DFactories> factories;
if (factories.systemFonts != nullptr)
if (factories->systemFonts != nullptr)
{ {
ComSmartPtr<IDWriteFontFamily> fontFamily; ComSmartPtr<IDWriteFontFamily> fontFamily;
uint32 fontFamilyCount = 0; uint32 fontFamilyCount = 0;
fontFamilyCount = factories.systemFonts->GetFontFamilyCount();
fontFamilyCount = factories->systemFonts->GetFontFamilyCount();
for (uint32 i = 0; i < fontFamilyCount; ++i) for (uint32 i = 0; i < fontFamilyCount; ++i)
{ {
HRESULT hr = factories.systemFonts->GetFontFamily (i, fontFamily.resetAndGetPointerAddress());
HRESULT hr = factories->systemFonts->GetFontFamily (i, fontFamily.resetAndGetPointerAddress());
if (SUCCEEDED (hr)) if (SUCCEEDED (hr))
results.addIfNotAlreadyThere (getFontFamilyName (fontFamily)); results.addIfNotAlreadyThere (getFontFamilyName (fontFamily));
@@ -226,20 +226,20 @@ StringArray Font::findAllTypefaceStyles (const String& family)
StringArray results; StringArray results;
#if JUCE_USE_DIRECTWRITE #if JUCE_USE_DIRECTWRITE
const Direct2DFactories& factories = Direct2DFactories::getInstance();
SharedResourcePointer<Direct2DFactories> factories;
if (factories.systemFonts != nullptr)
if (factories->systemFonts != nullptr)
{ {
BOOL fontFound = false; BOOL fontFound = false;
uint32 fontIndex = 0; uint32 fontIndex = 0;
HRESULT hr = factories.systemFonts->FindFamilyName (family.toWideCharPointer(), &fontIndex, &fontFound);
HRESULT hr = factories->systemFonts->FindFamilyName (family.toWideCharPointer(), &fontIndex, &fontFound);
if (! fontFound) if (! fontFound)
fontIndex = 0; fontIndex = 0;
// Get the font family using the search results // Get the font family using the search results
// Fonts like: Times New Roman, Times New Roman Bold, Times New Roman Italic are all in the same font family // Fonts like: Times New Roman, Times New Roman Bold, Times New Roman Italic are all in the same font family
ComSmartPtr<IDWriteFontFamily> fontFamily; ComSmartPtr<IDWriteFontFamily> fontFamily;
hr = factories.systemFonts->GetFontFamily (fontIndex, fontFamily.resetAndGetPointerAddress());
hr = factories->systemFonts->GetFontFamily (fontIndex, fontFamily.resetAndGetPointerAddress());
// Get the font faces // Get the font faces
ComSmartPtr<IDWriteFont> dwFont; ComSmartPtr<IDWriteFont> dwFont;
@@ -619,11 +619,11 @@ const MAT2 WindowsTypeface::identityMatrix = { { 0, 1 }, { 0, 0 }, { 0, 0 }, { 0
Typeface::Ptr Typeface::createSystemTypefaceFor (const Font& font) Typeface::Ptr Typeface::createSystemTypefaceFor (const Font& font)
{ {
#if JUCE_USE_DIRECTWRITE #if JUCE_USE_DIRECTWRITE
const Direct2DFactories& factories = Direct2DFactories::getInstance();
SharedResourcePointer<Direct2DFactories> factories;
if (factories.systemFonts != nullptr)
if (factories->systemFonts != nullptr)
{ {
ScopedPointer<WindowsDirectWriteTypeface> wtf (new WindowsDirectWriteTypeface (font, factories.systemFonts));
ScopedPointer<WindowsDirectWriteTypeface> wtf (new WindowsDirectWriteTypeface (font, factories->systemFonts));
if (wtf->loadedOk()) if (wtf->loadedOk())
return wtf.release(); return wtf.release();


+ 42
- 46
source/modules/juce_gui_basics/layout/juce_Viewport.cpp View File

@@ -30,6 +30,8 @@ Viewport::Viewport (const String& name)
showHScrollbar (true), showHScrollbar (true),
showVScrollbar (true), showVScrollbar (true),
deleteContent (true), deleteContent (true),
allowScrollingWithoutScrollbarV (false),
allowScrollingWithoutScrollbarH (false),
verticalScrollBar (true), verticalScrollBar (true),
horizontalScrollBar (false) horizontalScrollBar (false)
{ {
@@ -234,31 +236,23 @@ void Viewport::updateVisibleArea()
Point<int> visibleOrigin (-contentBounds.getPosition()); Point<int> visibleOrigin (-contentBounds.getPosition());
if (hBarVisible)
{
horizontalScrollBar.setBounds (0, contentArea.getHeight(), contentArea.getWidth(), scrollbarWidth);
horizontalScrollBar.setRangeLimits (0.0, contentBounds.getWidth());
horizontalScrollBar.setCurrentRange (visibleOrigin.x, contentArea.getWidth());
horizontalScrollBar.setSingleStepSize (singleStepX);
horizontalScrollBar.cancelPendingUpdate();
}
else if (canShowHBar)
{
horizontalScrollBar.setBounds (0, contentArea.getHeight(), contentArea.getWidth(), scrollbarWidth);
horizontalScrollBar.setRangeLimits (0.0, contentBounds.getWidth());
horizontalScrollBar.setCurrentRange (visibleOrigin.x, contentArea.getWidth());
horizontalScrollBar.setSingleStepSize (singleStepX);
horizontalScrollBar.cancelPendingUpdate();
if (canShowHBar && ! hBarVisible)
visibleOrigin.setX (0); visibleOrigin.setX (0);
}
if (vBarVisible)
{
verticalScrollBar.setBounds (contentArea.getWidth(), 0, scrollbarWidth, contentArea.getHeight());
verticalScrollBar.setRangeLimits (0.0, contentBounds.getHeight());
verticalScrollBar.setCurrentRange (visibleOrigin.y, contentArea.getHeight());
verticalScrollBar.setSingleStepSize (singleStepY);
verticalScrollBar.cancelPendingUpdate();
}
else if (canShowVBar)
{
verticalScrollBar.setBounds (contentArea.getWidth(), 0, scrollbarWidth, contentArea.getHeight());
verticalScrollBar.setRangeLimits (0.0, contentBounds.getHeight());
verticalScrollBar.setCurrentRange (visibleOrigin.y, contentArea.getHeight());
verticalScrollBar.setSingleStepSize (singleStepY);
verticalScrollBar.cancelPendingUpdate();
if (canShowVBar && ! vBarVisible)
visibleOrigin.setY (0); visibleOrigin.setY (0);
}
// Force the visibility *after* setting the ranges to avoid flicker caused by edge conditions in the numbers. // Force the visibility *after* setting the ranges to avoid flicker caused by edge conditions in the numbers.
horizontalScrollBar.setVisible (hBarVisible); horizontalScrollBar.setVisible (hBarVisible);
@@ -301,8 +295,13 @@ void Viewport::setSingleStepSizes (const int stepX, const int stepY)
} }
void Viewport::setScrollBarsShown (const bool showVerticalScrollbarIfNeeded, void Viewport::setScrollBarsShown (const bool showVerticalScrollbarIfNeeded,
const bool showHorizontalScrollbarIfNeeded)
const bool showHorizontalScrollbarIfNeeded,
const bool allowVerticalScrollingWithoutScrollbar,
const bool allowHorizontalScrollingWithoutScrollbar)
{ {
allowScrollingWithoutScrollbarV = allowVerticalScrollingWithoutScrollbar;
allowScrollingWithoutScrollbarH = allowHorizontalScrollingWithoutScrollbar;
if (showVScrollbar != showVerticalScrollbarIfNeeded if (showVScrollbar != showVerticalScrollbarIfNeeded
|| showHScrollbar != showHorizontalScrollbarIfNeeded) || showHScrollbar != showHorizontalScrollbarIfNeeded)
{ {
@@ -347,47 +346,44 @@ void Viewport::mouseWheelMove (const MouseEvent& e, const MouseWheelDetails& whe
Component::mouseWheelMove (e, wheel); Component::mouseWheelMove (e, wheel);
} }
static float rescaleMouseWheelDistance (float distance, int singleStepSize) noexcept
{
if (distance == 0)
return 0;
distance *= 14.0f * singleStepSize;
return distance < 0 ? jmin (distance, -1.0f)
: jmax (distance, 1.0f);
}
bool Viewport::useMouseWheelMoveIfNeeded (const MouseEvent& e, const MouseWheelDetails& wheel) bool Viewport::useMouseWheelMoveIfNeeded (const MouseEvent& e, const MouseWheelDetails& wheel)
{ {
if (! (e.mods.isAltDown() || e.mods.isCtrlDown() || e.mods.isCommandDown())) if (! (e.mods.isAltDown() || e.mods.isCtrlDown() || e.mods.isCommandDown()))
{ {
const bool hasVertBar = verticalScrollBar.isVisible();
const bool hasHorzBar = horizontalScrollBar.isVisible();
const bool canScrollVert = (allowScrollingWithoutScrollbarV || verticalScrollBar.isVisible());
const bool canScrollHorz = (allowScrollingWithoutScrollbarH || horizontalScrollBar.isVisible());
if (hasHorzBar || hasVertBar)
if (canScrollHorz || canScrollVert)
{ {
float wheelIncrementX = wheel.deltaX;
float wheelIncrementY = wheel.deltaY;
if (wheelIncrementX != 0)
{
wheelIncrementX *= 14.0f * singleStepX;
wheelIncrementX = (wheelIncrementX < 0) ? jmin (wheelIncrementX, -1.0f)
: jmax (wheelIncrementX, 1.0f);
}
if (wheelIncrementY != 0)
{
wheelIncrementY *= 14.0f * singleStepY;
wheelIncrementY = (wheelIncrementY < 0) ? jmin (wheelIncrementY, -1.0f)
: jmax (wheelIncrementY, 1.0f);
}
float wheelIncrementX = rescaleMouseWheelDistance (wheel.deltaX, singleStepX);
float wheelIncrementY = rescaleMouseWheelDistance (wheel.deltaY, singleStepY);
Point<int> pos (getViewPosition()); Point<int> pos (getViewPosition());
if (wheelIncrementX != 0 && wheelIncrementY != 0 && hasHorzBar && hasVertBar)
if (wheelIncrementX != 0 && wheelIncrementY != 0 && canScrollHorz && canScrollVert)
{ {
pos.setX (pos.x - roundToInt (wheelIncrementX)); pos.setX (pos.x - roundToInt (wheelIncrementX));
pos.setY (pos.y - roundToInt (wheelIncrementY)); pos.setY (pos.y - roundToInt (wheelIncrementY));
} }
else if (hasHorzBar && (wheelIncrementX != 0 || e.mods.isShiftDown() || ! hasVertBar))
else if (canScrollHorz && (wheelIncrementX != 0 || e.mods.isShiftDown() || ! canScrollVert))
{ {
if (wheelIncrementX == 0 && ! hasVertBar)
if (wheelIncrementX == 0 && ! canScrollVert)
wheelIncrementX = wheelIncrementY; wheelIncrementX = wheelIncrementY;
pos.setX (pos.x - roundToInt (wheelIncrementX)); pos.setX (pos.x - roundToInt (wheelIncrementX));
} }
else if (hasVertBar && wheelIncrementY != 0)
else if (canScrollVert && wheelIncrementY != 0)
{ {
pos.setY (pos.y - roundToInt (wheelIncrementY)); pos.setY (pos.y - roundToInt (wheelIncrementY));
} }


+ 9
- 3
source/modules/juce_gui_basics/layout/juce_Viewport.h View File

@@ -191,9 +191,15 @@ public:
If set to false, the scrollbars won't ever appear. When true (the default) If set to false, the scrollbars won't ever appear. When true (the default)
they will appear only when needed. they will appear only when needed.
The allowVerticalScrollingWithoutScrollbar parameters allow you to enable
mouse-wheel scrolling even when there the scrollbars are hidden. When the
scrollbars are visible, these parameters are ignored.
*/ */
void setScrollBarsShown (bool showVerticalScrollbarIfNeeded, void setScrollBarsShown (bool showVerticalScrollbarIfNeeded,
bool showHorizontalScrollbarIfNeeded);
bool showHorizontalScrollbarIfNeeded,
bool allowVerticalScrollingWithoutScrollbar = false,
bool allowHorizontalScrollingWithoutScrollbar = false);
/** True if the vertical scrollbar is enabled. /** True if the vertical scrollbar is enabled.
@see setScrollBarsShown @see setScrollBarsShown
@@ -258,9 +264,9 @@ private:
int scrollBarThickness; int scrollBarThickness;
int singleStepX, singleStepY; int singleStepX, singleStepY;
bool showHScrollbar, showVScrollbar, deleteContent; bool showHScrollbar, showVScrollbar, deleteContent;
bool allowScrollingWithoutScrollbarV, allowScrollingWithoutScrollbarH;
Component contentHolder; Component contentHolder;
ScrollBar verticalScrollBar;
ScrollBar horizontalScrollBar;
ScrollBar verticalScrollBar, horizontalScrollBar;
Point<int> viewportPosToCompPos (Point<int>) const; Point<int> viewportPosToCompPos (Point<int>) const;
void updateVisibleArea(); void updateVisibleArea();


+ 2
- 3
source/modules/juce_gui_extra/misc/juce_ColourSelector.h View File

@@ -62,7 +62,7 @@ public:
gapAroundColourSpaceComponent indicates how much of a gap to put around the gapAroundColourSpaceComponent indicates how much of a gap to put around the
colourspace and hue selector components. colourspace and hue selector components.
*/ */
ColourSelector (int sectionsToShow = (showAlphaChannel | showColourAtTop | showSliders | showColourspace),
ColourSelector (int flags = (showAlphaChannel | showColourAtTop | showSliders | showColourspace),
int edgeGap = 4, int edgeGap = 4,
int gapAroundColourSpaceComponent = 7); int gapAroundColourSpaceComponent = 7);
@@ -79,8 +79,7 @@ public:
*/ */
Colour getCurrentColour() const; Colour getCurrentColour() const;
/** Changes the colour that is currently being shown.
*/
/** Changes the colour that is currently being shown. */
void setCurrentColour (Colour newColour); void setCurrentColour (Colour newColour);
//============================================================================== //==============================================================================


+ 0
- 1
source/modules/juce_gui_extra/native/juce_mac_NSViewComponent.mm View File

@@ -22,7 +22,6 @@
============================================================================== ==============================================================================
*/ */
struct NSViewResizeWatcher struct NSViewResizeWatcher
{ {
NSViewResizeWatcher() : callback (nil) {} NSViewResizeWatcher() : callback (nil) {}


Loading…
Cancel
Save