@@ -70,10 +70,10 @@ public static void main(String[] args) {
70
70
71
71
// define PixelTransformers
72
72
GTKDisablingTransformer gtkTransformer = new GTKDisablingTransformer ();
73
- ThresholdBasedDisablingTransformer win32MacTransformer = new ThresholdBasedDisablingTransformer (GRAY_LOW , GRAY_HIGH , GRAY_HIGH , WIN32_COCOA_THRESHOLD , WIN32_COCOA_THRESHOLD );
73
+ ThresholdBasedDisablingTransformer win32MacTransformer = new ThresholdBasedDisablingTransformer (GRAY_LOW , GRAY_HIGH , GRAY_HIGH , WIN32_COCOA_THRESHOLD , WIN32_COCOA_THRESHOLD , 1.f );
74
74
EclipseRenderMojoDisablingTransformer eclipseMojoTransformer = new EclipseRenderMojoDisablingTransformer (ECLIPSE_RENDER_MOJOE_BRIGHTNESS_DEFAULT / 100f , ECLIPSE_RENDER_MOJO_ALPHA_DEFAULT / 100.f );
75
75
HSBConversionDisablingTransformer hsbTransformer = new HSBConversionDisablingTransformer (HSB_DISABLING_BRIGHTNESS_DEFAULT / 100.f , HSB_DISABLING_ALPHA_DEFAULT / 100.f , HSB_DISABLING_SATURATION_DEFAULT / 100.f );
76
- ThresholdBasedDisablingTransformer adjThreshAdditGray = new ThresholdBasedDisablingTransformer (GRAY_LOW , ADDITIONAL_GRAY_MID_DEFAULT , GRAY_HIGH , ADJUSTABLE_THRESHOLD_LOW_DEFAULT , ADJUSTABLE_THRESHOLD_HIGH_DEFAULT );
76
+ ThresholdBasedDisablingTransformer adjThreshAdditGray = new ThresholdBasedDisablingTransformer (GRAY_LOW , ADDITIONAL_GRAY_MID_DEFAULT , GRAY_HIGH , ADJUSTABLE_THRESHOLD_LOW_DEFAULT , ADJUSTABLE_THRESHOLD_HIGH_DEFAULT , 1.f );
77
77
78
78
// create transformed icon rows
79
79
Composite imagesComposite = new Composite (shell , SWT .NONE );
@@ -101,11 +101,12 @@ public static void main(String[] args) {
101
101
Scale eclipsePreDisablingAlpha = addScale (eclipseMojoSliderComposite , "Eclipse Mojo Alpha %:" , 0 , 100 , ECLIPSE_RENDER_MOJO_ALPHA_DEFAULT );
102
102
103
103
Composite adjThreshAddGraySliderComposite = new Composite (shell , SWT .NONE );
104
- adjThreshAddGraySliderComposite .setLayout (new GridLayout (9 , false ));
104
+ adjThreshAddGraySliderComposite .setLayout (new GridLayout (12 , false ));
105
105
adjThreshAddGraySliderComposite .setBackgroundMode (SWT .INHERIT_DEFAULT );
106
106
Scale lowScale = addScale (adjThreshAddGraySliderComposite , "Low Threshold:" , 0 , MAX_BRIGHTNESS , WIN32_COCOA_THRESHOLD );
107
107
Scale highScale = addScale (adjThreshAddGraySliderComposite , "High Threshold:" , 0 , MAX_BRIGHTNESS , ADJUSTABLE_THRESHOLD_HIGH_DEFAULT );
108
108
Scale thirdGray = addScale (adjThreshAddGraySliderComposite , "3rd Gray:" , GRAY_LOW .red , GRAY_HIGH .red , ADDITIONAL_GRAY_MID_DEFAULT .red );
109
+ Scale adjThreshAlphaChange = addScale (adjThreshAddGraySliderComposite , "Alpha %:" , 0 , 100 , 100 );
109
110
110
111
// update images on slider change
111
112
addImageUpdateScaleListener (hsbDisablingBrightness , hsbTransformer , value -> hsbTransformer .setBrightnessChange (value / 100.f ), imageRowStorage , originalImages );
@@ -118,6 +119,7 @@ public static void main(String[] args) {
118
119
addImageUpdateScaleListener (lowScale , adjThreshAdditGray , adjThreshAdditGray ::setThresholdLow , imageRowStorage , originalImages );
119
120
addImageUpdateScaleListener (highScale , adjThreshAdditGray , adjThreshAdditGray ::setThresholdHigh , imageRowStorage , originalImages );
120
121
addImageUpdateScaleListener (thirdGray , adjThreshAdditGray , value -> adjThreshAdditGray .setGrayMid (new RGB (value , value , value )), imageRowStorage , originalImages );
122
+ addImageUpdateScaleListener (adjThreshAlphaChange , adjThreshAdditGray , value -> adjThreshAdditGray .setAlphaChange (value / 100.f ), imageRowStorage , originalImages );
121
123
122
124
// combo box for theme selection
123
125
Combo themeCombo = new Combo (shell , SWT .DROP_DOWN | SWT .READ_ONLY );
@@ -248,14 +250,16 @@ public static class ThresholdBasedDisablingTransformer implements PixelTransform
248
250
private RGB grayHigh ;
249
251
private int thresholdLow ;
250
252
private int thresholdHigh ;
253
+ private float alphaChange ;
251
254
252
255
public ThresholdBasedDisablingTransformer (RGB grayLow , RGB grayMid , RGB grayHigh , int thresholdLow ,
253
- int thresholdHigh ) {
256
+ int thresholdHigh , float alphaChange ) {
254
257
this .grayLow = grayLow ;
255
258
this .grayMid = grayMid ;
256
259
this .grayHigh = grayHigh ;
257
260
this .thresholdLow = thresholdLow ;
258
261
this .thresholdHigh = thresholdHigh ;
262
+ this .alphaChange = alphaChange ;
259
263
}
260
264
261
265
public void setThresholdLow (int thresholdLow ) {
@@ -270,6 +274,10 @@ public void setGrayMid(RGB grayMid) {
270
274
this .grayMid = grayMid ;
271
275
}
272
276
277
+ public void setAlphaChange (float alphaChange ) {
278
+ this .alphaChange = alphaChange ;
279
+ }
280
+
273
281
@ Override
274
282
public RGBA transform (RGBA originalRgba ) {
275
283
int red = originalRgba .rgb .red ;
@@ -280,11 +288,11 @@ public RGBA transform(RGBA originalRgba) {
280
288
RGBA disabled ;
281
289
int squareDist = red * red + green * green + blue * blue ;
282
290
if (squareDist < thresholdLow ) {
283
- disabled = new RGBA (grayLow .red , grayLow .green , grayLow .blue , alpha );
291
+ disabled = new RGBA (grayLow .red , grayLow .green , grayLow .blue , ( int ) ( alphaChange * alpha ) );
284
292
} else if (squareDist < thresholdHigh ) {
285
- disabled = new RGBA (grayMid .red , grayMid .green , grayMid .blue , alpha );
293
+ disabled = new RGBA (grayMid .red , grayMid .green , grayMid .blue , ( int ) ( alphaChange * alpha ) );
286
294
} else {
287
- disabled = new RGBA (grayHigh .red , grayHigh .green , grayHigh .blue , alpha );
295
+ disabled = new RGBA (grayHigh .red , grayHigh .green , grayHigh .blue , ( int ) ( alphaChange * alpha ) );
288
296
}
289
297
return disabled ;
290
298
}
0 commit comments