mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
.reference
git-svn-id: svn://ultimatepp.org/upp/trunk@15866 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
3fc6a99646
commit
1f059054ce
2 changed files with 68 additions and 0 deletions
11
reference/Pen/Pen.upp
Normal file
11
reference/Pen/Pen.upp
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
description "Pen support (drawing with pen, reacting to pressure)\377";
|
||||
|
||||
uses
|
||||
CtrlLib;
|
||||
|
||||
file
|
||||
main.cpp;
|
||||
|
||||
mainconfig
|
||||
"" = "GUI";
|
||||
|
||||
57
reference/Pen/main.cpp
Normal file
57
reference/Pen/main.cpp
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
#include <CtrlLib/CtrlLib.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
struct MyApp : TopWindow {
|
||||
Point pos;
|
||||
|
||||
Vector<Vector<Tuple<double, Pointf>>> drawing;
|
||||
|
||||
PenInfo pen;
|
||||
|
||||
virtual bool Pen(Point p, const PenInfo& pn, dword keyflags) {
|
||||
if(pn.pressure) {
|
||||
if((!!pn.pressure == !!pen.pressure) && drawing.GetCount())
|
||||
drawing.Top().Add(MakeTuple(pn.pressure, p));
|
||||
else
|
||||
drawing.Add().Add(MakeTuple(pn.pressure, p));
|
||||
}
|
||||
pen = pn;
|
||||
Refresh();
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual void Paint(Draw& w0) {
|
||||
DrawPainter w(w0, GetSize());
|
||||
w.Co();
|
||||
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() << "Pressure: " << pen.pressure);
|
||||
Text(String() << "Rotation: " << pen.rotation);
|
||||
Text(String() << "Tilt: " << pen.tilt);
|
||||
Text(String() << "Barrel: " << pen.barrel);
|
||||
Text(String() << "Inverted: " << pen.inverted);
|
||||
Text(String() << "Eraser: " << pen.eraser);
|
||||
}
|
||||
};
|
||||
|
||||
GUI_APP_MAIN
|
||||
{
|
||||
MyApp().Run();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue