me

/

vendetta Public
17 commits 0 issues 0 pull requests 1 contributor Discussions Projects Snippets LOC history Platform CI

properly handle -d no_png_icons

diviocity committed last Nov 1 · ab986e3d9fcaf9fb033a45a21415139923ea8c83 View patch
Unverified signature 1 files changed +17 -8
libvendetta/draw.v +17 -8

@@ -823,6 +823,22 @@ fn icon_bundle_dirs() []string {

823823 ]

824824}

825825

826+// bundled_icon is the path of a PNG in assets/icons, or '' where the layout

827+// ships none or the build compiled the icons out.

828+pub fn bundled_icon(name string) string {

829+ $if no_png_icons ? {

830+ return ''

831+ } $else {

832+ for dir_path in icon_bundle_dirs() {

833+ bundle_path := os.join_path(dir_path, name + '.png')

834+ if os.is_file(bundle_path) {

835+ return bundle_path

836+ }

837+ }

838+ return ''

839+ }

840+}

841+

826842// resolve_strip_icons maps the icon roles to what the strip's buttons draw:

827843// each bundled PNG's path, or '' where this layout has none (the buttons then

828844// fall to the glyphs). `-d no_png_icons` compiles the resolution out entirely,

@@ -833,14 +849,7 @@ fn resolve_strip_icons() map[string]string {

833849 return icons

834850 } $else {

835851 for name in strip_icon_names {

836- icons[name] = ''

837- for dir_path in icon_bundle_dirs() {

838- bundle_path := os.join_path(dir_path, name + '.png')

839- if os.is_file(bundle_path) {

840- icons[name] = bundle_path

841- break

842- }

843- }

852+ icons[name] = bundled_icon(name)

844853 }

845854 return icons

846855 }