Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
stores.h
Go to the documentation of this file.
1
// SPDX-License-Identifier: GPL-2.0-or-later
5
/*
6
* Copyright (C) 2022 PBS <pbs3141@gmail.com>
7
* Released under GNU GPL v2+, read the file 'COPYING' for more information.
8
*/
9
10
#ifndef INKSCAPE_UI_WIDGET_CANVAS_STORES_H
11
#define INKSCAPE_UI_WIDGET_CANVAS_STORES_H
12
13
#include "
fragment.h
"
14
#include "util.h"
15
#include "
ui/util.h
"
16
17
namespace
Inkscape::UI::Widget
{
18
19
struct
Fragment;
20
class
Prefs;
21
class
Graphics;
22
23
class
Stores
24
{
25
public
:
26
enum class
Mode
27
{
28
None
,
29
Normal
,
30
Decoupled
31
};
32
33
enum class
Action
34
{
35
None
,
36
Recreated
,
37
Shifted
38
};
39
40
struct
Store
:
Fragment
41
{
46
Cairo::RefPtr<Cairo::Region>
drawn
;
47
};
48
50
Stores
(
Prefs
const
&prefs)
51
:
_mode
(
Mode
::
None
)
52
,
_graphics
(nullptr)
53
,
_prefs
(prefs) {}
54
56
void
set_graphics
(
Graphics
*g) {
_graphics
= g; }
57
59
void
reset
();
60
62
Action
update
(
Fragment
const
&view);
63
65
Action
finished_draw
(
Fragment
const
&view);
66
68
void
mark_drawn
(
Geom::IntRect
const
&rect) {
_store
.
drawn
->do_union(
geom_to_cairo
(rect)); }
69
70
// Getters.
71
Store
const
&
store
()
const
{
return
_store
; }
72
Store
const
&
snapshot
()
const
{
return
_snapshot
; }
73
Mode
mode
()
const
{
return
_mode
; }
74
75
private
:
76
// Internal state.
77
Mode
_mode
;
78
Store
_store
,
_snapshot
;
79
80
// The graphics object that executes the operations on the stores.
81
Graphics
*
_graphics
;
82
83
// The preferences object we read preferences from.
84
Prefs
const
&
_prefs
;
85
86
// Internal actions.
87
Geom::IntRect
centered
(
Fragment
const
&view)
const
;
88
void
recreate_store
(
Fragment
const
&view);
89
void
shift_store
(
Fragment
const
&view);
90
void
take_snapshot
(
Fragment
const
&view);
91
void
snapshot_combine
(
Fragment
const
&view);
92
};
93
94
}
// namespace Inkscape::UI::Widget
95
96
#endif
// INKSCAPE_UI_WIDGET_CANVAS_STORES_H
97
98
/*
99
Local Variables:
100
mode:c++
101
c-file-style:"stroustrup"
102
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
103
indent-tabs-mode:nil
104
fill-column:99
105
End:
106
*/
107
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
Geom::GenericRect
Axis aligned, non-empty, generic rectangle.
Definition
generic-rect.h:60
Inkscape::UI::Widget::Graphics
Definition
graphics.h:38
Inkscape::UI::Widget::Prefs
Definition
prefs.h:10
Inkscape::UI::Widget::Stores
Definition
stores.h:24
Inkscape::UI::Widget::Stores::recreate_store
void recreate_store(Fragment const &view)
Definition
stores.cpp:103
Inkscape::UI::Widget::Stores::Stores
Stores(Prefs const &prefs)
Construct a blank object with no stores.
Definition
stores.h:50
Inkscape::UI::Widget::Stores::update
Action update(Fragment const &view)
Respond to a viewport change. (Requires a valid graphics.)
Definition
stores.cpp:257
Inkscape::UI::Widget::Stores::mark_drawn
void mark_drawn(Geom::IntRect const &rect)
Record a rectangle as being drawn to the store.
Definition
stores.h:68
Inkscape::UI::Widget::Stores::Mode
Mode
Definition
stores.h:27
Inkscape::UI::Widget::Stores::Mode::None
@ None
Inkscape::UI::Widget::Stores::Mode::Normal
@ Normal
Not initialised or just reset; no stores exist yet.
Inkscape::UI::Widget::Stores::Mode::Decoupled
@ Decoupled
Normal mode consisting of just a backing store.
Inkscape::UI::Widget::Stores::_store
Store _store
Definition
stores.h:78
Inkscape::UI::Widget::Stores::mode
Mode mode() const
Definition
stores.h:73
Inkscape::UI::Widget::Stores::_graphics
Graphics * _graphics
Definition
stores.h:81
Inkscape::UI::Widget::Stores::centered
Geom::IntRect centered(Fragment const &view) const
Definition
stores.cpp:97
Inkscape::UI::Widget::Stores::snapshot
Store const & snapshot() const
Definition
stores.h:72
Inkscape::UI::Widget::Stores::shift_store
void shift_store(Fragment const &view)
Definition
stores.cpp:113
Inkscape::UI::Widget::Stores::store
Store const & store() const
Definition
stores.h:71
Inkscape::UI::Widget::Stores::set_graphics
void set_graphics(Graphics *g)
Set the pointer to the graphics object.
Definition
stores.h:56
Inkscape::UI::Widget::Stores::snapshot_combine
void snapshot_combine(Fragment const &view)
Definition
stores.cpp:137
Inkscape::UI::Widget::Stores::take_snapshot
void take_snapshot(Fragment const &view)
Definition
stores.cpp:125
Inkscape::UI::Widget::Stores::reset
void reset()
Discards all stores. (The actual operation on the graphics is performed on the next update()....
Definition
stores.cpp:249
Inkscape::UI::Widget::Stores::_mode
Mode _mode
Definition
stores.h:77
Inkscape::UI::Widget::Stores::_prefs
Prefs const & _prefs
Definition
stores.h:84
Inkscape::UI::Widget::Stores::finished_draw
Action finished_draw(Fragment const &view)
Respond to drawing of the backing store having finished. (Requires a valid graphics....
Definition
stores.cpp:346
Inkscape::UI::Widget::Stores::_snapshot
Store _snapshot
Definition
stores.h:78
Inkscape::UI::Widget::Stores::Action
Action
Definition
stores.h:34
Inkscape::UI::Widget::Stores::Action::Shifted
@ Shifted
The backing store was completely recreated.
Inkscape::UI::Widget::Stores::Action::Recreated
@ Recreated
The backing store was not changed.
fragment.h
Inkscape::UI::Widget
Custom widgets.
Definition
desktop.h:126
Inkscape::UI::Widget::Fragment
A "fragment" is a rectangle of drawn content at a specfic place.
Definition
fragment.h:12
Inkscape::UI::Widget::Stores::Store
Definition
stores.h:41
Inkscape::UI::Widget::Stores::Store::drawn
Cairo::RefPtr< Cairo::Region > drawn
The region of space containing drawn content.
Definition
stores.h:46
geom_to_cairo
Cairo::RectangleInt geom_to_cairo(const Geom::IntRect &rect)
Definition
util.cpp:338
util.h
src
ui
widget
canvas
stores.h
Generated on Sun Jul 13 2025 04:02:22 for Inkscape by
1.9.8