Basic feature implemented. Needs improvement.

This commit is contained in:
Matthias Koefferlein
2024-08-03 09:55:59 +02:00
parent a5ea8eb590
commit cd69f29508
10 changed files with 62 additions and 67 deletions
+12 -5
View File
@@ -151,6 +151,7 @@ LayoutCanvas::LayoutCanvas (lay::LayoutViewBase *view)
m_background (0), m_foreground (0), m_active (0),
m_oversampling (1),
m_hrm (false),
m_srm (false),
m_need_redraw (false),
m_redraw_clearing (false),
m_redraw_force_update (true),
@@ -201,11 +202,7 @@ LayoutCanvas::~LayoutCanvas ()
double
LayoutCanvas::resolution () const
{
if (m_hrm) {
return 1.0 / m_oversampling;
} else {
return 1.0 / (m_oversampling * dpr ());
}
return (m_srm ? 1.0 : 1.0 / m_oversampling) * (m_hrm ? 1.0 : 1.0 / dpr ());
}
#if defined(HAVE_QT)
@@ -283,6 +280,16 @@ LayoutCanvas::set_highres_mode (bool hrm)
}
}
void
LayoutCanvas::set_subres_mode (bool srm)
{
if (srm != m_srm) {
m_image_cache.clear ();
m_srm = srm;
do_redraw_all ();
}
}
double
LayoutCanvas::dpr () const
{
+14
View File
@@ -277,6 +277,19 @@ public:
return m_hrm;
}
/**
* @brief Set sub resolution mode (sub-pixel resolution in oversampling mode)
*/
void set_subres_mode (bool srm);
/**
* @brief Gets the sub resolution mode flag
*/
bool subres_mode () const
{
return m_srm;
}
/**
* @brief Gets the default device pixel ratio for this canvas
*/
@@ -412,6 +425,7 @@ private:
std::map<unsigned int, std::vector <lay::ViewOp> > m_scaled_view_ops;
unsigned int m_oversampling;
bool m_hrm;
bool m_srm;
double m_gamma;
bool m_need_redraw;
@@ -790,6 +790,13 @@ LayoutViewBase::configure (const std::string &name, const std::string &value)
mp_canvas->set_highres_mode (hrm);
return true;
} else if (name == cfg_subres_mode) {
bool srm = false;
tl::from_string (value, srm);
mp_canvas->set_subres_mode (srm);
return true;
} else if (name == cfg_image_cache_size) {
int sz = 0;
@@ -114,6 +114,7 @@ public:
options.push_back (std::pair<std::string, std::string> (cfg_array_border_instances, "false"));
options.push_back (std::pair<std::string, std::string> (cfg_bitmap_oversampling, "1"));
options.push_back (std::pair<std::string, std::string> (cfg_highres_mode, "false"));
options.push_back (std::pair<std::string, std::string> (cfg_subres_mode, "false"));
options.push_back (std::pair<std::string, std::string> (cfg_image_cache_size, "1"));
options.push_back (std::pair<std::string, std::string> (cfg_default_font_size, "0"));
options.push_back (std::pair<std::string, std::string> (cfg_color_palette, lay::ColorPalette ().to_string ()));
+1
View File
@@ -126,6 +126,7 @@ static const std::string cfg_tip_window_hidden ("tip-window-hidden");
static const std::string cfg_bitmap_oversampling ("bitmap-oversampling");
static const std::string cfg_highres_mode ("highres-mode");
static const std::string cfg_subres_mode ("subres-mode");
static const std::string cfg_image_cache_size ("image-cache-size");
static const std::string cfg_default_font_size ("default-font-size");