git-svn-id: svn://ultimatepp.org/upp/trunk@15826 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2021-03-09 11:01:56 +00:00
parent e4a0ed6c9d
commit bebfe1f581
2 changed files with 68 additions and 0 deletions

View file

@ -0,0 +1,9 @@
uses
CtrlLib;
file
main.cpp;
mainconfig
"" = "GUI";

59
upptst/PenTest/main.cpp Normal file
View file

@ -0,0 +1,59 @@
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
struct MyApp : TopWindow {
Point pos;
Vector<Vector<Tuple<double, Pointf>>> 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();
}