bugGNUstep - Bugs: bug #18970, NSToolbarItem setImage: scales...

Group
 
 

bug #18970: NSToolbarItem setImage: scales image only on initial creation ?

Submitter:  Paddy Smith <padski>
Submitted:  Tue 06 Feb 2007 07:49:07 AM UTC
   
 
Category:  Gui/AppKit Severity:  3 - Normal
Item Group:  Bug Status:  Invalid
Privacy:  Public Assigned to:  gcasa
Open/Closed:  Declined
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 04 Jan 2008 01:22:42 PM UTC, comment #2: 

Requested clarification and have not been able to reproduce this issue since.

Closed due to:

1) Cannot reproduce and
2) Lack of communication with original poster.

GJC

Gregory John Casamento <gcasa>
Group administrator
Sat 19 May 2007 03:52:45 PM UTC, comment #1: 

I realize it's been a while, but would it be possible for you to attach an image file demonstrating the problem?

Gregory John Casamento <gcasa>
Group administrator
Tue 06 Feb 2007 07:49:07 AM UTC, original submission:  

test code to show this effect when the images used are 128x128 pngs.  The button changes the image on the toolbarItem, the second image appears unscaled.

AppController.h:

#include <Foundation/Foundation.h>
#import <AppKit/AppKit.h>

@class NSWindow;
@class NSTextField;
@class NSNotification;

@interface AppController : NSWindowController
{
    NSWindow *window;
    BOOL readyToPlayStatus;
}
- (void)applicationWillFinishLaunching:(NSNotification *) not;
- (void)applicationDidFinishLaunching:(NSNotification *) not;
@end

AppController.m:

#include "AppController.h"
#include <AppKit/AppKit.h>

@interface AppController (AppControllerToolbar)

- (NSToolbarItem ) toolbar: (NSToolbar ) toolbar
      itemForItemIdentifier: (NSString *) itemIdentifier
  willBeInsertedIntoToolbar: (BOOL) flag;

- (NSArray ) toolbarAllowedItemIdentifiers: (NSToolbar) toolbar;

- (NSArray ) toolbarDefaultItemIdentifiers: (NSToolbar) toolbar;

- (BOOL) validateToolbarItem: (NSToolbarItem *) theItem;

@end

@implementation AppController (AppControllerToolbar)

- (NSToolbarItem ) toolbar: (NSToolbar ) toolbar
      itemForItemIdentifier: (NSString *) itemIdentifier
  willBeInsertedIntoToolbar: (BOOL) flag
{
  NSToolbarItem *item;
  if ([itemIdentifier isEqualToString: @"ready"]){
    item = [[NSToolbarItem alloc] initWithItemIdentifier: itemIdentifier];
    [item setLabel: @"Ready"];
    [item setPaletteLabel: @"Toggle Ready"];
    [item setImage: [NSImage imageNamed: @"toolbarStatusNotReady"]];
    [item setTarget: self];
    [item setAction: @selector(toggleReady:)];
  }
  return item;
}

- (NSArray ) toolbarAllowedItemIdentifiers: (NSToolbar) toolbar
{
  return [NSArray arrayWithObjects: @"ready", nil];
}

- (NSArray ) toolbarDefaultItemIdentifiers: (NSToolbar) toolbar
{
  return [NSArray arrayWithObjects: @"ready", nil];
}

- (BOOL) validateToolbarItem: (NSToolbarItem *) theItem { return YES; }

@end

@implementation AppController

- (void) toggleReady: (id) sender { NSLog(@"do stuff"); }

- (void) toggleReadyItem: (id) sender
{
        NSToolbarItem *anItem;
        NSEnumerator *enumerator = [[[window toolbar] items] objectEnumerator];
        while (anItem = [ enumerator nextObject ]){
                if([[anItem itemIdentifier] isEqualToString: @"ready"]){
                        if (readyToPlayStatus) {
                                readyToPlayStatus=NO;
                                [anItem setImage: [NSImage imageNamed: @"toolbarStatusReady"]];
                        }else{
                                readyToPlayStatus=YES;
                                [anItem setImage: [NSImage imageNamed: @"toolbarStatusNotReady"]];
                        }
                }
        }
}

- (void) applicationWillFinishLaunching: (NSNotification *) not
{
  NSMenu *menu = [NSMenu new];
  [menu addItemWithTitle: @"Quit"
                  action: @selector(terminate:)
           keyEquivalent: @"q"];
  [NSApp setMainMenu:menu];
  RELEASE(menu);

  window = [[NSWindow alloc] initWithContentRect: NSMakeRect(300, 300, 200, 100)
                                       styleMask: (NSTitledWindowMask |
                                                   NSMiniaturizableWindowMask |
                                                   NSResizableWindowMask)
                                          backing: NSBackingStoreBuffered
                                           defer: YES];
  [window setTitle: @"Test Toolbar"];

  NSToolbar *aToolbar = [[NSToolbar alloc] initWithIdentifier: @"AppControllerToolbar"];
  [aToolbar setDelegate: self];
  [aToolbar setAllowsUserCustomization: YES];
  [aToolbar setAutosavesConfiguration: YES];
  [window setToolbar: aToolbar];
  RELEASE(aToolbar);

  readyToPlayStatus=NO;

  NSButton *myButton= [[NSButton alloc] initWithFrame: NSMakeRect(30, 30, 80, 30)];
  [myButton setTarget: self];
  [myButton setAction: @selector(toggleReadyItem:)];
  [[window contentView] addSubview: myButton];
  RELEASE(myButton);

}

- (void) applicationDidFinishLaunching: (NSNotification *) not
{
  [window makeKeyAndOrderFront: self];
}

- (void) dealloc
{
  RELEASE(window);
  [super dealloc];
}

@end

I'm using the gnustep in debian etch (ie: latest gnustep release), but with base from svn at 20061227.

Regards,
Paddy

Paddy Smith <padski>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #12812:  gnustep_bug18970_example1.png added by padski (19KiB - image/png - on the left is an image correctly scaled, on the right an image which is green but otherwise the same, but not scaling the same.)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by gcasa (Posted a comment)
  • -email is unavailable- added by padski (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2008-01-04 gcasa StatusIn Progress Invalid
        Open/ClosedOpen Declined
    2007-05-20 padski Attached File- Added gnustep_bug18970_example1.png, #12812
    2007-05-19 gcasa StatusNone In Progress
        Assigned toNone gcasa

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code