Saturday, December 16, 2017

#1 2015-10-13 05:26:10 am

ilexxey
Member
From:: Moscow
Registered: 2012-08-02
Posts: 94
Website

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 sad


Regards, Alex

Offline

 

#2 2015-10-13 07:04:13 am

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5200

Re: Any way to change progress bar default image?

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.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#3 2015-10-14 04:26:11 am

ilexxey
Member
From:: Moscow
Registered: 2012-08-02
Posts: 94
Website

Re: Any way to change progress bar default image?

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.


Regards, Alex

Offline

 

#4 2015-10-14 05:30:18 am

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5200

Re: Any way to change progress bar default image?

Alas, at this stage there are no more editions planned sad


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#5 2015-10-14 07:24:29 am

ilexxey
Member
From:: Moscow
Registered: 2012-08-02
Posts: 94
Website

Re: Any way to change progress bar default image?

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


Regards, Alex

Offline

 

#6 2015-10-14 07:27:47 am

DJ Bazzie Wazzie
Member
From:: the Netherlands
Registered: 2004-10-20
Posts: 2727
Website

Re: Any way to change progress bar default image?

ilexxey wrote:

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


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.

Last edited by DJ Bazzie Wazzie (2015-10-14 07:28:13 am)

Offline

 

#7 2015-10-14 08:35:26 am

ilexxey
Member
From:: Moscow
Registered: 2012-08-02
Posts: 94
Website

Re: Any way to change progress bar default image?

DJ Bazzie Wazzie wrote:

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 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 smile.

I want some one simple, like that:

Samle 1
Sample 2

Regards, Alex

Last edited by ilexxey (2015-10-14 08:53:33 am)


Regards, Alex

Offline

 

#8 2015-10-14 10:22:51 am

DJ Bazzie Wazzie
Member
From:: the Netherlands
Registered: 2004-10-20
Posts: 2727
Website

Re: Any way to change progress bar default image?

ilexxey wrote:
DJ Bazzie Wazzie wrote:

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 smile


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:



ilexxey wrote:

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 smile.

I want some one simple, like that:

Samle 1
Sample 2

Regards, Alex


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

Applescript:

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

Offline

 

#9 2015-10-14 10:00:55 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5200

Re: Any way to change progress bar default image?

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.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#10 2015-10-14 10:51:39 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5200

Re: Any way to change progress bar default image?

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


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#11 2015-10-15 04:39:58 am

ilexxey
Member
From:: Moscow
Registered: 2012-08-02
Posts: 94
Website

Re: Any way to change progress bar default image?

Thanks, DJ, thanks Shane.

DJ's code work well 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.

Applescript:


- (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.


Regards, Alex

Offline

 

#12 2015-10-15 05:12:22 am

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5200

Re: Any way to change progress bar default image?

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 Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#13 2015-10-15 06:43:42 am

ilexxey
Member
From:: Moscow
Registered: 2012-08-02
Posts: 94
Website

Re: Any way to change progress bar default image?

Shane, I apologize for my stupidity...

I have a header

Applescript:


// 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

Applescript:


// 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 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...

sad


Regards, Alex

Offline

 

#14 2015-10-15 06:48:05 am

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5200

Re: Any way to change progress bar default image?

They're the wrong files -- you want ITProgressBar.h and ITProgressBar.m.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#15 2015-10-15 09:45:43 am

ilexxey
Member
From:: Moscow
Registered: 2012-08-02
Posts: 94
Website

Re: Any way to change progress bar default image?

I'm really not a very smart sad

Progress is done.

Thanks, Shane.


Regards, Alex

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)