From df3630998c857099c58814a775d080e37af0d23f Mon Sep 17 00:00:00 2001 From: diviocity Date: Sun, 1 Nov 2026 16:29:52 +0100 Subject: [PATCH] move icons to svg (optional), adjust slider bar height --- AGENTS.md | 63 +++++++-- assets/icons/forward30.png | Bin 0 -> 1117 bytes assets/icons/pause.png | Bin 0 -> 174 bytes assets/icons/play.png | Bin 0 -> 383 bytes assets/icons/replay30.png | Bin 0 -> 1108 bytes assets/icons/volume_mute.png | Bin 0 -> 275 bytes assets/icons/volume_off.png | Bin 0 -> 877 bytes assets/icons/volume_up.png | Bin 0 -> 776 bytes libvendetta/draw.v | 130 +++++++++++++++--- libvendetta/lib.v | 12 ++ ...24dp_E3E3E3_FILL1_wght400_GRAD0_opsz24.svg | 1 + ...24dp_E3E3E3_FILL1_wght400_GRAD0_opsz24.svg | 1 + ...24dp_E3E3E3_FILL1_wght400_GRAD0_opsz24.svg | 1 + ...24dp_E3E3E3_FILL1_wght400_GRAD0_opsz24.svg | 1 + ...24dp_E3E3E3_FILL1_wght400_GRAD0_opsz24.svg | 1 + ...24dp_E3E3E3_FILL1_wght400_GRAD0_opsz24.svg | 1 + ...24dp_E3E3E3_FILL1_wght400_GRAD0_opsz24.svg | 1 + scripts/make_pngs.sh | 63 +++++++++ src/main.v | 1 + src/settings.v | 10 ++ 20 files changed, 257 insertions(+), 29 deletions(-) create mode 100644 assets/icons/forward30.png create mode 100644 assets/icons/pause.png create mode 100644 assets/icons/play.png create mode 100644 assets/icons/replay30.png create mode 100644 assets/icons/volume_mute.png create mode 100644 assets/icons/volume_off.png create mode 100644 assets/icons/volume_up.png create mode 100644 scripts/icons/forward_30_24dp_E3E3E3_FILL1_wght400_GRAD0_opsz24.svg create mode 100644 scripts/icons/pause_24dp_E3E3E3_FILL1_wght400_GRAD0_opsz24.svg create mode 100644 scripts/icons/play_arrow_24dp_E3E3E3_FILL1_wght400_GRAD0_opsz24.svg create mode 100644 scripts/icons/replay_30_24dp_E3E3E3_FILL1_wght400_GRAD0_opsz24.svg create mode 100644 scripts/icons/volume_mute_24dp_E3E3E3_FILL1_wght400_GRAD0_opsz24.svg create mode 100644 scripts/icons/volume_off_24dp_E3E3E3_FILL1_wght400_GRAD0_opsz24.svg create mode 100644 scripts/icons/volume_up_24dp_E3E3E3_FILL1_wght400_GRAD0_opsz24.svg create mode 100755 scripts/make_pngs.sh diff --git a/AGENTS.md b/AGENTS.md index 873e8bc..1ddc135 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -136,6 +136,7 @@ Debug flags, each compiled only behind `$if ?`: | `-d playback_probe` | a worker prints mpv's pacing/counters per second during playback (decoder/display drops, presents, repeat skips, mistimed/vo-delayed deltas, sync mode, hwdec, fps, position) to pin a choppy file to a pipeline stage | | `-d debug_cadence` | one-line stderr trace at the interesting points: keys, pointer moves, property changes, pause flips, queue moves, file end | | `-d mpv_noflip` | disables the `flip_y` render param override (`flip_on_android` exists to flip for Android's bottom-up convention; the define is the opt-out) | +| `-d no_png_icons` | compiles the assets/icons resolution out so the strip's buttons draw the compiled-in Material glyphs alone (see §6.8); useful for builds that ship no assets tree | --- @@ -377,7 +378,9 @@ render pump, the relay, the control bar geometry and its build). and `bg_docked` styles the static docked strip separately from the floating one (which keeps `bg_dark`). - `Config` — `overlay` (floating strip over full-height video vs docked band - below), `seek_step` (30 s), `volume_step` (5), `block_target_time` (mpv's + below), `seek_step` (30 s), `volume_step` (5), `slider_h` (the seek and volume + tracks' shared height, 10 by default, kept within 1..30), + `block_target_time` (mpv's default presentation pacing), `input_scope` (`.frame` — only input inside the widget's frame, keys follow the pointer — or `.window`), `ao` (audio server name, 'auto', or empty), plus three hooks: @@ -411,9 +414,11 @@ render pump, the relay, the control bar geometry and its build). `new(cfg)`/`setup(cfg)`: -1. (Android) registers the JavaVM with libavcodec. -2. `mpv.create()`. -3. Sets `vo=libmpv` (hands mpv's output to the render API instead of a +1. Resolves the strip's icons into `p.icon_files` (`resolve_strip_icons`, + §6.8) before any build reads them; everything below is mpv's setup. +2. (Android) registers the JavaVM with libavcodec. +3. `mpv.create()`. +4. Sets `vo=libmpv` (hands mpv's output to the render API instead of a window of its own), the audio output, `keep-open=yes`, and — because display sync cannot measure the vsync rate with the libmpv video output — @@ -423,10 +428,10 @@ render pump, the relay, the control bar geometry and its build). (mpv's own autoprobing), other names pass through; on Android the same default is `audiotrack`; on other platforms only an explicit non-auto name is written. -4. Log level 'warn' ('v' under `-d video_debug`; the shader chain logs +5. Log level 'warn' ('v' under `-d video_debug`; the shader chain logs reconfigures, pass compilation and GL errors at info/verbose which warn would swallow). -5. Calls the `pre_init` hook (this is where the standalone app seeds +6. Calls the `pre_init` hook (this is where the standalone app seeds `--mpv-opt`s and the display-fps override), `mpv.initialize`, then observes its nine properties (§6.4). @@ -649,7 +654,10 @@ time columns (down to a floor computed from the short-label saving; and hh:mm:ss from then on). The volume column's width mirrors the button cluster's exactly so the seek slider sits at the strip's centre. -Sliders are drawn bare (`thumb_size: seek_thumb_hidden = -1`). The seek +Sliders are drawn bare (`thumb_size: seek_thumb_hidden = -1`), and their +visible height is the style's `track_width`, set from `Config.slider_h`, not +the rect's height: `slider_frame` only grows the rect around a track taller +than the row, so the whole track takes input. The seek slider's seed value is `p.glide_pos()`, **not** the raw reported position: a rebuild can land between reports, and seeding with the report would snap the thumb back. `glide_pos()` — the smooth bar — extrapolates the last reported @@ -662,9 +670,21 @@ the chain's next link, the scheduler coalesces it with the slider write's own ask, and the chain dies (on pause, hidden strip, or the option off) by simply not asking. -Buttons are `glyph_button`s: ui2 buttons whose `image_path` is a `'symbol:' -` glyph (`symbol:play.fill`, `symbol:gobackward.30`, ...), tinted by the -button's text style. +Buttons are `glyph_button`s: ui2 buttons whose `image_path` is the icon the +strip's role resolves to (`p.strip_icon(name)`). The icons are the rastered +set under `assets/icons/` — Google's filled Material exports, rendered at +64 px and colorized to the palette colours by `scripts/make_pngs.sh` from +the SVG sources in `scripts/icons/` +(ImageMagick for now; **stb_image**, what ui2 draws button images through, +cannot parse SVG) — found one of three places: `assets/icons` beside the +executable (the release layout), in the module tree the build came from, in +the working directory; resolved once in `setup` into `p.icon_files`. A +rastered image draws as it is, so a theme cannot tint it the way a glyph is +tinted by the button's text style. Where no bundle is found — an Android +run, a host that ships no assets — and for builds compiled with +`-d no_png_icons`, the roles fall back to the compiled-in `'symbol:'` +Material glyphs (`symbol:play.fill`, `symbol:gobackward.30`, ...), which +tint by the text style instead. ### 6.9 What a host owes the widget @@ -760,7 +780,8 @@ Flags (every one documented above; the value-form `--mpv-opt name=value` may repeat): `--help/-h`, `--theme`, `--volume`, `--mute`, `--speed`, `--fullscreen`, `--overlay/--no-overlay`, `--loop/--loop-playlist`, `--hwdec/--no-hwdec`, `--deinterlace`, `--low-quality`, `--preview/--no-preview`, -`--smooth-bar/--no-smooth-bar`, `--media-controls/--no-media-controls`, +`--smooth-bar/--no-smooth-bar`, `--slider-height`, +`--media-controls/--no-media-controls`, `--ao`, `--display-fps` (for `display-fps-override` on multi-monitor/Wayland setups where detection cannot know the screen), `--no-block-target-time`, `--start-at` (seconds or mm:ss), `--sub-file`, `--mpv-opt`, trailing files. @@ -1040,7 +1061,7 @@ pass and the audio-server/output-device writes do. Results arrive on max_volume, muted, speed, ao, loop_file, loop_playlist, hwdec, deinterlace, ui_scale, sub_visible, aspect, rotate, zoom, windowed_overlay, fullscreen_overlay, show_stats, show_queue, show_preview, open_mode, -low_quality, continuous, smooth_bar, theme, preset, media_controls, +low_quality, continuous, smooth_bar, slider_height, theme, preset, media_controls, mpv_opts. Written a second after the last `settings_changed()` (debounced) and once more after the window closes; `save_settings` skips the write when the file already holds the same text, so a key that saves nothing costs an @@ -1344,6 +1365,24 @@ Icons is the front of the portable-symbol fallback chain, Noto Sans Symbols 2 covers the marks an interface labels rows with and follows one machine-installed symbol face for the blocks it misses. +`assets/icons/` — the control strip's icons: the PNGs the widget's buttons +actually draw, and nothing else (`assets/` ships everywhere — CI zips it +beside the binary and vab packages it into the APK whole). The SVG sources +live in `scripts/icons/`, Google's filled +exports (`*_24dp_E3E3E3_FILL1_wght400_GRAD0_opsz24.svg`, fair license), and +are rendered by `scripts/make_pngs.sh` — ImageMagick (for now) renders the +24 px viewBox straight at 64 px and colorizes each raster to the palette +colour its role draws with (`text_main`, `#ffffff`, for every strip icon +today), because the exports carry their own `#e3e3e3` fill. The script keys +on the role table, not the export names: Google's names churn with every +fill/weight change, and the prefix lookup follows along. The drawing names +are the roles, not the export names: `play`, `pause`, `replay30`, +`forward30`, `volume_up`, `volume_off`. `libvendetta/draw.v`'s +`glyph_button` draws the PNGs where the bundle resolves (see §6.8 for the +search order and the `-d no_png_icons` glyph-only build); `volume_mute.png` +has no call site — it is the set's alternate mute glyph, generated alongside +so the bundle stays whole. + `libvendetta/mpv/win64/` — headers + an import library generated from the DLL's export table (recipe in its README) + a `.def` of the exported symbols; no runtime DLL (that ships beside the exe). diff --git a/assets/icons/forward30.png b/assets/icons/forward30.png new file mode 100644 index 0000000000000000000000000000000000000000..5e4ff8eb049f64ad238963139883e9092914d39f GIT binary patch literal 1117 zcmeAS@N?(olHy`uVBq!ia0y~yU~m9o4i*Lm28M*4p$rTxDxNNmAsP4HM*3!ix=YyV zzn^);m<^c9hcRLF0W_&o3h1cgX5gf zJ8CyGGHjMnwp(z%(Xwgl!g#IxNk2q%m>7;Q^2ooB`rvV9>W-a_Gn?*)ox1K_6ML_r zi#dZypkVrHe#e~&{7p-Zn(NrTSgO|@4f0@SSk|+oG3ns1tr0uFnS5w3TJovK;%VxG z-Wd+bO0S<4{h5;FTTrpoWY@kPwg_i|Ifof_x5Z}N)bRTK_3Yfc-y835 zP&@z2Aau^Rwayos7iXORER}OmMX<7$+d{8S^`pS!Pk*MIEk5#0bf?!VPv;l5=gTy2 zm;c+AQdriZ78%wuN&mU`#MgGh|9Beid$0SSawo#>oc$7?t^dkg6lNsszEUuMW8>bS zX=S_rS;E>#edSg7j&z1~WanY;!E@y4dEQ-0f4$?yf1y zet31Z3c_Ia1`D{no| z;>=-SQQthT-qV^*^8dz}U-P`rrLT~H=Kbr^R0ahRUN~HgfqMP=1A!$>RN7{_bA8mYn9`&IlInk zIQzZLo1wGZ)!J{; z-@G2QE1HKsUCU5rbMdij(UnJBc9I(>$zAhHIIUb;S^1Vl%;(?lN4df)M9!HpHWrj| zaCx^ f4ECu2!##%T<>y;VQ$puF1_i9AtDnm{r-UW|UE-Q4 literal 0 HcmV?d00001 diff --git a/assets/icons/replay30.png b/assets/icons/replay30.png new file mode 100644 index 0000000000000000000000000000000000000000..8931730137cde7516b5c4edbc4750f41342ab563 GIT binary patch literal 1108 zcmeAS@N?(olHy`uVBq!ia0y~yU~m9o4i*Lm28M*4p$rTx(w;7kAsP4HMtbM)21@+P z%MT0`R=OwkHIHTKLcNIsVrELQ3GPa}UN!A#auMY2=Uv&lVWJ0zP`RV)g%%dkweHTd z6r@5QU0vqU92R`%{GmI==Vw}e-cc;yd&GQp{kigg|Nozxb9|1mu+lH_%D;2$a~aus z{)r?k;JY3$BaDY_Kabf2mHdK&4;n9*tDm&uJGGUe`MXB4e;(_JwdyBt%S`fSl=P8z zad5jVyig?EiMh1HCbn3X(Dl8TDfU);R)&Y_hz-!N_e!g(a}{MR$*`x?B? zf8pHo$n9BbvcS8~x{WyrnPzDR&xxpfDe^X3w(ysTRphaUbB=P!J*qvHtK?VN+kS=h zhUyu?Gb-<%i+8u2e)qmpf$5G)0~`Nl|A+cJcuyoS-BE4$d~?+YcO!j=sRGa0xUGA( zi|kYS%rr^p(V9yeSobJ-{x}mjQ+&b%fzkx_&+AkkmYA_L{Em2gsP7s3O6gOZ6%V|Q z(zI>X{;SB)<9R+|+T8E^5-3@l^f0CWtj2u#Gj*~UpT9G zZcW27`ttAJ;LyKN7*|y|wy6$~AVcX6^{}o7t`olBOMu7kXc%1=i1+ zdg|=QJ)se<2j?>|xSYu}QFLXDZ%MWGyv@4C@x&IXkJk=~-V9@|e<5~FAfGWkAR$V+ zKrO(^nvL^y`_xVSjZ30_Z||3I;!s?|<6-aN_UoCh!p;t{^c8;(xFnWFXjY4FS#V^F z*Oa22-<2;o#;O!M=MG5o7{8s7_AeuD&+4VqLN1?Qee3NlUDxQR`QBpBxF23R z`)JE0@sG1Rz6O>1UD=&GCFFjJMZqtFe26^I4JMw)kYeO;*87{9n$H?}n(P(r3@(;E<8q`JZyPw;amw0UB z*-e*qzfZM0q~3KuyRUrRTe&PYd##0apVz!AQI6eQ*|%SGe*c_@&mLZ#r8&)?H)RfQ zPtm%k9fHqn@{$+ldgeV$`Ob6Cee*?&ZqZqv;C*xE0GdUC}>VKY|{wjXWQ>Ooc!Ga7;k9RhI zop!!}^UKD0)_0c0Y;auRta!>m_NYXs6T|(Bo!2uQCvRE&tv7+msH6Vh^|$qmnUDD& X?qFZ>uJO}ZP-)@m>gTe~DWM4feliRB literal 0 HcmV?d00001 diff --git a/assets/icons/volume_mute.png b/assets/icons/volume_mute.png new file mode 100644 index 0000000000000000000000000000000000000000..63b06aacc7e2ba623bf3e58574e643c9f9518680 GIT binary patch literal 275 zcmeAS@N?(olHy`uVBq!ia0y~yU~m9o4i*Lm28M*4p$rTRw>(`OLo)8Yy?K!Huz>)} zflw}kC1TGXGsQTq^3u#y5IAvp{}rJEW30S literal 0 HcmV?d00001 diff --git a/assets/icons/volume_off.png b/assets/icons/volume_off.png new file mode 100644 index 0000000000000000000000000000000000000000..d958ed3c8b3082723602f1258d7f5ff901d87ded GIT binary patch literal 877 zcmeAS@N?(olHy`uVBq!ia0y~yU~m9o4i*Lm28M*4p$rVnCY~;iAsP4H-aMNv>?pzh zz$l<*$>JcX=Zm6aM_?R&qc-drVP)qZuzeZI@BFo9-REY zK;f&-Bk|tMBVt^Q8IBVqZq09>akH{Ky*#bVe72lb^~^KRC(oRF_oNEztGpYRp8hju zoZZmN=5cZ65!QlrB65r;nw{d*CvIG?TK->Pt-!PZrVnzLCAgRic5PQ)63f8wqgz~J zBP&k=;|8@QhU*!&2yEs_H(+(X)?)IEQJ#T8C+QBG!;Mz|HI0jw{VsP96YMsNdOLXE?sqgde2VPk!_U<<08F$4Oa`PR6qb4mb zV+d}VT*TXMlY3|KtNoi;X9&(YuWC{#tQnRjy|43D_K90eJ{(32405}pEad;Vd?;JV zo!2DIa3@K%>O<_6*be3g{~Pj{r7X@|TE29bav{T?xZrcAU+{X{D_q?p#qVIt_33uO zjHf!?U((-2C6*sGp2B}-{{g$bq8lGRh%GcZv`a)j*)mn|w)ht9Z8MqnyWZsU)_LCM z5#Re-?t5ZYxxQ<7t=5`-K4KS z7+oyOtixWK=w4sFQbErvx?#=6G!*Re}aP1AFuRQ2(#JGx^j+Go68dm+zk`Q_59!6gnJk zB=4yGyY|+s*-RX_4WBa`+&ywXbZa)>2jvNh3)}v!VEF2?<#UN}Vc^|mvJR$Pe)I1B zbnH8>( z9dr7i;^=%}hJ?YzggyQHk50Tf^X|>Nx98rqoiaQ3-tE8pzt<9}7>XQDUO(iyP}hp_(F{S}#OY6_7JA>feKAw~IOBw48y?wD zdc*9=z+ijA^Pam8xAlA;hJXns128XI)aWVUGg%xT{@DV22J$>CyH_vkYNL*>6ICC|UE zN?>rbJ6ra7_L8d8B_<4hEPGcSh@X@;&vJXsLB>D!=Wkawhk6D+O8lOa$goFDBkc2* zPo7?36_>QbEg1d^`Oe$EGhw&WDVv9LHFX+F-6N{!bcfjAcsyO*rs2QQUGKENn`baw z5%|Jj{O0+os-hW;FQ#Yh|HO3t>gTjnSb{1V&puy<0 k_5Z7WPvHfeAM%<0urA@QF0T!FXbwu@p00i_>zopr0LNTfl>h($ literal 0 HcmV?d00001 diff --git a/libvendetta/draw.v b/libvendetta/draw.v index d690d4d..f0ccbe3 100644 --- a/libvendetta/draw.v +++ b/libvendetta/draw.v @@ -622,6 +622,9 @@ const bar_mute_w = 24.0 const bar_volume_w = bar_button_play_w + bar_button_seek_w * 2 + bar_gap * 2 - bar_mute_w - bar_gap const bar_time_pad = 20.0 const bar_time_gap = 5.0 +// The time labels sit this far below the row's centre: the font's digits ride +// high, so a centred label reads above the sliders beside it. +const bar_time_nudge = 1.0 const bar_seek_min_w = 60.0 const bar_volume_min_w = 40.0 const bar_time_min_w = 56.0 @@ -633,6 +636,15 @@ fn time_column_w(duration f64) f64 { return if duration >= 0 && duration < bar_time_hour { bar_time_short_w } else { bar_time_w } } +// slider_frame is a slider's rect for a track of height h: a track taller than +// the row grows the frame around its centre, so the whole track takes input. +fn slider_frame(row ui2.Rect, h f64) ui2.Rect { + if h <= row.height { + return row + } + return ui2.rect(row.x, row.y - (h - row.height) / 2, row.width, h) +} + // A negative slider thumb_size draws no thumb; the bars are bare tracks. const seek_thumb_hidden = -1.0 @@ -662,7 +674,6 @@ pub: // coordinates: seek back, play, seek forward, elapsed, seek slider, total, // mute, volume. The seek slider takes the leftover width; in a narrow strip // the volume slider shrinks first, then the time columns. -@[live] pub fn control_bar(b ui2.Rect, duration f64) ControlBar { bar_y := b.height - bar_height mid := bar_y + bar_height / 2 @@ -694,9 +705,10 @@ pub fn control_bar(b ui2.Rect, duration f64) ControlBar { seek_back := ui2.rect(bar_pad, mid - bar_button / 2, bar_button_seek_w, bar_button) toggle := ui2.rect(seek_back.x + bar_button_seek_w + bar_gap, mid - bar_button / 2, bar_button_play_w, bar_button) seek_forward := ui2.rect(toggle.x + bar_button_play_w + bar_gap, mid - bar_button / 2, bar_button_seek_w, bar_button) - elapsed := ui2.rect(seek_forward.x + bar_button_seek_w + outer_gap, mid - bar_row / 2, time_w, bar_row) + elapsed := ui2.rect(seek_forward.x + bar_button_seek_w + outer_gap, mid - bar_row / 2 + bar_time_nudge, + time_w, bar_row) seek := ui2.rect(elapsed.x + time_w + bar_time_gap, mid - bar_row / 2, seek_w, bar_row) - total := ui2.rect(seek.x + seek_w + bar_time_gap, mid - bar_row / 2, time_w, bar_row) + total := ui2.rect(seek.x + seek_w + bar_time_gap, mid - bar_row / 2 + bar_time_nudge, time_w, bar_row) mute := ui2.rect(total.x + time_w + outer_gap, mid - bar_row / 2, bar_mute_w, bar_row) volume := ui2.rect(mute.x + bar_mute_w + bar_gap, mid - bar_row / 2, volume_w, bar_row) return ControlBar{ @@ -764,6 +776,87 @@ pub fn (mut p Player) build(frame ui2.Rect) ui2.Element { return ui2.view(root_id, frame, ui2.BoxStyle{ transparent: true }, children) } +// The control strip's icons come from assets/icons: the Material Symbols the +// SVGs there export raster to PNGs at 64 px (stb_image, what ui2 draws button +// images through, cannot parse SVG). The keys are the roles the strip's +// buttons play, not the files' names, so an icon can change under them. +const strip_icon_names = ['play', 'pause', 'replay30', 'forward30', 'volume_up', 'volume_off'] + +// strip_icon_glyph names the Material glyph each icon role falls back to: a +// build with no raster icons (`-d no_png_icons`) or a layout without the +// assets bundle draws these, rendered from the fonts on every platform — +// a missing PNG would otherwise come out as ui2's outline box. +fn strip_icon_glyph(name string) string { + return match name { + 'play' { + 'symbol:play.fill' + } + 'pause' { + 'symbol:pause.fill' + } + 'replay30' { + 'symbol:gobackward.30' + } + 'forward30' { + 'symbol:goforward.30' + } + 'volume_up' { + 'symbol:speaker.wave.2.fill' + } + 'volume_off' { + 'symbol:speaker.slash.fill' + } + else { + '' + } + } +} + +// icon_bundle_dirs lists the places assets/icons ships: beside the executable +// (the release layout zips assets/ next to the binary), in the module tree the +// build came from, and the working directory. The first hit wins. +fn icon_bundle_dirs() []string { + return [ + os.join_path(os.dir(os.executable()), 'assets', 'icons'), + os.join_path(@VMODROOT, 'assets', 'icons'), + os.join_path(os.getwd(), 'assets', 'icons'), + ] +} + +// resolve_strip_icons maps the icon roles to what the strip's buttons draw: +// each bundled PNG's path, or '' where this layout has none (the buttons then +// fall to the glyphs). `-d no_png_icons` compiles the resolution out entirely, +// leaving the glyphs alone to carry the strip. +fn resolve_strip_icons() map[string]string { + mut icons := map[string]string{} + $if no_png_icons ? { + return icons + } $else { + for name in strip_icon_names { + icons[name] = '' + for dir_path in icon_bundle_dirs() { + bundle_path := os.join_path(dir_path, name + '.png') + if os.is_file(bundle_path) { + icons[name] = bundle_path + break + } + } + } + return icons + } +} + +// strip_icon is the string the button for `name` draws: the bundled PNG's +// path, or the Material glyph the old build carried when the role has none. +fn (p &Player) strip_icon(name string) string { + if icon := p.icon_files[name] { + if icon.len > 0 { + return icon + } + } + return strip_icon_glyph(name) +} + // build_controls returns the control elements in the strip's coordinates. // They are appended one at a time: the checker panics on array literals that // mix many of these constructor calls. @@ -790,18 +883,20 @@ fn build_controls(p &Player, bar ControlBar) []ui2.Element { ...label_text align: .right } + // The seek and volume tracks share one height, kept inside the strip. + slider_h := math.min(math.max(p.cfg.slider_h, 1.0), bar_height) mut children := []ui2.Element{} - children << glyph_button('vd_seek_back', bar.seek_back, button_box_seek, button_text, 'symbol:gobackward.30') + children << glyph_button('vd_seek_back', bar.seek_back, button_box_seek, button_text, p.strip_icon('replay30')) children << glyph_button('vd_toggle', bar.toggle, button_box, button_text, if p.paused { - 'symbol:play.fill' + p.strip_icon('play') } else { - 'symbol:pause.fill' + p.strip_icon('pause') }) - children << glyph_button('vd_seek_forward', bar.seek_forward, button_box_seek, button_text, 'symbol:goforward.30') + children << glyph_button('vd_seek_forward', bar.seek_forward, button_box_seek, button_text, p.strip_icon('forward30')) children << ui2.label('vd_elapsed', fmt_time(p.pos), bar.elapsed, elapsed_text) children << ui2.slider(ui2.SliderConfig{ id: 'vd_seek' - frame: bar.seek + frame: slider_frame(bar.seek, slider_h) min: 0 max: if p.duration > 0 { p.duration } else { 1.0 } // The glide's position, not the raw report: a rebuild lands between @@ -813,14 +908,14 @@ fn build_controls(p &Player, bar ControlBar) []ui2.Element { style: ui2.SliderStyle{ track_color: p.palette.slider_track value_track_color: p.palette.slider_value - track_width: 10.0 + track_width: slider_h thumb_size: seek_thumb_hidden } }) children << ui2.label('vd_total', fmt_time(p.duration), bar.total, label_text) children << ui2.slider(ui2.SliderConfig{ id: 'vd_volume' - frame: bar.volume + frame: slider_frame(bar.volume, slider_h) min: 0 max: 100 value: p.volume @@ -833,7 +928,7 @@ fn build_controls(p &Player, bar ControlBar) []ui2.Element { } else { p.palette.slider_value } - track_width: 10.0 + track_width: slider_h thumb_size: seek_thumb_hidden } }) @@ -841,16 +936,17 @@ fn build_controls(p &Player, bar ControlBar) []ui2.Element { bg: p.palette.btn_mute radius: 6 opacity: 0.8 - }, button_text, if p.muted { 'symbol:speaker.slash.fill' } else { 'symbol:speaker.wave.2.fill' }) + }, button_text, if p.muted { p.strip_icon('volume_off') } else { p.strip_icon('volume_up') }) return children } -// glyph_button builds an image-only control button: the control line uses -// symbol glyphs instead of text, sized by the button's rect and tinted by its -// style. -fn glyph_button(id string, frame ui2.Rect, box_style ui2.BoxStyle, text_style ui2.TextStyle, symbol string) ui2.Element { +// glyph_button builds an image-only control button from the string the icon +// resolution hands it: a file path draws the rastered PNG as it is (no tint — +// a theme cannot restyle it), a 'symbol:' name draws the glyph tinted by the +// button's text style. +fn glyph_button(id string, frame ui2.Rect, box_style ui2.BoxStyle, text_style ui2.TextStyle, icon string) ui2.Element { return ui2.Element{ ...ui2.button(id, '', frame, box_style, text_style) - image_path: symbol + image_path: icon } } diff --git a/libvendetta/lib.v b/libvendetta/lib.v index 18ff95d..94daa5e 100644 --- a/libvendetta/lib.v +++ b/libvendetta/lib.v @@ -77,6 +77,9 @@ pub mut: seek_step f64 = 30 // How far one wheel or arrow key step moves the volume. volume_step f64 = 5 + // The height of the seek and volume tracks, in layout pixels: 1 up to the + // strip's 30. Read on every build. + slider_h f64 = 10 // Whether mpv's render call waits out each frame's target display time. // Disabling it trades presentation pacing for a snappier UI thread. block_target_time bool = true @@ -178,6 +181,11 @@ mut: // relay spawns, released on destroy: two embedded players then wake only // their own relays instead of trading frame-rate asks. wake_slot int = -1 + // The strip's icon roles (play, pause, the seek steps, the volume states) + // resolved once in setup: the bundled PNG's path under assets/icons, or '' + // where the build carries none (`-d no_png_icons`, or no bundle on this + // layout) and the glyph fallback takes over. Builds read this. + icon_files map[string]string } // Observed property ids. The widget tracks the playback properties its @@ -283,6 +291,10 @@ pub fn new(cfg Config) &Player { // larger struct than the widget. It mirrors the standalone player's options. pub fn (mut p Player) setup(cfg Config) { p.cfg = cfg + // The strip's icons resolve before any build reads them: a layout without + // the assets bundle leaves the roles empty, and draw.v's glyphs carry the + // buttons instead. + p.icon_files = resolve_strip_icons() register_android_vm() p.mpv_ctx = mpv.create() if p.mpv_ctx == unsafe { nil } { diff --git a/scripts/icons/forward_30_24dp_E3E3E3_FILL1_wght400_GRAD0_opsz24.svg b/scripts/icons/forward_30_24dp_E3E3E3_FILL1_wght400_GRAD0_opsz24.svg new file mode 100644 index 0000000..0e4c2a9 --- /dev/null +++ b/scripts/icons/forward_30_24dp_E3E3E3_FILL1_wght400_GRAD0_opsz24.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/scripts/icons/pause_24dp_E3E3E3_FILL1_wght400_GRAD0_opsz24.svg b/scripts/icons/pause_24dp_E3E3E3_FILL1_wght400_GRAD0_opsz24.svg new file mode 100644 index 0000000..94b7a9e --- /dev/null +++ b/scripts/icons/pause_24dp_E3E3E3_FILL1_wght400_GRAD0_opsz24.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/scripts/icons/play_arrow_24dp_E3E3E3_FILL1_wght400_GRAD0_opsz24.svg b/scripts/icons/play_arrow_24dp_E3E3E3_FILL1_wght400_GRAD0_opsz24.svg new file mode 100644 index 0000000..fa44af8 --- /dev/null +++ b/scripts/icons/play_arrow_24dp_E3E3E3_FILL1_wght400_GRAD0_opsz24.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/scripts/icons/replay_30_24dp_E3E3E3_FILL1_wght400_GRAD0_opsz24.svg b/scripts/icons/replay_30_24dp_E3E3E3_FILL1_wght400_GRAD0_opsz24.svg new file mode 100644 index 0000000..3e7e45e --- /dev/null +++ b/scripts/icons/replay_30_24dp_E3E3E3_FILL1_wght400_GRAD0_opsz24.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/scripts/icons/volume_mute_24dp_E3E3E3_FILL1_wght400_GRAD0_opsz24.svg b/scripts/icons/volume_mute_24dp_E3E3E3_FILL1_wght400_GRAD0_opsz24.svg new file mode 100644 index 0000000..34cbf30 --- /dev/null +++ b/scripts/icons/volume_mute_24dp_E3E3E3_FILL1_wght400_GRAD0_opsz24.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/scripts/icons/volume_off_24dp_E3E3E3_FILL1_wght400_GRAD0_opsz24.svg b/scripts/icons/volume_off_24dp_E3E3E3_FILL1_wght400_GRAD0_opsz24.svg new file mode 100644 index 0000000..6439f7c --- /dev/null +++ b/scripts/icons/volume_off_24dp_E3E3E3_FILL1_wght400_GRAD0_opsz24.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/scripts/icons/volume_up_24dp_E3E3E3_FILL1_wght400_GRAD0_opsz24.svg b/scripts/icons/volume_up_24dp_E3E3E3_FILL1_wght400_GRAD0_opsz24.svg new file mode 100644 index 0000000..311a731 --- /dev/null +++ b/scripts/icons/volume_up_24dp_E3E3E3_FILL1_wght400_GRAD0_opsz24.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/scripts/make_pngs.sh b/scripts/make_pngs.sh new file mode 100755 index 0000000..64d4a87 --- /dev/null +++ b/scripts/make_pngs.sh @@ -0,0 +1,63 @@ +#!/bin/sh +# make_pngs.sh regenerates the bundled PNGs in assets/icons from the SVG +# sources in scripts/icons. assets/ is what ships — CI zips it beside the +# binary and vab packages it into the APK whole — so its tree stays +# runtime-only: the sources live beside this script, and nothing but the +# PNGs ends up bundled. +# +# Each entry maps one source SVG (its export name found by prefix; Google's +# export names churn with every fill/weight change) to the PNG name the +# widget's buttons draw — the role, spelled in libvendetta/draw.v as +# strip_icon_names — and the colour the role draws with in the compiled-in +# vinix-dark palette (text_main, #ffffff, for every strip icon today). The +# colour step exists because the exports carry their own #e3e3e3 fill: raster +# colorization makes the bundle conform to the palette no matter what colour +# the export tool is pointed at. +# +# ImageMagick is the rasterizer for now; it renders the 24 px viewBox +# straight at 64 px (density 96 * 64/24 = 256), which is what the buttons and +# their 2x ui scale need. Swap the tool at the `one` function below if the +# rasterizer changes; the role and colour tables remain the stable part. +set -eu + +here=$(cd "$(dirname "$0")" && pwd) +svg_dir="$here/icons" +out_dir="$here/../assets/icons" + +entries='play_arrow play #ffffff +pause pause #ffffff +replay_30 replay30 #ffffff +forward_30 forward30 #ffffff +volume_up volume_up #ffffff +volume_mute volume_mute #ffffff +volume_off volume_off #ffffff' + +if command -v magick >/dev/null 2>&1; then + rasterizer=magick +elif command -v convert >/dev/null 2>&1; then + rasterizer=convert +else + echo 'make_pngs: ImageMagick is missing: install magick (or convert) or replace it in one() here' >&2 + exit 1 +fi + +one() { + # one : raster at 64 px from the SVG's 24 + # px viewBox, colourize the raster to the palette colour keeping alpha, + # and strip the export metadata the PNG bundle does not carry. + svg=$(ls "$svg_dir/${1}"_24dp_*.svg 2>/dev/null | head -n 1) + if [ -z "$svg" ]; then + echo "make_pngs: no *_24dp_*.svg match for prefix ${1} under ${svg_dir}" >&2 + exit 1 + fi + $rasterizer -background none -density 256 "$svg" \ + -fill "$3" -colorize 100 -strip "$out_dir/$2.png" +} + +mkdir -p "$out_dir" +echo "$entries" | while read -r prefix png colour; do + [ -z "$prefix" ] && continue + one "$prefix" "$png" "$colour" +done + +echo 'make_pngs: bundle refreshed' diff --git a/src/main.v b/src/main.v index 0e959e4..26fae34 100644 --- a/src/main.v +++ b/src/main.v @@ -78,6 +78,7 @@ struct Config { no_preview bool @[long: 'no-preview'; xdoc: 'Start without the seek-bar hover preview, and never create the hidden thumbnail mpv instance (saves memory on low-end machines)'] smooth_bar bool @[long: 'smooth-bar'; xdoc: 'Start with the smooth seek bar: while the file plays, the UI redraws at the display rate so the bar glides between mpv\'s position reports'] no_smooth_bar bool @[long: 'no-smooth-bar'; xdoc: 'Start with strictly asked redraws only: the bar steps to each position report mpv makes'] + slider_height f64 = -1 @[long: 'slider-height'; xdoc: 'Height of the seek and volume bars in pixels, 1 to 30 (default: the saved setting)'] media_controls bool @[long: 'media-controls'; xdoc: 'Expose the desktop media controls (MPRIS on the session bus) (default: the saved setting)'] no_media_controls bool @[long: 'no-media-controls'; xdoc: 'Do not expose the desktop media controls'] ao string @[long: 'ao'; xdoc: 'Audio server: auto (mpv\'s autoprobing) or a named output, e.g. pipewire, pulse, alsa (default: the saved audio server)'] diff --git a/src/settings.v b/src/settings.v index 15768f0..9ad168b 100644 --- a/src/settings.v +++ b/src/settings.v @@ -45,6 +45,9 @@ pub mut: // between mpv's position reports and redraws the window at the display rate // while it plays. smooth_bar bool + // The height of the seek and volume bars; 0, as in a file saved before the + // setting existed, keeps the widget's default. + slider_height f64 // The window title's two halves, shown while set (both default on): // '(paused)' while playback is paused, then the playing file's name. show_playback_status bool = true @@ -179,6 +182,7 @@ fn (p &Player) collect_settings() Settings { low_quality: p.low_quality continuous: p.continuous smooth_bar: p.smooth_bar + slider_height: p.cfg.slider_h show_playback_status: p.show_playback_status show_title_filename: p.show_title_filename theme: p.theme_name @@ -272,6 +276,9 @@ fn (mut p Player) apply_settings(s Settings) { // The smooth bar needs no start-up work: its glide arms itself from the // first time-pos report, and the chain dies on a pause by itself. p.smooth_bar = s.smooth_bar + if s.slider_height > 0 { + p.cfg.slider_h = s.slider_height + } // The title needs none either: the two rows only reshape what the // property events write, and the window opens before anything plays. p.show_playback_status = s.show_playback_status @@ -343,6 +350,9 @@ fn (mut p Player) apply_cli(cfg Config) { } else if cfg.smooth_bar { p.smooth_bar = true } + if cfg.slider_height > 0 { + p.cfg.slider_h = cfg.slider_height + } if cfg.volume >= 0 { p.volume = cfg.volume if p.volume > p.max_volume { -- 2.56.1