Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 282903
Collapse All | Expand All

(-)src/org/eclipse/rwt/internal/theme/css/StyleSheet_Test.java (-14 lines)
Lines 14-20 Link Here
14
import junit.framework.TestCase;
14
import junit.framework.TestCase;
15
15
16
import org.eclipse.rwt.internal.theme.*;
16
import org.eclipse.rwt.internal.theme.*;
17
import org.eclipse.swt.graphics.Rectangle;
18
17
19
18
20
public class StyleSheet_Test extends TestCase {
19
public class StyleSheet_Test extends TestCase {
Lines 68-86 Link Here
68
    assertEquals( QxColor.create( 192, 192, 192 ), values[ 5 ].value );
67
    assertEquals( QxColor.create( 192, 192, 192 ), values[ 5 ].value );
69
  }
68
  }
70
69
71
  public void testMergeBorderRadius() throws Exception {
72
    StyleSheet styleSheet = ThemeTestUtil.getStyleSheet( TEST_EXAMPLE_CSS );
73
    ConditionalValue[] values = styleSheet.getValues( "Composite", "border" );
74
//    assertEquals( 1, values.length );
75
    assertEquals( "[BORDER", join( values[ 0 ].constraints ) );
76
    QxBorder expected = QxBorder.create( 2, "solid", "#1695d4" );
77
    expected.radius = new Rectangle( 5, 10, 5, 10 );
78
    assertEquals( expected, values[ 0 ].value );
79
    values = styleSheet.getValues( "Composite", "border-radius" );
80
    assertEquals( "[BORDER", join( values[ 0 ].constraints ) );
81
    assertEquals( QxBoxDimensions.create( 5, 10, 5, 10 ), values[ 0 ].value );
82
  }
83
84
  private static String join( final String[] array ) {
70
  private static String join( final String[] array ) {
85
    StringBuffer result = new StringBuffer();
71
    StringBuffer result = new StringBuffer();
86
    for( int i = 0; i < array.length; i++ ) {
72
    for( int i = 0; i < array.length; i++ ) {
(-)js/org/eclipse/swt/theme/ThemeValues.js (+10 lines)
Lines 39-44 Link Here
39
      var values = this._store.getThemeValues();
39
      var values = this._store.getThemeValues();
40
      var result = values.borders[ vkey ];
40
      var result = values.borders[ vkey ];
41
      this.__checkDefined( result, element, key );
41
      this.__checkDefined( result, element, key );
42
      // construct rounded border if "border-radius" is set
43
      var rkey = this._store.getCssValue( element, this._states, "border-radius" );
44
      var radius = values.boxdims[ rkey ];
45
      if( radius != null && result instanceof qx.ui.core.Border ) {
46
        var width = result.getWidthTop();
47
        var color = result.getColorTop();
48
        result = new org.eclipse.rwt.RoundedBorder( width );
49
        result.setRadii( radius );
50
        result.setColor( color );
51
      }
42
      return result;
52
      return result;
43
    },
53
    },
44
54
(-)js/org/eclipse/swt/theme/ThemeStore.js (-6 / +1 lines)
Lines 143-154 Link Here
143
            }
143
            }
144
          }
144
          }
145
          if( border == null ) {
145
          if( border == null ) {
146
            if( value.radius ) {
146
            border = new qx.ui.core.Border( value.width, value.style );
147
              border = new org.eclipse.rwt.RoundedBorder( value.width );
148
              border.setRadii( value.radius );
149
            } else {
150
              border = new qx.ui.core.Border( value.width, value.style );
151
            }
152
            if( value.color ) {
147
            if( value.color ) {
153
              border.setColor( value.color );
148
              border.setColor( value.color );
154
            }
149
            }
(-)src/org/eclipse/rwt/internal/theme/QxBorder.java (-12 / +2 lines)
Lines 11-18 Link Here
11
 ******************************************************************************/
11
 ******************************************************************************/
12
package org.eclipse.rwt.internal.theme;
12
package org.eclipse.rwt.internal.theme;
13
13
14
import org.eclipse.swt.graphics.Rectangle;
15
16
14
17
public class QxBorder implements QxType {
15
public class QxBorder implements QxType {
18
16
Lines 41-48 Link Here
41
  //            color theme. Check for valid colors.
39
  //            color theme. Check for valid colors.
42
  public final String color;
40
  public final String color;
43
41
44
  public Rectangle radius;
45
46
  private QxBorder( final int width, final String style, final String color ) {
42
  private QxBorder( final int width, final String style, final String color ) {
47
    this.width = width;
43
    this.width = width;
48
    this.style = style;
44
    this.style = style;
Lines 145-154 Link Here
145
                    : style.equals( other.style ) )
141
                    : style.equals( other.style ) )
146
               && ( color == null
142
               && ( color == null
147
                    ? other.color == null
143
                    ? other.color == null
148
                    : color.equals( other.color ) )
144
                    : color.equals( other.color ) );
149
               && ( radius == null
150
                    ? other.radius == null
151
                    : radius.equals( other.radius ) );
152
    }
145
    }
153
    return result;
146
    return result;
154
  }
147
  }
Lines 164-179 Link Here
164
    if( color != null ) {
157
    if( color != null ) {
165
      result += 37 * result + color.hashCode();
158
      result += 37 * result + color.hashCode();
166
    }
159
    }
167
    if( radius != null ) {
168
      result += 37 * result + radius.hashCode();
169
    }
170
    return result;
160
    return result;
171
  }
161
  }
172
162
173
  public String toString() {
163
  public String toString() {
174
    // TODO [rst] Adapt this method as soon as properties for left, right, etc.
164
    // TODO [rst] Adapt this method as soon as properties for left, right, etc.
175
    //            exist
165
    //            exist
176
    return "QxBorder{ " + width + ", " + style + ", " + color + ", " + radius + " }";
166
    return "QxBorder{ " + width + ", " + style + ", " + color + " }";
177
  }
167
  }
178
168
179
  private static String parseStyle( final String part ) {
169
  private static String parseStyle( final String part ) {
(-)src/org/eclipse/rwt/internal/theme/ThemeStoreWriter.java (-8 lines)
Lines 105-118 Link Here
105
        borderObject.append( "width", border.width );
105
        borderObject.append( "width", border.width );
106
        borderObject.append( "style", border.style );
106
        borderObject.append( "style", border.style );
107
        borderObject.append( "color", border.color );
107
        borderObject.append( "color", border.color );
108
        if( border.radius != null ) {
109
          JsonArray boxArray = new JsonArray();
110
          boxArray.append( border.radius.x );
111
          boxArray.append( border.radius.y );
112
          boxArray.append( border.radius.width );
113
          boxArray.append( border.radius.height );
114
          borderObject.append( "radius", boxArray );
115
        }
116
        borderMap.append( key, borderObject );
108
        borderMap.append( key, borderObject );
117
      }
109
      }
118
    }
110
    }
(-)src/org/eclipse/rwt/internal/theme/css/StyleSheet.java (-20 lines)
Lines 14-20 Link Here
14
import java.util.*;
14
import java.util.*;
15
15
16
import org.eclipse.rwt.internal.theme.*;
16
import org.eclipse.rwt.internal.theme.*;
17
import org.eclipse.swt.graphics.Rectangle;
18
import org.w3c.css.sac.Selector;
17
import org.w3c.css.sac.Selector;
19
import org.w3c.css.sac.SelectorList;
18
import org.w3c.css.sac.SelectorList;
20
19
Lines 33-40 Link Here
33
32
34
  public StyleSheet( final StyleRule[] styleRules ) {
33
  public StyleSheet( final StyleRule[] styleRules ) {
35
    this.styleRules = styleRules;
34
    this.styleRules = styleRules;
36
    // TODO: [if] Find better solution for merging border and border-radius
37
    mergeBorderRadius();
38
    createSelectorWrappers();
35
    createSelectorWrappers();
39
  }
36
  }
40
37
Lines 89-111 Link Here
89
    return buffer.toString();
86
    return buffer.toString();
90
  }
87
  }
91
88
92
  private void mergeBorderRadius() {
93
    for( int i_rule = 0; i_rule < styleRules.length; i_rule++ ) {
94
      StyleRule styleRule = styleRules[ i_rule ];
95
      IStylePropertyMap properties = styleRule.getProperties();
96
      QxBorder border = ( QxBorder )properties.getValue( "border" );
97
      QxBoxDimensions radius
98
        = ( QxBoxDimensions )properties.getValue( "border-radius" );
99
      if( border != null && radius != null ) {
100
        Rectangle borderRadius = new Rectangle( radius.top,
101
                                                radius.right,
102
                                                radius.bottom,
103
                                                radius.left );
104
        border.radius = borderRadius;
105
      }
106
    }
107
  }
108
109
  private void createSelectorWrappers() {
89
  private void createSelectorWrappers() {
110
    ArrayList selectorWrappersList = new ArrayList();
90
    ArrayList selectorWrappersList = new ArrayList();
111
    for( int i_rule = 0; i_rule < styleRules.length; i_rule++ ) {
91
    for( int i_rule = 0; i_rule < styleRules.length; i_rule++ ) {

Return to bug 282903