3 This file is part of libmspgltk
4 Copyright © 2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
8 #include <msp/gl/transform.h>
11 #include "resources.h"
18 Part::Part(const string &n):
21 for(unsigned i=0; i<N_STATES_; ++i)
25 const Graphic *Part::get_graphic(State state) const
28 throw InvalidParameterValue("Invalid state");
30 return graphic[state];
33 void Part::render(const Geometry &parent, State state) const
39 align.apply(rgeom, parent, margin);
40 GL::translate(rgeom.x, rgeom.y, 0);
41 graphic[state]->render(rgeom.w, rgeom.h);
45 Part::Loader::Loader(Part &p, Resources &r):
49 add("graphic", &Loader::graphic);
50 add("align", &Loader::align);
51 add("fill", &Loader::fill);
52 add("margin", &Loader::margin);
53 add("size", &Loader::size);
56 Part::Loader::~Loader()
58 for(unsigned i=0; i<N_STATES_; ++i)
61 const Sides &shadow=part.graphic[i]->get_shadow();
62 part.geom.w=max(part.geom.w, part.graphic[i]->get_width()-shadow.left-shadow.right);
63 part.geom.h=max(part.geom.h, part.graphic[i]->get_height()-shadow.bottom-shadow.top);
67 void Part::Loader::graphic(State s, const string &n)
69 Graphic *grph=res.get<Graphic>(n);
70 for(int i=0; i<N_STATES_; ++i)
75 void Part::Loader::align(float x, float y)
81 void Part::Loader::fill(float w, float h)
87 void Part::Loader::margin()
89 load_sub(part.margin);
92 void Part::Loader::size(unsigned w, unsigned h)