From 1e8bb56b7c493ac04f0861807df18c253f5306be Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Sat, 4 Mar 2023 22:07:59 -0500 Subject: [PATCH] Added small icons to default theme --- theme/assets/wintergreen-icons-small.png | Bin 1752 -> 1832 bytes theme/default.go | 76 ++++++++++++++++++++++- theme/theme.go | 19 +++--- theme/wrapped.go | 4 +- 4 files changed, 86 insertions(+), 13 deletions(-) diff --git a/theme/assets/wintergreen-icons-small.png b/theme/assets/wintergreen-icons-small.png index cd65704ed14d81d174b1d70dcc5fce8f457143a1..a6ebc9318b764fa3ce170fc3b227d03695de8114 100644 GIT binary patch literal 1832 zcmV+@2iN$CP)f>8|NJda2-NihspF}9b+$s2z?RyZhaL(SdKADNZWRnKXzD`v6SsWI2iv+u5& zBH3DUl2zsIqLZFJKV9A7SfPqV>5Dxw#(z%!`1|~x=Mg-=ldl))Meqm@pUXKCALJRH zBcBY94a~EA5aVKbNWhV*RaBKLNW7g+2J(>>&d8Z8#*#B6&|1+t$rlI^&CO=p*Vz^( zIY&&BNwL&o?V%QljzkbGK%bfo!U>_`#bQBAoi; zkbvUPF!M*{%15ye)7dsk+;vjzIs6R3@g5)@E7m%#Wh!vdvJf~-Kfl3;GnCKLS8yH`nqG{#ql1=c2({R#mx(Of#2 zaKh3FJ`g1dt_`1{!s;YLf+Yz8k5kf#opdk#3`<$@+o1;IZKinBW`FF{87w@*X2N*H z?Tkl!P=Epypa2CZKmiI+fC3cw{{<{_-;dhCBTq;PDna=6GUJ}mSv#b#jbJ0_axNFe zE@xUg3xDV`ieD#J4glJUR@JI-foGb(HpzGJM4jCo-yP3zyW?uT4@`BtTF0~+!Qz2~ zXHl)I^_3R%FTPCGj(yKz5^POuO=Os*To>Ix%`@Gp#2cT_)Q|6u9{@g^QA_GS0T6`cG9*~~ z&Am(aE^RGrEkrAY#a=`w3Dl|iz{bhi@kTKI^CuH@)HQW;r8Tz{EnHcuo%@O;AV+Bt zZK6$U`>(%f1p9!NxcK?W{}S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Ijz-3z_kDKt&4jz^He2XK8zd4u4E2P5FsDH&q*% z2xcx$l#aea3K|dQz+7YD$4@GB2T&rXe%tvM0?u;8bQ3Ae-PnME#NHK!#EHa-hL$?0 zQi}})z|qzpJ8{t$xMhX(iIEA8yWqFGr15Eg+TU!P9)7mxPaXr2PL~Xy4dn2We)^0h zlMAK6N~cRHn1W6H#s*t~B}cuIM{g`8&#ov$-%HJL++2TYi#>;#y)#?Yf!SHCfctlz zoaomZ^}aB{|@H5LF7-fE6}w#MbBlN=|u#FF9^0tT)~$GyP9;OM7eE3V{k; z6c-!VXJVKjH2(G1oxFs8uwRguET&^VRD%_0K{a48cnQ z3%Gy_yi?%cI}5@3@J5AGlf~q-64OQ-6@&(D&>FAtCPXnJ&~E9x)r z)B?YpQv{W20hGk#hCDwsKV%?4U@Wu9YdBL4!2pqzu>wv_Dm9my4wpW{fG+A{+Dw~9 zK;y$cqnhWntV*@NY9n9@F9D|}2$4e3R?si%7eO7=4MyX6x}xFbNgnICg@DUA-{I7x zQX2m_ugfb6zyzk@)A%5zW>j9IB#-Gg2Z>}H12_-ps4S&i5;=|~|4~4ta~_FPDV&>5 z`cLjBl5B;p&^R?MY_XW>yxssU(CR2GfCU4o;^<%lcl>uSVE7ClRw(aBzsn1Q9RMjP zHKn#1VErrtE_Ifam&eOn>PZDDbe1%ti%MQ8uU?W3jN!9Hr7Y*l`w>vq8=az0BaNIc zuP)l~8>na@Tn$&1kQ`c3z`%>p3-)#BHM>?@#i%#xRnl@AD@f~YU@^UzZtiOCT4QkF zA}&%1DIr}ng?hg|xZ=7ZVTCMq4QsHt7*bj8iePO3UjI<=IRoq^ zVF4(&jNb`0P>9w#QpKqfdoZZY>a_W(RNYzhw!I|k5q_aRdVW*h@S zjy+TjbDU#< 0x8000 && (r + g + b) / 3 < 0x8000 { + icon.data[dstIndex] = true + } + dstIndex ++ + }} + return +} + func init () { defaultAtlasImage, _, _ := image.Decode(bytes.NewReader(defaultAtlasBytes)) defaultAtlas = canvas.FromImage(defaultAtlasImage) @@ -64,6 +112,20 @@ func init () { atlasCol(11, artist.Inset { 3, 3, 5, 3 }) // PatternRaised: fun.sharpKey atlasCol(12, artist.Inset { 3, 3, 4, 3 }) + + // set up small icons + defaultIconsSmallAtlasImage, _, _ := image.Decode ( + bytes.NewReader(defaultIconsSmallAtlasBytes)) + bounds := defaultIconsSmallAtlasImage.Bounds() + point := image.Point { } + iconIndex := 0 + for point.Y = bounds.Min.Y; point.Y < bounds.Max.Y; point.Y += 16 { + for point.X = bounds.Min.X; point.X < bounds.Max.X; point.X += 16 { + defaultIconsSmall[iconIndex] = binaryIconFrom ( + defaultIconsSmallAtlasImage, + image.Rect(0, 0, 16, 16).Add(point)) + iconIndex ++ + }} } // Default is the default theme. @@ -84,9 +146,17 @@ func (Default) FontFace (style FontStyle, size FontSize, c Case) font.Face { } // Icon returns an icon from the default set corresponding to the given name. -func (Default) Icon (string, IconSize, Case) artist.Icon { - // TODO - return nil +func (Default) Icon (id Icon, size IconSize, c Case) artist.Icon { + if size == IconSizeLarge { + // TODO + return nil + } else { + if id < 0 || int(id) >= len(defaultIconsSmall) { + return nil + } else { + return defaultIconsSmall[id] + } + } } // MimeIcon returns an icon from the default set corresponding to the given mime. diff --git a/theme/theme.go b/theme/theme.go index f3341ab..2db0276 100644 --- a/theme/theme.go +++ b/theme/theme.go @@ -78,10 +78,11 @@ type Icon int; const ( IconLibraries IconDownloads IconRepositories - IconSettings + IconSettings) +const ( // Object icons - IconFile = iota + 0x80 + IconFile Icon = iota + 0x80 IconDirectory IconPopulatedDirectory @@ -127,8 +128,9 @@ type Icon int; const ( IconParallelPort IconSerialPort IconPS2Port - IconMonitorPort + IconMonitorPort) +const ( // Action icons IconOpen = iota + 0x100 IconSave @@ -166,17 +168,18 @@ type Icon int; const ( IconHistory IconYes - IconNo + IconNo) +const ( // Status icons IconInformation = iota + 0x180 IconQuestion IconWarning - IconError + IconError) +const ( // Tool icons - -) + ) // Hints specifies rendering hints for a particular pattern. Elements can take // these into account in order to gain extra performance. @@ -197,7 +200,7 @@ type Theme interface { FontFace (FontStyle, FontSize, Case) font.Face // Icon returns an appropriate icon given an icon name, size, and case. - Icon (string, IconSize, Case) artist.Icon + Icon (Icon, IconSize, Case) artist.Icon // Icon returns an appropriate icon given a file mime type, size, and, // case. diff --git a/theme/wrapped.go b/theme/wrapped.go index a2c8706..f535dcb 100644 --- a/theme/wrapped.go +++ b/theme/wrapped.go @@ -21,9 +21,9 @@ func (wrapped Wrapped) FontFace (style FontStyle, size FontSize) font.Face { } // Icon returns an appropriate icon given an icon name. -func (wrapped Wrapped) Icon (name string, size IconSize) artist.Icon { +func (wrapped Wrapped) Icon (id Icon, size IconSize) artist.Icon { real := wrapped.ensure() - return real.Icon(name, size, wrapped.Case) + return real.Icon(id, size, wrapped.Case) } // MimeIcon returns an appropriate icon given file mime type.