mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-21 06:45:39 -06:00
CtrlCore: Pen attributes (pressure etc..) support in Win32
git-svn-id: svn://ultimatepp.org/upp/trunk@15827 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
bebfe1f581
commit
b43185fc1e
3 changed files with 71 additions and 0 deletions
|
|
@ -675,6 +675,14 @@ private:
|
|||
static void Csizeinit();
|
||||
static void (*skin)();
|
||||
|
||||
static bool pen;
|
||||
static bool pen_barrel;
|
||||
static bool pen_inverted;
|
||||
static bool pen_eraser;
|
||||
static double pen_pressure;
|
||||
static double pen_rotation;
|
||||
static Pointf pen_tilt;
|
||||
|
||||
friend void InitRichTextZoom();
|
||||
friend void AvoidPaintingCheck__();
|
||||
friend dword GetKeyStateSafe(dword what);
|
||||
|
|
@ -1289,6 +1297,14 @@ public:
|
|||
|
||||
static int64 GetEventId() { return eventid; }
|
||||
|
||||
static bool IsPointerPen() { return pen; }
|
||||
static bool IsPenBarrelPressed() { return pen_barrel; }
|
||||
static bool IsPenInverted() { return pen_inverted; }
|
||||
static bool IsPenEraserPressed() { return pen_eraser; }
|
||||
static double GetPenPressure() { return pen_pressure; }
|
||||
static double GetPenRotation() { return pen_rotation; }
|
||||
static Pointf GetPenTilt() { return pen_tilt; }
|
||||
|
||||
Ctrl();
|
||||
virtual ~Ctrl();
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,14 @@ Point Ctrl::leftmousepos = Null;
|
|||
Point Ctrl::rightmousepos = Null;
|
||||
Point Ctrl::middlemousepos = Null;
|
||||
|
||||
bool Ctrl::pen;
|
||||
bool Ctrl::pen_barrel;
|
||||
bool Ctrl::pen_inverted;
|
||||
bool Ctrl::pen_eraser;
|
||||
double Ctrl::pen_pressure = Null;
|
||||
double Ctrl::pen_rotation = Null;
|
||||
Pointf Ctrl::pen_tilt = Null;
|
||||
|
||||
dword GetMouseFlags() {
|
||||
dword style = 0;
|
||||
if(GetAlt()) style |= K_ALT;
|
||||
|
|
|
|||
|
|
@ -63,7 +63,54 @@ LRESULT Ctrl::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) {
|
|||
// LLOG("Ctrl::WindowProc(" << message << ") in " << ::Name(this) << ", focus " << (void *)::GetFocus());
|
||||
Ptr<Ctrl> _this = this;
|
||||
HWND hwnd = GetHWND();
|
||||
|
||||
switch(message) {
|
||||
case WM_POINTERDOWN:
|
||||
case WM_POINTERUPDATE:
|
||||
case WM_POINTERUP:
|
||||
{
|
||||
pen = false;
|
||||
pen_pressure = pen_rotation = Null;
|
||||
pen_tilt = Null;
|
||||
pen_eraser = false;
|
||||
pen_barrel = false;
|
||||
pen_inverted = false;
|
||||
|
||||
static BOOL (WINAPI *GetPointerInfo)(UINT32 pointerId, POINTER_INFO *pointerInfo);
|
||||
static BOOL (WINAPI *GetPointerPenInfo)(UINT32 pointerId, POINTER_PEN_INFO *penInfo);
|
||||
ONCELOCK {
|
||||
DllFn(GetPointerInfo, "User32.dll", "GetPointerInfo");
|
||||
DllFn(GetPointerPenInfo, "User32.dll", "GetPointerPenInfo");
|
||||
};
|
||||
|
||||
POINTER_INFO pi;
|
||||
if(GetPointerInfo(GET_POINTERID_WPARAM(wParam), &pi)) {
|
||||
if(pi.pointerType == PT_PEN) {
|
||||
POINTER_PEN_INFO ppi;
|
||||
if(GetPointerPenInfo(pi.pointerId, &ppi)) {
|
||||
pen = true;
|
||||
if(ppi.penFlags & PEN_FLAG_BARREL)
|
||||
pen_barrel = true;
|
||||
if(ppi.penFlags & PEN_FLAG_INVERTED)
|
||||
pen_inverted = true;
|
||||
if(ppi.penFlags & PEN_FLAG_ERASER)
|
||||
pen_eraser = true;
|
||||
if(ppi.penMask & PEN_MASK_PRESSURE)
|
||||
pen_pressure = ppi.pressure / 1024.0;
|
||||
if(ppi.penMask & PEN_MASK_ROTATION)
|
||||
pen_pressure = ppi.rotation * M_2PI / 360;
|
||||
if(ppi.penMask & PEN_MASK_TILT_X)
|
||||
pen_tilt.x = ppi.tiltX * M_2PI / 360;
|
||||
if(ppi.penMask & PEN_MASK_TILT_Y)
|
||||
pen_tilt.y = ppi.tiltY * M_2PI / 360;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case WM_POINTERLEAVE:
|
||||
pen = false;
|
||||
break;
|
||||
case WM_PALETTECHANGED:
|
||||
if((HWND)wParam == hwnd)
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue