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

Fix element color selection #53

Merged
merged 3 commits into from
Apr 18, 2020
Merged
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
75 changes: 39 additions & 36 deletions Sources/arm2d/ui/UIProperties.hx
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ class UIProperties {
ui.unindent();
}
if (ui.panel(Id.handle({selected: false}), "Color")){
ui.indent();

function drawColorSelection(idMult: Int, color:Null<Int>, defaultColor:Int) {
ui.row([1/2, 1/2]);

Expand All @@ -213,43 +215,44 @@ class UIProperties {
return color;
}

ui.indent();
if (elem.type == ElementType.Text) {
ui.text("Text:");
elem.color_text = drawColorSelection(1, elem.color_text, Canvas.getTheme(canvas.theme).TEXT_COL);

} else if (elem.type == ElementType.Button) {
ui.text("Text:");
elem.color_text = drawColorSelection(1, elem.color_text, Canvas.getTheme(canvas.theme).BUTTON_TEXT_COL);
ui.text("Background:");
elem.color = drawColorSelection(2, elem.color, Canvas.getTheme(canvas.theme).BUTTON_COL);
ui.text("On Hover:");
elem.color_hover = drawColorSelection(3, elem.color_hover, Canvas.getTheme(canvas.theme).BUTTON_HOVER_COL);
ui.text("On Pressed:");
elem.color_press = drawColorSelection(4, elem.color_press, Canvas.getTheme(canvas.theme).BUTTON_PRESSED_COL);

} else if (elem.type == ElementType.FRectangle || elem.type == ElementType.FCircle ||
elem.type == ElementType.Rectangle || elem.type == ElementType.Circle ||
elem.type == ElementType.Triangle || elem.type == ElementType.FTriangle) {
ui.text("Color:");
elem.color = drawColorSelection(1, elem.color, Canvas.getTheme(canvas.theme).BUTTON_COL);

} else if (elem.type == ElementType.ProgressBar || elem.type == ElementType.CProgressBar) {
ui.text("Progress:");
elem.color_progress = drawColorSelection(1, elem.color_progress, Canvas.getTheme(canvas.theme).TEXT_COL);
ui.text("Background:");
elem.color = drawColorSelection(2, elem.color, Canvas.getTheme(canvas.theme).BUTTON_COL);

} else if (elem.type == ElementType.Empty) {
ui.text("No color for element type empty");
var canvasTheme = Canvas.getTheme(canvas.theme);

switch(elem.type) {
case Text:
ui.text("Text:");
elem.color_text = drawColorSelection(1, elem.color_text, canvasTheme.TEXT_COL);

case Button:
ui.text("Text:");
elem.color_text = drawColorSelection(1, elem.color_text, canvasTheme.BUTTON_TEXT_COL);
ui.text("Background:");
elem.color = drawColorSelection(2, elem.color, canvasTheme.BUTTON_COL);
ui.text("On Hover:");
elem.color_hover = drawColorSelection(3, elem.color_hover, canvasTheme.BUTTON_HOVER_COL);
ui.text("On Pressed:");
elem.color_press = drawColorSelection(4, elem.color_press, canvasTheme.BUTTON_PRESSED_COL);

case Rectangle, FRectangle, Circle, FCircle, Triangle, FTriangle:
ui.text("Color:");
elem.color = drawColorSelection(1, elem.color, canvasTheme.BUTTON_COL);

case ProgressBar, CProgressBar:
ui.text("Progress:");
elem.color_progress = drawColorSelection(1, elem.color_progress, canvasTheme.TEXT_COL);
ui.text("Background:");
elem.color = drawColorSelection(2, elem.color, canvasTheme.BUTTON_COL);

case Check, TextInput, KeyInput, Combo, Slider:
ui.text("Text:");
elem.color_text = drawColorSelection(1, elem.color_text, canvasTheme.TEXT_COL);
ui.text("Background:");
elem.color = drawColorSelection(2, elem.color, canvasTheme.BUTTON_COL);
ui.text("On Hover:");
elem.color_hover = drawColorSelection(3, elem.color_hover, canvasTheme.BUTTON_HOVER_COL);

default:
ui.text("This element type has no color settings!");

} else {
ui.text("Text:");
elem.color_text = drawColorSelection(1, elem.color, Canvas.getTheme(canvas.theme).TEXT_COL);
ui.text("Background:");
elem.color = drawColorSelection(2, elem.color, Canvas.getTheme(canvas.theme).BUTTON_COL);
ui.text("On Hover:");
elem.color_hover = drawColorSelection(3, elem.color, Canvas.getTheme(canvas.theme).BUTTON_HOVER_COL);
}
ui.unindent();
}
Expand Down