mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 11:16:55 +00:00
New method zoomedPixel to compute pixel amount also in HiDpi
The function does not use for now any information from the BufferView (only lyxrc), but this should eventually change if we want to honor multi monitor setups properly.
This commit is contained in:
parent
7a93aa47cc
commit
1a969fa4a6
@ -81,6 +81,7 @@
|
||||
#include "support/gettext.h"
|
||||
#include "support/lassert.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "support/lyxlib.h"
|
||||
#include "support/Package.h"
|
||||
#include "support/types.h"
|
||||
|
||||
@ -361,8 +362,8 @@ BufferView::~BufferView()
|
||||
|
||||
int BufferView::rightMargin() const
|
||||
{
|
||||
// The value used to be hardcoded to 10, which is 0.1in at 100dpi
|
||||
int const default_margin = Length(0.1, Length::IN).inPixels(0);
|
||||
// The value used to be hardcoded to 10
|
||||
int const default_margin = zoomedPixels(10);
|
||||
// The additional test for the case the outliner is opened.
|
||||
if (!full_screen_ || !lyxrc.full_screen_limit
|
||||
|| width_ < lyxrc.full_screen_width + 2 * default_margin)
|
||||
@ -385,6 +386,21 @@ int BufferView::inPixels(Length const & len) const
|
||||
}
|
||||
|
||||
|
||||
int BufferView::zoomedPixels(int pix) const
|
||||
{
|
||||
// FIXME: the dpi setting should really depend on the BufferView
|
||||
// (think different monitors).
|
||||
|
||||
// Zoom factor specified by user in percent
|
||||
double const zoom = lyxrc.currentZoom / 100.0; // [percent]
|
||||
|
||||
// DPI setting for monitor: pixels/inch
|
||||
double const dpi = lyxrc.dpi; // screen resolution [pixels/inch]
|
||||
|
||||
return support::iround(pix * zoom * dpi);
|
||||
}
|
||||
|
||||
|
||||
bool BufferView::isTopScreen() const
|
||||
{
|
||||
return 0 == d->scrollbarParameters_.min;
|
||||
|
@ -114,6 +114,11 @@ public:
|
||||
*/
|
||||
int inPixels(Length const & len) const;
|
||||
|
||||
/** Return the number of pixels equivalent to \c pix pixels at
|
||||
* 100dpi and 100% zoom.
|
||||
*/
|
||||
int zoomedPixels(int pix) const;
|
||||
|
||||
/// \return true if the BufferView is at the top of the document.
|
||||
bool isTopScreen() const;
|
||||
|
||||
|
@ -501,7 +501,7 @@ bool TextMetrics::redoParagraph(pit_type const pit)
|
||||
// Top and bottom margin of the document (only at top-level)
|
||||
if (text_->isMainText()) {
|
||||
// original value was 20px, which is 0.2in at 100dpi
|
||||
int const margin = Length(0.2, Length::IN).inPixels(0);
|
||||
int const margin = bv_->zoomedPixels(20);
|
||||
if (pit == 0) {
|
||||
pm.rows().front().dimension().asc += margin;
|
||||
/* coverity thinks that we should update pm.dim().asc
|
||||
|
@ -565,7 +565,7 @@ void InsetMathHull::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
|
||||
if (l)
|
||||
// Value was hardcoded to 30 pixels
|
||||
dim.wid += mi.base.inPixels(Length(0.3, Length::IN)) + l;
|
||||
dim.wid += mi.base.bv->zoomedPixels(30) + l;
|
||||
}
|
||||
|
||||
// reserve some space for marker.
|
||||
@ -674,7 +674,7 @@ void InsetMathHull::draw(PainterInfo & pi, int x, int y) const
|
||||
|
||||
if (l)
|
||||
// Value was hardcoded to 30 pixels
|
||||
xmath += pi.base.inPixels(Length(0.3, Length::IN)) + l;
|
||||
xmath += pi.base.bv->zoomedPixels(30) + l;
|
||||
}
|
||||
|
||||
InsetMathGrid::draw(pi, xmath + 1, y);
|
||||
|
Loading…
Reference in New Issue
Block a user