Hi there,
after the short discussion last week about the Camaelon themes not
being drawn correctly anymore, I sat down and tried to make something
up.
I did some quick hackery to fix the (at least for me) most obvious
problems: Table headers and sliders. You find my changes in te
attached patch which is against today's SVN.
Some remarks:
1. I have left the original code outcommented. This was more or less
for documentary reasons.
2. GraphicToolbox contains code to save and restore graphics contexts
in various places. For some reason on my system only the vertical
rectabgle drawing worked, the hrozontal did not. I was able to fill
horizontal rects only after disabling the context saving/restoring. I
have no idea why this is the case. I solved the clipping issue for the
time being by reordering the drawing of the parts, e.g.
left-fill-right. This may not work for some rare cases where the fill
area is too large, i could imagine. This needs to be cleaned up by
someone who knows more about that.
3. I did not care about the more complex rectangle drawing like
buttons, where you fill the rectangle in both directions. At first
glance this seems to work anyway, at least my buttons here look OK.
4. For disabled table header cells I need yet another caps image. This
is attached as well (for the Narcissus theme only). Note that this
only a quick draft, that looks OK here, but may need further graphical
refinement by a more enabled person than me.
5. As I've already said, this was some quick hackery and may not be
clean in some places, in particular when it comes to drawing other
widgets than table headers and sliders.

Hope that gets you started on fixing Camaelon anyway.
Have fun

Andreas

<Camaelon.diff>
<ListHeader-caps-unselected.tiff>

--
Mail: andreas dot schik at web dot de
Home: http://www.andreasheppel.de

PGP Key is available from the MIT key server (pgp.mit.edu).
Index: GSDrawFunctions.m
===================================================================
--- GSDrawFunctions.m	(Revision 2761)
+++ GSDrawFunctions.m	(Arbeitskopie)
@@ -158,6 +158,7 @@
 	NSSize fillSize = NSMakeSize ([fill size].width, frame.size.height);
 	[fill setScalesWhenResized: YES];
 	[fill setSize: fillSize];
+	frame.origin.y += [fill size].height;
 	[GraphicToolbox fillHorizontalRect: frame withImage: fill];
 }
 
@@ -167,20 +168,21 @@
 	NSSize fillSize = NSMakeSize ([fill size].width, frame.size.height);
 	[fill setScalesWhenResized: YES];
 	[fill setSize: fillSize];
+	frame.origin.y += [fill size].height;
 	[GraphicToolbox fillHorizontalRect: frame withImage: fill];
 }
 
 - (void) drawTableHeaderCellInRect: (NSRect) frame highlighted: (BOOL) highlighted 
 {
-	frame.origin.y -= 1;
-	NSImage* separation = nil;
-	NSImage* fill = nil;
+//	frame.origin.y -= 1;
+//	NSImage* separation = nil;
+//	NSImage* fill = nil;
 	if (highlighted)
 	{
 		CLHBoxCompositor* compositor = [CLHBoxCompositor new];
 		[compositor addImage: [NSImage imageNamed: @"ListHeader/ListHeader-caps-selected.tiff"] named: @"caps"];
 		[compositor addImage: [NSImage imageNamed: @"ListHeader/ListHeader-fill-selected.tiff"] named: @"fill"];
-		[compositor drawInRect: frame];
+		[compositor drawInRect: frame flipped: YES];
 		[compositor release];
 /*
 		fill = [NSImage imageNamed: @"ListHeader/ListHeader-fill-selected.tiff"];
@@ -190,11 +192,17 @@
 	}
 	else
 	{
-		fill = [NSImage imageNamed: @"ListHeader/ListHeader-fill-unselected.tiff"];
-		separation = [NSImage imageNamed: @"ListHeader/ListHeader-separator-unselected.tiff"];
+		CLHBoxCompositor* compositor = [CLHBoxCompositor new];
+		[compositor addImage: [NSImage imageNamed: @"ListHeader/ListHeader-caps-unselected.tiff"] named: @"caps"];
+		[compositor addImage: [NSImage imageNamed: @"ListHeader/ListHeader-fill-unselected.tiff"] named: @"fill"];
+//		frame.origin.y += [image size].height;
+		[compositor drawInRect: frame flipped: YES];
+		[compositor release];
+//		fill = [NSImage imageNamed: @"ListHeader/ListHeader-fill-unselected.tiff"];
+//		separation = [NSImage imageNamed: @"ListHeader/ListHeader-separator-unselected.tiff"];
 	}
-	[separation compositeToPoint: NSMakePoint (frame.origin.x + frame.size.width -1, frame.origin.y +1)
-		operation: NSCompositeSourceOver];
+//	[separation compositeToPoint: NSMakePoint (frame.origin.x + frame.size.width -1, frame.origin.y +1)
+//		operation: NSCompositeSourceOver];
 }
 
 - (void) drawGradient: (NSData*) gradient withSize: (NSArray*) size 
Index: NSSliderCell.m
===================================================================
--- NSSliderCell.m	(Revision 2761)
+++ NSSliderCell.m	(Arbeitskopie)
@@ -12,9 +12,9 @@
 	{
 			knobImage = [NSImage imageNamed: @"Slider/Slider-vertical-thumb.tiff"];
 			
-			float hKnob = [knobImage size].height;
-         	rect.origin.y += hKnob / 2;
-          	rect.size.height -= hKnob;
+//			float hKnob = [knobImage size].height;
+//         	rect.origin.y += hKnob / 2;
+//          	rect.size.height -= hKnob;
 
 			CLCompositor* compositor = [CLVBoxCompositor new];
 			[compositor addImage: [NSImage imageNamed: @"Slider/Slider-vertical-track-caps.tiff"]
@@ -28,16 +28,16 @@
 	{
 			knobImage = [NSImage imageNamed: @"Slider/Slider-horizontal-thumb.tiff"];
 
-			float wKnob = [knobImage size].width;
-         	rect.origin.x += wKnob / 2;
-          	rect.size.width -= wKnob;
+//			float wKnob = [knobImage size].width;
+//         	rect.origin.x += wKnob / 2;
+//          	rect.size.width -= wKnob;
 
 			CLCompositor* compositor = [CLHBoxCompositor new];
 			[compositor addImage: [NSImage imageNamed: @"Slider/Slider-horizontal-track-caps.tiff"]
 				named: @"caps"];
 			[compositor addImage: [NSImage imageNamed: @"Slider/Slider-horizontal-track-fill.tiff"]
 				named: @"fill"];
-			[compositor drawInRect: rect];
+			[compositor drawInRect: rect flipped: YES];
 			[compositor release];
 	}
 }
@@ -87,28 +87,45 @@
   return NSMakeRect (origin.x, origin.y, size.width, size.height);
 }
 
+// Private helper method overridden in subclasses
+- (void) _drawBorderAndBackgroundWithFrame: (NSRect)cellFrame 
+                                    inView: (NSView*)controlView
+{
+  [THEME drawWindowBackground: cellFrame on: controlView];
+}
+
+// Private helper method
+- (void) _drawFocusRingWithFrame: (NSRect)cellFrame inView: (NSView*)controlView
+{
+}
+
+#if 0
 - (void) drawWithFrame: (NSRect)cellFrame inView: (NSView*)controlView
 {
   _cell.is_bordered = NO;
-  _cell.is_bezeled = YES;
+  _cell.is_bezeled = NO;
+  _cell.focus_ring_type = NSFocusRingTypeNone;
   //[THEME drawGrayBezelRound: cellFrame :NSZeroRect];
   //[[NSColor greenColor] set];
   //NSRectFill (cellFrame);
   [THEME drawWindowBackground: cellFrame on: controlView];
-  [self drawInteriorWithFrame: cellFrame inView: controlView];
+  [super drawWithFrame: cellFrame inView: controlView];
+ // [self drawInteriorWithFrame: cellFrame inView: controlView];
 }
+#endif
 - (void) drawKnob: (NSRect)knobRect
 {
   NSImage* knobImage = nil;
   NSPoint point = NSMakePoint (knobRect.origin.x, knobRect.origin.y);
-  
   if (_isVertical)
   {
 	knobImage = [NSImage imageNamed: @"Slider/Slider-vertical-thumb.tiff"];
+	point.y += [knobImage size].height;
   }
   else
   {
 	knobImage = [NSImage imageNamed: @"Slider/Slider-horizontal-thumb.tiff"];
+	point.y += [knobImage size].height;
   }
 
   [knobImage compositeToPoint: point operation: NSCompositeSourceOver];
Index: CLVBoxCompositor.m
===================================================================
--- CLVBoxCompositor.m	(Revision 2761)
+++ CLVBoxCompositor.m	(Arbeitskopie)
@@ -62,16 +62,16 @@
 
 	float deltaX = (rect.size.width - [fill size].width)/2.0;
 
-	[bottom compositeToPoint: NSMakePoint (rect.origin.x+deltaX,rect.origin.y)
+	[top compositeToPoint: NSMakePoint (rect.origin.x+deltaX,rect.origin.y+[top size].height)
 		operation: NSCompositeSourceOver];
-	[top compositeToPoint: 
-		NSMakePoint (rect.origin.x + deltaX, rect.origin.y + rect.size.height - [top size].height)
-		operation: NSCompositeSourceOver];
 
 	[GraphicToolbox fillVerticalRect: 
-		NSMakeRect (rect.origin.x+deltaX, rect.origin.y + [bottom size].height,
+		NSMakeRect (rect.origin.x+deltaX, rect.origin.y + [top size].height + [fill size].height,
 			[fill size].width, rect.size.height - [bottom size].height - [top size].height)
 		withImage: fill];
+	[bottom compositeToPoint: 
+		NSMakePoint (rect.origin.x + deltaX, rect.origin.y + rect.size.height)
+		operation: NSCompositeSourceOver];
 }
 
 @end
Index: GraphicToolbox.m
===================================================================
--- GraphicToolbox.m	(Revision 2761)
+++ GraphicToolbox.m	(Arbeitskopie)
@@ -130,11 +130,11 @@
 
 + (void) fillHorizontalRect: (NSRect) rect withImage: (NSImage*) image flipped: (BOOL) flipped
 {
-	NSGraphicsContext* ctxt = GSCurrentContext ();
+/*	NSGraphicsContext* ctxt = GSCurrentContext ();
 	DPSgsave (ctxt);
 	NSBezierPath* path = [NSBezierPath bezierPathWithRect: rect];
 	[path addClip];
-
+*/
 	float wImage = [image size].width;
 //	float hImage = [image size].height;
 	float wRect = rect.size.width;
@@ -157,7 +157,7 @@
 		[image compositeToPoint: p operation: NSCompositeSourceOver];
 	}
 
-	DPSgrestore (ctxt);	
+//	DPSgrestore (ctxt);	
 }
 
 /*
@@ -171,17 +171,17 @@
 
 + (void) fillVerticalRect: (NSRect) rect withImage: (NSImage*) image flipped: (BOOL) flipped
 {
-	[image retain];
+/*	[image retain];
 	NSGraphicsContext* ctxt = GSCurrentContext ();
 	DPSgsave (ctxt);
 	NSBezierPath* path = [NSBezierPath bezierPathWithRect: rect];
-
+*/
 //	float wImage = [image size].width;
 	float hImage = [image size].height;
 //	float wRect = rect.size.width;
 	float hRect = rect.size.height;
 
-	[path addClip];
+//	[path addClip];
 
 	if (flipped)
 	{
@@ -214,8 +214,8 @@
 		}
 	}
 
-	DPSgrestore (ctxt);	
-	[image release];
+//	DPSgrestore (ctxt);	
+//	[image release];
 }
 
 /*
Index: CLHBoxCompositor.m
===================================================================
--- CLHBoxCompositor.m	(Revision 2761)
+++ CLHBoxCompositor.m	(Arbeitskopie)
@@ -11,6 +11,11 @@
 
 - (void) drawInRect: (NSRect) rect
 {
+    [self drawInRect: rect flipped: NO];
+}
+
+- (void) drawInRect: (NSRect) rect flipped: (BOOL)flipped
+{
 	// A HBox is composed of 3 images:
 
 	NSImage* left = [images objectForKey: @"left"];
@@ -55,15 +60,17 @@
 	// Ok, drawing ...
 
 	float deltaY = (rect.size.height - [fill size].height)/2.0;
+	rect.origin.y += [fill size].height;
 
 	[left compositeToPoint: NSMakePoint (rect.origin.x,rect.origin.y+deltaY)
 		operation: NSCompositeSourceOver];
-	[right compositeToPoint: NSMakePoint (rect.origin.x+rect.size.width-[right size].width,rect.origin.y+deltaY)
-		operation: NSCompositeSourceOver];
 
 	[GraphicToolbox fillHorizontalRect: NSMakeRect (rect.origin.x+[left size].width, rect.origin.y+deltaY,
 		rect.size.width-[left size].width-[right size].width,
 				[fill size].height) withImage: fill];
+
+	[right compositeToPoint: NSMakePoint (rect.origin.x+rect.size.width-[right size].width,rect.origin.y+deltaY)
+		operation: NSCompositeSourceOver];
 }
 
 @end

<<attachment: ListHeader-caps-unselected.tiff>>

Attachment: pgpIHdTPCC0w4.pgp
Description: PGP signature

_______________________________________________
Etoile-discuss mailing list
[email protected]
https://mail.gna.org/listinfo/etoile-discuss

Répondre à