From: Mikko Rasa Date: Tue, 14 Aug 2018 23:47:53 +0000 (+0300) Subject: Add inheritance for appearances X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=c5005fef005eb3b34a656a3e669347e96a3455cf;p=poefilter.git Add inheritance for appearances --- diff --git a/source/appearance.cpp b/source/appearance.cpp index ccd8476..ffe47ff 100644 --- a/source/appearance.cpp +++ b/source/appearance.cpp @@ -60,6 +60,7 @@ Appearance::Loader::Loader(Appearance &a, const Theme *t): add("border_color", &Loader::border_color_alpha); add("border_color", &Loader::border_color_named); add("font_size", &Loader::font_size); + add("inherit", &Loader::inherit); add("text_color", &Loader::text_color); add("text_color", &Loader::text_color_alpha); add("text_color", &Loader::text_color_named); @@ -105,6 +106,13 @@ void Appearance::Loader::font_size(float s) obj.font_size = base_size*s+0.5f; } +void Appearance::Loader::inherit(const string &name) +{ + if(!theme) + throw logic_error("No theme"); + obj = theme->get_appearance(name); +} + void Appearance::Loader::text_color(unsigned r, unsigned g, unsigned b) { obj.text_color = Color(r, g, b); diff --git a/source/appearance.h b/source/appearance.h index 6806ed2..9e6fb69 100644 --- a/source/appearance.h +++ b/source/appearance.h @@ -26,6 +26,7 @@ public: void border_color_alpha(unsigned, unsigned, unsigned, unsigned); void border_color_named(const std::string &); void font_size(float); + void inherit(const std::string &); void text_color(unsigned, unsigned, unsigned); void text_color_alpha(unsigned, unsigned, unsigned, unsigned); void text_color_named(const std::string &);