]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/style.h
Rework how widget ownership works in Container
[libs/gltk.git] / source / style.h
index 56f7ac484afce3e94fd2ee4b639b70466e32eeeb..62a451100e7f21391240fcb647924be539d9a88d 100644 (file)
@@ -3,7 +3,9 @@
 
 #include <msp/gl/color.h>
 #include <msp/gl/font.h>
-#include <msp/datafile/loader.h>
+#include <msp/gl/sampler.h>
+#include <msp/datafile/objectloader.h>
+#include "mspgltk_api.h"
 #include "part.h"
 
 namespace Msp {
@@ -15,43 +17,37 @@ class Resources;
 Styles define what wigets look like.  They are made up of Parts and some
 generic properties.
 */
-class Style
+class MSPGLTK_API Style
 {
 public:
-       class Loader: public DataFile::Loader
+       class Loader: public DataFile::CollectionObjectLoader<Style, Resources>
        {
-       private:
-               Style &style;
-               Resources &res;
-
        public:
-               typedef Resources Collection;
-
                Loader(Style &, Resources &);
-               Style &get_object() const { return style; }
-               Resources &get_collection() const { return res; }
+
        private:
                void font(const std::string &);
-               void font_color(float, float, float);
-               void part();
+               void font_color_normal(float, float, float);
+               void font_color(State, float, float, float);
                void part(const std::string &);
+               void unnamed_part();
        };
 
-       typedef std::list<Part> PartSeq;
-
 private:
-       const GL::Font *font;
-       unsigned font_size;
-       GL::Color font_color;
-       PartSeq parts;
+       const GL::Font *font = nullptr;
+       unsigned font_size = 0;
+       GL::Color font_color[N_STATES_];
+       const GL::Sampler *sampler = nullptr;
+       std::vector<Part> parts;
 
 public:
-       Style(Resources &);
-       const GL::Font &get_font() const  { return *font; }
+       const GL::Font &get_font() const;
        unsigned get_font_size() const { return font_size; }
-       const GL::Color &get_font_color() const { return font_color; }
-       const PartSeq &get_parts() const { return parts; }
-       const Part *get_part(const std::string &) const;
+       const GL::Color &get_font_color(State) const;
+       const GL::Sampler &get_sampler() const;
+       const std::vector<Part> &get_parts() const { return parts; }
+       const Part *find_part(const std::string &) const;
+       bool compare_states(State, State) const;
 };
 
 } // namespace GLtk