mirror of
https://github.com/TermiT/Flycut.git
synced 2025-02-20 22:13:14 +08:00
Consolidate repeated Bezel code so that changes only need to be made in one place.
This commit is contained in:
parent
f068db6b03
commit
1dcb2b9f8d
1 changed files with 24 additions and 7 deletions
|
@ -32,8 +32,9 @@ static const float lineHeight = 16;
|
|||
[self setHasShadow:NO];
|
||||
[self setMovableByWindowBackground:NO];
|
||||
[self setColor:NO];
|
||||
[self setBackgroundColor:[self sizedBezelBackgroundWithRadius:25.0 withAlpha:[[DBUserDefaults standardUserDefaults] floatForKey:@"bezelAlpha"]]];
|
||||
NSRect textFrame = NSMakeRect(12, 36, self.frame.size.width - 24, self.frame.size.height - 50);
|
||||
[self setBackgroundColor:[self backgroundColor]];
|
||||
|
||||
NSRect textFrame = [self textFrame];
|
||||
textField = [[RoundRecTextField alloc] initWithFrame:textFrame];
|
||||
[[self contentView] addSubview:textField];
|
||||
[textField setEditable:NO];
|
||||
|
@ -44,7 +45,8 @@ static const float lineHeight = 16;
|
|||
[textField setDrawsBackground:YES];
|
||||
[textField setBordered:NO];
|
||||
[textField setAlignment:NSLeftTextAlignment];
|
||||
NSRect charFrame = NSMakeRect(([self frame].size.width - (3 * lineHeight)) / 2, 7, 4 * lineHeight, 1.2 * lineHeight);
|
||||
|
||||
NSRect charFrame = [self charFrame];
|
||||
charField = [[RoundRecTextField alloc] initWithFrame:charFrame];
|
||||
[[self contentView] addSubview:charField];
|
||||
[charField setEditable:NO];
|
||||
|
@ -62,17 +64,32 @@ static const float lineHeight = 16;
|
|||
|
||||
- (void) update {
|
||||
[super update];
|
||||
[self setBackgroundColor:[self sizedBezelBackgroundWithRadius:25.0 withAlpha:[[DBUserDefaults standardUserDefaults] floatForKey:@"bezelAlpha"]]];
|
||||
NSRect textFrame = NSMakeRect(12, 36, self.frame.size.width - 24, self.frame.size.height - 50);
|
||||
[self setBackgroundColor:[self backgroundColor]];
|
||||
NSRect textFrame = [self textFrame];
|
||||
[textField setFrame:textFrame];
|
||||
NSRect charFrame = NSMakeRect(([self frame].size.width - (3 * lineHeight)) / 2, 7, 4 * lineHeight, 1.2 * lineHeight);
|
||||
NSRect charFrame = [self charFrame];
|
||||
[charField setFrame:charFrame];
|
||||
|
||||
}
|
||||
|
||||
-(NSRect) textFrame
|
||||
{
|
||||
return NSMakeRect(12, 36, self.frame.size.width - 24, self.frame.size.height - 50);
|
||||
}
|
||||
|
||||
-(NSRect) charFrame
|
||||
{
|
||||
return NSMakeRect(([self frame].size.width - (3 * lineHeight)) / 2, 7, 4 * lineHeight, 1.2 * lineHeight);
|
||||
}
|
||||
|
||||
-(NSColor*) backgroundColor
|
||||
{
|
||||
return [self sizedBezelBackgroundWithRadius:25.0 withAlpha:[[DBUserDefaults standardUserDefaults] floatForKey:@"bezelAlpha"]];
|
||||
}
|
||||
|
||||
- (void) setAlpha:(float)newValue
|
||||
{
|
||||
[self setBackgroundColor:[self sizedBezelBackgroundWithRadius:25.0 withAlpha:[[DBUserDefaults standardUserDefaults] floatForKey:@"bezelAlpha"]]];
|
||||
[self setBackgroundColor:[self backgroundColor]];
|
||||
[[self contentView] setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue