Krita

Scratchpad.cpp
1/*
2 * SPDX-FileCopyrightText: 2020 Scott Petrovic <scottpetrovic@gmail.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6#include "Scratchpad.h"
7#include <KoResource.h>
8#include <kis_config.h>
9#include "kis_scratch_pad.h"
10#include "Resource.h"
11#include "View.h"
12#include "Canvas.h"
13#include <KoCanvasBase.h>
14#include <kis_canvas2.h>
15
16#include <QColor>
17#include <QVBoxLayout>
18
19
20struct Scratchpad::Private
21{
22 KisScratchPad *scratchpad = 0;
23};
24
25
26Scratchpad::Scratchpad(View *view, const QColor & defaultColor, QWidget *parent)
27 : QWidget(parent), d(new Private)
28{
29 d->scratchpad = new KisScratchPad();
30 d->scratchpad->setupScratchPad(view->view()->resourceProvider(), defaultColor);
31 d->scratchpad->setMinimumSize(50, 50);
32
33 QVBoxLayout *layout = new QVBoxLayout(this);
34 layout->addWidget(d->scratchpad);
35}
36
37Scratchpad::~Scratchpad()
38{
39}
40
42{
43 d->scratchpad->setModeManually(value);
44}
45
47{
48 d->scratchpad->setModeType(modeType);
49}
50
52{
53 d->scratchpad->linkCanvasToZoomLevel(value);
54}
55
57{
58 d->scratchpad->loadScratchpadImage(image);
59}
60
62{
63 return d->scratchpad->copyScratchpadImageData();
64}
65
67{
68 // need ability to set color
69 d->scratchpad->fillDefault();
70}
71
73{
74 d->scratchpad->setFillColor(color);
75}
QImage copyScratchpadImageData()
Take what is on the scratchpad area and grab image.
void setModeManually(bool value)
Switches between a GUI controlling the current mode and when mouse clicks control mode.
void linkCanvasZoom(bool value)
Makes a connection between the zoom of the canvas and scratchpad area so they zoom in sync.
void setFillColor(QColor color)
Fill the entire scratchpad with a color.
void setMode(QString modeName)
Manually set what mode scratchpad is in.
void clear()
Clears out scratchpad with color specified set during setup.
void loadScratchpadImage(QImage image)
Load image data to the scratchpad.
View represents one view on a document.
Definition View.h:25
void addWidget(QWidget *widget, int stretch, Qt::Alignment alignment)
T qobject_cast(QObject *object)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:20:53 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.