Browse Source

Fixed some Mac window sizing and menu issues, optimised Graphics::drawImageTransformed(), and added an accuravy parameter to Path::contains().

tags/2021-05-28
jules 16 years ago
parent
commit
f7b48e55dd
9 changed files with 95 additions and 41 deletions
  1. +1
    -1
      build/macosx/platform_specific_code/juce_mac_Files.mm
  2. +20
    -3
      build/macosx/platform_specific_code/juce_mac_MainMenu.mm
  3. +1
    -7
      build/macosx/platform_specific_code/juce_mac_NSViewComponentPeer.mm
  4. +1
    -1
      build/win32/vc8/JUCE.vcproj
  5. +35
    -18
      juce_amalgamated.cpp
  6. +12
    -2
      juce_amalgamated.h
  7. +8
    -1
      src/juce_appframework/gui/graphics/contexts/juce_Graphics.cpp
  8. +5
    -6
      src/juce_appframework/gui/graphics/geometry/juce_Path.cpp
  9. +12
    -2
      src/juce_appframework/gui/graphics/geometry/juce_Path.h

+ 1
- 1
build/macosx/platform_specific_code/juce_mac_Files.mm View File

@@ -243,7 +243,7 @@ const File File::getSpecialLocation (const SpecialLocationType type)
{ {
const ScopedAutoReleasePool pool; const ScopedAutoReleasePool pool;
const char* resultPath = 0;
String resultPath;
switch (type) switch (type)
{ {


+ 20
- 3
build/macosx/platform_specific_code/juce_mac_MainMenu.mm View File

@@ -182,9 +182,28 @@ public:
[menu removeItem: item]; [menu removeItem: item];
} }
static NSMenuItem* findMenuItem (NSMenu* const menu, const ApplicationCommandTarget::InvocationInfo& info)
{
for (int i = [menu numberOfItems]; --i >= 0;)
{
NSMenuItem* m = [menu itemAtIndex: i];
if ([m tag] == info.commandID)
return m;
if ([m submenu] != 0)
{
NSMenuItem* found = findMenuItem ([m submenu], info);
if (found != 0)
return found;
}
}
return 0;
}
void menuCommandInvoked (MenuBarModel*, const ApplicationCommandTarget::InvocationInfo& info) void menuCommandInvoked (MenuBarModel*, const ApplicationCommandTarget::InvocationInfo& info)
{ {
NSMenuItem* item = [[NSApp mainMenu] itemWithTag: info.commandID];
NSMenuItem* item = findMenuItem ([NSApp mainMenu], info);
if (item != 0) if (item != 0)
flashMenuBar ([item menu]); flashMenuBar ([item menu]);
@@ -234,7 +253,6 @@ public:
keyEquivalent: @""]; keyEquivalent: @""];
[item setEnabled: false]; [item setEnabled: false];
[item setIndentationLevel: 5];
} }
else if (iter.subMenu != 0) else if (iter.subMenu != 0)
{ {
@@ -247,7 +265,6 @@ public:
NSMenu* sub = createMenu (*iter.subMenu, iter.itemName, topLevelMenuId, topLevelIndex); NSMenu* sub = createMenu (*iter.subMenu, iter.itemName, topLevelMenuId, topLevelIndex);
[menuToAddTo setSubmenu: sub forItem: item]; [menuToAddTo setSubmenu: sub forItem: item];
[sub release];
} }
else else
{ {


+ 1
- 7
build/macosx/platform_specific_code/juce_mac_NSViewComponentPeer.mm View File

@@ -821,13 +821,7 @@ void NSViewComponentPeer::setBounds (int x, int y, int w, int h, const bool isNo
{ {
r.origin.y = [[[NSScreen screens] objectAtIndex: 0] frame].size.height - (r.origin.y + r.size.height); r.origin.y = [[[NSScreen screens] objectAtIndex: 0] frame].size.height - (r.origin.y + r.size.height);
const BorderSize border (getFrameSize());
r.origin.x -= border.getLeft();
r.origin.y -= border.getTop();
r.size.width += border.getLeftAndRight();
r.size.height += border.getTopAndBottom();
[window setFrame: r
[window setFrame: [window frameRectForContentRect: r]
display: true]; display: true];
} }
} }


+ 1
- 1
build/win32/vc8/JUCE.vcproj View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="Windows-1252"?> <?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject <VisualStudioProject
ProjectType="Visual C++" ProjectType="Visual C++"
Version="9.00"
Version="8.00"
Name="JUCE" Name="JUCE"
ProjectGUID="{AE232C11-D91C-4CA1-B24E-8B11A52EFF26}" ProjectGUID="{AE232C11-D91C-4CA1-B24E-8B11A52EFF26}"
RootNamespace="JUCE" RootNamespace="JUCE"


+ 35
- 18
juce_amalgamated.cpp View File

@@ -76519,7 +76519,14 @@ void Graphics::drawImageTransformed (const Image* const imageToDraw,
&& (! context->isClipEmpty()) && (! context->isClipEmpty())
&& ! transform.isSingularity()) && ! transform.isSingularity())
{ {
if (fillAlphaChannelWithCurrentBrush)
if (transform.isIdentity())
{
drawImage (imageToDraw,
sourceClipX, sourceClipY, sourceClipWidth, sourceClipHeight,
sourceClipX, sourceClipY, sourceClipWidth, sourceClipHeight,
fillAlphaChannelWithCurrentBrush);
}
else if (fillAlphaChannelWithCurrentBrush)
{ {
Path p; Path p;
p.addRectangle ((float) sourceClipX, (float) sourceClipY, p.addRectangle ((float) sourceClipX, (float) sourceClipY,
@@ -85391,15 +85398,13 @@ const AffineTransform Path::getTransformToScaleToFit (const float x, const float
} }
} }


static const float collisionDetectionTolerence = 20.0f;

bool Path::contains (const float x, const float y) const throw()
bool Path::contains (const float x, const float y, const float tolerence) const throw()
{ {
if (x <= pathXMin || x >= pathXMax if (x <= pathXMin || x >= pathXMax
|| y <= pathYMin || y >= pathYMax) || y <= pathYMin || y >= pathYMax)
return false; return false;


PathFlatteningIterator i (*this, AffineTransform::identity, collisionDetectionTolerence);
PathFlatteningIterator i (*this, AffineTransform::identity, tolerence);


int positiveCrossings = 0; int positiveCrossings = 0;
int negativeCrossings = 0; int negativeCrossings = 0;
@@ -85426,9 +85431,10 @@ bool Path::contains (const float x, const float y) const throw()
} }


bool Path::intersectsLine (const float x1, const float y1, bool Path::intersectsLine (const float x1, const float y1,
const float x2, const float y2) throw()
const float x2, const float y2,
const float tolerence) throw()
{ {
PathFlatteningIterator i (*this, AffineTransform::identity, collisionDetectionTolerence);
PathFlatteningIterator i (*this, AffineTransform::identity, tolerence);


const Line line1 (x1, y1, x2, y2); const Line line1 (x1, y1, x2, y2);


@@ -265243,7 +265249,7 @@ const File File::getSpecialLocation (const SpecialLocationType type)
{ {
const ScopedAutoReleasePool pool; const ScopedAutoReleasePool pool;


const char* resultPath = 0;
String resultPath;


switch (type) switch (type)
{ {
@@ -266631,13 +266637,7 @@ void NSViewComponentPeer::setBounds (int x, int y, int w, int h, const bool isNo
{ {
r.origin.y = [[[NSScreen screens] objectAtIndex: 0] frame].size.height - (r.origin.y + r.size.height); r.origin.y = [[[NSScreen screens] objectAtIndex: 0] frame].size.height - (r.origin.y + r.size.height);


const BorderSize border (getFrameSize());
r.origin.x -= border.getLeft();
r.origin.y -= border.getTop();
r.size.width += border.getLeftAndRight();
r.size.height += border.getTopAndBottom();

[window setFrame: r
[window setFrame: [window frameRectForContentRect: r]
display: true]; display: true];
} }
} }
@@ -268177,9 +268177,28 @@ public:
[menu removeItem: item]; [menu removeItem: item];
} }


static NSMenuItem* findMenuItem (NSMenu* const menu, const ApplicationCommandTarget::InvocationInfo& info)
{
for (int i = [menu numberOfItems]; --i >= 0;)
{
NSMenuItem* m = [menu itemAtIndex: i];
if ([m tag] == info.commandID)
return m;

if ([m submenu] != 0)
{
NSMenuItem* found = findMenuItem ([m submenu], info);
if (found != 0)
return found;
}
}

return 0;
}

void menuCommandInvoked (MenuBarModel*, const ApplicationCommandTarget::InvocationInfo& info) void menuCommandInvoked (MenuBarModel*, const ApplicationCommandTarget::InvocationInfo& info)
{ {
NSMenuItem* item = [[NSApp mainMenu] itemWithTag: info.commandID];
NSMenuItem* item = findMenuItem ([NSApp mainMenu], info);


if (item != 0) if (item != 0)
flashMenuBar ([item menu]); flashMenuBar ([item menu]);
@@ -268229,7 +268248,6 @@ public:
keyEquivalent: @""]; keyEquivalent: @""];


[item setEnabled: false]; [item setEnabled: false];
[item setIndentationLevel: 5];
} }
else if (iter.subMenu != 0) else if (iter.subMenu != 0)
{ {
@@ -268242,7 +268260,6 @@ public:


NSMenu* sub = createMenu (*iter.subMenu, iter.itemName, topLevelMenuId, topLevelIndex); NSMenu* sub = createMenu (*iter.subMenu, iter.itemName, topLevelMenuId, topLevelIndex);
[menuToAddTo setSubmenu: sub forItem: item]; [menuToAddTo setSubmenu: sub forItem: item];
[sub release];
} }
else else
{ {


+ 12
- 2
juce_amalgamated.h View File

@@ -16541,19 +16541,29 @@ public:


The path's winding rule is taken into account by this method. The path's winding rule is taken into account by this method.


The tolerence parameter is passed to the PathFlatteningIterator that
is used to trace the path - for more info about it, see the notes for
the PathFlatteningIterator constructor.

@see closeSubPath, setUsingNonZeroWinding @see closeSubPath, setUsingNonZeroWinding
*/ */
bool contains (const float x, bool contains (const float x,
const float y) const throw();
const float y,
const float tolerence = 10.0f) const throw();


/** Checks whether a line crosses the path. /** Checks whether a line crosses the path.


This will return positive if the line crosses any of the paths constituent This will return positive if the line crosses any of the paths constituent
lines or curves. It doesn't take into account whether the line is inside lines or curves. It doesn't take into account whether the line is inside
or outside the path, or whether the path is open or closed. or outside the path, or whether the path is open or closed.

The tolerence parameter is passed to the PathFlatteningIterator that
is used to trace the path - for more info about it, see the notes for
the PathFlatteningIterator constructor.
*/ */
bool intersectsLine (const float x1, const float y1, bool intersectsLine (const float x1, const float y1,
const float x2, const float y2) throw();
const float x2, const float y2,
const float tolerence = 10.0f) throw();


/** Removes all lines and curves, resetting the path completely. */ /** Removes all lines and curves, resetting the path completely. */
void clear() throw(); void clear() throw();


+ 8
- 1
src/juce_appframework/gui/graphics/contexts/juce_Graphics.cpp View File

@@ -917,7 +917,14 @@ void Graphics::drawImageTransformed (const Image* const imageToDraw,
&& (! context->isClipEmpty()) && (! context->isClipEmpty())
&& ! transform.isSingularity()) && ! transform.isSingularity())
{ {
if (fillAlphaChannelWithCurrentBrush)
if (transform.isIdentity())
{
drawImage (imageToDraw,
sourceClipX, sourceClipY, sourceClipWidth, sourceClipHeight,
sourceClipX, sourceClipY, sourceClipWidth, sourceClipHeight,
fillAlphaChannelWithCurrentBrush);
}
else if (fillAlphaChannelWithCurrentBrush)
{ {
Path p; Path p;
p.addRectangle ((float) sourceClipX, (float) sourceClipY, p.addRectangle ((float) sourceClipX, (float) sourceClipY,


+ 5
- 6
src/juce_appframework/gui/graphics/geometry/juce_Path.cpp View File

@@ -999,15 +999,13 @@ const AffineTransform Path::getTransformToScaleToFit (const float x, const float
} }
//============================================================================== //==============================================================================
static const float collisionDetectionTolerence = 20.0f;
bool Path::contains (const float x, const float y) const throw()
bool Path::contains (const float x, const float y, const float tolerence) const throw()
{ {
if (x <= pathXMin || x >= pathXMax if (x <= pathXMin || x >= pathXMax
|| y <= pathYMin || y >= pathYMax) || y <= pathYMin || y >= pathYMax)
return false; return false;
PathFlatteningIterator i (*this, AffineTransform::identity, collisionDetectionTolerence);
PathFlatteningIterator i (*this, AffineTransform::identity, tolerence);
int positiveCrossings = 0; int positiveCrossings = 0;
int negativeCrossings = 0; int negativeCrossings = 0;
@@ -1034,9 +1032,10 @@ bool Path::contains (const float x, const float y) const throw()
} }
bool Path::intersectsLine (const float x1, const float y1, bool Path::intersectsLine (const float x1, const float y1,
const float x2, const float y2) throw()
const float x2, const float y2,
const float tolerence) throw()
{ {
PathFlatteningIterator i (*this, AffineTransform::identity, collisionDetectionTolerence);
PathFlatteningIterator i (*this, AffineTransform::identity, tolerence);
const Line line1 (x1, y1, x2, y2); const Line line1 (x1, y1, x2, y2);


+ 12
- 2
src/juce_appframework/gui/graphics/geometry/juce_Path.h View File

@@ -112,19 +112,29 @@ public:
The path's winding rule is taken into account by this method. The path's winding rule is taken into account by this method.
The tolerence parameter is passed to the PathFlatteningIterator that
is used to trace the path - for more info about it, see the notes for
the PathFlatteningIterator constructor.
@see closeSubPath, setUsingNonZeroWinding @see closeSubPath, setUsingNonZeroWinding
*/ */
bool contains (const float x, bool contains (const float x,
const float y) const throw();
const float y,
const float tolerence = 10.0f) const throw();
/** Checks whether a line crosses the path. /** Checks whether a line crosses the path.
This will return positive if the line crosses any of the paths constituent This will return positive if the line crosses any of the paths constituent
lines or curves. It doesn't take into account whether the line is inside lines or curves. It doesn't take into account whether the line is inside
or outside the path, or whether the path is open or closed. or outside the path, or whether the path is open or closed.
The tolerence parameter is passed to the PathFlatteningIterator that
is used to trace the path - for more info about it, see the notes for
the PathFlatteningIterator constructor.
*/ */
bool intersectsLine (const float x1, const float y1, bool intersectsLine (const float x1, const float y1,
const float x2, const float y2) throw();
const float x2, const float y2,
const float tolerence = 10.0f) throw();
//============================================================================== //==============================================================================
/** Removes all lines and curves, resetting the path completely. */ /** Removes all lines and curves, resetting the path completely. */


Loading…
Cancel
Save