multiSurface.cpp
00001
00002
00003
00004
00005
00006
00007 #include "multiSurface.h"
00008
00009
00010 MultiSurface:: MultiSurface(const VXV::Rect& size) {
00011 w = size.w;
00012 h = size.h;
00013 }
00014
00015
00016 MultiSurface::~MultiSurface(void) {
00017 }
00018
00019
00020 bool MultiSurface::draw(const VXV::Rect& size, const VXV::Grid& pos,
00021 unsigned long ticks) {
00022
00023 for (surface_t::iterator it = objs.begin();
00024 it != objs.end(); ++it) {
00025 it->surface->draw(it->range, pos + it->offset, ticks);
00026 }
00027 return true;
00028 }
00029
00030
00031 void MultiSurface::addSurface(SurfaceInterface* surface, char align,
00032 const VXV::Grid& pos) {
00033 surfaceOffset_t surfaceInfo;
00034 surfaceInfo.surface = surface;
00035
00036
00037
00038 surfaceInfo.offset.x = 0;
00039 if (align & VXV::Center) {
00040 surfaceInfo.offset.x = w/2 - surface->w/2;
00041 } else if (align & VXV::Right) {
00042 surfaceInfo.offset.x = w - surface->w;
00043 }
00044 surfaceInfo.offset.y = 0;
00045 if (align & VXV::Middle) {
00046 surfaceInfo.offset.y = h/2 - surface->h/2;
00047 } else if (align & VXV::Bottom) {
00048 surfaceInfo.offset.y = h - surface->h;
00049 }
00050
00051
00052 surfaceInfo.range = VXV::Rect(surface->w, surface->h);
00053
00054 objs.push_back(surfaceInfo);
00055 }
00056