X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Fpart.cpp;h=f2797f9058ad66fe8633256c286eb3b794fe8cab;hb=b92c878a286036af106e969a29b2689876aa5f65;hp=38e75d7c034d4526f08662ec732deb7d8493f83d;hpb=c1f038acb91eb3bfaa34dfd4729d19ed3f871a42;p=libs%2Fgltk.git diff --git a/source/part.cpp b/source/part.cpp index 38e75d7..f2797f9 100644 --- a/source/part.cpp +++ b/source/part.cpp @@ -1,3 +1,11 @@ +/* $Id$ + +This file is part of libmspgltk +Copyright © 2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + +#include #include "geometry.h" #include "part.h" #include "resources.h" @@ -7,14 +15,11 @@ using namespace std; namespace Msp { namespace GLtk { -Part::Part(const Resources &r, const string &n): - res(r), - name(n), - fill_x(true), - fill_y(true) +Part::Part(const string &n): + name(n) { for(unsigned i=0; iget_shadow(); - unsigned gw=(fill_x ? geom.w : graphic[state]->get_width())-shadow.left-shadow.right; - unsigned gh=(fill_y ? geom.h : graphic[state]->get_height())-shadow.top-shadow.bottom; - align.apply(geom, gw, gh); - graphic[state]->render(gw, gh); + if(!graphic[state]) + return; + + Geometry rgeom = geom; + align.apply(rgeom, parent, margin); + GL::translate(rgeom.x, rgeom.y, 0); + graphic[state]->render(rgeom.w, rgeom.h); } -Part::Loader::Loader(Part &p): - part(p) +Part::Loader::Loader(Part &p, Resources &r): + DataFile::CollectionObjectLoader(p, &r) { add("graphic", &Loader::graphic); add("align", &Loader::align); add("fill", &Loader::fill); + add("margin", &Loader::margin); + add("size", &Loader::size); +} + +Part::Loader::~Loader() +{ + for(unsigned i=0; i(n); + for(int i=0; i