Window frames in the style of V's Flatkit Aurorae theme, the classic frame as a setting
CI / test (push) Canceled after 52s
CI / test (push) Canceled after 52s
The default frame now follows codegod100/kde aurorae (Flatkit / Flatkit Dark): the kit's neutral title bar, a 1px outline with 10px top corners, a hairline under the title, a soft 16px shadow all round, a centred title and 24px flat buttons with hover and pressed fills (close turns red). 38px title bar, 1px border. Maximized: no shadow, square corners. - scene: WindowStyle (frame sizes, button layout, hit test) and build_window_decoration; the shadow is part of the decoration ops, so the three rasterisers lost their own offset shadow and redraw 18px around a changed window. - host: the frame size follows the style (work area, wm title-bar room, CSD client boxes, hit zones, screenshots); title-bar buttons track hover, show pressed, act on release. - Settings > Session > Flat window frames (off: the old Breeze-like frame), saved as :window-style :breeze; an unknown value is logged. - docs/window-frames.md; tests for both styles' pixels, button states and switching. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DPL5hmKDDLLES2aBrrnPxT
This commit is contained in:
20 files changed
+1005
-142
No files matched your search
@@ -10,6 +10,10 @@ pub fn build_breeze_decoration(String, String, Bool, Bool, Int32, Int32, ThemeTo
|
||||
|
||||
pub fn build_shell_ops(Int32, Int32, ThemeTokens, String, Array[String]) -> (Array[DrawOp], Array[DrawOp])
|
||||
|
||||
pub fn build_window_decoration(WindowStyle, DecorationState, Int32, Int32, ThemeTokens, (String, Int32, Bool) -> Int32) -> ((Int32, Int32, Int32, Int32), Array[DrawOp])
|
||||
|
||||
pub let decoration_shadow_reach : Int32
|
||||
|
||||
// Errors
|
||||
|
||||
// Types and methods
|
||||
@@ -22,6 +26,15 @@ pub fn DamageTracker::mark_rect(Self, Rect) -> Unit
|
||||
pub fn DamageTracker::new() -> Self
|
||||
pub fn DamageTracker::take_damage(Self, Int32, Int32) -> Array[Rect]
|
||||
|
||||
pub(all) struct DecorationState {
|
||||
title : String
|
||||
app_id : String
|
||||
focused : Bool
|
||||
maximized : Bool
|
||||
hover : Int32
|
||||
pressed : Int32
|
||||
}
|
||||
|
||||
#derive(Eq)
|
||||
pub(all) enum DrawOp {
|
||||
FillRect(Rect, Rgba, Int32)
|
||||
@@ -35,6 +48,8 @@ pub(all) enum DrawOp {
|
||||
Image(Rect, UInt32)
|
||||
}
|
||||
|
||||
type FlatColors
|
||||
|
||||
pub(all) struct PanelWidgetNode {
|
||||
id : String
|
||||
rect : Rect
|
||||
@@ -92,6 +107,7 @@ pub(all) enum TextAlign {
|
||||
Right
|
||||
}
|
||||
|
||||
#derive(Eq)
|
||||
pub(all) struct ThemePalette {
|
||||
desktop_top : Rgba
|
||||
desktop_bottom : Rgba
|
||||
@@ -105,6 +121,7 @@ pub(all) struct ThemePalette {
|
||||
border : Rgba
|
||||
}
|
||||
|
||||
#derive(Eq)
|
||||
pub(all) struct ThemeTokens {
|
||||
name : String
|
||||
palette : ThemePalette
|
||||
@@ -114,6 +131,7 @@ pub(all) struct ThemeTokens {
|
||||
panel_height : Int32
|
||||
}
|
||||
pub fn ThemeTokens::from_json_string(String) -> Self
|
||||
pub fn ThemeTokens::is_dark(Self) -> Bool
|
||||
pub fn ThemeTokens::moon_day() -> Self
|
||||
pub fn ThemeTokens::moon_night() -> Self
|
||||
|
||||
@@ -129,6 +147,18 @@ pub(all) struct WindowSceneNode {
|
||||
surface : ShmBufferSnapshot?
|
||||
}
|
||||
|
||||
#derive(Eq, @debug.Debug)
|
||||
pub(all) enum WindowStyle {
|
||||
Flat
|
||||
Breeze
|
||||
}
|
||||
pub fn WindowStyle::button_at(Self, Int32, Int32, Int32) -> Int32
|
||||
pub fn WindowStyle::buttons(Self, Int32) -> Array[(Int32, Rect, Int32)]
|
||||
pub fn WindowStyle::frame_side(Self) -> Int32
|
||||
pub fn WindowStyle::frame_top(Self) -> Int32
|
||||
pub fn WindowStyle::name(Self) -> String
|
||||
pub fn WindowStyle::parse(String) -> Self?
|
||||
|
||||
// Type aliases
|
||||
|
||||
// Traits
|
||||
@@ -561,3 +561,431 @@ pub fn build_shell_ops(
|
||||
|
||||
(bg_ops, panel_ops)
|
||||
}
|
||||
|
||||
///| How Chandra draws the frame around a server-decorated window. `Flat` follows V's Flatkit
|
||||
/// Aurorae theme (github.com/codegod100/kde, aurorae/): the kit's neutral title bar, a 1px
|
||||
/// outline with 10px top corners, a hairline under the title, a soft 16px shadow all round, a
|
||||
/// centred title and 24px flat buttons that show a hover / pressed fill (close turns red).
|
||||
/// `Breeze` is the frame Chandra drew before: accent outline, 18px round buttons, offset shadow.
|
||||
#derive(Eq, Debug)
|
||||
pub(all) enum WindowStyle {
|
||||
Flat
|
||||
Breeze
|
||||
}
|
||||
|
||||
///| The name state.edn stores (`:window-style :flat` / `:breeze`).
|
||||
pub fn WindowStyle::name(self : WindowStyle) -> String {
|
||||
match self {
|
||||
Flat => "flat"
|
||||
Breeze => "breeze"
|
||||
}
|
||||
}
|
||||
|
||||
///|
|
||||
pub fn WindowStyle::parse(s : String) -> WindowStyle? {
|
||||
match s {
|
||||
"flat" => Some(Flat)
|
||||
"breeze" => Some(Breeze)
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
|
||||
///| Height of the frame above the client: the title bar, its outline and the line under it.
|
||||
pub fn WindowStyle::frame_top(self : WindowStyle) -> Int {
|
||||
match self {
|
||||
Flat => flat_title_h
|
||||
Breeze => 32
|
||||
}
|
||||
}
|
||||
|
||||
///| Width of the frame left, right and below the client.
|
||||
pub fn WindowStyle::frame_side(self : WindowStyle) -> Int {
|
||||
match self {
|
||||
Flat => 1
|
||||
Breeze => 2
|
||||
}
|
||||
}
|
||||
|
||||
///| How far around the frame the decoration's ops may draw (its shadow): hosts redraw this much
|
||||
/// around a window that moved.
|
||||
pub let decoration_shadow_reach : Int = 18
|
||||
|
||||
///| Flat: the outline row, 36px of title bar with the 24px buttons centred, and the hairline:
|
||||
/// 38px, TitleEdgeTop 7 + TitleHeight 24 + TitleEdgeBottom 7 in Flatkitrc.
|
||||
let flat_title_h : Int = 38
|
||||
|
||||
///|
|
||||
let flat_radius : Int = 10
|
||||
|
||||
///|
|
||||
let flat_button : Int = 24
|
||||
|
||||
///|
|
||||
let flat_button_gap : Int = 4
|
||||
|
||||
///| From the frame's right edge to the close button (TitleEdgeRight 7 + the outline).
|
||||
let flat_button_margin : Int = 8
|
||||
|
||||
///|
|
||||
let flat_shadow : Int = 16
|
||||
|
||||
///| The title-bar buttons of a frame `outer_w` wide, in the frame's coordinates, as
|
||||
/// (button, rect, slop): 1 minimize, 2 maximize, 3 close; slop widens the click target.
|
||||
pub fn WindowStyle::buttons(self : WindowStyle, outer_w : Int) -> Array[(Int, Rect, Int)] {
|
||||
match self {
|
||||
Flat => {
|
||||
let y = (flat_title_h - flat_button) / 2
|
||||
let close_x = outer_w - flat_button_margin - flat_button
|
||||
let max_x = close_x - flat_button_gap - flat_button
|
||||
let min_x = max_x - flat_button_gap - flat_button
|
||||
[
|
||||
(1, Rect::new(min_x, y, flat_button, flat_button), 2),
|
||||
(2, Rect::new(max_x, y, flat_button, flat_button), 2),
|
||||
(3, Rect::new(close_x, y, flat_button, flat_button), 2),
|
||||
]
|
||||
}
|
||||
Breeze => {
|
||||
let size = 18
|
||||
let y = (32 - size) / 2
|
||||
let close_x = outer_w - 10 - size
|
||||
let max_x = close_x - 8 - size
|
||||
let min_x = max_x - 8 - size
|
||||
[
|
||||
(1, Rect::new(min_x, y, size, size), 3),
|
||||
(2, Rect::new(max_x, y, size, size), 3),
|
||||
(3, Rect::new(close_x, y, size, size), 3),
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///| The button (1 minimize, 2 maximize, 3 close) at (lx, ly) in a frame `outer_w` wide; 0 none.
|
||||
pub fn WindowStyle::button_at(self : WindowStyle, outer_w : Int, lx : Int, ly : Int) -> Int {
|
||||
for b in self.buttons(outer_w) {
|
||||
let (id, r, slop) = b
|
||||
if lx >= r.x - slop && lx < r.x + r.w + slop && ly >= r.y - slop && ly < r.y + r.h + slop {
|
||||
return id
|
||||
}
|
||||
}
|
||||
0
|
||||
}
|
||||
|
||||
///| One window's decoration: what it shows and the pointer's state over its buttons.
|
||||
pub(all) struct DecorationState {
|
||||
title : String
|
||||
app_id : String
|
||||
focused : Bool
|
||||
maximized : Bool
|
||||
/// The button under the pointer (1 minimize, 2 maximize, 3 close; 0 none) ...
|
||||
hover : Int
|
||||
/// ... and the one held down.
|
||||
pressed : Int
|
||||
}
|
||||
|
||||
///| Colours of the Flat frame: flatkit's KitColors (lib/src/theme.dart in codegod100/flutterkit),
|
||||
/// as aurorae/generate.py has them.
|
||||
struct FlatColors {
|
||||
background : Rgba
|
||||
hover : Rgba
|
||||
pressed : Rgba
|
||||
border : Rgba
|
||||
text : Rgba
|
||||
text_dim : Rgba
|
||||
danger : Rgba
|
||||
danger_hover : Rgba
|
||||
on_danger : Rgba
|
||||
/// Shadow opacity (0-255) at the outline, focused and unfocused.
|
||||
shadow : Int
|
||||
shadow_inactive : Int
|
||||
}
|
||||
|
||||
///|
|
||||
fn flat_colors(dark : Bool) -> FlatColors {
|
||||
if dark {
|
||||
{
|
||||
background: Rgba::from_hex("#1C1C1F"),
|
||||
hover: Rgba::from_hex("#323237"),
|
||||
pressed: Rgba::from_hex("#3C3C42"),
|
||||
border: Rgba::from_hex("#3A3A40"),
|
||||
text: Rgba::from_hex("#EDEDF0"),
|
||||
text_dim: Rgba::from_hex("#A0A0A8"),
|
||||
danger: Rgba::from_hex("#E5484D"),
|
||||
danger_hover: Rgba::from_hex("#EC5F63"),
|
||||
on_danger: Rgba::from_hex("#FFFFFF"),
|
||||
shadow: 115, // 0.45
|
||||
shadow_inactive: 71, // 0.28
|
||||
}
|
||||
} else {
|
||||
{
|
||||
background: Rgba::from_hex("#F6F6F7"),
|
||||
hover: Rgba::from_hex("#EDEDEF"),
|
||||
pressed: Rgba::from_hex("#DEDEE2"),
|
||||
border: Rgba::from_hex("#DADADE"),
|
||||
text: Rgba::from_hex("#1E1E22"),
|
||||
text_dim: Rgba::from_hex("#66666E"),
|
||||
danger: Rgba::from_hex("#D12D3A"),
|
||||
danger_hover: Rgba::from_hex("#B8232F"),
|
||||
on_danger: Rgba::from_hex("#FFFFFF"),
|
||||
shadow: 51, // 0.20
|
||||
shadow_inactive: 28, // 0.11
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///| True for a dark theme (its surface colour is dark): Moon Night, not Moon Day.
|
||||
pub fn ThemeTokens::is_dark(self : ThemeTokens) -> Bool {
|
||||
let s = self.palette.surface
|
||||
s.r.to_int() * 299 + s.g.to_int() * 587 + s.b.to_int() * 114 < 128 * 1000
|
||||
}
|
||||
|
||||
///| The shadow's falloff from the outline out, as (fraction of the reach, fraction of the
|
||||
/// opacity): SHADOW_STOPS in aurorae/generate.py.
|
||||
let shadow_stops : Array[(Double, Double)] = [
|
||||
(0.0, 1.0),
|
||||
(0.15, 0.72),
|
||||
(0.35, 0.40),
|
||||
(0.6, 0.15),
|
||||
(0.8, 0.05),
|
||||
(1.0, 0.0),
|
||||
]
|
||||
|
||||
///| Shadow opacity (0-255) at `t` (0 at the outline, 1 at the shadow's reach).
|
||||
fn shadow_alpha(max_a : Int, t : Double) -> Int {
|
||||
let mut i = 0
|
||||
while i + 1 < shadow_stops.length() && shadow_stops[i + 1].0 < t {
|
||||
i = i + 1
|
||||
}
|
||||
if i + 1 >= shadow_stops.length() {
|
||||
return 0
|
||||
}
|
||||
let (t0, f0) = shadow_stops[i]
|
||||
let (t1, f1) = shadow_stops[i + 1]
|
||||
let f = f0 + (f1 - f0) * ((t - t0) / (t1 - t0))
|
||||
(max_a.to_double() * f + 0.5).to_int().clamp(min=0, max=255)
|
||||
}
|
||||
|
||||
///| A soft shadow all round a frame `w` x `h` with rounded top corners (`radius`) and square
|
||||
/// bottom ones, drawn in 2px bands out to `flat_shadow`. The straight edges are 1-band rows and
|
||||
/// columns; each corner stacks translucent rounded rectangles inside a square clip, so their sum
|
||||
/// fades with the distance from the corner's arc (the radial gradients of decoration.svg).
|
||||
/// Everything is plain spans: cheap for the software rasterisers.
|
||||
fn push_flat_shadow(ops : Array[DrawOp], w : Int, h : Int, radius : Int, max_a : Int) -> Unit {
|
||||
let step = 2
|
||||
let bands = flat_shadow / step
|
||||
// Opacity of band k (1 = next to the outline), and of the layer that adds it over band k + 1.
|
||||
let total = Array::make(bands + 2, 0)
|
||||
for k = 1; k <= bands; k = k + 1 {
|
||||
total[k] = shadow_alpha(max_a, (k.to_double() - 0.5) / bands.to_double())
|
||||
}
|
||||
let layer = Array::make(bands + 2, 0)
|
||||
for k = 1; k <= bands; k = k + 1 {
|
||||
let outer = 255 - total[k + 1]
|
||||
layer[k] = if outer <= 0 {
|
||||
0
|
||||
} else {
|
||||
(255.0 * (1.0 - (255 - total[k]).to_double() / outer.to_double()) + 0.5).to_int().clamp(min=0, max=255)
|
||||
}
|
||||
}
|
||||
let black = fn(a : Int) { Rgba::new(0, 0, 0, a) }
|
||||
// Edges.
|
||||
for k = 1; k <= bands; k = k + 1 {
|
||||
let c = black(total[k])
|
||||
if total[k] == 0 {
|
||||
continue
|
||||
}
|
||||
let d = k * step
|
||||
ops.push(FillRect(Rect::new(radius, -d, w - 2 * radius, step), c, 0))
|
||||
ops.push(FillRect(Rect::new(0, h + d - step, w, step), c, 0))
|
||||
ops.push(FillRect(Rect::new(-d, radius, step, h - radius), c, 0))
|
||||
ops.push(FillRect(Rect::new(w + d - step, radius, step, h - radius), c, 0))
|
||||
}
|
||||
// Corners: top ones round about the outline's arc, bottom ones about the square corner.
|
||||
let reach = flat_shadow
|
||||
let corners = [
|
||||
(Rect::new(-reach, -reach, reach + radius, reach + radius), radius),
|
||||
(Rect::new(w - radius, -reach, reach + radius, reach + radius), radius),
|
||||
(Rect::new(-reach, h, reach, reach), 0),
|
||||
(Rect::new(w, h, reach, reach), 0),
|
||||
]
|
||||
for corner in corners {
|
||||
let (clip, r0) = corner
|
||||
ops.push(PushClip(clip))
|
||||
for k = bands; k >= 1; k = k - 1 {
|
||||
if layer[k] > 0 {
|
||||
let d = k * step
|
||||
ops.push(FillRect(Rect::new(-d, -d, w + 2 * d, h + 2 * d), black(layer[k]), r0 + d))
|
||||
}
|
||||
}
|
||||
ops.push(PopClip)
|
||||
}
|
||||
}
|
||||
|
||||
///| The Breeze frame's drop shadow, offset 4px right and 6px down; only the strips that stick
|
||||
/// out from under the window (and the part under the translucent title bar) are blended.
|
||||
fn push_breeze_shadow(ops : Array[DrawOp], w : Int, h : Int, top : Int) -> Unit {
|
||||
let shadow = Rect::new(4, 6, w, h)
|
||||
let col = Rgba::new(0, 0, 0, 80)
|
||||
for strip in [Rect::new(w, 0, 4, h + 6), Rect::new(0, h, w + 4, 6), Rect::new(0, 0, w, top + 2)] {
|
||||
ops.push(PushClip(strip))
|
||||
ops.push(FillRect(shadow, col, 8))
|
||||
ops.push(PopClip)
|
||||
}
|
||||
}
|
||||
|
||||
///| Shorten `label` with ".." until `text_w` says it fits in `max_w` pixels ("" if nothing does).
|
||||
fn fit_title(label : String, max_w : Int, text_w : (String) -> Int) -> String {
|
||||
if text_w(label) <= max_w {
|
||||
return label
|
||||
}
|
||||
let chars = label.to_array()
|
||||
let mut n = chars.length() - 1
|
||||
while n > 0 {
|
||||
let s = String::from_array(chars[:n]) + ".."
|
||||
if text_w(s) <= max_w {
|
||||
return s
|
||||
}
|
||||
n = n - 1
|
||||
}
|
||||
""
|
||||
}
|
||||
|
||||
///| A window's frame (title bar, outline, shadow and buttons) in `style`, as draw ops in the
|
||||
/// coordinates of its outer box (`outer_w` x `outer_h`: the client plus `style`'s frame), and the
|
||||
/// frame's insets (top, right, bottom, left). `text_w(s, size, bold)` measures title text.
|
||||
pub fn build_window_decoration(
|
||||
style : WindowStyle,
|
||||
d : DecorationState,
|
||||
outer_w : Int,
|
||||
outer_h : Int,
|
||||
tokens : ThemeTokens,
|
||||
text_w : (String, Int, Bool) -> Int,
|
||||
) -> ((Int, Int, Int, Int), Array[DrawOp]) {
|
||||
match style {
|
||||
Breeze => {
|
||||
let (insets, deco) = build_breeze_decoration(d.title, d.app_id, d.focused, false, outer_w, outer_h, tokens)
|
||||
let ops : Array[DrawOp] = []
|
||||
push_breeze_shadow(ops, outer_w, outer_h, insets.0)
|
||||
// Hover / pressed: a ring around the button, in the accent colour while pressed.
|
||||
for b in style.buttons(outer_w) {
|
||||
let (id, r, _) = b
|
||||
if id == d.pressed {
|
||||
deco.push(StrokeRect(Rect::new(r.x - 1, r.y - 1, r.w + 2, r.h + 2), tokens.palette.accent, 2, 10))
|
||||
} else if id == d.hover {
|
||||
deco.push(StrokeRect(Rect::new(r.x - 1, r.y - 1, r.w + 2, r.h + 2), tokens.palette.foreground_muted, 1, 10))
|
||||
}
|
||||
}
|
||||
ops.append(deco)
|
||||
(insets, ops)
|
||||
}
|
||||
Flat => build_flat_decoration(d, outer_w, outer_h, tokens, text_w)
|
||||
}
|
||||
}
|
||||
|
||||
///| Flatkit's frame (see `WindowStyle::Flat`). Maximized: no shadow and square corners.
|
||||
fn build_flat_decoration(
|
||||
d : DecorationState,
|
||||
w : Int,
|
||||
h : Int,
|
||||
tokens : ThemeTokens,
|
||||
text_w : (String, Int, Bool) -> Int,
|
||||
) -> ((Int, Int, Int, Int), Array[DrawOp]) {
|
||||
let c = flat_colors(tokens.is_dark())
|
||||
let top = flat_title_h
|
||||
let radius = if d.maximized { 0 } else { flat_radius }
|
||||
let ops : Array[DrawOp] = []
|
||||
if !d.maximized {
|
||||
push_flat_shadow(ops, w, h, radius, if d.focused { c.shadow } else { c.shadow_inactive })
|
||||
}
|
||||
// Title bar inside its outline: two rounded fills, clipped to the title bar so nothing is
|
||||
// drawn under the client (a translucent client shows what is behind it, not the frame).
|
||||
ops.push(PushClip(Rect::new(0, 0, w, top)))
|
||||
ops.push(FillRect(Rect::new(0, 0, w, top + radius), c.border, radius))
|
||||
ops.push(FillRect(Rect::new(1, 1, w - 2, top + radius), c.background, if radius > 1 { radius - 1 } else { 0 }))
|
||||
ops.push(PopClip)
|
||||
// The hairline under the title, then the outline down the sides and along the bottom.
|
||||
ops.push(FillRect(Rect::new(1, top - 1, w - 2, 1), c.border, 0))
|
||||
ops.push(FillRect(Rect::new(0, top, 1, h - top), c.border, 0))
|
||||
ops.push(FillRect(Rect::new(w - 1, top, 1, h - top), c.border, 0))
|
||||
ops.push(FillRect(Rect::new(1, h - 1, w - 2, 1), c.border, 0))
|
||||
|
||||
// Buttons: nothing behind the glyph at rest, the hover / pressed fill under the pointer.
|
||||
let buttons = WindowStyle::Flat.buttons(w)
|
||||
for b in buttons {
|
||||
let (id, r, _) = b
|
||||
let close = id == 3
|
||||
let state = if id == d.pressed { 2 } else if id == d.hover { 1 } else { 0 }
|
||||
let fill = match (state, close) {
|
||||
(1, true) => Some(c.danger)
|
||||
(2, true) => Some(c.danger_hover)
|
||||
(1, false) => Some(c.hover)
|
||||
(2, false) => Some(c.pressed)
|
||||
_ => None
|
||||
}
|
||||
match fill {
|
||||
Some(col) => ops.push(FillRect(r, col, 6))
|
||||
None => ()
|
||||
}
|
||||
let fg = if close && state > 0 {
|
||||
c.on_danger
|
||||
} else if d.focused || state > 0 {
|
||||
c.text
|
||||
} else {
|
||||
c.text_dim
|
||||
}
|
||||
push_flat_glyph(ops, id, d.maximized, r.x, r.y, fg)
|
||||
}
|
||||
|
||||
// Title: centred on the whole bar while it fits between the buttons on both sides, else
|
||||
// shortened and left of the buttons.
|
||||
let size = if tokens.font_size > 1 { tokens.font_size - 1 } else { tokens.font_size }
|
||||
let fg = if d.focused { c.text } else { c.text_dim }
|
||||
let label = if d.title.length() > 0 { d.title } else { d.app_id }
|
||||
let first_btn = buttons[0].1.x
|
||||
let side = w - first_btn + 8
|
||||
let measure = fn(s : String) { text_w(s, size, true) }
|
||||
let tw = measure(label)
|
||||
let cy = top / 2
|
||||
if tw <= w - 2 * side {
|
||||
ops.push(Text(w / 2, cy, label, size, fg, Center, true))
|
||||
} else {
|
||||
let shown = fit_title(label, first_btn - 8 - 12, measure)
|
||||
if shown.length() > 0 {
|
||||
ops.push(Text(12, cy, shown, size, fg, Left, true))
|
||||
}
|
||||
}
|
||||
((top, 1, 1, 1), ops)
|
||||
}
|
||||
|
||||
///| A button glyph in its 24px box at (x, y): the 1.5px line icons of aurorae/generate.py, as
|
||||
/// 1px lines with a faint second line beside them for the half pixel.
|
||||
fn push_flat_glyph(ops : Array[DrawOp], id : Int, maximized : Bool, x : Int, y : Int, fg : Rgba) -> Unit {
|
||||
let soft = fg.with_alpha(fg.a.to_int() * 2 / 5)
|
||||
match id {
|
||||
1 => {
|
||||
ops.push(FillRect(Rect::new(x + 8, y + 12, 9, 1), fg, 0))
|
||||
ops.push(FillRect(Rect::new(x + 8, y + 13, 9, 1), soft, 0))
|
||||
}
|
||||
2 =>
|
||||
if maximized {
|
||||
// Restore: a front square and the corner of one behind it.
|
||||
ops.push(StrokeRect(Rect::new(x + 7, y + 9, 8, 8), fg, 1, 2))
|
||||
ops.push(StrokeRect(Rect::new(x + 8, y + 10, 6, 6), soft, 1, 1))
|
||||
ops.push(FillRect(Rect::new(x + 10, y + 7, 6, 1), fg, 0))
|
||||
ops.push(FillRect(Rect::new(x + 17, y + 8, 1, 6), fg, 0))
|
||||
ops.push(FillRect(Rect::new(x + 16, y + 7, 1, 1), soft, 0))
|
||||
ops.push(FillRect(Rect::new(x + 10, y + 8, 6, 1), soft, 0))
|
||||
ops.push(FillRect(Rect::new(x + 16, y + 8, 1, 6), soft, 0))
|
||||
} else {
|
||||
ops.push(StrokeRect(Rect::new(x + 7, y + 7, 10, 10), fg, 1, 2))
|
||||
ops.push(StrokeRect(Rect::new(x + 8, y + 8, 8, 8), soft, 1, 1))
|
||||
}
|
||||
_ => {
|
||||
ops.push(Line(x + 8, y + 8, x + 16, y + 16, fg, 1))
|
||||
ops.push(Line(x + 16, y + 8, x + 8, y + 16, fg, 1))
|
||||
ops.push(Line(x + 9, y + 8, x + 16, y + 15, soft, 1))
|
||||
ops.push(Line(x + 8, y + 9, x + 15, y + 16, soft, 1))
|
||||
ops.push(Line(x + 15, y + 8, x + 8, y + 15, soft, 1))
|
||||
ops.push(Line(x + 16, y + 9, x + 9, y + 16, soft, 1))
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user