From bebfe1f581a24a964d46d76e990dd0969bf6e081 Mon Sep 17 00:00:00 2001 From: cxl Date: Tue, 9 Mar 2021 11:01:56 +0000 Subject: [PATCH] .upptst git-svn-id: svn://ultimatepp.org/upp/trunk@15826 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- upptst/PenTest/PenTest.upp | 9 ++++++ upptst/PenTest/main.cpp | 59 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 upptst/PenTest/PenTest.upp create mode 100644 upptst/PenTest/main.cpp diff --git a/upptst/PenTest/PenTest.upp b/upptst/PenTest/PenTest.upp new file mode 100644 index 000000000..5c4f53e15 --- /dev/null +++ b/upptst/PenTest/PenTest.upp @@ -0,0 +1,9 @@ +uses + CtrlLib; + +file + main.cpp; + +mainconfig + "" = "GUI"; + diff --git a/upptst/PenTest/main.cpp b/upptst/PenTest/main.cpp new file mode 100644 index 000000000..9dc2b9e7e --- /dev/null +++ b/upptst/PenTest/main.cpp @@ -0,0 +1,59 @@ +#include + +using namespace Upp; + +struct MyApp : TopWindow { + Point pos; + + Vector>> drawing; + + virtual void LeftDown(Point p, dword) + { + if(IsPointerPen()) + drawing.Add().Add(MakeTuple(GetPenPressure(), p)); + Refresh(); + } + + virtual void MouseMove(Point p, dword keyflags) { + pos = p; + if(IsPointerPen() && drawing.GetCount()) + drawing.Top().Add(MakeTuple(GetPenPressure(), p)); + Refresh(); + } + + virtual void Paint(Draw& w0) + { + DrawPainter w(w0, GetSize()); + w.Clear(SColorPaper()); + + w.LineCap(LINECAP_ROUND); + for(const auto& stroke : drawing) + if(stroke.GetCount()) + for(int i = 0; i < stroke.GetCount() - 1; i++) { + w.Move(stroke[i].b); + w.Line(stroke[i + 1].b); + w.Stroke(DPI(20) * stroke[i].a, Black()); + } + + int fcy = GetStdFontCy(); + int y = 10; + auto Text = [&] (const String& text) { + w.DrawText(10, y, text); + y += fcy; + }; + Text(AsString(pos)); + Text(String() << "Pen: " << IsPointerPen()); + Text(String() << "Pressure: " << GetPenPressure()); + Text(String() << "Rotation: " << GetPenRotation()); + Text(String() << "Tilt: " << GetPenTilt()); + Text(String() << "Barrel: " << IsPenBarrelPressed()); + Text(String() << "Inverted: " << IsPenInverted()); + Text(String() << "Eraser: " << IsPenInverted()); + Refresh(); + } +}; + +GUI_APP_MAIN +{ + MyApp().Run(); +}