Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_acs_types.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2014 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7#ifndef __KIS_ACS_TYPES_H
8#define __KIS_ACS_TYPES_H
9
10#include <QPoint>
11#include <KoColor.h>
12#include "kis_iterator_ng.h"
13
14
15namespace Acs {
17
18 inline ColorRole buttonToRole(Qt::MouseButton button) {
19 return button == Qt::LeftButton ? Acs::Foreground : Acs::Background;
20 }
21
22 inline ColorRole buttonsToRole(Qt::MouseButton button, Qt::MouseButtons buttons) {
23 return button == Qt::LeftButton || buttons & Qt::LeftButton ? Acs::Foreground : Acs::Background;
24 }
25
26 template <class ResourceProvider>
27 void setCurrentColor(ResourceProvider *provider, ColorRole role, const KoColor &color) {
28 if (role == Acs::Foreground) {
29 provider->setFGColor(color);
30 } else {
31 provider->setBGColor(color);
32 }
33 }
34
35 template <class ResourceProvider>
36 KoColor currentColor(ResourceProvider *provider, ColorRole role) {
37 return role == Acs::Foreground ? provider->fgColor() : provider->bgColor();
38 }
39
40 template <class PaintDeviceSP>
41 KoColor sampleColor(PaintDeviceSP device, const QPoint &pt) {
42 KoColor color;
43 if (device) {
44 (void) device->pixel(pt.x(), pt.y(), &color);
45 }
46 return color;
47 }
48
49 template <class PaintDeviceSP>
50 void setColor(PaintDeviceSP device, const QPoint &pt, const KoColor &color) {
51 (void) device->setPixel(pt.x(), pt.y(), color);
52 }
53
54 template<class Iterator>
55 void setColorWithIterator(Iterator &it, const KoColor &color, const int pixelSize) {
56 memcpy(it.rawData(), color.data(), pixelSize);
57 }
58
59}
60
61
62
63#endif /* __KIS_ACS_TYPES_H */
quint8 * data()
Definition KoColor.h:144
typedef void(QOPENGLF_APIENTRYP PFNGLINVALIDATEBUFFERDATAPROC)(GLuint buffer)
QString button(const QWheelEvent &ev)
QString buttons(const T &ev)
ColorRole buttonsToRole(Qt::MouseButton button, Qt::MouseButtons buttons)
ColorRole buttonToRole(Qt::MouseButton button)
void setColorWithIterator(Iterator &it, const KoColor &color, const int pixelSize)
void setColor(PaintDeviceSP device, const QPoint &pt, const KoColor &color)
KoColor currentColor(ResourceProvider *provider, ColorRole role)
KoColor sampleColor(PaintDeviceSP device, const QPoint &pt)
@ Background
@ Foreground
void setCurrentColor(ResourceProvider *provider, ColorRole role, const KoColor &color)