blob: 86d527597a26a0ba40e97711540448bfe91bc181 (
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
62
63
64
65
66
|
// SPDX-License-Identifier: GPL-2.0-or-later
#ifndef INKSCAPE_PATTERN_MANAGER_H
#define INKSCAPE_PATTERN_MANAGER_H
#include <gtkmm/treemodel.h>
#include <vector>
#include <unordered_map>
#include "ui/widget/pattern-store.h"
class SPPattern;
class SPDocument;
namespace Inkscape {
class PatternManager {
public:
static PatternManager& get();
~PatternManager() = default;
struct Category : Glib::Object {
const Glib::ustring name;
const std::vector<SPPattern*> patterns;
const bool all;
Category(Glib::ustring name, std::vector<SPPattern*> patterns, bool all)
: name(std::move(name)), patterns(std::move(patterns)), all(all) {}
};
class PatternCategoryColumns : public Gtk::TreeModel::ColumnRecord {
public:
PatternCategoryColumns() {
add(name);
add(category);
add(all_patterns);
}
Gtk::TreeModelColumn<Glib::ustring> name;
Gtk::TreeModelColumn<Glib::RefPtr<Category>> category;
Gtk::TreeModelColumn<bool> all_patterns;
} columns;
// get all stock pattern categories
Glib::RefPtr<Gtk::TreeModel> get_categories();
// get pattern description item
Glib::RefPtr<Inkscape::UI::Widget::PatternItem> get_item(SPPattern* pattern);
// get pattern image on a solid background for use in UI lists
Cairo::RefPtr<Cairo::Surface> get_image(SPPattern* pattern, int width, int height, double device_scale);
// get pattern image on checkerboard background for use as a larger preview
Cairo::RefPtr<Cairo::Surface> get_preview(SPPattern* pattern, int width, int height, unsigned int rgba_background, double device_scale);
private:
PatternManager();
Glib::RefPtr<Gtk::TreeModel> _model;
std::vector<std::shared_ptr<SPDocument>> _documents;
std::vector<Glib::RefPtr<Category>> _categories;
std::unordered_map<SPPattern*, Glib::RefPtr<Inkscape::UI::Widget::PatternItem>> _cache;
std::shared_ptr<SPDocument> _preview_doc;
std::shared_ptr<SPDocument> _big_preview_doc;
};
} // namespace
#endif
|