forked from Omega-Numworks/Omega-Atomic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
atomic_cell.cpp
61 lines (50 loc) · 1.43 KB
/
atomic_cell.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include "atomic_cell.h"
#include <assert.h>
#include <escher/palette.h>
namespace Atomic {
AtomicCell::AtomicCell() :
HighlightCell(),
m_visible(true)
{
}
KDColor AtomicCell::colorForType(AtomType type) const {
return Palette::AtomColor[type];
}
void AtomicCell::drawRect(KDContext * ctx, KDRect rect) const {
if(m_visible) {
KDColor color = colorForType(m_atom.type);
ctx->fillRect(rect, color);
KDPoint textPosition(bounds().topLeft().x() + 2, bounds().topLeft().y() + 2);
ctx->drawString(m_atom.symbol, textPosition, KDFont::SmallFont, Palette::PrimaryText, color);
if(isHighlighted()) {
KDColor highlighColor = KDColor::blend(color, Palette::AtomHighlight, 0x7F);
ctx->strokeRect(bounds(), highlighColor);
KDRect rect2(bounds().topLeft().x() + 1, bounds().topLeft().y() + 1, bounds().width() - 2, bounds().height() - 2);
ctx->strokeRect(rect2, highlighColor);
}
} else {
ctx->fillRect(rect, Palette::BackgroundApps);
}
}
int AtomicCell::numberOfSubviews() const {
return 0;
}
View * AtomicCell::subviewAtIndex(int index) {
return nullptr;
}
void AtomicCell::layoutSubviews(bool force) {
}
void AtomicCell::setVisible(bool visible) {
if (m_visible != visible) {
m_visible = visible;
markRectAsDirty(bounds());
}
}
void AtomicCell::setAtom(AtomDef atom) {
m_atom = atom;
markRectAsDirty(bounds());
}
void AtomicCell::reloadCell() {
markRectAsDirty(bounds());
}
}