git-svn-id: svn://ultimatepp.org/upp/trunk@15882 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2021-03-29 11:59:15 +00:00
parent 5ba975ba8a
commit f9e53ac7dd
3 changed files with 50 additions and 38 deletions

View file

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

View file

@ -0,0 +1,16 @@
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
GUI_APP_MAIN
{
EditDouble q, q1;
q.AlignRight();
q <<= 1.234;
TopWindow win;
win.Add(q.LeftPosZ(10, 40).TopPosZ(10));
win.Add(q1.LeftPosZ(10, 100).TopPosZ(40));
win.Run();
}

View file

@ -2,50 +2,39 @@
using namespace Upp;
#define LLOG(x)
struct MyApp : TopWindow {
Point pos;
Vector<Vector<Tuple<double, Pointf>>> drawing;
bool pendown;
PenInfo pen;
MyApp(){
pendown=false;
}
virtual void LeftUp(Point p, dword)
{
if(IsPointerPen()) {
LLOG("End line");
pendown=false;
virtual bool Pen(Point p, const PenInfo& pn, dword keyflags) {
if(keyflags&K_SHIFT)
return false;
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 LeftDown(Point p, dword)
{
if(IsPointerPen()) {
LLOG("Start line");
pendown=true;
drawing.Add().Add(MakeTuple(GetPenPressure(), p));
void LeftDown(Point p, dword keyflags) override {
if(keyflags & K_SHIFT) {
RectTracker tracker(*this);
tracker.MinSize(Size(-100000,-100000));
tracker.Track(Rect(p,p));
}
Refresh();
}
virtual void MouseMove(Point p, dword keyflags) {
pos = p;
if(IsPointerPen() && drawing.GetCount() && pendown) {
LLOG("Drawing line, pressure: " << GetPenPressure());
drawing.Top().Add(MakeTuple(GetPenPressure(), p));
}
Refresh();
}
virtual void Paint(Draw& w0)
{
virtual void Paint(Draw& w0) {
DrawPainter w(w0, GetSize());
w.Co();
w.Clear(SColorPaper());
w.LineCap(LINECAP_ROUND);
@ -64,14 +53,12 @@ struct MyApp : TopWindow {
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: " << IsPenEraserPressed()); // FIXED to IsPenEraserPressed()
//Refresh(); // REMOVED
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); // FIXED to IsPenEraserPressed()
}
};