diff --git a/docs/gamerig-library.md b/docs/gamerig-library.md index f06b9aa..c1f172e 100644 --- a/docs/gamerig-library.md +++ b/docs/gamerig-library.md @@ -34,8 +34,9 @@ or pick **Gamerig Library** in Settings > Desktop. Escape edit the search; the wheel scrolls the grid. * It fits the screen: when the cards don't fit, they get narrower and say less (fewer description and hint lines, then name and buttons only) before the grid would scroll. -* It is the desktop's "wallpaper": panels and cards are glassy and the desktop wallpaper shows - through. Module settings (right-click the desktop): Background, *Wallpaper* or *Solid* +* It is the desktop's "wallpaper": panels and cards are glassy over an even gamerig gradient + (no pattern or logo behind the cards). Module settings (right-click the desktop): Background, + *Gradient* (the default), *Wallpaper* (the desktop wallpaper through the glass) or *Solid* (gamerig's own background colour); Colours, *Follow desktop* (gamerig dark or light after the desktop theme), *Dark* or *Light*. diff --git a/docs/screenshots/desktop-gamerig-library.png b/docs/screenshots/desktop-gamerig-library.png index b8de5be..629ab24 100644 Binary files a/docs/screenshots/desktop-gamerig-library.png and b/docs/screenshots/desktop-gamerig-library.png differ diff --git a/lib/gamelib/gamelib_test.mbt b/lib/gamelib/gamelib_test.mbt index 953cd6d..1731eca 100644 --- a/lib/gamelib/gamelib_test.mbt +++ b/lib/gamelib/gamelib_test.mbt @@ -171,13 +171,20 @@ test "disconnected: says it is waiting, and the error" { } ///| -test "nine games fit a 1280x720 desktop without scrolling, and the wallpaper shows through" { +test "nine games fit a 1280x720 desktop without scrolling; gradient, wallpaper and solid backdrops" { let lib = @gamelib.Library::new() let base = sample_state().games[1] let games = Array::makei(9, i => { ..base, id: "g" + i.to_string(), featured: i < 2 }) let ops = lib.render(games, [], @gamelib.Rig::unknown(), { w: 1280, h: 720 }, tokens()) assert_true(lib.content_h <= lib.view_h, msg="grid \{lib.content_h} > view \{lib.view_h}") - // No opaque full-screen background in the default Wallpaper mode. + // The default Gradient backdrop: even 4 px bands, no full-screen fill. + match ops[0] { + FillRect(f) => assert_eq(f.rect.h, 4) + _ => fail("no gradient") + } + // Over the desktop wallpaper: no opaque full-screen background. + assert_true(lib.set_config("background", "Wallpaper")) + let ops = lib.render(games, [], @gamelib.Rig::unknown(), { w: 1280, h: 720 }, tokens()) match ops[0] { FillRect(f) => assert_true(f.rect.h != 720 || f.color.a.to_int() < 255) _ => () diff --git a/lib/gamelib/view.mbt b/lib/gamelib/view.mbt index 1c5820f..2a8be6d 100644 --- a/lib/gamelib/view.mbt +++ b/lib/gamelib/view.mbt @@ -50,8 +50,9 @@ pub(all) struct ConfigEntry { ///| pub let colors_choices : Array[String] = ["Follow desktop", "Dark", "Light"] -///| Behind the library: the desktop's wallpaper through glassy panels, or gamerig's solid colour. -pub let background_choices : Array[String] = ["Wallpaper", "Solid"] +///| Behind the library: its own smooth gradient under glassy panels, the desktop's wallpaper +/// through those panels, or gamerig's solid colour. +pub let background_choices : Array[String] = ["Gradient", "Wallpaper", "Solid"] ///| Gamerig's colours. pub(all) struct Pal { @@ -158,7 +159,7 @@ pub fn Library::new() -> Library { selected: "", focused: false, colors: "Follow desktop", - background: "Wallpaper", + background: "Gradient", regions: [], shown: [], content_h: 0, @@ -541,6 +542,37 @@ pub fn grid_fit(games : Array[Game], inner_w : Int, inner_h : Int) -> (Array[(In last } +///| The library's own backdrop: an even, gently lit gradient with no pattern or text in it, so +/// nothing behind the glassy cards reads as a glitch. Bands of 4 px and glows of many faint rings +/// keep each step below one colour level. +fn draw_gradient(ops : Array[@types.DrawOp], w : Int, h : Int, dark : Bool) -> Unit { + let (top, bottom) = if dark { + (c(31, 35, 54), c(13, 14, 21)) + } else { + (c(236, 239, 247), c(205, 211, 228)) + } + let band = 4 + let n = (h + band - 1) / band + for i in 0.. 1 { n - 1 } else { 1 }))) + } + // Two soft glows: gamerig's amber up right, a cool blue down left. + let glow = (cx : Int, cy : Int, r : Int, col : @types.Color, a : Int) => { + let rings = 24 + for k in 0.. h { w } else { h } + if dark { + glow(w * 4 / 5, h / 6, big * 2 / 5, c(246, 183, 46), 1) + glow(w / 6, h * 5 / 6, big * 2 / 5, c(80, 110, 220), 2) + } else { + glow(w * 4 / 5, h / 6, big * 2 / 5, c(246, 183, 46), 2) + glow(w / 6, h * 5 / 6, big * 2 / 5, c(120, 150, 240), 2) + } +} + ///| Draw the whole library for an output `size`. pub fn Library::render( self : Library, @@ -559,6 +591,8 @@ pub fn Library::render( let ops : Array[@types.DrawOp] = [] if self.background == "Solid" { ops.push(@ui.fill_rect(@ui.rect(0, 0, w, h), p.bg)) + } else if self.background == "Gradient" { + draw_gradient(ops, w, h, p.dark) } else { // A light veil under the top bar keeps its text readable on any wallpaper. ops.push(@ui.fill_rect(@ui.rect(0, 0, w, top_h), @ui.with_alpha(p.panel, 120)))