mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 19:40:48 +00:00
Improve handling of rotated bounds.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@24893 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
023175d761
commit
bbc902731f
2 changed files with 46 additions and 34 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
2007-03-17 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
|
* Source/NSView.m (-setBoundsRotation:): Adjust _bounds ivar to
|
||||||
|
the rotation.
|
||||||
|
* Source/NSView.m (-translateOriginToPoint:, -rotateByAngle:):
|
||||||
|
Implemented via setBoundsOrigin: and rotateByAngle:.
|
||||||
|
* Source/NSView.m (-_lockFocusInContext:inRect:): For rotated
|
||||||
|
views compute the actual clip region instead of using _bounds.
|
||||||
|
|
||||||
2007-03-17 Nicola Pero <nicola.pero@meta-innovation.com>
|
2007-03-17 Nicola Pero <nicola.pero@meta-innovation.com>
|
||||||
|
|
||||||
* GNUmakefile.postamble (before-uninstall): Uninstall gui.make.
|
* GNUmakefile.postamble (before-uninstall): Uninstall gui.make.
|
||||||
|
|
|
@ -53,6 +53,7 @@
|
||||||
|
|
||||||
#include "AppKit/NSAffineTransform.h"
|
#include "AppKit/NSAffineTransform.h"
|
||||||
#include "AppKit/NSApplication.h"
|
#include "AppKit/NSApplication.h"
|
||||||
|
#include "AppKit/NSBezierPath.h"
|
||||||
#include "AppKit/NSCursor.h"
|
#include "AppKit/NSCursor.h"
|
||||||
#include "AppKit/NSDocumentController.h"
|
#include "AppKit/NSDocumentController.h"
|
||||||
#include "AppKit/NSDocument.h"
|
#include "AppKit/NSDocument.h"
|
||||||
|
@ -971,22 +972,6 @@ GSSetDragTypes(NSView* obj, NSArray *types)
|
||||||
- (void) willRemoveSubview: (NSView *)subview
|
- (void) willRemoveSubview: (NSView *)subview
|
||||||
{}
|
{}
|
||||||
|
|
||||||
- (void) rotateByAngle: (float)angle
|
|
||||||
{
|
|
||||||
if (_coordinates_valid)
|
|
||||||
{
|
|
||||||
(*invalidateImp)(self, invalidateSel);
|
|
||||||
}
|
|
||||||
[_boundsMatrix rotateByDegrees: angle];
|
|
||||||
_is_rotated_from_base = _is_rotated_or_scaled_from_base = YES;
|
|
||||||
|
|
||||||
if (_post_bounds_changes)
|
|
||||||
{
|
|
||||||
[nc postNotificationName: NSViewBoundsDidChangeNotification
|
|
||||||
object: self];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) _updateBoundsMatrix
|
- (void) _updateBoundsMatrix
|
||||||
{
|
{
|
||||||
float sx;
|
float sx;
|
||||||
|
@ -1243,12 +1228,11 @@ GSSetDragTypes(NSView* obj, NSArray *types)
|
||||||
|
|
||||||
- (void) setBoundsOrigin: (NSPoint)newOrigin
|
- (void) setBoundsOrigin: (NSPoint)newOrigin
|
||||||
{
|
{
|
||||||
_bounds.origin = newOrigin;
|
|
||||||
|
|
||||||
if (_coordinates_valid)
|
if (_coordinates_valid)
|
||||||
{
|
{
|
||||||
(*invalidateImp)(self, invalidateSel);
|
(*invalidateImp)(self, invalidateSel);
|
||||||
}
|
}
|
||||||
|
_bounds.origin = newOrigin;
|
||||||
[_boundsMatrix setFrameOrigin: NSMakePoint(-newOrigin.x, -newOrigin.y)];
|
[_boundsMatrix setFrameOrigin: NSMakePoint(-newOrigin.x, -newOrigin.y)];
|
||||||
|
|
||||||
if (_post_bounds_changes)
|
if (_post_bounds_changes)
|
||||||
|
@ -1287,12 +1271,19 @@ GSSetDragTypes(NSView* obj, NSArray *types)
|
||||||
|
|
||||||
- (void) setBoundsRotation: (float)angle
|
- (void) setBoundsRotation: (float)angle
|
||||||
{
|
{
|
||||||
|
NSAffineTransform *matrix;
|
||||||
|
|
||||||
if (_coordinates_valid)
|
if (_coordinates_valid)
|
||||||
{
|
{
|
||||||
(*invalidateImp)(self, invalidateSel);
|
(*invalidateImp)(self, invalidateSel);
|
||||||
}
|
}
|
||||||
[_boundsMatrix setFrameRotation: angle];
|
[_boundsMatrix rotateByDegrees: angle - [_boundsMatrix rotationAngle]];
|
||||||
_is_rotated_from_base = _is_rotated_or_scaled_from_base = YES;
|
_is_rotated_from_base = _is_rotated_or_scaled_from_base = YES;
|
||||||
|
// Adjust bounds
|
||||||
|
matrix = [_boundsMatrix copy];
|
||||||
|
[matrix invert];
|
||||||
|
[matrix boundingRectFor: _frame result: &_bounds];
|
||||||
|
RELEASE(matrix);
|
||||||
|
|
||||||
if (_post_bounds_changes)
|
if (_post_bounds_changes)
|
||||||
{
|
{
|
||||||
|
@ -1303,17 +1294,13 @@ GSSetDragTypes(NSView* obj, NSArray *types)
|
||||||
|
|
||||||
- (void) translateOriginToPoint: (NSPoint)point
|
- (void) translateOriginToPoint: (NSPoint)point
|
||||||
{
|
{
|
||||||
if (_coordinates_valid)
|
[self setBoundsOrigin: NSMakePoint(NSMinX(_bounds) - point.x,
|
||||||
{
|
NSMinY(_bounds) - point.y)];
|
||||||
(*invalidateImp)(self, invalidateSel);
|
}
|
||||||
}
|
|
||||||
[_boundsMatrix translateToPoint: point];
|
|
||||||
|
|
||||||
if (_post_bounds_changes)
|
- (void) rotateByAngle: (float)angle
|
||||||
{
|
{
|
||||||
[nc postNotificationName: NSViewBoundsDidChangeNotification
|
[self setBoundsRotation: [self boundsRotation] + angle];
|
||||||
object: self];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSRect) centerScanRect: (NSRect)aRect
|
- (NSRect) centerScanRect: (NSRect)aRect
|
||||||
|
@ -1845,12 +1832,28 @@ static NSRect convert_rect_using_matrices(NSRect aRect, NSAffineTransform *matri
|
||||||
|
|
||||||
if ([self wantsDefaultClipping])
|
if ([self wantsDefaultClipping])
|
||||||
{
|
{
|
||||||
/* Clip to the visible rectangle - which will never be greater
|
/*
|
||||||
* than the bounds of the view. This prevents drawing outside
|
* Clip to the visible rectangle - which will never be greater
|
||||||
* our bounds
|
* than the bounds of the view. This prevents drawing outside
|
||||||
|
* our bounds.
|
||||||
*/
|
*/
|
||||||
DPSrectclip(ctxt, NSMinX(rect), NSMinY(rect),
|
if (_is_rotated_from_base)
|
||||||
NSWidth(rect), NSHeight(rect));
|
{
|
||||||
|
// When the view is rotated, more complex clipping is needed.
|
||||||
|
NSAffineTransform *matrix;
|
||||||
|
NSBezierPath *bp = [NSBezierPath bezierPathWithRect: _frame];
|
||||||
|
|
||||||
|
matrix = [_boundsMatrix copy];
|
||||||
|
[matrix invert];
|
||||||
|
[bp transformUsingAffineTransform: matrix];
|
||||||
|
[bp addClip];
|
||||||
|
RELEASE(matrix);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DPSrectclip(ctxt, NSMinX(rect), NSMinY(rect),
|
||||||
|
NSWidth(rect), NSHeight(rect));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Tell backends that images are drawn upside down.
|
/* Tell backends that images are drawn upside down.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue