mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
Editable toggle switch color
This commit is contained in:
Binary file not shown.
+30
-5
@@ -51,6 +51,9 @@ public class MiniToggleSwitch extends AbstractTransparentComponent<ToggleSwitchT
|
|||||||
private OrientationHV orientation = OrientationHV.VERTICAL;
|
private OrientationHV orientation = OrientationHV.VERTICAL;
|
||||||
private Size spacing = SPACING;
|
private Size spacing = SPACING;
|
||||||
|
|
||||||
|
private Color bodyColor = BODY_COLOR;
|
||||||
|
private Color borderColor = BORDER_COLOR;
|
||||||
|
|
||||||
public MiniToggleSwitch() {
|
public MiniToggleSwitch() {
|
||||||
super();
|
super();
|
||||||
updateControlPoints();
|
updateControlPoints();
|
||||||
@@ -189,15 +192,15 @@ public class MiniToggleSwitch extends AbstractTransparentComponent<ToggleSwitchT
|
|||||||
// Reset body shape.
|
// Reset body shape.
|
||||||
body = null;
|
body = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EditableProperty
|
@EditableProperty
|
||||||
public Size getSpacing() {
|
public Size getSpacing() {
|
||||||
if (spacing == null) {
|
if (spacing == null) {
|
||||||
spacing = SPACING;
|
spacing = SPACING;
|
||||||
}
|
}
|
||||||
return spacing;
|
return spacing;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSpacing(Size spacing) {
|
public void setSpacing(Size spacing) {
|
||||||
this.spacing = spacing;
|
this.spacing = spacing;
|
||||||
updateControlPoints();
|
updateControlPoints();
|
||||||
@@ -217,7 +220,7 @@ public class MiniToggleSwitch extends AbstractTransparentComponent<ToggleSwitchT
|
|||||||
if (alpha < MAX_ALPHA) {
|
if (alpha < MAX_ALPHA) {
|
||||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
|
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
|
||||||
}
|
}
|
||||||
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : BODY_COLOR);
|
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : getBodyColor());
|
||||||
g2d.fill(body);
|
g2d.fill(body);
|
||||||
g2d.setComposite(oldComposite);
|
g2d.setComposite(oldComposite);
|
||||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
||||||
@@ -229,7 +232,7 @@ public class MiniToggleSwitch extends AbstractTransparentComponent<ToggleSwitchT
|
|||||||
} else {
|
} else {
|
||||||
finalBorderColor =
|
finalBorderColor =
|
||||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||||
: BORDER_COLOR;
|
: getBorderColor();
|
||||||
}
|
}
|
||||||
g2d.setColor(finalBorderColor);
|
g2d.setColor(finalBorderColor);
|
||||||
g2d.draw(body);
|
g2d.draw(body);
|
||||||
@@ -315,4 +318,26 @@ public class MiniToggleSwitch extends AbstractTransparentComponent<ToggleSwitchT
|
|||||||
- 1);
|
- 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EditableProperty(name = "Body")
|
||||||
|
public Color getBodyColor() {
|
||||||
|
if (bodyColor == null)
|
||||||
|
bodyColor = BODY_COLOR;
|
||||||
|
return bodyColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBodyColor(Color bodyColor) {
|
||||||
|
this.bodyColor = bodyColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EditableProperty(name = "Border")
|
||||||
|
public Color getBorderColor() {
|
||||||
|
if (borderColor == null)
|
||||||
|
borderColor = BORDER_COLOR;
|
||||||
|
return borderColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBorderColor(Color borderColor) {
|
||||||
|
this.borderColor = borderColor;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -1781,6 +1781,10 @@
|
|||||||
<org.diylc.appframework.update.Change>
|
<org.diylc.appframework.update.Change>
|
||||||
<changeType>IMPROVEMENT</changeType>
|
<changeType>IMPROVEMENT</changeType>
|
||||||
<description>DIL IC label rotates to fit the longer side of the component. Name and value are displayed in separate lines</description>
|
<description>DIL IC label rotates to fit the longer side of the component. Name and value are displayed in separate lines</description>
|
||||||
|
</org.diylc.appframework.update.Change>
|
||||||
|
<org.diylc.appframework.update.Change>
|
||||||
|
<changeType>IMPROVEMENT</changeType>
|
||||||
|
<description>Editable toggle switch color</description>
|
||||||
</org.diylc.appframework.update.Change>
|
</org.diylc.appframework.update.Change>
|
||||||
</changes>
|
</changes>
|
||||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||||
|
|||||||
Reference in New Issue
Block a user