mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[Escher] Image setter for the ImageView
Change-Id: I18c5083c130ba5602cb8279ecb6c1a51692bacbe
This commit is contained in:
@@ -6,7 +6,8 @@
|
||||
|
||||
class ImageView : public ChildlessView {
|
||||
public:
|
||||
ImageView(const Image * image);
|
||||
ImageView();
|
||||
void setImage(const Image * image);
|
||||
void drawRect(KDContext * ctx, KDRect rect) const override;
|
||||
private:
|
||||
const Image * m_image;
|
||||
|
||||
@@ -3,14 +3,24 @@ extern "C" {
|
||||
#include <assert.h>
|
||||
}
|
||||
|
||||
ImageView::ImageView(const Image * image) :
|
||||
ImageView::ImageView() :
|
||||
ChildlessView(),
|
||||
m_image(image)
|
||||
m_image(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
void ImageView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
if (m_image == nullptr) {
|
||||
return;
|
||||
}
|
||||
assert(bounds().width() == m_image->width());
|
||||
assert(bounds().height() == m_image->height());
|
||||
ctx->fillRectWithPixels(bounds(), m_image->pixels(), nullptr);
|
||||
}
|
||||
|
||||
void ImageView::setImage(const Image * image) {
|
||||
if (image != m_image) {
|
||||
m_image = image;
|
||||
markRectAsDirty(bounds());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user