Enable Windows Ink Support (#2152)

* Enable Windows Ink Support

close #2017
close #2149
This commit is contained in:
manongjohn 2018-08-07 01:39:08 -04:00 committed by shun-iwasawa
parent 03ecf4d7bd
commit c5bc8d2da8
9 changed files with 1414 additions and 2 deletions

View file

@ -0,0 +1,23 @@
Windows Pointer Input Message support code files from Krita
Copyright (c) 2017 Alvin Wong <alvinhochun@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View file

@ -575,6 +575,11 @@ public:
} //! \sa The \p sysctl unix command.
std::string getLayerNameEncoding() const { return m_layerNameEncoding; };
// Tablet tab
void enableWinInk(bool on);
bool isWinInkEnabled() const { return m_enableWinInk; }
Q_SIGNALS:
void stopAutoSave();
@ -706,6 +711,8 @@ private:
TPixel32 m_currentColumnColor;
bool m_enableWinInk = false;
private:
Preferences();
~Preferences();

View file

@ -123,6 +123,7 @@ set(MOC_HEADERS
svnupdatedialog.h
svnpurgedialog.h
tapp.h
kis_tablet_support_win8.h
tasksviewer.h
testpanel.h
tfarmstuff.h
@ -259,6 +260,7 @@ set(SOURCES
soundtrackexport.cpp
startuppopup.cpp
subcameramanager.cpp
kis_tablet_support_win8.cpp
timestretchpopup.cpp
trackerpopup.cpp
vectorizerpopup.cpp

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,73 @@
/*
* This file is based on the Windows Pointer Input Message support code files by
* Alvin Wong.
* Notwithstanding the license specified in this repository, this file is
* redistributed under BSD 2-Clause license written below in order to keep
* backporting available.
*
* All contributions by Alvin Wong:
* Copyright (c) 2017 Alvin Wong <alvinhochun@gmail.com>
* All rights reserved.
*
* All other contributions:
* Copyright (c) 2018, the respective contributors.
* All rights reserved.
*
* Each contributor holds copyright over their respective contributions.
* The project versioning (Git) records all such contribution source information.
*
* Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef KIS_TABLET_SUPPORT_WIN8_H
#define KIS_TABLET_SUPPORT_WIN8_H
#include <QAbstractNativeEventFilter>
#ifdef _WIN32
#ifdef KRITA
#include <kritaui_export.h>
class KRITAUI_EXPORT KisTabletSupportWin8 : public QAbstractNativeEventFilter
#else
class KisTabletSupportWin8 : public QAbstractNativeEventFilter
#endif
{
Q_DISABLE_COPY(KisTabletSupportWin8)
public:
static bool isAvailable();
static bool isPenDeviceAvailable();
KisTabletSupportWin8() = default;
~KisTabletSupportWin8() = default;
bool init();
// void registerPointerDeviceNotifications();
virtual bool nativeEventFilter(const QByteArray &eventType, void *message,
long *result) override;
};
#endif // _WIN32
#endif // KIS_TABLET_SUPPORT_WIN8_H

View file

@ -64,6 +64,8 @@
#include "tvectorbrushstyle.h"
#include "tfont.h"
#include "kis_tablet_support_win8.h"
#ifdef MACOSX
#include "tipc.h"
#endif
@ -731,6 +733,17 @@ int main(int argc, char *argv[]) {
#endif
#endif
#ifdef _WIN32
if (Preferences::instance()->isWinInkEnabled()) {
KisTabletSupportWin8 *penFilter = new KisTabletSupportWin8();
if (penFilter->init()) {
a.installNativeEventFilter(penFilter);
} else {
delete penFilter;
}
}
#endif
a.installEventFilter(TApp::instance());
int ret = a.exec();

View file

@ -35,6 +35,8 @@
#include "tsystem.h"
#include "tfont.h"
#include "kis_tablet_support_win8.h"
// Qt includes
#include <QHBoxLayout>
#include <QComboBox>
@ -1224,6 +1226,12 @@ void PreferencesPopup::onCurrentColumnDataChanged(const TPixel32 &,
m_pref->setCurrentColumnData(m_currentColumnColor->getColor());
}
//---------------------------------------------------------------------------------------
void PreferencesPopup::onEnableWinInkChanged(int index) {
m_pref->enableWinInk(index == Qt::Checked);
}
//**********************************************************************************
// PrefencesPopup's constructor
//**********************************************************************************
@ -1234,6 +1242,12 @@ PreferencesPopup::PreferencesPopup()
, m_inksOnly(0)
, m_blanksCount(0)
, m_blankColor(0) {
bool showTabletSettings = false;
#ifdef _WIN32
showTabletSettings = KisTabletSupportWin8::isAvailable();
#endif
setWindowTitle(tr("Preferences"));
setObjectName("PreferencesPopup");
@ -1561,6 +1575,19 @@ PreferencesPopup::PreferencesPopup()
new QLabel(tr("* Changes will take effect the next time you run Toonz"));
note_version->setStyleSheet("font-size: 10px; font: italic;");
QLabel *note_tablet;
//--- Tablet Settings ------------------------------
if (showTabletSettings) {
categoryList->addItem(tr("Tablet Settings"));
m_enableWinInk =
new DVGui::CheckBox(tr("Enable Windows Ink Support* (EXPERIMENTAL)"));
note_tablet = new QLabel(
tr("* Changes will take effect the next time you run Toonz"));
note_tablet->setStyleSheet("font-size: 10px; font: italic;");
}
/*--- set default parameters ---*/
categoryList->setFixedWidth(160);
categoryList->setCurrentRow(0);
@ -1883,6 +1910,9 @@ PreferencesPopup::PreferencesPopup()
m_pref->isAutomaticSVNFolderRefreshEnabled());
checkForTheLatestVersionCB->setChecked(m_pref->isLatestVersionCheckEnabled());
//--- Tablet Settings ------------------------------
if (showTabletSettings) m_enableWinInk->setChecked(m_pref->isWinInkEnabled());
/*--- layout ---*/
QHBoxLayout *mainLayout = new QHBoxLayout();
@ -2621,6 +2651,23 @@ PreferencesPopup::PreferencesPopup()
versionControlBox->setLayout(vcLay);
stackedWidget->addWidget(versionControlBox);
//--- Tablet Settings --------------------------
if (showTabletSettings) {
QWidget *tabletSettingsBox = new QWidget(this);
QVBoxLayout *tsLay = new QVBoxLayout();
tsLay->setMargin(15);
tsLay->setSpacing(10);
{
tsLay->addWidget(m_enableWinInk, 0, Qt::AlignLeft | Qt::AlignVCenter);
tsLay->addStretch(1);
tsLay->addWidget(note_tablet, 0);
}
tabletSettingsBox->setLayout(tsLay);
stackedWidget->addWidget(tabletSettingsBox);
}
mainLayout->addWidget(stackedWidget, 1);
}
setLayout(mainLayout);
@ -2945,6 +2992,12 @@ PreferencesPopup::PreferencesPopup()
SLOT(onAutomaticSVNRefreshChanged(int)));
ret = ret && connect(checkForTheLatestVersionCB, SIGNAL(clicked(bool)),
SLOT(onCheckLatestVersionChanged(bool)));
//--- Tablet Settings ----------------------
if (showTabletSettings)
ret = ret && connect(m_enableWinInk, SIGNAL(stateChanged(int)),
SLOT(onEnableWinInkChanged(int)));
assert(ret);
}

View file

@ -82,7 +82,7 @@ private:
*m_useHigherDpiOnVectorSimplifyCB, *m_keepFillOnVectorSimplifyCB,
*m_newLevelToCameraSizeCB, *m_ignoreImageDpiCB,
*m_syncLevelRenumberWithXsheet, *m_downArrowInLevelStripCreatesNewFrame,
*m_enableAutoStretch;
*m_enableAutoStretch, *m_enableWinInk;
DVGui::FileField *m_customProjectRootFileField;
@ -217,6 +217,7 @@ private slots:
void onCursorBrushStyleChanged(int index);
void onCursorOutlineChanged(int);
void onCurrentColumnDataChanged(const TPixel32 &, bool isDragging);
void onEnableWinInkChanged(int index);
};
//**********************************************************************************

View file

@ -343,7 +343,8 @@ Preferences::Preferences()
, m_cursorBrushType("Small")
, m_cursorBrushStyle("Default")
, m_cursorOutlineEnabled(true)
, m_currentColumnColor(TPixel::Black) {
, m_currentColumnColor(TPixel::Black)
, m_enableWinInk(false) {
TCamera camera;
m_defLevelType = PLI_XSHLEVEL;
m_defLevelWidth = camera.getSize().lx;
@ -715,6 +716,8 @@ Preferences::Preferences()
getValue(*m_settings, "currentColumnColor.g", g);
getValue(*m_settings, "currentColumnColor.b", b);
m_currentColumnColor = TPixel32(r, g, b);
getValue(*m_settings, "winInkEnabled", m_enableWinInk);
}
//-----------------------------------------------------------------
@ -1737,3 +1740,8 @@ void Preferences::setCurrentColumnData(const TPixel &currentColumnColor) {
m_settings->setValue("currentColumnColor.b",
QString::number(currentColumnColor.b));
}
void Preferences::enableWinInk(bool on) {
m_enableWinInk = on;
m_settings->setValue("winInkEnabled", on ? "1" : "0");
}