Initial commit for real hidpi support

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
This commit is contained in:
Pandagrapher
2022-08-19 16:47:28 +02:00
parent 1e2dc30738
commit 89d2bdce5b
108 changed files with 1949 additions and 2032 deletions

View File

@@ -26,14 +26,11 @@
SHCSelector::SHCSelector() : movingPosition(-1), tmpX(0.0), tmpPos(0.0), wslider(0.0), cl(nullptr), coloredBar(RTO_Left2Right)
{
int s = RTScalable::getScale();
positions[0] = defaults[0] = 0.25;
positions[1] = defaults[1] = 0.5;
positions[2] = defaults[2] = 0.75;
leftMargin = (RADIUS - 1.5) * s;
rightMargin = (RADIUS - 1.5) * s;
leftMargin = static_cast<int>(RTScalable::scalePixelSize(RADIUS - 1.5));
rightMargin = static_cast<int>(RTScalable::scalePixelSize(RADIUS - 1.5));
Glib::RefPtr<Gtk::StyleContext> style = get_style_context();
style->add_class("drawingarea");
@@ -62,14 +59,13 @@ void SHCSelector::get_preferred_height_vfunc (int &minimum_height, int &natural_
void SHCSelector::get_preferred_width_vfunc (int &minimum_width, int &natural_width) const
{
int s = RTScalable::getScale();
minimum_width = 100 * s;
natural_width = 150 * s;
minimum_width = RTScalable::scalePixelSize(100);
natural_width = RTScalable::scalePixelSize(150);
}
void SHCSelector::get_preferred_height_for_width_vfunc (int width, int &minimum_height, int &natural_height) const
{
natural_height = minimum_height = 14 * RTScalable::getScale();
natural_height = minimum_height = RTScalable::scalePixelSize(14);
}
void SHCSelector::get_preferred_width_for_height_vfunc (int height, int &minimum_width, int &natural_width) const
@@ -141,7 +137,7 @@ void SHCSelector::updateBackBuffer()
int w = get_width () - leftMargin - rightMargin;
int h = get_height ();
double s = RTScalable::getScale();
const double s = RTScalable::scalePixelSize(1.);
wslider = (double)std::max(h / 5, 10) * s;
double hwslider = wslider / 2.;
@@ -244,7 +240,7 @@ bool SHCSelector::on_button_press_event (GdkEventButton* event)
double w = double(get_width () - leftMargin - rightMargin);
movingPosition = -1;
double s = RTScalable::getScale();
const double s = RTScalable::scalePixelSize(1.);
for (int i = 0; i < 3; i++) {
double currPos = double(leftMargin) + 1. * s + (w - 2. * s) * positions[i];
@@ -290,7 +286,7 @@ bool SHCSelector::on_motion_notify_event (GdkEventMotion* event)
{
if (movingPosition >= 0) {
double s = RTScalable::getScale();
const double s = RTScalable::scalePixelSize(1.);
double innerw = double(get_width () - leftMargin - rightMargin) - 2. * s;
positions[movingPosition] = tmpPos + (event->x - tmpX) / innerw;