mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
46 lines
933 B
C++
46 lines
933 B
C++
#include "app_cell.h"
|
|
#include <assert.h>
|
|
|
|
namespace Home {
|
|
|
|
AppCell::AppCell() :
|
|
TableViewCell(),
|
|
m_visible(true)
|
|
{
|
|
}
|
|
|
|
int AppCell::numberOfSubviews() const {
|
|
return m_visible ? 2 : 0;
|
|
}
|
|
|
|
View * AppCell::subviewAtIndex(int index) {
|
|
View * views[] = {&m_iconView, &m_nameView};
|
|
return views[index];
|
|
}
|
|
|
|
void AppCell::layoutSubviews() {
|
|
m_iconView.setFrame(KDRect(0,0,k_iconSize,k_iconSize));
|
|
if (bounds().height() > k_iconSize) {
|
|
m_nameView.setFrame(KDRect(0, k_iconSize, bounds().width(), bounds().height()-k_iconSize));
|
|
}
|
|
}
|
|
|
|
void AppCell::setApp(::App * app) {
|
|
m_iconView.setImage(app->icon());
|
|
m_nameView.setText(app->name());
|
|
}
|
|
|
|
void AppCell::setVisible(bool visible) {
|
|
if (m_visible != visible) {
|
|
m_visible = visible;
|
|
markRectAsDirty(bounds());
|
|
}
|
|
}
|
|
|
|
void AppCell::reloadCell() {
|
|
TableViewCell::reloadCell();
|
|
m_nameView.setBackgroundColor(isHighlighted() ? KDColorRed : KDColorWhite);
|
|
}
|
|
|
|
}
|