Skip to content

Commit 373b1d9

Browse files
committed
- version 0.8.9.26 (0.9-beta23)
- finalising calculated background color - updating docs
1 parent 2dd8e48 commit 373b1d9

15 files changed

+359
-64
lines changed

Changelog

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
2022-08-14 s-n-g
1+
2022-08-28 s-n-g
22
* version 0.8.9.26 (0.9-beta23)
3+
* adding calculated messages windows color
4+
* adding "Calculated Color" config option
35
* Windows installation will try to install 7-Zip, if not
46
already installed
57

README.html

+54-2
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ <h2 id="table-of-contents">Table of Contents <span style="padding-left: 10px;"><
101101
<li><a href="#pyradio-themes">PyRadio Themes</a>
102102
<ul>
103103
<li><a href="#css-color-themes-restrictions">CSS color themes restrictions</a></li>
104+
<li><a href="#secondary-windows-background">Secondary windows background</a>
105+
<ul>
106+
<li><a href="#theme-defined-secondary-windows-color">Theme defined secondary windows color</a></li>
107+
<li><a href="#calculated-secondary-windows-color">Calculated secondary windows color</a></li>
108+
</ul></li>
104109
<li><a href="#user-themes">User themes</a>
105110
<ul>
106111
<li><a href="#converting-old-themes">Converting old themes</a></li>
@@ -174,8 +179,10 @@ <h2 id="requirements">Requirements <span style="padding-left: 10px;"><sup style=
174179
<h2 id="changelog">Changelog <span style="padding-left: 10px;"><sup style="font-size: 50%"><a href="#" title="Go to top of the page">Top</a></sup></span></h2>
175180
<pre style="height: 200px;">
176181

177-
2022-08-14 s-n-g
182+
2022-08-28 s-n-g
178183
* version 0.8.9.26 (0.9-beta23)
184+
* adding calculated messages windows color
185+
* adding "Calculated Color" config option
179186
* Windows installation will try to install 7-Zip, if not
180187
already installed
181188

@@ -1314,7 +1321,7 @@ <h2 id="pyradio-themes">PyRadio Themes <span style="padding-left: 10px;"><sup st
13141321
# Message window border foreground and background.
13151322
# The background color can be left unset.
13161323
# Please refer to the following link for more info
1317-
# https://github.com/coderholic/pyradio#calculated-colors
1324+
# https://github.com/coderholic/pyradio#secondary-windows-background
13181325
#
13191326
Messages Border #a3b367
13201327

@@ -1343,6 +1350,51 @@ <h3 id="css-color-themes-restrictions">CSS color themes restrictions</h3>
13431350
<br />
13441351
This means that, in order for a theme change to take full effect, <strong>PyRadio</strong> will have to be restarted.</p></li>
13451352
</ol>
1353+
<h3 id="secondary-windows-background">Secondary windows background</h3>
1354+
<p>Secondary windows (such as messages, questions, the “<em>Theme Selection window</em>” the “<em>Encoding Selection window</em>”, etc.) originally use the same background color as the “<em>Main window</em>”.</p>
1355+
<p>It is now possible to use a different background color for these windows, to get better visual result.</p>
1356+
<p>There are two way to do that:</p>
1357+
<ol type="1">
1358+
<li><p>Defined in a theme</p></li>
1359+
<li><p>Using a calculated color</p></li>
1360+
</ol>
1361+
<h4 id="theme-defined-secondary-windows-color">Theme defined secondary windows color</h4>
1362+
<p>Themes have the following entry</p>
1363+
<pre># Message window border foreground and background.
1364+
# The background color can be left unset.
1365+
# Please refer to the following link for more info
1366+
# https://github.com/coderholic/pyradio#secondary-windows-background
1367+
#
1368+
Messages Border #a3b367</pre>
1369+
<p>It is possible to define a background color as well, like so</p>
1370+
<pre>Messages Border #a3b367 #F5DBDE</pre>
1371+
<p>In this case, this color will be used as the Secondary Windows background color.</p>
1372+
<p>Although one can use any color here, it is recommended to follow these guidelines for best visual result:</p>
1373+
<ol type="1">
1374+
<li>The color should be 1-20% lighter or darker than the “<em>Stations Background</em>” color setting of the theme.<br />
1375+
<br />
1376+
One can use <a target="_blank" href="http://www.workwithcolor.com/hsl-color-picker-01.htm">this page</a> (or a similar one) to insert the base color and adjust the “<em>L</em>” component as needed.<br />
1377+
<br />
1378+
A terminal alternative is <a target="_blank" href="https://github.com/sharkdp/pastel">pastel</a>, which can be used like so:</li>
1379+
</ol>
1380+
<pre>pastel color &#39;#fbf1f2&#39; # show color info
1381+
pastel lighten .1 &#39;#fbf1f2&#39; # color lightened by 10%
1382+
pastel darken .1 &#39;#fbf1f2&#39; # color darkened by 10%</pre>
1383+
<ol start="2" type="1">
1384+
<li>If the “<em>Stations Background</em>” color is dark, create a lighter version of it; if it’s light, create a darker version of it.<br />
1385+
<br />
1386+
This is just a recomenration, though; just get a color that combines well with existing ones (border foreground, stations foreground and active station).</li>
1387+
</ol>
1388+
<p>This information is actually relevant to creating a new <strong>PyRadio</strong> theme, but it’s very important in order to understand how the calculated background color works.</p>
1389+
<h4 id="calculated-secondary-windows-color">Calculated secondary windows color</h4>
1390+
<p><strong>PyRadio</strong> will use the same background color for all windows by default, provided that the theme used does not define a “<em>Messages Border</em>” background color.</p>
1391+
<p>In order to use a “<em>Messages Border</em>” background color different than the “<em>Stations background</em>” color, when “<em>Messages Border</em>” background color is not defined in the selected theme, a config option is available; “<strong>Calculated color</strong>”.</p>
1392+
<p>This config option takes a value that’s between 0 and 0.2.</p>
1393+
<p>If it is 0, no color change will occur.</p>
1394+
<p>Otherwise, the value acts as a percentage (a <strong>factor</strong>), which indicates how much the luminance of the “<em>Stations background</em>” color will change to produce the new background color.</p>
1395+
<p>This is how this works: <strong>PyRadio</strong> will calculate the “<em>Stations background</em>” color perceived brightness, which will indicate whether the color is dark or light. Then depending on that, will add or subtract <strong>factor</strong> percent from its luminance value.</p>
1396+
<p>Finally, a check will be made to see if this color is close to “<em>Messages Border</em>” foreground color, and re-adjusted as possible.</p>
1397+
<p style="margin: 1.5em 4em 0 4em; text-indent: -2.5em;"><strong>Note:</strong> When a calculated background color is used, pressing “<strong>~</strong>” (<strong>tilde</strong>) will toggle it on and off. This setting will be valid until <strong>PyRadio</strong> terminates, or a new theme is loaded.</p>
13461398
<h3 id="user-themes">User themes</h3>
13471399
<p>Users can easiliy create their own themes, using for example <a target="_blank" href="https://www.cssportal.com/css3-color-names/">CSS color names</a> as a resource, and</p>
13481400
<ol type="1">

README.md

+77-1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ Ben Dowling - [https://github.com/coderholic](https://github.com/coderholic)
4848
* [Copying and pasting - Registers](#copying-and-pasting---registers)
4949
* [PyRadio Themes](#pyradio-themes)
5050
* [CSS color themes restrictions](#css-color-themes-restrictions)
51+
* [Secondary windows background](#secondary-windows-background)
52+
* [Theme defined secondary windows color](#theme-defined-secondary-windows-color)
53+
* [Calculated secondary windows color](#calculated-secondary-windows-color)
5154
* [User themes](#user-themes)
5255
* [Converting old themes](#converting-old-themes)
5356
* [Using transparency](#using-transparency)
@@ -794,7 +797,7 @@ PyRadio URL #a3b367
794797
# Message window border foreground and background.
795798
# The background color can be left unset.
796799
# Please refer to the following link for more info
797-
# https://github.com/coderholic/pyradio#calculated-colors
800+
# https://github.com/coderholic/pyradio#secondary-windows-background
798801
#
799802
Messages Border #a3b367
800803
@@ -832,6 +835,79 @@ These terminal will default to the old "**dark**" theme, displaying whatever col
832835
\
833836
This means that, in order for a theme change to take full effect, **PyRadio** will have to be restarted.
834837

838+
### Secondary windows background
839+
840+
Secondary windows (such as messages, questions, the "*Theme Selection window*" the "*Encoding Selection window*", etc.) originally use the same background color as the "*Main window*".
841+
842+
It is now possible to use a different background color for these windows, to get better visual result.
843+
844+
There are two way to do that:
845+
846+
1. Defined in a theme
847+
848+
2. Using a calculated color
849+
850+
#### Theme defined secondary windows color
851+
852+
Themes have the following entry
853+
854+
```
855+
# Message window border foreground and background.
856+
# The background color can be left unset.
857+
# Please refer to the following link for more info
858+
# https://github.com/coderholic/pyradio#secondary-windows-background
859+
#
860+
Messages Border #a3b367
861+
```
862+
863+
It is possible to define a background color as well, like so
864+
865+
866+
```
867+
Messages Border #a3b367 #F5DBDE
868+
```
869+
870+
In this case, this color will be used as the Secondary Windows background color.
871+
872+
Although one can use any color here, it is recommended to follow these guidelines for best visual result:
873+
874+
1. The color should be 1-20% lighter or darker than the "*Stations Background*" color setting of the theme. \
875+
\
876+
One can use [this page](http://www.workwithcolor.com/hsl-color-picker-01.htm) (or a similar one) to insert the base color and adjust the "*L*" component as needed. \
877+
\
878+
A terminal alternative is [pastel](https://github.com/sharkdp/pastel), which can be used like so:
879+
880+
```
881+
pastel color '#fbf1f2' # show color info
882+
pastel lighten .1 '#fbf1f2' # color lightened by 10%
883+
pastel darken .1 '#fbf1f2' # color darkened by 10%
884+
```
885+
886+
887+
2. If the "*Stations Background*" color is dark, create a lighter version of it; if it's light, create a darker version of it. \
888+
\
889+
This is just a recomenration, though; just get a color that combines well with existing ones (border foreground, stations foreground and active station).
890+
891+
This information is actually relevant to creating a new **PyRadio** theme, but it's very important in order to understand how the calculated background color works.
892+
893+
#### Calculated secondary windows color
894+
895+
**PyRadio** will use the same background color for all windows by default, provided that the theme used does not define a "*Messages Border*" background color.
896+
897+
In order to use a "*Messages Border*" background color different than the "*Stations background*" color, when "*Messages Border*" background color is not defined in the selected theme, a config option is available; "**Calculated color**".
898+
899+
This config option takes a value that's between 0 and 0.2.
900+
901+
If it is 0, no color change will occur.
902+
903+
Otherwise, the value acts as a percentage (a **factor**), which indicates how much the luminance of the "*Stations background*" color will change to produce the new background color.
904+
905+
This is how this works: **PyRadio** will calculate the "*Stations background*" color perceived brightness, which will indicate whether the color is dark or light. Then depending on that, will add or subtract **factor** percent from its luminance value.
906+
907+
Finally, a check will be made to see if this color is close to "*Messages Border*" foreground color, and re-adjusted as possible.
908+
909+
**Note:** When a calculated background color is used, pressing "**~**" (**tilde**) will toggle it on and off. This setting will be valid until **PyRadio** terminates, or a new theme is loaded.
910+
835911
### User themes
836912

837913
Users can easiliy create their own themes, using for example [CSS color names](https://www.cssportal.com/css3-color-names/) as a resource, and

pyradio.1

+103-1
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,104 @@ There are a couple of terminals (that I know of) which will permit changing thei
879879

880880
This means that, in order for a theme change to take full effect, \fBpyradio\fR will have to be restarted.
881881

882+
.RE
883+
.PP
884+
\fBSecondary windows background\fR
885+
886+
Secondary windows (such as messages, questions, the \fITheme Selection window\fR the \fIEncoding Selection window\fR, etc.) originally use the same background color as the \fIMain window\fR.
887+
888+
It is now possible to use a different background color for these windows, to get better visual result.
889+
890+
There are two way to do that:
891+
892+
.RS 3
893+
.IP 1. 3
894+
Defined in a theme
895+
896+
.IP 2. 3
897+
Using a calculated color
898+
899+
.PP
900+
\fBTheme defined secondary windows color \fR
901+
902+
.RS 3
903+
Themes have the following entry
904+
905+
.RS 3
906+
\fI# Message window border foreground and background.
907+
.br
908+
# The background color can be left unset.
909+
.br
910+
# Please refer to the following link for more info
911+
.br
912+
# https://github.com/coderholic/pyradio#secondary-windows-background
913+
.br
914+
#
915+
.br
916+
Messages Border #a3b367\fR
917+
.RE
918+
919+
It is possible to define a background color as well, like so
920+
921+
.RS 3
922+
\fIMessages Border #a3b367 #F5DBDE\fR
923+
.RE
924+
925+
In this case, this color will be used as the \fISecondary Windows\fR background color.
926+
927+
Although one can use any color here, it is recommended to follow these guidelines for best visual result:
928+
929+
.RS 3
930+
.IP 1. 3
931+
The color should be 1-20% lighter or darker than the "*Stations Background*" color setting of the theme.
932+
933+
One can use this page \fIhttp://www.workwithcolor.com/hsl-color-picker-01.htm\fR (or a similar one) to insert the base color and adjust the \fBL\fR component as needed.
934+
935+
A terminal alternative is \fBpastel\fR (\fIhttps://github.com/sharkdp/pastel\fR), which can be used like so:
936+
937+
938+
.RS 6
939+
\fIpastel color '#fbf1f2'\fR # show color info
940+
.br
941+
\fIpastel lighten .1 '#fbf1f2'\fR # color lightened by 10%
942+
.br
943+
\fIpastel darken .1 '#fbf1f2'\fR # color darkened by 10%\fR
944+
.RE
945+
946+
.IP 2. 3
947+
If the \fIStations Background\fR color is dark, create a lighter version of it; if it's light, create a darker version of it.
948+
949+
This is just a recomenration, though; just get a color that combines well with existing ones (border foreground, stations foreground and active station).
950+
951+
This information is actually relevant to creating a new \fBpyradio\fR theme, but it's very important in order to understand how the calculated background color works.
952+
953+
954+
.RE
955+
.RE
956+
\fBCalculated secondary windows color\fR
957+
.RS 3
958+
959+
960+
\fBpyradio\fR will use the same background color for all windows by default, provided that the theme used does not define a \fIMessages Border\fR background color.
961+
962+
In order to use a \fIMessages Border\fR background color different than the \fIStations background\fR color, when \fIMessages Border\fR background color is not defined in the selected theme, a config option is available; \fBCalculated color\fR".
963+
964+
This config option takes a value that's between 0 and 0.2.
965+
966+
If it is 0, no color change will occur.
967+
968+
Otherwise, the value acts as a percentage (a \fBfactor\fR), which indicates how much the luminance of the \fIStations background\fR color will change to produce the new background color.
969+
970+
This is how this works: \fBpyradio\fR will calculate the \fIStations background\fR color perceived brightness, which will indicate whether the color is dark or light. Then depending on that, will add or subtract \fBfactor\fR percent from its luminance value.
971+
972+
Finally, a check will be made to see if this color is close to \fIMessages Border\fR foreground color, and re-adjusted as possible.
973+
974+
975+
.IP \fBNote\fR
976+
When a calculated background color is used, pressing \fI~\fR (\fItilde\fR) will toggle it on and off. This setting will be valid until \fBPyRadio\fR terminates, or a new theme is loaded.
977+
978+
.RE
979+
882980
.RE
883981
.PP
884982
\fBUser themes\fR
@@ -891,11 +989,15 @@ Copy (and rename) one of the \fISystem Themes\fR to the user's \fBthemes\fR fold
891989

892990
To gain access to the \fISystem Themes\fR, execute the following commands
893991

992+
.RS 6
894993
\fIcd `python -c 'import site; print(site.getusersitepackages())'`\fR
895-
.BR
994+
.br
896995
\fIcd pyradio/themes\fR
996+
.RE
897997

998+
.RS 3
898999
(you may have to use \fIpython2\fR or \fIpython3\fR instead of plain \fIpython\fR, depending on your OS and distribution).
1000+
.RE
8991001

9001002
.IP 2. 3
9011003
Customize it as desired

pyradio/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
" pyradio -- Console radio player. "
22

3-
version_info = (0, 8, 9, 25)
3+
version_info = (0, 8, 9, 26)
44

55
# Set it to True if new stations have been
66
# added to the package's stations.csv

pyradio/config.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -2852,7 +2852,7 @@ def download(self, a_theme=None, a_path=None, print_errors=None):
28522852
# Message window border foreground and background.
28532853
# The background color can be left unset.
28542854
# Please refer to the following link for more info
2855-
# https://github.com/coderholic/pyradio#calculated-colors
2855+
# https://github.com/coderholic/pyradio#secondary-windows-background
28562856
#
28572857
Messages Border {color4}
28582858
@@ -2895,7 +2895,7 @@ def download(self, a_theme=None, a_path=None, print_errors=None):
28952895
# Message window border foreground and background.
28962896
# The background color can be left unset.
28972897
# Please refer to the following link for more info
2898-
# https://github.com/coderholic/pyradio#calculated-colors
2898+
# https://github.com/coderholic/pyradio#secondary-windows-background
28992899
#
29002900
Messages Border {color2}
29012901
@@ -3041,7 +3041,7 @@ def download(self, a_theme=None, a_path=None, print_errors=None):
30413041
# Message window border foreground and background.
30423042
# The background color can be left unset.
30433043
# Please refer to the following link for more info
3044-
# https://github.com/coderholic/pyradio#calculated-colors
3044+
# https://github.com/coderholic/pyradio#secondary-windows-background
30453045
#
30463046
Messages Border {color8}
30473047
@@ -3084,7 +3084,7 @@ def download(self, a_theme=None, a_path=None, print_errors=None):
30843084
# Message window border foreground and background.
30853085
# The background color can be left unset.
30863086
# Please refer to the following link for more info
3087-
# https://github.com/coderholic/pyradio#calculated-colors
3087+
# https://github.com/coderholic/pyradio#secondary-windows-background
30883088
#
30893089
Messages Border {color8}
30903090
@@ -3127,7 +3127,7 @@ def download(self, a_theme=None, a_path=None, print_errors=None):
31273127
# Message window border foreground and background.
31283128
# The background color can be left unset.
31293129
# Please refer to the following link for more info
3130-
# https://github.com/coderholic/pyradio#calculated-colors
3130+
# https://github.com/coderholic/pyradio#secondary-windows-background
31313131
#
31323132
Messages Border {color8}
31333133
@@ -3170,7 +3170,7 @@ def download(self, a_theme=None, a_path=None, print_errors=None):
31703170
# Message window border foreground and background.
31713171
# The background color can be left unset.
31723172
# Please refer to the following link for more info
3173-
# https://github.com/coderholic/pyradio#calculated-colors
3173+
# https://github.com/coderholic/pyradio#secondary-windows-background
31743174
#
31753175
Messages Border {color8}
31763176

pyradio/config_window.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class PyRadioConfigWindow(object):
7979
'|', 'Default value = dark'])
8080
_help_text.append(['If False, theme colors will be used.', '|',
8181
"If True and a compositor is running, the stations' window background will be transparent.", '|', "If True and a compositor is not running, the terminal's background color will be used.", '|', 'Default value: False'])
82-
_help_text.append(['Pyradio can calculate and use an alternative color for secondary windows.', '|', 'This option will determine if this color will be used (value > 0) or not (value = 0), provided that the theme used does not already provide it.', '|', 'The value of this option is actually the factor to darken or lighten the main (stations) background color.', '|', 'You can get more info on this at https://github.com/coderholic/pyradio#calculated-colors' , '|', 'Valid Values: 0-0.2', 'Default value: 0'])
82+
_help_text.append(['Pyradio can calculate and use an alternative color for secondary windows.', '|', 'This option will determine if this color will be used (value > 0) or not (value = 0), provided that the theme used does not already provide it.', '|', 'The value of this option is actually the factor to darken or lighten the main (stations) background color.', '|', 'You can get more info on this at https://github.com/coderholic/pyradio#secondary-windows-background', '|', 'Valid Values: 0-0.2', 'Default value: 0'])
8383
_help_text.append(None)
8484
_help_text.append(['Specify whether you will be asked to confirm every station deletion action.',
8585
'|', 'Default value: True'])
@@ -350,6 +350,8 @@ def _check_if_config_is_dirty(self):
350350
def _apply_a_theme(self, a_theme, use_transparency=None):
351351
theme = PyRadioTheme(self._cnf)
352352
theme.readAndApplyTheme(a_theme, use_transparency=use_transparency)
353+
self._cnf.use_calculated_colors = False if self._cnf.opts['calculated_color_factor'][1] == '0' else True
354+
self._cnf.update_calculated_colors()
353355
theme = None
354356
curses.doupdate()
355357

0 commit comments

Comments
 (0)