mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 06:05:58 -06:00
.examples
git-svn-id: svn://ultimatepp.org/upp/trunk@14048 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
8db16daaf3
commit
8f5af08a9d
2 changed files with 54 additions and 0 deletions
11
examples/TimerAnimate/TimerAnimate.upp
Normal file
11
examples/TimerAnimate/TimerAnimate.upp
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
description "Uses periodic callback to animate content of window and app icon\377";
|
||||||
|
|
||||||
|
uses
|
||||||
|
CtrlLib;
|
||||||
|
|
||||||
|
file
|
||||||
|
main.cpp;
|
||||||
|
|
||||||
|
mainconfig
|
||||||
|
"" = "GUI";
|
||||||
|
|
||||||
43
examples/TimerAnimate/main.cpp
Normal file
43
examples/TimerAnimate/main.cpp
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
#include <CtrlLib/CtrlLib.h>
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue