allow any CompoundPart to gain focus, if it canGainFocus()
[openc2e.git] / renderable.cpp
blob12b12b836a8479f51a441843c44a8a43c49d71fc
1 /*
2 * renderable.cpp
3 * openc2e
5 * Created by Alyssa Milburn on Thu Dec 29 2005.
6 * Copyright (c) 2005 Alyssa Milburn. All rights reserved.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
20 #include "renderable.h"
21 #include "World.h"
23 //#include "CompoundPart.h"
24 bool renderablezorder::operator ()(const renderable *s1, const renderable *s2) const {
25 // TODO: There's got to be a less stupid way to do this. - fuzzie
26 if (s1->getZOrder() == s2->getZOrder()) {
27 const CompoundPart *p1 = dynamic_cast<const CompoundPart *>(s1);
28 const CompoundPart *p2 = dynamic_cast<const CompoundPart *>(s2);
29 if (p1 && p2)
30 return p1->id < p2->id;
33 return s1->getZOrder() < s2->getZOrder();
36 void renderable::zapZOrder() {
37 assert(added);
38 world.renders.erase(renders_iter);
39 added = false;
42 void renderable::addZOrder() {
43 assert(!added);
44 renders_iter = world.renders.insert(this);
45 added = true;
48 renderable::~renderable() {
49 if (added)
50 world.renders.erase(renders_iter);
53 /* vim: set noet: */