From 8f5af08a9db176556c12209cb772c000c89681bc Mon Sep 17 00:00:00 2001 From: cxl Date: Thu, 20 Feb 2020 09:36:45 +0000 Subject: [PATCH] .examples git-svn-id: svn://ultimatepp.org/upp/trunk@14048 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- examples/TimerAnimate/TimerAnimate.upp | 11 +++++++ examples/TimerAnimate/main.cpp | 43 ++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 examples/TimerAnimate/TimerAnimate.upp create mode 100644 examples/TimerAnimate/main.cpp diff --git a/examples/TimerAnimate/TimerAnimate.upp b/examples/TimerAnimate/TimerAnimate.upp new file mode 100644 index 000000000..0c72de8d6 --- /dev/null +++ b/examples/TimerAnimate/TimerAnimate.upp @@ -0,0 +1,11 @@ +description "Uses periodic callback to animate content of window and app icon\377"; + +uses + CtrlLib; + +file + main.cpp; + +mainconfig + "" = "GUI"; + diff --git a/examples/TimerAnimate/main.cpp b/examples/TimerAnimate/main.cpp new file mode 100644 index 000000000..f114f726d --- /dev/null +++ b/examples/TimerAnimate/main.cpp @@ -0,0 +1,43 @@ +#include + +using namespace Upp; + +struct MyApp : TopWindow { + double phase = 0; + + TimeCallback tm; + + void PaintCircle(Draw& w, int sc) { + sc /= 2; + int pp = int(phase * sc); + w.DrawEllipse(int(sc - pp), int(sc - pp), int(2 * pp), int(2 * pp), SBlue()); + } + + virtual void Paint(Draw& w) { + Size sz = GetSize(); + w.DrawRect(sz, SWhite()); + PaintCircle(w, min(sz.cx, sz.cy)); + } + + MyApp() { + tm.Set(-10, [=] { + phase = msecs() % 2000 / 2000.0; + for(int pass = 0; pass < 2; pass++) { + int sc = pass ? 32 : 16; + ImageDraw iw(sc, sc); + iw.DrawRect(0, 0, sc, sc, White()); + PaintCircle(iw, sc); + if(pass) + LargeIcon(iw); + else + Icon(iw); + } + Refresh(); + }); + } +}; + +GUI_APP_MAIN +{ + MyApp().Run(); +}