Any way to change progress bar default image?

Hi, people!

Can i change IB default image for progress bar to my own image? I really enraged bikini instead of the normal display :frowning:

It would involve subclassing NSProgressIndicator, and would be a fair challenge. But you could make a series of images and swap them into a wide and shallow image view.

Hi, Shane

I’m waiting for a separate chapter about this subject in the next edition of your book!

Because i found some working projects on Github, but don’t know how to make it work with a ready AS-project.

Regards, Alex.

Alas, at this stage there are no more editions planned :frowning:

So many changes in 10.11 and no more editions? Very sadly…

Depends on what you want. I had my own AppleScript-Studio progress bars by putting two NSImages on top of eachother or next to each other. One progress bar was from an grayscale image to full color which was two image views next to each other where the bounds of the image view was changed. The other one was a fill where you showed on top an image with the same color as the window background color and the silhouette cut out (transparant) and on the background you have simply 1px color image that grows in bounds. It’s quite easy and it doesn’t involve any coding that’s not covered in Shane’s book.

All peoples, who is a professional in his own work, thinking it’s really easy for others :slight_smile:

For me was a high-pilotage make a working progress bar (with Shane’s book and loot of samples from there) when my old script has been destroyed by El Coyote :).

I want some one simple, like that:

Samle 1
Sample 2

Regards, Alex

My Apologies if it sounded like that. What I meant is that it involves more working presenting images (and creating images) than writing code. At least my examples:

You can add an Core Image Filter (CIFilter) to the progress indicator and change the color of the progress bar. Here an example on hoe to add an hue filter to give it a red glow

property CIFilter : class "CIFilter"
property CIVector : class "CIVector"
property NSColor : class "NSColor"
property NSArray : class "NSArray"
script AppDelegate
	property parent : class "NSObject"
	
	-- IBOutlets
	property theWindow : missing value
    property progressBar : missing value
	
	on applicationWillFinishLaunching_(aNotification)
		-- Insert code here to initialize your application before any files are opened
        progressBar's setMaxValue:10
        progressBar's setMinValue:1
        progressBar's setDoubleValue:5
        
        set theFilter to CIFilter's filterWithName:"CIHueAdjust"
        theFilter's setDefaults()
        
        theFilter's setValue:2 forKey:"inputAngle" --gives it a red like hue
        
        set theFilters to NSArray's arrayWithObject:theFilter
        
        progressBar's setContentFilters:theFilters
        progressBar's setNeedsDisplay:true
	end applicationWillFinishLaunching_
	
	on applicationShouldTerminate_(sender)
		-- Insert code here to do any housekeeping before your application quits 
		return current application's NSTerminateNow
	end applicationShouldTerminate_
	
end script

Alex,

As well as what DJ suggests, it looks like those two screenshots are from cocoacontrols.com, and you can download them and add them to your project.

In the case of ITProgressBar, you need to add ITProgressBar.h and ITProgressBar.m to your project, then in the interface add a custom view where you want it to appear, and in the Identity Inspector change the view’s class to ITProgressBar. Connect it as an outlet to a property as usual, and use the .h file as your documentation. it looks like floatValue is the fraction of width.

For GRProgressIndicator there’s also a GRProgressIndicatorThemes.h file to copy across. Set up is similar, and it looks like it has methods similar to progress indicator, plus a theme property.

And I forgot a very important point: you also need to add the authors’ copyright notices.

Thanks, DJ, thanks Shane.

DJ’s code work well :slight_smile:

What about projects from cocoacontrols.com… I found where i can call these progress bars, but i don’t understand, how i can coerce them current value. There have a sender and loop, whose call from sender.


- (IBAction)setFloatValue:(id)sender {
    [self.progressBar.animator setFloatValue:[sender doubleValue]];
}

Here set current value from slider.

Maybe you get a point to any article with info about how to exchange data between AScripts and Objective-C? And set current value from variable of my Script?

Regards, Alex.

ou add a property that is an outlet for the view, just as you do for a normal progress bar, and then say:

theProgressBar’s setFloatValue:0.5

Shane, I apologize for my stupidity…

I have a header


//  ITAppDelegate.h
//  ITProgressBar

#import <Cocoa/Cocoa.h>
#import "ITProgressBar.h"

@interface ITAppDelegate : NSObject <NSApplicationDelegate>

@property (assign) IBOutlet NSWindow *window;
@property (assign) IBOutlet ITProgressBar *progressBar;
@property (assign) IBOutlet NSLayoutConstraint *heightConstraint;

@end

and body


//  ITAppDelegate.m

#import "ITAppDelegate.h"

@implementation ITAppDelegate

- (IBAction)toggleAnimation:(id)sender {
    self.progressBar.animates = !self.progressBar.animates;
}

- (IBAction)toggleHidden:(id)sender {
    [CATransaction begin]; {
        // Comment-out to disable animation
        // [CATransaction setValue: (id) kCFBooleanTrue forKey: kCATransactionDisableActions];
        
        [self.progressBar setHidden:!self.progressBar.isHidden];
    }[CATransaction commit];
}

- (IBAction)setFloatValue:(id)sender {
    [self.progressBar.animator setFloatValue:[sender doubleValue]];
}

- (IBAction)setHeight:(id)sender {
    self.heightConstraint.constant = [sender doubleValue];
    [self.window setContentBorderThickness:[sender doubleValue] + (7 * 2) forEdge:NSMinYEdge];
}

And my script, with default progress bar.

Then i did added new object to my project with new progress bar.
They live different :slight_smile:
How i can establish connection between AS and Objective-C classes?

If i connect my new view with outlet from my AS class “ he is don’t work…

:frowning:

They’re the wrong files – you want ITProgressBar.h and ITProgressBar.m.

I’m really not a very smart :frowning:

Progress is done.

Thanks, Shane.