]> git.tdb.fi Git - poefilter.git/commitdiff
Add alpha channel support for colors
authorMikko Rasa <tdb@tdb.fi>
Tue, 14 Aug 2018 23:22:59 +0000 (02:22 +0300)
committerMikko Rasa <tdb@tdb.fi>
Wed, 15 Aug 2018 00:02:00 +0000 (03:02 +0300)
source/appearance.cpp
source/appearance.h
source/color.cpp
source/color.h
source/theme.cpp
source/theme.h

index f1bb993c90544f65a2dcb758a36a54a98e4bf5c3..ccd847666b388900534464f1ae196b0d09737e53 100644 (file)
@@ -35,13 +35,13 @@ void Appearance::add_lines(FilterStatement &st) const
                st.add_line(format("SetFontSize %d", font_size));
 
        if(background_color.defined)
-               st.add_line(format("SetBackgroundColor %d %d %d", background_color.r, background_color.g, background_color.b));
+               st.add_line(format("SetBackgroundColor %d %d %d %d", background_color.r, background_color.g, background_color.b, background_color.a));
 
        if(border_color.defined)
-               st.add_line(format("SetBorderColor %d %d %d", border_color.r, border_color.g, border_color.b));
+               st.add_line(format("SetBorderColor %d %d %d %d", border_color.r, border_color.g, border_color.b, border_color.a));
 
        if(text_color.defined)
-               st.add_line(format("SetTextColor %d %d %d", text_color.r, text_color.g, text_color.b));
+               st.add_line(format("SetTextColor %d %d %d %d", text_color.r, text_color.g, text_color.b, text_color.a));
 
        if(sound_type)
                st.add_line(format("PlayAlertSound %d %d", sound_type, sound_volume));
@@ -54,11 +54,14 @@ Appearance::Loader::Loader(Appearance &a, const Theme *t):
 {
        add("alert_sound", &Appearance::sound_type, &Appearance::sound_volume);
        add("background_color", &Loader::background_color);
+       add("background_color", &Loader::background_color_alpha);
        add("background_color", &Loader::background_color_named);
        add("border_color", &Loader::border_color);
+       add("border_color", &Loader::border_color_alpha);
        add("border_color", &Loader::border_color_named);
        add("font_size", &Loader::font_size);
        add("text_color", &Loader::text_color);
+       add("text_color", &Loader::text_color_alpha);
        add("text_color", &Loader::text_color_named);
 }
 
@@ -67,6 +70,11 @@ void Appearance::Loader::background_color(unsigned r, unsigned g, unsigned b)
        obj.background_color = Color(r, g, b);
 }
 
+void Appearance::Loader::background_color_alpha(unsigned r, unsigned g, unsigned b, unsigned a)
+{
+       obj.background_color = Color(r, g, b, a);
+}
+
 void Appearance::Loader::background_color_named(const string &name)
 {
        if(!theme)
@@ -79,6 +87,11 @@ void Appearance::Loader::border_color(unsigned r, unsigned g, unsigned b)
        obj.border_color = Color(r, g, b);
 }
 
+void Appearance::Loader::border_color_alpha(unsigned r, unsigned g, unsigned b, unsigned a)
+{
+       obj.border_color = Color(r, g, b, a);
+}
+
 void Appearance::Loader::border_color_named(const string &name)
 {
        if(!theme)
@@ -97,6 +110,11 @@ void Appearance::Loader::text_color(unsigned r, unsigned g, unsigned b)
        obj.text_color = Color(r, g, b);
 }
 
+void Appearance::Loader::text_color_alpha(unsigned r, unsigned g, unsigned b, unsigned a)
+{
+       obj.text_color = Color(r, g, b, a);
+}
+
 void Appearance::Loader::text_color_named(const string &name)
 {
        if(!theme)
index 41350744234f877b84b7d7142bc114792ee361f2..6806ed238d1d88085b5e714fa1056b927882f7ee 100644 (file)
@@ -20,11 +20,14 @@ public:
                Loader(Appearance &, const Theme * = 0);
 
                void background_color(unsigned, unsigned, unsigned);
+               void background_color_alpha(unsigned, unsigned, unsigned, unsigned);
                void background_color_named(const std::string &);
                void border_color(unsigned, unsigned, unsigned);
+               void border_color_alpha(unsigned, unsigned, unsigned, unsigned);
                void border_color_named(const std::string &);
                void font_size(float);
                void text_color(unsigned, unsigned, unsigned);
+               void text_color_alpha(unsigned, unsigned, unsigned, unsigned);
                void text_color_named(const std::string &);
        };
 
index a7d8330642dac57814c2ca083c2b117f5e91dd37..ebfe154fc4c629ef5b81c68cbc383287148bcc79 100644 (file)
@@ -4,12 +4,14 @@ Color::Color():
        defined(false),
        r(0),
        g(0),
-       b(0)
+       b(0),
+       a(0)
 { }
 
-Color::Color(unsigned r_, unsigned g_, unsigned b_):
+Color::Color(unsigned r_, unsigned g_, unsigned b_, unsigned a_):
        defined(true),
        r(r_),
        g(g_),
-       b(b_)
+       b(b_),
+       a(a_)
 { }
index 5ade1808d42467e5514d44e1164797ab3e4f0c2a..8d73e7ee530cd1c4aee82753811a736acbc15924 100644 (file)
@@ -7,9 +7,10 @@ struct Color
        unsigned r;
        unsigned g;
        unsigned b;
+       unsigned a;
 
        Color();
-       Color(unsigned, unsigned, unsigned);
+       Color(unsigned, unsigned, unsigned, unsigned = 255);
 };
 
 #endif
index 7557caaa8c8f90083a323e39b9e0e7ffb168fd7f..6f9f5d95913394e13309eb1ef46f716d4286aac5 100644 (file)
@@ -46,6 +46,7 @@ Theme::Loader::Loader(Theme &t):
        add("appearance", &Loader::appearance);
        add("base_font_size", &Theme::base_font_size);
        add("color", &Loader::color);
+       add("color", &Loader::color_alpha);
 }
 
 void Theme::Loader::appearance(const string &name)
@@ -60,3 +61,8 @@ void Theme::Loader::color(const string &name, unsigned r, unsigned g, unsigned b
 {
        obj.set_color(name, Color(r, g, b));
 }
+
+void Theme::Loader::color_alpha(const string &name, unsigned r, unsigned g, unsigned b, unsigned a)
+{
+       obj.set_color(name, Color(r, g, b, a));
+}
index 43584a2a0d28ce3c49097a0a789b318c020add61..f7c3f9472b66d4113182bbce477829fabf3d91b6 100644 (file)
@@ -18,6 +18,7 @@ public:
        private:
                void appearance(const std::string &);
                void color(const std::string &, unsigned, unsigned, unsigned);
+               void color_alpha(const std::string &, unsigned, unsigned, unsigned, unsigned);
        };
 
 private: