Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 282575

Summary: [CSS] CTabItem should support color, background-color
Product: [Eclipse Project] e4 Reporter: Kevin McGuire <Kevin_McGuire>
Component: UIAssignee: Project Inbox <e4.ui-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: kai.toedter, remy.suen
Version: 0.9   
Target Milestone: 0.9 RC1   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Bug Depends on:    
Bug Blocks: 282898    
Attachments:
Description Flags
CTabItem color attributes patch v1
none
CTabItem color attributes patch v2
none
CTabItem color attributes patch v2b none

Description Kevin McGuire CLA 2009-07-06 16:11:14 EDT
We should support color and background-color for CTabItem.
This would allow things like:

CTabItem {
  color: black;
}

CTabItem:selected {
  color: orange;
}

Under the covers it would call CTabFolder API (since that's where the colors are stored).  Certain things wouldn't work though, like:

CTabItem {
  color: black;
}

CTabItem.special {
  color: green;
}

since a given CTabFolder can only maintain two colors, one for selected and one for non-selected tabs.
Comment 1 Remy Suen CLA 2009-07-11 12:35:40 EDT
(In reply to comment #0)
> Under the covers it would call CTabFolder API (since that's where the colors
> are stored).

Kevin, you are speaking of CTabFolder's setForeground/setSelectionForeground and setBackground/setSelectionBackground, correct?

> Certain things wouldn't work though, like:
> 
> CTabItem {
>   color: black;
> }
> 
> CTabItem.special {
>   color: green;
> }
> 
> since a given CTabFolder can only maintain two colors, one for selected and one
> for non-selected tabs.

This should change if SWT implements bug 280969.
Comment 2 Kevin McGuire CLA 2009-07-11 18:16:18 EDT
(In reply to comment #1)
> (In reply to comment #0)
> > Under the covers it would call CTabFolder API (since that's where the colors
> > are stored).
> 
> Kevin, you are speaking of CTabFolder's setForeground/setSelectionForeground
> and setBackground/setSelectionBackground, correct?

Correct Remi.  Conceptually from a CSS point of view, these should be set on the tabs themselves.


One problem I hit in trying to implement Linda's design mockup is that setBackground() sets both the background area of the tab folder itself (ie. the top area if there were no tabs), as well as the color of the unselected tab.  We wanted those to be different.

In ETabFolder/ETabItem I added another color for the tab area background, which presently is hardcoded to Linda's design.  I want to be able to set it from the CSS obviously.

To do so, we need to be able to style from CSS the tabs themselves (why I'm discussing all this in this bug). So we'd have:

ETabItem {
   background: ...;  /* unselected tab background color */
}
ETabItem:selected {
   background: ...;  /* selected tab background color */
}
ETabFolder {
   background: ...;  /* the NEW tab area background color"
}

Otherwise we'd need to add a new property for ETabFolder, "tabAreaBackground:" or something ucky. It's a bit tight but I'd love to be able to get this fixed this week.

See bug #282898.

> This should change if SWT implements bug 280969.

Cool! We could apply this to ETabFolder/Item but maybe post 0.9 as I have something now that works for the cases we care about, we just minus the CSS.
Comment 3 Kevin McGuire CLA 2009-07-12 11:25:13 EDT
Should consider for RC1 as would allow us to fix bug #282898
Comment 4 Remy Suen CLA 2009-07-12 12:45:17 EDT
Created attachment 141376 [details]
CTabItem color attributes patch v1

This patch reuses the same (somewhat annoying and verbose) class checking logic to consider Widgets instead of Controls that we introduced with attachment 139714 [details].
Comment 5 Remy Suen CLA 2009-07-12 12:46:44 EDT
Created attachment 141377 [details]
CTabItem color attributes patch v2

Whoops, I forgot to include GradientTest in my patch.
Comment 6 Remy Suen CLA 2009-07-12 22:57:50 EDT
For the CTabItem background case, there is bug 75411.
Comment 7 Remy Suen CLA 2009-07-13 19:54:21 EDT
(In reply to comment #5)
> Created an attachment (id=141377) [details]
> CTabItem color attributes patch v2

If a style sheet simply defines a colour without defining one for the "selected" pseudo, the selection colour will be set as the "parent" one's anyway.
Comment 8 Remy Suen CLA 2009-07-13 20:42:39 EDT
(In reply to comment #7)
> If a style sheet simply defines a colour without defining one for the
> "selected" pseudo, the selection colour will be set as the "parent" one's
> anyway.

I guess it's questionable as to whether this is a problem or not. If the person thinks about the API then it doesn't really map right. On the other hand, if one just wants the foreground colour to change, it may be their intent to set it at a "global" level encompassing both unselected and selected foreground colours.
Comment 9 Kevin McGuire CLA 2009-07-14 16:03:06 EDT
Remy, with this patch, CTabFolder:selected would no longer work for tab background and text coloring, right?  It's a complete switch to CTabItem?

Just wondering if that'd be harsh for adopters for RC1 ... but maybe I need to stop thinking about backwards compat :)
Comment 10 Remy Suen CLA 2009-07-14 18:06:49 EDT
Created attachment 141579 [details]
CTabItem color attributes patch v2b

This patch v2b will alter AbstractCSSEngine to correct the problem described by comment 7, if it really is a problem. From testing CTabFolder, this does not appear to be an actual regression, that is, our original code exhibited the identical behaviour for CTabFolder styling.

(In reply to comment #9)
> Remy, with this patch, CTabFolder:selected would no longer work for tab
> background and text coloring, right?  It's a complete switch to CTabItem?

This is correct. I could attempt to make modifications to the code to keep it in if you wish.
Comment 11 Kevin McGuire CLA 2009-07-15 15:26:11 EDT
Released, thanks for the patch Remy!

(In reply to comment #10)
> This patch v2b will alter AbstractCSSEngine to correct the problem described by
> comment 7, if it really is a problem. From testing CTabFolder, this does not
> appear to be an actual regression, that is, our original code exhibited the
> identical behaviour for CTabFolder styling.

Great!
 
> (In reply to comment #9)
> > Remy, with this patch, CTabFolder:selected would no longer work for tab
> > background and text coloring, right?  It's a complete switch to CTabItem?
> 
> This is correct. I could attempt to make modifications to the code to keep it
> in if you wish.

Decided not to worry about it.  Fact is, I'll be changing what ETabFolder { background-color: } means wrt tabs so I think the 'breakage' in terms of who now gets styled and why is unavoidable and acceptable given it's an incubator.

Just need to inform the community once all the changes are in.

Comment 12 Kevin McGuire CLA 2009-07-15 15:38:25 EDT
Kai, FYI.
I will update the contacts demo.
Comment 13 Kevin McGuire CLA 2009-07-15 15:44:25 EDT
Released changes to demo.contacts and demo.e4photo.

Kai, do you want to double check the contacts demo to make sure it still looks like you intended?