Commit graph

197 commits

Author SHA1 Message Date
Ivan Vučica
280c3e0095 Clean up -[NSImage initWithCoder:], reduce amount of releases of self.
Some context available in PR #12 and  PR #13.
2017-12-07 19:07:43 +00:00
Ivan Vučica
350ba62d7d
Cleanup: Replace tabs with spaces in NSImage.m. 2017-10-29 14:25:47 +00:00
Graham Lee
aff13d41bb correct decoding of named images from keyed archivers
As @tedge noted on the original pull request for this work, I didn't return the correct object in the keyed archiver case.
2017-10-29 14:23:35 +00:00
Graham Lee
2c34ae8fe5 revert spurious whitespace change 2017-10-28 08:48:36 +01:00
Graham Lee
5e3ed6dff7 If an unknown named image is unarchived, keep the name 2017-10-28 08:45:05 +01:00
Fred Kiefer
2efe9de227 Merge some of the changes from the testplant branch.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@40362 72102866-910b-0410-8b05-ffd578937521
2017-03-05 22:12:15 +00:00
Riccardo Mottola
4368207db7 Actually allocate a NSMutableArray, since that is the expected return type
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@39577 72102866-910b-0410-8b05-ffd578937521
2016-03-21 10:01:25 +00:00
Riccardo Mottola
c442abbaab Trivial implementation of new 10.9 drawInRect: method
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@39332 72102866-910b-0410-8b05-ffd578937521
2016-02-03 00:08:23 +00:00
Richard Frith-MacDonald
79e04b545a Try Fred's idea for theme image lookup improvement.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@39168 72102866-910b-0410-8b05-ffd578937521
2015-11-12 08:33:35 +00:00
Richard Frith-MacDonald
1501023c3b Theme alteration for Riccardo, plus some formatting tweaks
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@39110 72102866-910b-0410-8b05-ffd578937521
2015-11-01 15:38:47 +00:00
Fred Kiefer
8e8a1af817 * Source/nsimage-tiff.h: Correct field types.
* Source/NSImage.m (-TIFFRepresentation)
        (TIFFRepresentationUsingCompression:factor:): Pass on bitmaps
only.
        * Source/NSBitmapImageRep.m: Implement methods to generate tiff
        for multiple bitmaps.
        * Source/tiff.m: Fix long standing bug in TiffHandleSeek.
        In NSTiffWrite write image tiff directory to allow for multiple
        images.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@39050 72102866-910b-0410-8b05-ffd578937521
2015-10-10 19:18:33 +00:00
Fred Kiefer
ab61aefcfa * Source/NSImage.m (-lockFocusOnRepresentation:): Allow image
caching during printing.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@38106 72102866-910b-0410-8b05-ffd578937521
2014-10-05 19:59:37 +00:00
Fred Kiefer
dc50232e07 * Source/NSImage.m: Add description method.
Patch by Johannes Lundberg <johannes@brilliantservice.co.jp>.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@37518 72102866-910b-0410-8b05-ffd578937521
2013-12-26 12:34:57 +00:00
Fred Kiefer
47145c6c46 * Source/NSImage.m: Better protection against representation being nil.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@37169 72102866-910b-0410-8b05-ffd578937521
2013-09-29 16:37:59 +00:00
Ivan Vučica
fa522babc4 * Source/NSImage.m: Missing -retain inside the method
-compositeToPoint:fromRect:operation:fraction caused a crash
inside Opal backend.



git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@37140 72102866-910b-0410-8b05-ffd578937521
2013-09-23 16:58:18 +00:00
Quentin Mathe
4db314841a Fixed missing theme images if not listed in the theme bundle Info.plist.
Theme bundles that contain theme images named using either GNUstep or 
OPENSTEP names now work properly again (bug introduced in r36836).


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@36916 72102866-910b-0410-8b05-ffd578937521
2013-07-22 15:24:32 +00:00
Quentin Mathe
da2351d2b2 Added support for providing custom theme control images (e.g. checkbox) in the same way we support it for tiles
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@36836 72102866-910b-0410-8b05-ffd578937521
2013-07-04 15:46:11 +00:00
Eric Wasylishen
67daa51afa * Source/GSTheme.m:
* Source/NSImage.m: Revert previous commit and write a much cleaner
implementation that fixes the same bug.

I removed the step in theme activation where we call
+[NSImage _setImagePath:name:] on each image in the theme, and instead
modified +[NSImage _pathForImageNamed:] to also search the theme images
directory.

When a GSTheme activates now, it only calls +[NSImage _reloadCachedImages]
which checks all NSImage cached by name and reloads any whose path has
changed.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@36482 72102866-910b-0410-8b05-ffd578937521
2013-04-06 19:30:48 +00:00
Eric Wasylishen
23d47ca882 Revert "Allow themes to override only a "base" image like"
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@36481 72102866-910b-0410-8b05-ffd578937521
2013-04-06 19:30:30 +00:00
Eric Wasylishen
5dcf9e3251 Allow themes to override only a "base" image like
common_3DArrowRight and have images that map to it (NSMenuArrow)
automatically update.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@36474 72102866-910b-0410-8b05-ffd578937521
2013-04-06 07:57:57 +00:00
Fred Kiefer
4765d0f314 * Tests/gui/NSImage/basic.m: Add basic tests for NSImage.
* Tests/gui/NSCell/basic.m: Extend basic tests for NSCell.
        * Source/NSImage.m: Try to correct keyed encoding/decoding. Add
        incomplete isEqual: method.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@36384 72102866-910b-0410-8b05-ffd578937521
2013-03-18 22:50:11 +00:00
Fred Kiefer
270baf4037 More CGFloat, NSUInteger and NSInteger changes.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@36148 72102866-910b-0410-8b05-ffd578937521
2013-02-16 00:08:33 +00:00
Fred Kiefer
ac6909e871 Merged changes from gnustep_testplant_branch branch and cleaned them up
a bit.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@35417 72102866-910b-0410-8b05-ffd578937521
2012-08-17 13:16:12 +00:00
Gregory John Casamento
38ea4d65a6 * Source/NSImage.m: -[NSImage initWithCoder:] an extension to
the previous change.  If the URL doesn't load then try to load
	the image in the NSURL as a "named" image in resources so that
	the developer of the app has a way to provide this image.



git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@35316 72102866-910b-0410-8b05-ffd578937521
2012-07-24 10:39:29 +00:00
Gregory John Casamento
1a81de9b5d * Source/NSImage.m: -[NSImage initWithCoder:]
Some XIB files have image representations encoded
	via NSURL.  When this happens it causes the XIB not to be loaded at
	all since the image rep fails to load and causes the xib loading
	process to fail.



git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@35310 72102866-910b-0410-8b05-ffd578937521
2012-07-20 18:25:55 +00:00
Fred Kiefer
2d48b49175 Deal with images taht result in no data. This happens in themes that
have to small images to be split up into 9 tiles.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@34688 72102866-910b-0410-8b05-ffd578937521
2012-02-01 10:49:35 +00:00
Eric Wasylishen
cbf7bc52a9 * Source/NSImage.m (+imageNamed:): Don't try to look up path
if called with nil (just return nil).


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@34632 72102866-910b-0410-8b05-ffd578937521
2012-01-25 23:25:14 +00:00
Richard Frith-MacDonald
db92916b2f Attempt to get gnome and windows themes working again.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@34528 72102866-910b-0410-8b05-ffd578937521
2012-01-14 17:55:43 +00:00
Fred Kiefer
e2884bafce * Source/NSImage.m (+_clearFileTypeCaches): Use DESTROY instead of
RELEASE.
Patch by Philippe Roussel <p.o.roussel@free.fr>.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@34492 72102866-910b-0410-8b05-ffd578937521
2012-01-11 08:12:43 +00:00
Eric Wasylishen
53ac9ad559 * Source/NSImage.m: Remove duplicate #import
* Source/NSImage.m: Correct _clearFileTypeCaches notification
method to take a NSNotification* parameter.
* Soure/NSImage.m (themeDidActivate:): Move to a class method,
and move the GSThemeDidActivateNotification subscription
to +[NSImage initialize]. Now the +_themeDidActivate: updates
all images by looking at all the values in nameDict. This should
function exactly the same as before, but seems to be quite a bit
faster due to fewer notifications being sent (?)
* Source/NSImage.m (+imageNamed:): Remove redundant fetch from
nameDict pointed out by Fred


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@34482 72102866-910b-0410-8b05-ffd578937521
2012-01-10 19:16:46 +00:00
Eric Wasylishen
378ca9230e * Source/NSImage.m (+pathForImageNamed:): Add underscore and
move to private category. Also remove use of lock as it is
unnecessary
* Source/NSImage.m: (-themeDidActivate:): Extract method
_resetAndUseFromFile:. Don't reset _size if
flags.sizeWasExplicitlySet was true.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@34481 72102866-910b-0410-8b05-ffd578937521
2012-01-10 18:55:57 +00:00
Eric Wasylishen
bff0f57b54 * Source/GSTheme.m: Remove code which sets and unsets images
on theme activation/deactivation.
* Source/NSImage.m (+imageNamed:): Factor out code for finding
the path for a name to a separate method, +pathForImageNamed.
The code is unchanged otherwise, except for fixing the retrieval
of images from the theme bundle, which was broken.
* Source/NSImage.m (-setName:): Remove code for creating theme
proxy. Subscribe/unscribe to theme change notification when
the receiver is added/removed from the name dictionary.
* Source/NSImage.m (-themeDidActivate:): Method called in
response to a GSThemeDidActivateNotification on images with
a name set. It does a path lookup in the same way that
+imageNamed: would, and checks if the path has changed due
to the theme change. If it has, all reps are discarded and
the image at the new path is loaded. This avoids the need for
the theme proxy objects.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@34474 72102866-910b-0410-8b05-ffd578937521
2012-01-10 04:38:10 +00:00
Fred Kiefer
82eac9eaf0 Declare the new method
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@34470 72102866-910b-0410-8b05-ffd578937521
2012-01-09 14:40:45 +00:00
Fred Kiefer
93403780f3 Cache the file type results for the image reps and clear the cache when these change.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@34469 72102866-910b-0410-8b05-ffd578937521
2012-01-09 14:39:50 +00:00
Fred Kiefer
eaafb6754d * Source/NSImage.m (-bestRepresentationForDevice:): Fix last
change for the case where there are no representations for the
image.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@34168 72102866-910b-0410-8b05-ffd578937521
2011-11-13 19:24:17 +00:00
Eric Wasylishen
3ace7a7cf7 * Source/NSImage.m (-bestRepresentationForDevice:): When
all other matching criteria fail, use the first image instead
of the last (arbitrary, but seems to match cocoa.)


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@34166 72102866-910b-0410-8b05-ffd578937521
2011-11-12 01:57:01 +00:00
Eric Wasylishen
c7531f2386 * Source/NSImage.m (-setScalesWhenResized:): Disable this method
as it is currently broken on the cairo backend.
* Source/NSApplication.m (-setApplicationIconImage:): Don't
use call -setScalesWhenResized:, because if it worked as it is
supposed to, it would scale all icon reps down to 48x48,
making large icon sizes useless.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@34164 72102866-910b-0410-8b05-ffd578937521
2011-11-12 00:40:18 +00:00
Fred Kiefer
2fa1752b03 * Source/NSImage.m (-lockFocusOnRepresentation:): Draw the
representation into the new cache. Use NSRectFillUsingOperation
  instead of PScompositerect.
* Source/NSImage.m (-drawRepresentation:inRect:): Use DPS
  operations instead of PS operations.

Should fix bug #34470


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@33948 72102866-910b-0410-8b05-ffd578937521
2011-10-06 11:06:31 +00:00
Eric Wasylishen
507b4c76e8 * Source/NSImage.m (_cacheForRep:): Don't assume rep is non-nil. This should fix
locking focus on an image with no representations.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@33827 72102866-910b-0410-8b05-ffd578937521
2011-09-09 19:49:08 +00:00
Gregory John Casamento
9a606392b7 Correction for compilation error. NSSizesEqual should have been NSEqualSizes.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@33820 72102866-910b-0410-8b05-ffd578937521
2011-09-08 20:13:42 +00:00
Eric Wasylishen
192e2d6174 * Source/NSImage.m: Throw an exception if you attempt to lock focus on an image with
size (0, 0)
* Source/NSCachedImageRep.m: Throw an exception if you attempt to create a cached
image rep with a size of (0, 0).


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@33819 72102866-910b-0410-8b05-ffd578937521
2011-09-08 18:42:31 +00:00
Fred Kiefer
5554634f9c Correct last commit to use && instead of ||.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@33788 72102866-910b-0410-8b05-ffd578937521
2011-08-26 07:35:41 +00:00
Riccardo Mottola
4e0e32caac check that the array of reps is populated, not just non-nil
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@33786 72102866-910b-0410-8b05-ffd578937521
2011-08-25 15:20:45 +00:00
Eric Wasylishen
e14b034d8d * Source/NSImage.m (-setSize:): Don't invalidate the cache anymore,
because we now cache the entire representation and not the rep scaled
to the image's size.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@33770 72102866-910b-0410-8b05-ffd578937521
2011-08-20 18:37:52 +00:00
Eric Wasylishen
5531d27e56 * Source/NSImage.m: Reinstate use of the cached image rep, but only
on backends supporting GSdraw: (cairo).  This means we don't have to
create a window for every call to draw an image, and gives me a 5-10x
speedup for image drawing.
* Source/NSCachedImageRep.m: Implement private method
-nativeDrawInRect:.. which is called by NSImageRep's
-drawInRect:fromRect:..., and efficiently draw the cached rep
using GSdraw:. Also make some changes so cached image reps can have a
DPI != 72.
* Headers/AppKit/NSCachedImageRep.h: New private init method that lets
you specify diferent pixel size and point size.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@33765 72102866-910b-0410-8b05-ffd578937521
2011-08-19 19:06:41 +00:00
Eric Wasylishen
99abec2ebf * Headers/AppKit/NSImageRep.h: Add
-drawInRect:fromRect:operation:fraction:respectFlipped:hints: method
* Source/NSImage.m:
* Source/NSImageRep.m: Refactor drawing code from NSImage to NSImageRep.
This should cause no functionlity change, but it lets NSImageRep
subclasses implement more efficient versions of -drawInRect:fromRect:...
that don't involve the (expensive) drawing of the image in a temporary
offscreen window and then drawing from there on to the destination surface.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@33764 72102866-910b-0410-8b05-ffd578937521
2011-08-18 23:57:50 +00:00
Eric Wasylishen
6ec3f1a58b * Source/NSImage.m (GSResolutionOfImageRep): Specify behaviour when the
rep has a size of zero, or is a vector rep. Prevent division by 0.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@33742 72102866-910b-0410-8b05-ffd578937521
2011-08-15 20:19:21 +00:00
Eric Wasylishen
e9367ed059 * Source/NSImage.m (-nativeDrawInRect:...): Deal with a zero rep size
* Source/NSCustomImageRep.m:
- Don't retain the delegate (matching OS X)
- Remove unnecessary flip checks from -drawAtPoint: and -drawInRect:
  to match the code in NSImageRep
- Fix a mistake when setting the ctm scale factor


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@33741 72102866-910b-0410-8b05-ffd578937521
2011-08-15 20:11:11 +00:00
Eric Wasylishen
97e9d3bda8 * Source/NSImage.m: Implement
-[NSImage drawInRect:fromRect:operation:fraction:respectFlipped:hints:


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@33571 72102866-910b-0410-8b05-ffd578937521
2011-07-16 02:09:06 +00:00
Eric Wasylishen
4e36d04d40 * Source/NSImage.m (-nativeDrawInRect:...): Fix two bugs
demonstrated in GSTest:
- drawing an image in a flipped view with -drawInRect:... wasn't
  working, and
- drawing a vector rep in a dest rect larger than the point
  size of the rep was resulting in blurry output.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@33570 72102866-910b-0410-8b05-ffd578937521
2011-07-16 01:23:40 +00:00