Note: This commit has only been tested on MacOS Changes: - Icons now use the native hidpi support from Gtk (through Icon Theme) - Icons are now directly generated from scalable file (i.e. SVG file) - Widget sizes are scaled based on DPI and scale factor - Font size is scaled based on DPI and scale factor
89 lines
2.3 KiB
C++
89 lines
2.3 KiB
C++
/*
|
|
* This file is part of RawTherapee.
|
|
*
|
|
* Copyright (c) 2018 Jean-Christophe FRISCH <natureh.510@gmail.com>
|
|
* Copyright (c) 2022 Pierre CABRERA <pierre.cab@gmail.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 "rtscalable.h"
|
|
|
|
/**
|
|
* @brief A custom class in order to handle Hi-DPI surface.
|
|
*/
|
|
class RTSurface final : public RTScalable
|
|
{
|
|
public:
|
|
enum RTSurfaceType {
|
|
InvalidType = 1,
|
|
IconType = 2,
|
|
PNGType = 3,
|
|
SVGType = 4
|
|
};
|
|
|
|
private:
|
|
double dpiBack; // Used to identify dpi change
|
|
int scaleBack; // Used to identify scale change
|
|
RTSurfaceType type;
|
|
Glib::ustring name;
|
|
Gtk::IconSize icon_size;
|
|
Cairo::RefPtr<Cairo::ImageSurface> surface;
|
|
|
|
public:
|
|
RTSurface();
|
|
explicit RTSurface(const Glib::ustring &icon_name, const Gtk::IconSize iconSize);
|
|
explicit RTSurface(const Glib::ustring &fname);
|
|
|
|
int getWidth();
|
|
int getHeight();
|
|
bool hasSurface();
|
|
|
|
Cairo::RefPtr<Cairo::ImageSurface> get();
|
|
};
|
|
|
|
/**
|
|
* @brief A custom class in order to handle Hi-DPI pixbuf.
|
|
*/
|
|
class RTPixbuf final : public RTScalable
|
|
{
|
|
public:
|
|
enum RTPixbufType {
|
|
InvalidType = 1,
|
|
IconType = 2,
|
|
PNGType = 3,
|
|
SVGType = 4
|
|
};
|
|
|
|
private:
|
|
double dpiBack; // Used to identify dpi change
|
|
int scaleBack; // Used to identify scale change
|
|
RTPixbufType type;
|
|
Glib::ustring name;
|
|
Gtk::IconSize icon_size;
|
|
Glib::RefPtr<Gdk::Pixbuf> pixbuf;
|
|
|
|
public:
|
|
RTPixbuf();
|
|
explicit RTPixbuf(const Glib::ustring &icon_name, const Gtk::IconSize iconSize);
|
|
explicit RTPixbuf(const Glib::ustring &fname);
|
|
|
|
int getWidth();
|
|
int getHeight();
|
|
bool hasPixbuf();
|
|
|
|
Glib::RefPtr<Gdk::Pixbuf> get();
|
|
};
|