Skip to content

Commit

Permalink
Bug #550 - Open the NebulaSlider to allow user extension
Browse files Browse the repository at this point in the history
All graphical information (sizes, colors, font) are now handled by a
configuration that can be customized.
  • Loading branch information
lcaron committed Jan 22, 2024
1 parent 879f570 commit 7ab9c60
Show file tree
Hide file tree
Showing 14 changed files with 221 additions and 179 deletions.
2 changes: 1 addition & 1 deletion releng/org.eclipse.nebula.updatesite/category.xml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
<feature url="features/org.eclipse.nebula.widgets.progresscircle.feature_1.0.0.qualifier.jar" id="org.eclipse.nebula.widgets.progresscircle.feature" version="1.0.0.qualifier">
<category name="Nebula Release Individual Widgets"/>
</feature>
<feature url="features/org.eclipse.nebula.widgets.nebulaslider.feature_1.0.0.qualifier.jar" id="org.eclipse.nebula.widgets.nebulaslider.feature" version="1.0.0.qualifier">
<feature url="features/org.eclipse.nebula.widgets.nebulaslider.feature_1.1.0.qualifier.jar" id="org.eclipse.nebula.widgets.nebulaslider.feature" version="1.1.0.qualifier">
<category name="Nebula Release Individual Widgets"/>
</feature>
<feature url="features/org.eclipse.nebula.widgets.floatingtext.feature_1.0.0.qualifier.jar" id="org.eclipse.nebula.widgets.floatingtext.feature" version="1.0.0.qualifier">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<feature
id="org.eclipse.nebula.widgets.nebulaslider.feature"
label="Nebula Slider Widget"
version="1.0.0.qualifier"
version="1.1.0.qualifier"
provider-name="Eclipse Nebula, Laurent CARON">

<description url="http://eclipse.org/nebula">
Expand All @@ -23,7 +23,7 @@
install-size="0"
version="0.0.0"
unpack="false"/>

<plugin
id="org.eclipse.nebula.widgets.nebulaslider.source"
download-size="0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ Contributors:
<parent>
<groupId>org.eclipse.nebula</groupId>
<artifactId>nebulaslider</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.1.0-SNAPSHOT</version>
</parent>

<artifactId>org.eclipse.nebula.widgets.nebulaslider.feature</artifactId>
<packaging>eclipse-feature</packaging>
<version>1.0.0-SNAPSHOT</version>
<version>1.1.0-SNAPSHOT</version>

<name>Nebula Slider Feature</name>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ http://www.eclipse.org/legal/epl-v10.html
<parent>
<groupId>org.eclipse.nebula</groupId>
<artifactId>nebulaslider</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.1.0-SNAPSHOT</version>
</parent>

<artifactId>org.eclipse.nebula.widgets.nebulaslider.snippets</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
/*******************************************************************************
* Copyright (c) 2024 Laurent CARON
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors: Laurent CARON (laurent.caron at gmail dot com) - Initial
* implementation and API
*******************************************************************************/
package org.eclipse.nebula.widgets.opal.nebulaslider.snippets;

import org.eclipse.nebula.widgets.opal.nebulaslider.NebulaSlider;
import org.eclipse.nebula.widgets.opal.nebulaslider.NebularSliderDefaultConfiguration;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;

public class NebulaCustomSliderConfiguration extends NebularSliderDefaultConfiguration {

public NebulaCustomSliderConfiguration(final NebulaSlider parentSlider) {
super(parentSlider);
}

/**
* @see org.eclipse.nebula.widgets.opal.nebulaslider.NebularSliderDefaultConfiguration#getBarInsideColor()
*/
@Override
public Color getBarInsideColor() {
return getAndDisposeColor(231, 225, 219);
}

/**
* @see org.eclipse.nebula.widgets.opal.nebulaslider.NebularSliderDefaultConfiguration#getBarBorderColor()
*/
@Override
public Color getBarBorderColor() {
return getAndDisposeColor(219, 211, 203);
}

/**
* @see org.eclipse.nebula.widgets.opal.nebulaslider.NebularSliderDefaultConfiguration#getBarSelectionColor()
*/
@Override
public Color getBarSelectionColor() {
return getAndDisposeColor(129, 108, 91);
}

/**
* @see org.eclipse.nebula.widgets.opal.nebulaslider.NebularSliderDefaultConfiguration#getSelectorColor()
*/
@Override
public Color getSelectorColor() {
return getAndDisposeColor(148, 130, 113);
}

/**
* @see org.eclipse.nebula.widgets.opal.nebulaslider.NebularSliderDefaultConfiguration#getSelectorColorBorder()
*/
@Override
public Color getSelectorColorBorder() {
return getAndDisposeColor(238, 234, 230);
}

/**
* @see org.eclipse.nebula.widgets.opal.nebulaslider.NebularSliderDefaultConfiguration#getSelectorTextColor()
*/
@Override
public Color getSelectorTextColor() {
return getAndDisposeColor(255, 255, 204);
}

/**
* @see org.eclipse.nebula.widgets.opal.nebulaslider.NebularSliderDefaultConfiguration#getArrowColor()
*/
@Override
public Color getArrowColor() {
return getAndDisposeColor(203, 192, 181);
}

/**
* @see org.eclipse.nebula.widgets.opal.nebulaslider.NebularSliderDefaultConfiguration#getTextFont()
*/
@Override
public Font getTextFont() {
final FontData fontData = parentSlider.getFont().getFontData()[0];
final Font newFont = new Font(parentSlider.getDisplay(), "Arial", Math.max(fontData.getHeight(), 14), SWT.ITALIC);
parentSlider.addDisposeListener(e -> {
if (!newFont.isDisposed()) {
newFont.dispose();
}
});
return newFont;
}

/**
* @see org.eclipse.nebula.widgets.opal.nebulaslider.NebularSliderDefaultConfiguration#getHorizontalMargin()
*/
@Override
public int getHorizontalMargin() {
// TODO Auto-generated method stub
return super.getHorizontalMargin();
}

/**
* @see org.eclipse.nebula.widgets.opal.nebulaslider.NebularSliderDefaultConfiguration#getSelectorWidth()
*/
@Override
public int getSelectorWidth() {
return 100;
}

/**
* @see org.eclipse.nebula.widgets.opal.nebulaslider.NebularSliderDefaultConfiguration#getSelectorHeight()
*/
@Override
public int getSelectorHeight() {
return 40;
}

/**
* @see org.eclipse.nebula.widgets.opal.nebulaslider.NebularSliderDefaultConfiguration#getBarHeight()
*/
@Override
public int getBarHeight() {
return 18;
}

/**
* @see org.eclipse.nebula.widgets.opal.nebulaslider.NebularSliderDefaultConfiguration#getArrowLineWidth()
*/
@Override
public int getArrowLineWidth() {
return 5;
}

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011 Laurent CARON.
* Copyright (c) 2018-2024 Laurent CARON.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011 Laurent CARON.
* Copyright (c) 2024 Laurent CARON.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -49,7 +49,7 @@ public static void main(final String[] args) {
slider.setMinimum(0);
slider.setMaximum(1000);
slider.setValue(632);
slider.setRenderer(new NebulaCustomSliderRenderer(slider));
slider.setRenderer(new NebulaCustomSliderConfiguration(slider));
slider.setBackground(display.getSystemColor(SWT.COLOR_WHITE));

slider.addListener(SWT.Selection, e -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ http://www.eclipse.org/legal/epl-v10.html
<parent>
<groupId>org.eclipse.nebula</groupId>
<artifactId>nebulaslider</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.1.0-SNAPSHOT</version>
</parent>

<artifactId>org.eclipse.nebula.widgets.nebulaslider</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018 Laurent CARON
* Copyright (c) 2018-2024 Laurent CARON
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -37,7 +37,7 @@
*/
public class NebulaSlider extends Canvas {

private NebulaSliderRenderer renderer;
private NebulaSliderGraphicConfiguration renderer;

private int minimum;
private int maximum;
Expand Down Expand Up @@ -80,7 +80,7 @@ public class NebulaSlider extends Canvas {
public NebulaSlider(final Composite parent, final int style) {
super(parent, checkStyle(style) | SWT.DOUBLE_BUFFERED);

renderer = new NebularDefaultSliderRenderer(this);
renderer = new NebularSliderDefaultConfiguration(this);

minimum = Integer.MIN_VALUE;
maximum = Integer.MAX_VALUE;
Expand Down Expand Up @@ -428,7 +428,7 @@ public void setValue(final int value) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public NebulaSliderRenderer getRenderer() {
public NebulaSliderGraphicConfiguration getRenderer() {
checkWidget();
return renderer;
}
Expand All @@ -444,7 +444,7 @@ public NebulaSliderRenderer getRenderer() {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public void setRenderer(final NebulaSliderRenderer renderer) {
public void setRenderer(final NebulaSliderGraphicConfiguration renderer) {
checkWidget();
this.renderer = renderer;
redraw();
Expand Down
Loading

0 comments on commit 7ab9c60

Please sign in to comment.