summaryrefslogtreecommitdiffstats
path: root/src/ui/widget/pattern-store.h
blob: 9c183d1e684fa3a5d5b75f5a022c0e10f8c84e6b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// SPDX-License-Identifier: GPL-2.0-or-later

#ifndef INKSCAPE_UI_WIDGET_PATTERN_STORE_H
#define INKSCAPE_UI_WIDGET_PATTERN_STORE_H
/*
 * Copyright (C) 2022 Authors
 *
 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
 */

#include <optional>
#include <2geom/transforms.h>
#include <giomm/liststore.h>
#include <gtkmm/widget.h>
#include "color.h"
#include "ui/filtered-store.h"

class SPDocument;

namespace Inkscape {
namespace UI {
namespace Widget {

// pattern parameters
struct PatternItem : Glib::Object {
    Cairo::RefPtr<Cairo::Surface> pix;
    std::string id;
    std::string label;
    bool stock = false;
    bool uniform_scale = false;
    Geom::Affine transform;
    Geom::Point offset;
    std::optional<SPColor> color;
    Geom::Scale gap;
    SPDocument* collection = nullptr;

    bool operator == (const PatternItem& item) const {
        // compare all attributes apart from pixmap preview
        return
            id == item.id &&
            label == item.label &&
            stock == item.stock &&
            uniform_scale == item.uniform_scale &&
            transform == item.transform &&
            offset == item.offset &&
            color == item.color &&
            gap == item.gap &&
            collection == item.collection;
    }
};

struct PatternStore {
    Inkscape::FilteredStore<PatternItem> store;
    std::map<Gtk::Widget*, Glib::RefPtr<PatternItem>> widgets_to_pattern;
};

}
}
}

#endif