X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fpart.cpp;h=1f58b6187d679c983ad044310b20b5b739e1a6c5;hb=75a16eae9eb2714f8112d46fa5b8f7908b6d2487;hp=f5e4b79ef5c36a674f329fd9ca3dbc9a575c5e1c;hpb=c2635c5a3dca6a6cea5562fd387beb0662b18cf0;p=libs%2Fgltk.git diff --git a/source/part.cpp b/source/part.cpp index f5e4b79..1f58b61 100644 --- a/source/part.cpp +++ b/source/part.cpp @@ -5,6 +5,7 @@ Copyright © 2007 Mikko Rasa, Mikkosoft Productions Distributed under the LGPL */ +#include #include "geometry.h" #include "part.h" #include "resources.h" @@ -15,11 +16,7 @@ namespace Msp { namespace GLtk { Part::Part(const string &n): - name(n), - width(1), - height(1), - fill_x(true), - fill_y(true) + name(n) { for(unsigned i=0; irender(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); } @@ -49,38 +49,50 @@ Part::Loader::Loader(Part &p, Resources &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; iget_shadow(); - part.width=max(part.width, part.graphic[i]->get_width()-shadow.left-shadow.right); - part.height=max(part.height, part.graphic[i]->get_height()-shadow.bottom-shadow.top); + part.geom.w=max(part.geom.w, part.graphic[i]->get_width()-shadow.left-shadow.right); + part.geom.h=max(part.geom.h, part.graphic[i]->get_height()-shadow.bottom-shadow.top); } - else - part.graphic[i]=part.graphic[NORMAL]; - } } void Part::Loader::graphic(State s, const string &n) { - part.graphic[s]=res.get(n); + Graphic *grph=res.get(n); + for(int i=0; i