Skip to content

Commit

Permalink
Add primary shadow and adjust color scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
JD557 committed Nov 18, 2023
1 parent f97e1b7 commit 13f0935
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 28 deletions.
24 changes: 10 additions & 14 deletions core/src/main/scala/eu/joaocosta/interim/skins/ButtonSkin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Expand All @@ -51,21 +49,19 @@ 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,
activeColor = ColorScheme.lightPrimaryHighlight
)

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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand All @@ -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
)
21 changes: 14 additions & 7 deletions core/src/main/scala/eu/joaocosta/interim/skins/TextInputSkin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
)

0 comments on commit 13f0935

Please sign in to comment.