Navigation Menu

Skip to content

Commit

Permalink
set the same color (like in accordions) in text and graphics of expan…
Browse files Browse the repository at this point in the history
…ders titles, even when not enabled (similar to the change already made for rollups). Add a sample of this even in Kitchen Sink.

git-svn-id: https://svn.apache.org/repos/asf/pivot/trunk@1339185 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Sandro Martini committed May 16, 2012
1 parent 6549a1d commit 95ac73e
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 8 deletions.
13 changes: 11 additions & 2 deletions tests/src/org/apache/pivot/tests/expander_test.bxml
Expand Up @@ -27,10 +27,19 @@ limitations under the License.
</columns>

<TablePane.Row height="1*">
<Expander title="Left Expander">
<Expander title="Left Top Expander">
<Label text="Left" styles="{verticalAlignment:'center', horizontalAlignment:'center', wrapText:true}" />
</Expander>
<Expander title="Right Expander" collapsible="false">
<Expander title="Right Top Expander" collapsible="false">
<Label text="Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the 'License'); you may not use this file except in compliance with the License." styles="{verticalAlignment:'center', horizontalAlignment:'center', wrapText:true}" />
</Expander>
</TablePane.Row>

<TablePane.Row height="1*">
<Expander title="Left Bottom Expander, disabled" enabled="false">
<Label text="Left" styles="{verticalAlignment:'center', horizontalAlignment:'center', wrapText:true}" />
</Expander>
<Expander title="Right Bottom Expander, disabled" collapsible="false" enabled="false">
<Label text="Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the 'License'); you may not use this file except in compliance with the License." styles="{verticalAlignment:'center', horizontalAlignment:'center', wrapText:true}" />
</Expander>
</TablePane.Row>
Expand Down
11 changes: 9 additions & 2 deletions tutorials/src/org/apache/pivot/tutorials/navigation.bxml
Expand Up @@ -156,10 +156,15 @@ limitations under the License.
styles="{horizontalAlignment:'center', verticalAlignment:'center', font:{italic:true}}"/>
</Expander>

<Expander title="Three">
<Expander title="Three" enabled="false">
<Label preferredWidth="100" preferredHeight="50" text="Trois"
styles="{horizontalAlignment:'center', verticalAlignment:'bottom', font:{italic:true}}"/>
</Expander>

<Expander title="Four">
<Label preferredWidth="100" preferredHeight="50" text="Quatre"
styles="{horizontalAlignment:'center', verticalAlignment:'bottom', font:{italic:true}}"/>
</Expander>
</BoxPane>
</BoxPane>
</Border>
Expand All @@ -172,7 +177,9 @@ limitations under the License.
styles="{horizontalAlignment:'center', verticalAlignment:'top', font:{italic:true}}"/>
<Label Accordion.headerData="Two" text="Deux"
styles="{horizontalAlignment:'center', verticalAlignment:'center', font:{italic:true}}"/>
<Label Accordion.headerData="Three" text="Trois"
<Label Accordion.headerData="Three" text="Trois" enabled="false"
styles="{horizontalAlignment:'center', verticalAlignment:'bottom', font:{italic:true}}"/>
<Label Accordion.headerData="Four" text="Quatre"
styles="{horizontalAlignment:'center', verticalAlignment:'bottom', font:{italic:true}}"/>
</Accordion>
</BoxPane>
Expand Down
Expand Up @@ -149,8 +149,14 @@ public int getHeight() {
protected class CollapseImage extends ButtonImage {
@Override
public void paint(Graphics2D graphics) {
Expander expander = (Expander)TerraExpanderSkin.this.getComponent();

graphics.setStroke(new BasicStroke(0));
graphics.setPaint(shadeButtonColor);
if (expander.isEnabled()) {
graphics.setPaint(shadeButtonColor);
} else {
graphics.setPaint(disabledShadeButtonColor);
}
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);

Expand All @@ -164,8 +170,14 @@ public void paint(Graphics2D graphics) {
protected class ExpandImage extends ButtonImage {
@Override
public void paint(Graphics2D graphics) {
Expander expander = (Expander)TerraExpanderSkin.this.getComponent();

graphics.setStroke(new BasicStroke(0));
graphics.setPaint(shadeButtonColor);
if (expander.isEnabled()) {
graphics.setPaint(shadeButtonColor);
} else {
graphics.setPaint(disabledShadeButtonColor);
}
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);

Expand All @@ -189,6 +201,7 @@ public void paint(Graphics2D graphics) {
private Color titleBarBackgroundColor;
private Color titleBarBorderColor;
private Color shadeButtonColor;
private Color disabledShadeButtonColor;
private Color borderColor;
private Insets padding;

Expand Down Expand Up @@ -227,7 +240,8 @@ public TerraExpanderSkin() {

titleBarBackgroundColor = theme.getColor(10);
titleBarBorderColor = theme.getColor(7);
shadeButtonColor = theme.getColor(7);
shadeButtonColor = theme.getColor(12);
disabledShadeButtonColor = theme.getColor(7);
borderColor = theme.getColor(7);
padding = new Insets(4);

Expand Down Expand Up @@ -255,7 +269,7 @@ public TerraExpanderSkin() {
titleRow.add(titleBoxPane);
titleRow.add(buttonBoxPane);

titleLabel.getStyles().put("color", theme.getColor(12));
titleLabel.getStyles().put("color", shadeButtonColor);

Font titleFont = theme.getFont().deriveFont(Font.BOLD);
titleLabel.getStyles().put("font", titleFont);
Expand Down Expand Up @@ -453,6 +467,13 @@ public void paint(Graphics2D graphics) {

graphics.setPaint(borderColor);
GraphicsUtilities.drawRect(graphics, 0, 0, width, height);

Expander expander = (Expander)TerraExpanderSkin.this.getComponent();
if (expander.isEnabled()) {
setTitleBarColor(shadeButtonColor);
} else {
setTitleBarColor(disabledShadeButtonColor);
}
}

public Font getTitleBarFont() {
Expand Down Expand Up @@ -547,6 +568,10 @@ public final void setShadeButtonColor(String shadeButtonColor) {
setShadeButtonColor(GraphicsUtilities.decodeColor(shadeButtonColor));
}

public Color getDisabledShadeButtonColor() {
return disabledShadeButtonColor;
}

public Color getBorderColor() {
return borderColor;
}
Expand Down

0 comments on commit 95ac73e

Please sign in to comment.