mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-30 16:30:53 +00:00
Moved _sizeForBorderType() into GSTheme header and added more methods
for theme abstraction. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@26836 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
e3b12be40c
commit
7f9c5cf331
8 changed files with 338 additions and 263 deletions
|
@ -929,6 +929,14 @@ typedef struct _GSButtonCellFlags
|
|||
- (void) _drawBorderAndBackgroundWithFrame: (NSRect)cellFrame
|
||||
inView: (NSView*)controlView
|
||||
{
|
||||
// Draw gradient
|
||||
if (!_cell.is_highlighted)
|
||||
{
|
||||
[[GSTheme theme] drawGradientBorder: _gradient_type
|
||||
inRect: cellFrame
|
||||
withClip: NSZeroRect];
|
||||
}
|
||||
|
||||
// The inside check could also be done via a track rect, but then this would
|
||||
// only work with specially prepared controls. Therefore we dont use
|
||||
// _mouse_inside here.
|
||||
|
@ -941,105 +949,6 @@ typedef struct _GSButtonCellFlags
|
|||
}
|
||||
}
|
||||
|
||||
- (void) drawGradientWithFrame: (NSRect)cellFrame inView: (NSView *)controlView
|
||||
{
|
||||
float start_white = 0.0;
|
||||
float end_white = 0.0;
|
||||
float white = 0.0;
|
||||
float white_step = 0.0;
|
||||
float h, s, v, a;
|
||||
NSColor *lightGray = nil;
|
||||
NSColor *gray = nil;
|
||||
NSColor *darkGray = nil;
|
||||
NSPoint p1, p2;
|
||||
|
||||
lightGray = [NSColor colorWithDeviceRed:0.83 green:0.83 blue:0.83 alpha:1.0];
|
||||
gray = [NSColor colorWithDeviceRed:0.50 green:0.50 blue:0.50 alpha:1.0];
|
||||
darkGray = [NSColor colorWithDeviceRed:0.32 green:0.32 blue:0.32 alpha:1.0];
|
||||
|
||||
switch (_gradient_type)
|
||||
{
|
||||
case NSGradientNone:
|
||||
return;
|
||||
break;
|
||||
|
||||
case NSGradientConcaveWeak:
|
||||
[gray getHue: &h saturation: &s brightness: &v alpha: &a];
|
||||
start_white = [lightGray brightnessComponent];
|
||||
end_white = [gray brightnessComponent];
|
||||
break;
|
||||
|
||||
case NSGradientConvexWeak:
|
||||
[darkGray getHue: &h saturation: &s brightness: &v alpha: &a];
|
||||
start_white = [gray brightnessComponent];
|
||||
end_white = [lightGray brightnessComponent];
|
||||
break;
|
||||
|
||||
case NSGradientConcaveStrong:
|
||||
[lightGray getHue: &h saturation: &s brightness: &v alpha: &a];
|
||||
start_white = [lightGray brightnessComponent];
|
||||
end_white = [darkGray brightnessComponent];
|
||||
break;
|
||||
|
||||
case NSGradientConvexStrong:
|
||||
[darkGray getHue: &h saturation: &s brightness: &v alpha: &a];
|
||||
start_white = [darkGray brightnessComponent];
|
||||
end_white = [lightGray brightnessComponent];
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
white = start_white;
|
||||
white_step = fabs(start_white - end_white)
|
||||
/ (cellFrame.size.width + cellFrame.size.height);
|
||||
|
||||
// Start from top left
|
||||
p1 = NSMakePoint(cellFrame.origin.x,
|
||||
cellFrame.size.height + cellFrame.origin.y);
|
||||
p2 = NSMakePoint(cellFrame.origin.x,
|
||||
cellFrame.size.height + cellFrame.origin.y);
|
||||
|
||||
// Move by Y
|
||||
while (p1.y > cellFrame.origin.y)
|
||||
{
|
||||
[[NSColor
|
||||
colorWithDeviceHue: h saturation: s brightness: white alpha: 1.0] set];
|
||||
[NSBezierPath strokeLineFromPoint: p1 toPoint: p2];
|
||||
|
||||
if (start_white > end_white)
|
||||
white -= white_step;
|
||||
else
|
||||
white += white_step;
|
||||
|
||||
p1.y -= 1.0;
|
||||
if (p2.x < (cellFrame.size.width + cellFrame.origin.x))
|
||||
p2.x += 1.0;
|
||||
else
|
||||
p2.y -= 1.0;
|
||||
}
|
||||
|
||||
// Move by X
|
||||
while (p1.x < (cellFrame.size.width + cellFrame.origin.x))
|
||||
{
|
||||
[[NSColor
|
||||
colorWithDeviceHue: h saturation: s brightness: white alpha: 1.0] set];
|
||||
[NSBezierPath strokeLineFromPoint: p1 toPoint: p2];
|
||||
|
||||
if (start_white > end_white)
|
||||
white -= white_step;
|
||||
else
|
||||
white += white_step;
|
||||
|
||||
p1.x += 1.0;
|
||||
if (p2.x >= (cellFrame.size.width + cellFrame.origin.x))
|
||||
p2.y -= 1.0;
|
||||
else
|
||||
p2.x += 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
- (void) drawInteriorWithFrame: (NSRect)cellFrame inView: (NSView*)controlView
|
||||
{
|
||||
unsigned mask;
|
||||
|
@ -1275,13 +1184,6 @@ typedef struct _GSButtonCellFlags
|
|||
break;
|
||||
}
|
||||
|
||||
// Draw gradient
|
||||
if (!_cell.is_highlighted && _gradient_type != NSGradientNone)
|
||||
{
|
||||
// FIXME: I think this method is wrong.
|
||||
[self drawGradientWithFrame: cellFrame inView: controlView];
|
||||
}
|
||||
|
||||
// Draw image
|
||||
if (imageToDisplay != nil)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue