Cadabra
Computer algebra system for field theory problems
Loading...
Searching...
No Matches
ImageView.hh
Go to the documentation of this file.
1
2#pragma once
3
4#include <gtkmm/box.h>
5#include <gtkmm/image.h>
6#include <gtkmm/menu.h>
7#ifndef USE_GTK4
8#include <gtkmm/eventbox.h>
9#endif
10#include <gtkmm/drawingarea.h>
11
12namespace cadabra {
13
14 class ImageView;
15
18
19 class ImageArea : public Gtk::DrawingArea {
20 public:
23 const std::string& filename, bool raster);
24
25 void set_image_from_base64(const std::string& b64);
26 void set_image_from_svg(const std::string& svg);
27
28 // Re-render the image from the raw bytes at the indicated
29 // width (in logical pixels, which may be multiple display pixels).
30 void rerender(int width);
31
32 friend ImageView;
33 protected:
34 virtual bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr) override;
35
36 private:
37 Glib::RefPtr<Gdk::Pixbuf> pixbuf;
38
39 std::string decoded; // raw byte content of image
43 };
44
45
49
50#ifdef USE_GTK4
51 class ImageView : public Gtk::Box {
52#else
53 class ImageView : public Gtk::EventBox {
54#endif
55 public:
56 ImageView(double display_scale, int logical_width);
57 virtual ~ImageView();
58
59 virtual bool on_motion_notify_event(GdkEventMotion *event) override;
60 virtual bool on_button_press_event(GdkEventButton *event) override;
61 virtual bool on_button_release_event(GdkEventButton *event) override;
62 void on_save_as() const;
63
64 void set_image_from_base64(const std::string& b64);
65 void set_image_from_svg(const std::string& svg);
66
67 private:
69
70 bool sizing;
71 double prev_x, prev_y;
73
74 Gtk::Menu context_menu;
75 Gtk::MenuItem item_save_as;
76 };
77
78};
Widget which behaves as Gtk::Image, but instead uses the full device resolution (so images come out s...
Definition ImageView.hh:19
void set_image_from_svg(const std::string &svg)
Definition ImageView.cc:132
friend ImageView
Definition ImageView.hh:32
void set_image_from_base64(const std::string &b64)
Definition ImageView.cc:115
double display_scale
Definition ImageView.hh:41
void rerender(int width)
Definition ImageView.cc:139
int logical_width
Definition ImageView.hh:42
bool is_raster
Definition ImageView.hh:40
virtual bool on_draw(const Cairo::RefPtr< Cairo::Context > &cr) override
Definition ImageView.cc:184
std::string decoded
Definition ImageView.hh:39
Glib::RefPtr< Gdk::Pixbuf > pixbuf
Definition ImageView.hh:37
An image viewing widget.
Definition ImageView.hh:53
void set_image_from_svg(const std::string &svg)
Definition ImageView.cc:127
Gtk::MenuItem item_save_as
Definition ImageView.hh:75
ImageArea area
Definition ImageView.hh:68
void set_image_from_base64(const std::string &b64)
Definition ImageView.cc:110
virtual bool on_button_release_event(GdkEventButton *event) override
Definition ImageView.cc:101
int height_at_press
Definition ImageView.hh:72
virtual bool on_motion_notify_event(GdkEventMotion *event) override
Definition ImageView.cc:73
virtual bool on_button_press_event(GdkEventButton *event) override
Definition ImageView.cc:83
int width_at_press
Definition ImageView.hh:72
virtual ~ImageView()
Definition ImageView.cc:48
bool sizing
Definition ImageView.hh:70
Gtk::Menu context_menu
Definition ImageView.hh:74
double prev_x
Definition ImageView.hh:71
void on_save_as() const
Definition ImageView.cc:52
double prev_y
Definition ImageView.hh:71
Functions to handle the exchange properties of two or more symbols in a product.
Definition Adjform.cc:83
void set(rset_t::iterator &num, multiplier_t fac)
Definition Storage.cc:1179