Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a color picker instead of a textbox for color selection #121

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/com/lushprojects/circuitjs1/client/EditDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ public void onClick(ClickEvent event) {
if (ei.text == null) {
ei.textf.setText(unitString(ei));
}
if (ei.isColor){
ei.textf.getElement().setAttribute("type", "color");
ei.textf.getElement().setAttribute("style", "width:178px;padding:0");
}
}
if (vp.getWidgetCount() > 15) {
// start a new column
Expand Down
1 change: 1 addition & 0 deletions src/com/lushprojects/circuitjs1/client/EditInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ int changeFlagInverted(int flags, int bit) {
boolean dimensionless;
boolean noSliders;
double minVal, maxVal;
boolean isColor = false;

// for slider dialog
TextBox minBox, maxBox, labelBox;
Expand Down
40 changes: 30 additions & 10 deletions src/com/lushprojects/circuitjs1/client/EditOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,36 @@ public EditInfo getEditInfo(int n) {
return ei;
}

if (n == 3)
return new EditInfo("Positive Color", CircuitElm.positiveColor.getHexValue());
if (n == 4)
return new EditInfo("Negative Color", CircuitElm.negativeColor.getHexValue());
if (n == 5)
return new EditInfo("Neutral Color", CircuitElm.neutralColor.getHexValue());
if (n == 6)
return new EditInfo("Selection Color", CircuitElm.selectColor.getHexValue());
if (n == 7)
return new EditInfo("Current Color", CircuitElm.currentColor.getHexValue());
if (n == 3){
EditInfo ei = new EditInfo("Positive Color", CircuitElm.positiveColor.getHexValue());
ei.isColor = true;
return ei;
}

if (n == 4){
EditInfo ei = new EditInfo("Negative Color", CircuitElm.negativeColor.getHexValue());
ei.isColor = true;
return ei;
}

if (n == 5){
EditInfo ei = new EditInfo("Neutral Color", CircuitElm.neutralColor.getHexValue());
ei.isColor = true;
return ei;
}

if (n == 6){
EditInfo ei = new EditInfo("Selection Color", CircuitElm.selectColor.getHexValue());
ei.isColor = true;
return ei;
}

if (n == 7){
EditInfo ei = new EditInfo("Current Color", CircuitElm.currentColor.getHexValue());
ei.isColor = true;
return ei;
}

if (n == 8)
return new EditInfo("# of Decimal Digits (short format)", CircuitElm.shortDecimalDigits);
if (n == 9)
Expand Down