Omega-Numworks / Omega

Omega 2.0, the next evolution of Epsilon! Now available for your Numworks calculator!
https://getomega.dev
Other
316 stars 92 forks source link

ImageView::drawRect() doesn't display the set image #426

Closed ghost closed 3 years ago

ghost commented 3 years ago

Omega Version: 1.20.3

Whenever I call drawRect(ctx,rect) after calling setImage(img) nothing will appear, the image won't at all show up, and theres no change, nothing is being drawn

My code is

ImageView ImgView;
const Image* img = ImageStore::Help;
ImgView.setImage(img);
ImgView.drawRect(ctx, KDRect(KDPoint(250, 150), KDSize(100, 100)));
ImgView.drawRect(ctx, rect);

Is there something im doing wrong?

RedGl0w commented 3 years ago

Indeed, here is the source of a simple view showing an image : the cpp file :

#include "GaleryView.h"
#include "apps/i18n.h"
#include "PourLeTravail_image.h"

namespace PourLeTravail {

GaleryView::GaleryView() :
  View()
{
  m_image.setImage(ImageStore::PourLeTravailImage);
}

void GaleryView::drawRect(KDContext * ctx, KDRect rect) const {
  ctx->fillRect(KDRect(0, 0, bounds().width(), bounds().height()), KDColorWhite);
}

View * GaleryView::subviewAtIndex(int index) {
  assert(index==0);
  return &m_image;
}

void GaleryView::layoutSubviews(bool force) {
  m_image.setFrame(KDRect(0,0,58,56), force);
}

}

the h file :

#ifndef POURLETRAVAIL_GALERY_VIEW_H
#define POURLETRAVAIL_GALERY_VIEW_H

#include <escher.h>

namespace PourLeTravail {

class GaleryView : public View {
public:
  GaleryView();
  void drawRect(KDContext * ctx, KDRect rect) const override;
private:
  int numberOfSubviews() const override { return 1; }
  View * subviewAtIndex(int index) override;
  void layoutSubviews(bool force = false) override;
  ImageView m_image;
};

}

#endif