From 13f0935f449994f19c2d87767043ee00cfdc6617 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Costa?= Date: Sat, 18 Nov 2023 15:13:51 +0100 Subject: [PATCH] Add primary shadow and adjust color scheme --- .../joaocosta/interim/skins/ButtonSkin.scala | 24 ++++++++----------- .../joaocosta/interim/skins/ColorScheme.scala | 6 +++-- .../joaocosta/interim/skins/HandleSkin.scala | 6 ++--- .../joaocosta/interim/skins/SliderSkin.scala | 4 ++-- .../interim/skins/TextInputSkin.scala | 21 ++++++++++------ 5 files changed, 33 insertions(+), 28 deletions(-) diff --git a/core/src/main/scala/eu/joaocosta/interim/skins/ButtonSkin.scala b/core/src/main/scala/eu/joaocosta/interim/skins/ButtonSkin.scala index 9c93222..9366427 100644 --- a/core/src/main/scala/eu/joaocosta/interim/skins/ButtonSkin.scala +++ b/core/src/main/scala/eu/joaocosta/interim/skins/ButtonSkin.scala @@ -13,8 +13,7 @@ trait ButtonSkin: object ButtonSkin extends DefaultSkin: final case class Default( - shadowDelta: Int, - clickDelta: Int, + buttonHeight: Int, font: Font, shadowColor: Color, textColor: Color, @@ -24,23 +23,22 @@ object ButtonSkin extends DefaultSkin: ) extends ButtonSkin: def buttonArea(area: Rect): Rect = - area.copy(w = area.w - math.max(shadowDelta, clickDelta), h = area.h - math.max(shadowDelta, clickDelta)) + area.copy(w = area.w, h = area.h - buttonHeight) def renderButton(area: Rect, label: String, itemStatus: UiContext.ItemStatus)(using uiContext: UiContext ): Unit = val buttonArea = this.buttonArea(area) - val clickedArea = buttonArea.move(dx = clickDelta, dy = clickDelta) - rectangle( - buttonArea.move(dx = shadowDelta, dy = shadowDelta), - shadowColor - ) + val clickedArea = buttonArea.move(dx = 0, dy = buttonHeight) itemStatus match case UiContext.ItemStatus(false, false, _, _) => + rectangle(area.copy(y = buttonArea.y2, h = buttonHeight), shadowColor) rectangle(buttonArea, inactiveColor) case UiContext.ItemStatus(true, false, _, _) => + rectangle(area.copy(y = buttonArea.y2, h = buttonHeight), inactiveColor) rectangle(buttonArea, hotColor) case UiContext.ItemStatus(false, true, _, _) => + rectangle(area.copy(y = buttonArea.y2, h = buttonHeight), inactiveColor) rectangle(buttonArea, activeColor) case UiContext.ItemStatus(true, true, _, _) => rectangle(clickedArea, activeColor) @@ -51,10 +49,9 @@ object ButtonSkin extends DefaultSkin: text(buttonArea, textColor, label, font, HorizontalAlignment.Center, VerticalAlignment.Center) val lightDefault: Default = Default( - shadowDelta = 2, - clickDelta = 1, + buttonHeight = 3, font = Font.default, - shadowColor = ColorScheme.darkGray, + shadowColor = ColorScheme.lightPrimaryShadow, textColor = ColorScheme.black, inactiveColor = ColorScheme.lightPrimary, hotColor = ColorScheme.lightPrimaryHighlight, @@ -62,10 +59,9 @@ object ButtonSkin extends DefaultSkin: ) val darkDefault: Default = Default( - shadowDelta = 0, - clickDelta = 2, + buttonHeight = 3, font = Font.default, - shadowColor = ColorScheme.black, + shadowColor = ColorScheme.darkPrimaryShadow, textColor = ColorScheme.white, inactiveColor = ColorScheme.darkPrimary, hotColor = ColorScheme.darkPrimaryHighlight, diff --git a/core/src/main/scala/eu/joaocosta/interim/skins/ColorScheme.scala b/core/src/main/scala/eu/joaocosta/interim/skins/ColorScheme.scala index 29b1e9b..2b8a8a3 100644 --- a/core/src/main/scala/eu/joaocosta/interim/skins/ColorScheme.scala +++ b/core/src/main/scala/eu/joaocosta/interim/skins/ColorScheme.scala @@ -11,10 +11,12 @@ object ColorScheme: val black = Color(23, 21, 23) val lightPrimary = Color(9, 211, 222) - val lightPrimaryHighlight = Color(55, 221, 230) + val lightPrimaryShadow = Color(15, 172, 186) + val lightPrimaryHighlight = Color(0, 247, 255) val darkPrimary = Color(97, 31, 125) - val darkPrimaryHighlight = Color(121, 53, 150) + val darkPrimaryShadow = Color(67, 24, 92) + val darkPrimaryHighlight = Color(130, 38, 158) private var darkMode = false diff --git a/core/src/main/scala/eu/joaocosta/interim/skins/HandleSkin.scala b/core/src/main/scala/eu/joaocosta/interim/skins/HandleSkin.scala index 2d08e4d..c47de85 100644 --- a/core/src/main/scala/eu/joaocosta/interim/skins/HandleSkin.scala +++ b/core/src/main/scala/eu/joaocosta/interim/skins/HandleSkin.scala @@ -62,12 +62,12 @@ object HandleSkin extends DefaultSkin: val lightDefault: Default = Default( inactiveColor = ColorScheme.black, - hotColor = ColorScheme.lightPrimary, + hotColor = ColorScheme.pureGray, activeColor = ColorScheme.lightPrimaryHighlight ) val darkDefault: Default = Default( - inactiveColor = ColorScheme.white, - hotColor = ColorScheme.darkPrimary, + inactiveColor = ColorScheme.lightGray, + hotColor = ColorScheme.white, activeColor = ColorScheme.darkPrimaryHighlight ) diff --git a/core/src/main/scala/eu/joaocosta/interim/skins/SliderSkin.scala b/core/src/main/scala/eu/joaocosta/interim/skins/SliderSkin.scala index 54b4948..03d4a54 100644 --- a/core/src/main/scala/eu/joaocosta/interim/skins/SliderSkin.scala +++ b/core/src/main/scala/eu/joaocosta/interim/skins/SliderSkin.scala @@ -58,7 +58,7 @@ object SliderSkin extends DefaultSkin: padding = 1, minSliderSize = 8, scrollbarColor = ColorScheme.lightGray, - inactiveColor = ColorScheme.darkGray, + inactiveColor = ColorScheme.lightPrimaryShadow, hotColor = ColorScheme.lightPrimary, activeColor = ColorScheme.lightPrimaryHighlight ) @@ -67,7 +67,7 @@ object SliderSkin extends DefaultSkin: padding = 1, minSliderSize = 8, scrollbarColor = ColorScheme.darkGray, - inactiveColor = ColorScheme.lightGray, + inactiveColor = ColorScheme.darkPrimaryShadow, hotColor = ColorScheme.darkPrimary, activeColor = ColorScheme.darkPrimaryHighlight ) diff --git a/core/src/main/scala/eu/joaocosta/interim/skins/TextInputSkin.scala b/core/src/main/scala/eu/joaocosta/interim/skins/TextInputSkin.scala index 9c0fbf0..92fd5db 100644 --- a/core/src/main/scala/eu/joaocosta/interim/skins/TextInputSkin.scala +++ b/core/src/main/scala/eu/joaocosta/interim/skins/TextInputSkin.scala @@ -11,29 +11,32 @@ object TextInputSkin extends DefaultSkin: final case class Default( border: Int, + activeBorder: Int, font: Font, inactiveColor: Color, hotColor: Color, activeColor: Color, textAreaColor: Color, + activeTextAreaColor: Color, textColor: Color ) extends TextInputSkin: - def textInputArea(area: Rect): Rect = - area.shrink(border) + def textInputArea(area: Rect): Rect = area def renderTextInput(area: Rect, value: String, itemStatus: UiContext.ItemStatus)(using uiContext: UiContext): Unit = val textInputArea = this.textInputArea(area) itemStatus match case UiContext.ItemStatus(_, _, true, _) | UiContext.ItemStatus(_, true, _, _) => - rectangleOutline(area, activeColor, border) + rectangle(textInputArea, activeTextAreaColor) + rectangleOutline(area, activeColor, activeBorder) case UiContext.ItemStatus(true, _, _, _) => + rectangle(textInputArea, textAreaColor) rectangleOutline(area, hotColor, border) case _ => + rectangle(textInputArea, textAreaColor) rectangleOutline(area, inactiveColor, border) - rectangle(textInputArea, textAreaColor) text( - textInputArea.shrink(border), + textInputArea.shrink(activeBorder), textColor, value, font, @@ -43,20 +46,24 @@ object TextInputSkin extends DefaultSkin: val lightDefault: Default = Default( border = 1, + activeBorder = 2, font = Font.default, - inactiveColor = ColorScheme.darkGray, + inactiveColor = ColorScheme.pureGray, hotColor = ColorScheme.lightPrimary, activeColor = ColorScheme.lightPrimaryHighlight, textAreaColor = ColorScheme.lightGray, + activeTextAreaColor = ColorScheme.white, textColor = ColorScheme.black ) val darkDefault: Default = Default( border = 1, + activeBorder = 2, font = Font.default, - inactiveColor = ColorScheme.lightGray, + inactiveColor = ColorScheme.pureGray, hotColor = ColorScheme.darkPrimary, activeColor = ColorScheme.darkPrimaryHighlight, textAreaColor = ColorScheme.darkGray, + activeTextAreaColor = ColorScheme.pureGray, textColor = ColorScheme.white )