API Documentation
Loading...
Searching...
No Matches
ImageView.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Widgets
28File: ImageView
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/QTTools.h>
35#include <QWidget>
36#include <QStyle>
37namespace NDEVR
38{
39 /**--------------------------------------------------------------------------------------------------
40 \brief A widget that shows a raster image or icon.
41 *-----------------------------------------------------------------------------------------------**/
42 class NDEVR_WIDGETS_API ImageView : public QWidget
43 {
44 public:
46 {
47 e_keep//no size adjustment
48 , e_zoom_in//crop image frame
49 , e_zoom_out//Keep entire image in frame
50 , e_stretch//stretch image to frame
51 };
52 ImageView(const String& image, QWidget* parent = nullptr);
53 ImageView(QWidget* parent = nullptr);
55 void setImageID(const String& image, bool force_refresh = false);
56 void setIconID(const String& image, bool force_refresh = false);
57 void clearImage();
58 void paintEvent(QPaintEvent* event) override;
59 void setImage(const QPixmap& pixmap);
60 void setAlignment(Qt::Alignment alignment);
61 void setSizeHintPixelMetric(QStyle::PixelMetric metric);
62 void setSmoothResize(bool smooth_resize)
63 {
64 m_smooth_transform = smooth_resize;
65 }
66 void setImage(const QImage& image);
67 void setIcon(const QIcon& image, QIcon::Mode mode = QIcon::Mode::Normal);
68 void setIconMode(QIcon::Mode mode);
69 QSize sizeHint() const override;
70 QSize minimumSizeHint() const override
71 {
72 return QSize(0, 0);
73 }
74 void setAutoResize(bool auto_resize)
75 {
76 m_auto_resize = auto_resize;
77 }
79 {
80 m_view_mode = mode;
81 }
82 //0% = no blend, 100%=only blend_image
83 void setBlendFactor(fltp04 blend_factor);
84 void setBlendImage(const QPixmap& blend_image);
85 void resizeEvent(QResizeEvent* resize_event) override;
87 {
88 m_icon_scale = scale;
89 }
90 void setIgnoreDPR(bool ignore);
91 void setForceAspectRatioH(bool force);
92 void setForceAspectRatioW(bool force);
93 QIcon icon() { return m_icon; };
94 private:
95 void setupIconListener();
96 QRect alignRect(QSize size, QSize preferred_size) const;
97 private:
98 ViewMode m_view_mode = ViewMode::e_zoom_out;
99 bool m_auto_resize = true;
100 bool m_smooth_transform = true;
101 bool m_force_aspect_ratio_width = false;
102 bool m_force_aspect_ratio_height = false;
103 bool m_ignore_device_pixel_ratio = false;
104 fltp08 m_icon_scale;
105 fltp04 m_blend_factor;
106 QPixmap m_image;
107 QPixmap m_blend_image;
108 QIcon m_icon;
109 String m_image_path;
110 String m_icon_path;
111 QIcon::Mode m_icon_mode;
112 QStyle::PixelMetric m_size_hint_pixel_metric;
113 Qt::Alignment m_alignment;
114 QTResourceListener* m_theme_listener;
115 };
116
117
118}
#define NDEVR_WIDGETS_API
Definition DLLInfo.h:81
A widget that shows a raster image or icon.
Definition ImageView.h:43
ImageView(QWidget *parent=nullptr)
QSize minimumSizeHint() const override
Definition ImageView.h:70
void setIconID(const String &image, bool force_refresh=false)
void setViewMode(ViewMode mode)
Definition ImageView.h:78
void setImage(const QImage &image)
void setBlendFactor(fltp04 blend_factor)
void setImageScale(fltp08 scale)
Definition ImageView.h:86
QSize sizeHint() const override
ViewMode
Definition ImageView.h:46
void setAutoResize(bool auto_resize)
Definition ImageView.h:74
void setBlendImage(const QPixmap &blend_image)
void setSizeHintPixelMetric(QStyle::PixelMetric metric)
void setForceAspectRatioW(bool force)
void setAlignment(Qt::Alignment alignment)
void paintEvent(QPaintEvent *event) override
void setSmoothResize(bool smooth_resize)
Definition ImageView.h:62
void setImage(const QPixmap &pixmap)
void setImageID(const String &image, bool force_refresh=false)
void setIgnoreDPR(bool ignore)
QIcon icon()
Definition ImageView.h:93
void resizeEvent(QResizeEvent *resize_event) override
void setForceAspectRatioH(bool force)
void setIconMode(QIcon::Mode mode)
void setIcon(const QIcon &image, QIcon::Mode mode=QIcon::Mode::Normal)
ImageView(const String &image, QWidget *parent=nullptr)
Definition QTTools.h:179
The core String class for the software.
Definition String.h:47
Definition ACIColor.h:37
float fltp04
Defines an alias representing a 4 byte floating-point number.
Definition BaseValues.hpp:125
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:146