summaryrefslogtreecommitdiffstats
path: root/src/ui/widget/export-preview.h
blob: ad7f49c20e25994fa52074871249bad619e54164 (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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// SPDX-License-Identifier: GPL-2.0-or-later
/* Authors:
 *   Anshudhar Kumar Singh <anshudhar2001@gmail.com>
 *
 * Copyright (C) 2021 Authors
 *
 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
 */

#ifndef SP_EXPORT_PREVIEW_H
#define SP_EXPORT_PREVIEW_H

#include <gtkmm.h>

#include "desktop.h"
#include "document.h"

class SPObject;
class SPItem;

namespace Glib {
class Timer;
}

namespace Inkscape {
class Drawing;
namespace UI {
namespace Dialog {

class ExportPreview : public Gtk::Image
{
public:
    ExportPreview() {};
    ~ExportPreview() override;

    ExportPreview(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& refGlade):Gtk::Image(cobject){};
private:
    int size = 128; // size of preview image
    bool isLastHide = false;
    SPDocument *_document = nullptr;
    SPItem *_item = nullptr;
    Geom::OptRect _dbox;

    Drawing *drawing = nullptr;
    unsigned int visionkey = 0;
    Glib::Timer *timer = nullptr;
    Glib::Timer *renderTimer = nullptr;
    bool pending = false;
    gdouble minDelay = 0.1;

    std::vector<SPItem *> _hidden_excluded;
    bool _hidden_requested = false;
public:
    void setDocument(SPDocument *document);
    void refreshHide(const std::vector<SPItem *> &list = {});
    void hide_other_items_recursively(SPObject *o, const std::vector<SPItem *> &list);
    void setItem(SPItem *item);
    void setDbox(double x0, double x1, double y0, double y1);
    void queueRefresh();
    void resetPixels();

    void setSize(int newSize)
    {
        size = newSize;
        resetPixels();
    }
private:
    void refreshPreview();
    void renderPreview();
    bool refreshCB();
    void performHide(const std::vector<SPItem *> *list);
};
} // namespace Dialog
} // namespace UI
} // namespace Inkscape
#endif

/*
  Local Variables:
  mode:c++
  c-file-style:"stroustrup"
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
  indent-tabs-mode:nil
  fill-column:99
  End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :