From cc6dcbb9f2da7af0e0e164f55a8ba83a61ccd309 Mon Sep 17 00:00:00 2001 From: Romain Goyet Date: Tue, 12 Apr 2016 18:48:28 +0200 Subject: [PATCH] Add an Escher demo Replace app.o by escher_demo.o in the Makefile to give it a run Change-Id: Id5e81220db149b2f43f55be81559ecd252a01991 --- app/escher_demo.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 app/escher_demo.cpp diff --git a/app/escher_demo.cpp b/app/escher_demo.cpp new file mode 100644 index 000000000..a751ceec9 --- /dev/null +++ b/app/escher_demo.cpp @@ -0,0 +1,37 @@ +extern "C" { +#include +#include +#include +#include +} + +class MyTextView : public View { + using View::View; +public: + void drawRect(KDRect frame) override; +}; + +void MyTextView::drawRect(KDRect frame) { + KDPoint zero = {0, 0}; + KDDrawString("Hello, world!", zero, 0); +} + +void ion_app() { + KDRect wholeScreen = {0, 0, 100, 100}; + KDColor a = 0x55; + View * window = new SolidColorView(wholeScreen, a); + KDRect textRect = {0, 0, 50, 50}; + MyTextView * textView = new MyTextView(textRect); + window->addSubview(textView); + + window->draw(); + + while (1) { + ion_sleep(); + textRect.y = textRect.y+1; + textView->setFrame(textRect); + } + + delete textView; + delete window; +}