File: inspector.h

package info (click to toggle)
rawtherapee 5.12-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 124,328 kB
  • sloc: cpp: 271,715; ansic: 27,904; sh: 1,109; python: 521; cs: 155; xml: 57; makefile: 15
file content (142 lines) | stat: -rw-r--r-- 4,616 bytes parent folder | download
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/*
 *  This file is part of RawTherapee.
 *
 *  Copyright (c) 2004-2010 Gabor Horvath <hgabor@rawtherapee.com>
 *
 *  RawTherapee is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  RawTherapee is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with RawTherapee.  If not, see <https://www.gnu.org/licenses/>.
 */
#pragma once

#include <gtkmm.h>

#include "guiutils.h"

#include "rtengine/coord2d.h"

class InspectorBuffer
{
//private:
//    int infoFromImage (const Glib::ustring& fname);

public:
    BackBuffer imgBuffer;
    Glib::ustring imgPath;
    int currTransform;  // coarse rotation from RT, not from shot orientation
    bool fromRaw;

    explicit InspectorBuffer(const Glib::ustring &imgagePath);
    //~InspectorBuffer();
};

class Inspector final : public Gtk::DrawingArea
{

private:
    rtengine::Coord2D center;
    std::vector<InspectorBuffer*> images;
    InspectorBuffer* currImage;
    bool scaled;  // fit image into window
    double scale; // current scale
    double zoomScale, zoomScaleBegin; // scale during zoom
    rtengine::Coord2D centerBegin, dcenterBegin; // center during zoom
    bool active;
    bool pinned;
    bool dirty;
    bool initialized;
    bool fullscreen;  // window is shown in fullscreen mode
    bool keyDown;
    bool windowShowing;

    sigc::connection delayconn;
    Glib::ustring next_image_path;
    rtengine::Coord2D next_image_pos;

    Gtk::Window *window;
    bool on_key_release(GdkEventKey *event);
    bool on_key_press(GdkEventKey *event);

    void on_window_hide();
    bool on_inspector_window_state_event(GdkEventWindowState *event);

    rtengine::Coord button_pos;
    bool on_button_press_event(GdkEventButton *event) override;
    bool on_motion_notify_event(GdkEventMotion *event) override;

    bool on_scroll_event(GdkEventScroll *event) override;
    void moveCenter(int delta_x, int delta_y, int imW, int imH, int deviceScale);

    Glib::RefPtr<Gtk::GestureZoom> gestureZoom;
    void beginZoom(double x, double y);
    void on_zoom_begin(GdkEventSequence *);
    void on_zoom_scale_changed(double zscale);

    bool on_draw(const ::Cairo::RefPtr< Cairo::Context> &cr) override;
    void deleteBuffers();

    bool doSwitchImage();

public:
    Inspector();
    ~Inspector() override;

    /** @brief Show or hide window
     * @param pinned pin window
     * @param scaled fit image into window
     */
    void showWindow(bool pinned, bool scaled = true);

    /**
     * Hide the window.
     */
    void hideWindow();

    /** @brief Mouse movement to a new position
     * @param pos Location of the mouse, in percentage (i.e. [0;1] range) relative to the full size image ; -1,-1 == out of the image
     * @param transform H/V flip and coarse rotation transformation
     */
    void mouseMove (rtengine::Coord2D pos, int transform);

    /** @brief A new image is being flown over
     * @param fullPath Full path of the image that is being hovered inspect, or an empty string if out of any image.
     */
    void switchImage (const Glib::ustring &fullPath);

    /** @brief Set the new coarse rotation transformation
     * @param transform A semi-bitfield coarse transformation using #defines from iimage.h
     */
    void setTransformation (int transform);

    /** @brief Use this method to flush all image buffer whenever the Inspector panel is hidden
     */
    void flushBuffers ();

    /** @brief Set the inspector on/off
     * @param state true if to activate the Inspector, false to disable it and flush the buffers
     */
    void setActive(bool state);

    /** @brief Get the on/off state
     */
    bool isActive() const
    {
        return active;
    };

    Gtk::SizeRequestMode get_request_mode_vfunc () const override;
    void get_preferred_height_vfunc (int& minimum_height, int& natural_height) const override;
    void get_preferred_width_vfunc (int &minimum_width, int &natural_width) const override;
    void get_preferred_height_for_width_vfunc (int width, int &minimum_height, int &natural_height) const override;
    void get_preferred_width_for_height_vfunc (int height, int &minimum_width, int &natural_width) const override;

};