mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-28 20:45:47 +00:00
Make InsetInfo math/IPA icons visible in dark mode
This does not show the real colors, but the icons are at least readable.
This commit is contained in:
parent
e6e30caca5
commit
148748b0c2
@ -57,7 +57,7 @@ public:
|
|||||||
void point(int, int, Color) override {}
|
void point(int, int, Color) override {}
|
||||||
|
|
||||||
/// draw an image from the image cache
|
/// draw an image from the image cache
|
||||||
void image(int, int, int, int, graphics::Image const &) override {}
|
void image(int, int, int, int, graphics::Image const &, bool) override {}
|
||||||
|
|
||||||
/// draw a string
|
/// draw a string
|
||||||
void text(int, int, docstring const &, FontInfo const &) override {}
|
void text(int, int, docstring const &, FontInfo const &) override {}
|
||||||
|
@ -127,7 +127,7 @@ public:
|
|||||||
|
|
||||||
/// draw an image from the image cache
|
/// draw an image from the image cache
|
||||||
virtual void image(int x, int y, int w, int h,
|
virtual void image(int x, int y, int w, int h,
|
||||||
graphics::Image const & image) = 0;
|
graphics::Image const & image, bool const darkmode = false) = 0;
|
||||||
|
|
||||||
/// draw a string at position x, y (y is the baseline).
|
/// draw a string at position x, y (y is the baseline).
|
||||||
virtual void text(int x, int y, docstring const & str, FontInfo const & f) = 0;
|
virtual void text(int x, int y, docstring const & str, FontInfo const & f) = 0;
|
||||||
|
@ -233,14 +233,24 @@ void GuiPainter::arc(int x, int y, unsigned int w, unsigned int h,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GuiPainter::image(int x, int y, int w, int h, graphics::Image const & i)
|
void GuiPainter::image(int x, int y, int w, int h, graphics::Image const & i, bool const darkmode)
|
||||||
{
|
{
|
||||||
graphics::GuiImage const & qlimage =
|
graphics::GuiImage const & qlimage =
|
||||||
static_cast<graphics::GuiImage const &>(i);
|
static_cast<graphics::GuiImage const &>(i);
|
||||||
|
|
||||||
fillRectangle(x, y, w, h, Color_graphicsbg);
|
fillRectangle(x, y, w, h, Color_graphicsbg);
|
||||||
|
|
||||||
QImage const & image = qlimage.image();
|
QImage image = qlimage.image();
|
||||||
|
|
||||||
|
QPalette palette = QPalette();
|
||||||
|
QColor text_color = palette.color(QPalette::Active, QPalette::WindowText);
|
||||||
|
QColor bg_color = palette.color(QPalette::Active, QPalette::Window);
|
||||||
|
// guess whether we are in dark mode
|
||||||
|
if (darkmode && text_color.black() < bg_color.black())
|
||||||
|
// FIXME this is only a cheap approximation
|
||||||
|
// Ideally, replace colors as in GuiApplication::prepareForDarkmode()
|
||||||
|
image.invertPixels();
|
||||||
|
|
||||||
QRectF const drect = QRectF(x, y, w, h);
|
QRectF const drect = QRectF(x, y, w, h);
|
||||||
QRectF const srect = QRectF(0, 0, image.width(), image.height());
|
QRectF const srect = QRectF(0, 0, image.width(), image.height());
|
||||||
// Bilinear filtering is needed on a rare occasion for instant previews when
|
// Bilinear filtering is needed on a rare occasion for instant previews when
|
||||||
|
@ -104,7 +104,7 @@ public:
|
|||||||
|
|
||||||
/// draw an image from the image cache
|
/// draw an image from the image cache
|
||||||
void image(int x, int y, int w, int h,
|
void image(int x, int y, int w, int h,
|
||||||
lyx::graphics::Image const & image) override;
|
lyx::graphics::Image const & image, bool const darkmode = false) override;
|
||||||
|
|
||||||
/// draw a string at position x, y (y is the baseline).
|
/// draw a string at position x, y (y is the baseline).
|
||||||
void text(int x, int y, docstring const & str, FontInfo const & f) override;
|
void text(int x, int y, docstring const & str, FontInfo const & f) override;
|
||||||
|
@ -293,7 +293,7 @@ void InsetGraphics::metrics(MetricsInfo & mi, Dimension & dim) const
|
|||||||
|
|
||||||
void InsetGraphics::draw(PainterInfo & pi, int x, int y) const
|
void InsetGraphics::draw(PainterInfo & pi, int x, int y) const
|
||||||
{
|
{
|
||||||
graphic_->draw(pi, x, y);
|
graphic_->draw(pi, x, y, params_.darkModeSensitive);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -74,6 +74,7 @@ void InsetGraphicsParams::init()
|
|||||||
|
|
||||||
bbox = graphics::BoundingBox(); // bounding box
|
bbox = graphics::BoundingBox(); // bounding box
|
||||||
clip = false; // clip image
|
clip = false; // clip image
|
||||||
|
darkModeSensitive = false; // dark mode dependency (InsetInfo)
|
||||||
|
|
||||||
rotateAngle = "0"; // angle of rotation in degrees
|
rotateAngle = "0"; // angle of rotation in degrees
|
||||||
rotateOrigin.erase(); // Origin of rotation
|
rotateOrigin.erase(); // Origin of rotation
|
||||||
@ -96,6 +97,7 @@ void InsetGraphicsParams::copy(InsetGraphicsParams const & params)
|
|||||||
|
|
||||||
bbox = params.bbox;
|
bbox = params.bbox;
|
||||||
clip = params.clip;
|
clip = params.clip;
|
||||||
|
darkModeSensitive = params.darkModeSensitive;
|
||||||
|
|
||||||
rotateAngle = params.rotateAngle;
|
rotateAngle = params.rotateAngle;
|
||||||
rotateOrigin = params.rotateOrigin;
|
rotateOrigin = params.rotateOrigin;
|
||||||
@ -119,6 +121,7 @@ bool operator==(InsetGraphicsParams const & left,
|
|||||||
|
|
||||||
left.bbox == right.bbox &&
|
left.bbox == right.bbox &&
|
||||||
left.clip == right.clip &&
|
left.clip == right.clip &&
|
||||||
|
left.darkModeSensitive == right.darkModeSensitive &&
|
||||||
|
|
||||||
left.rotateAngle == right.rotateAngle &&
|
left.rotateAngle == right.rotateAngle &&
|
||||||
left.rotateOrigin == right.rotateOrigin &&
|
left.rotateOrigin == right.rotateOrigin &&
|
||||||
|
@ -63,6 +63,10 @@ public:
|
|||||||
/// any userdefined special command
|
/// any userdefined special command
|
||||||
std::string special;
|
std::string special;
|
||||||
|
|
||||||
|
/// Does this need to be handled specifically
|
||||||
|
/// in dark mode? (use by InsetInfo)
|
||||||
|
bool darkModeSensitive;
|
||||||
|
|
||||||
///
|
///
|
||||||
InsetGraphicsParams();
|
InsetGraphicsParams();
|
||||||
///
|
///
|
||||||
|
@ -1078,6 +1078,10 @@ void InsetInfo::updateBuffer(ParIterator const & it, UpdateType utype, bool cons
|
|||||||
igp.lyxscale = percent_scale;
|
igp.lyxscale = percent_scale;
|
||||||
igp.scale = string();
|
igp.scale = string();
|
||||||
igp.width = Length(1, Length::EM);
|
igp.width = Length(1, Length::EM);
|
||||||
|
if (contains(file.absoluteFilePath(), from_ascii("math"))
|
||||||
|
|| contains(file.absoluteFilePath(), from_ascii("ert-insert"))
|
||||||
|
|| suffixIs(file.onlyPath().absoluteFilePath(), from_ascii("ipa")))
|
||||||
|
igp.darkModeSensitive = true;
|
||||||
inset->setParams(igp);
|
inset->setParams(igp);
|
||||||
clear();
|
clear();
|
||||||
Font const f(inherit_font, params_.lang);
|
Font const f(inherit_font, params_.lang);
|
||||||
|
@ -36,7 +36,7 @@ public:
|
|||||||
/// \retval true if the metrics has changed.
|
/// \retval true if the metrics has changed.
|
||||||
virtual void metrics(MetricsInfo & mi, Dimension & dim) const = 0;
|
virtual void metrics(MetricsInfo & mi, Dimension & dim) const = 0;
|
||||||
/// draw inset and update (xo, yo)-cache
|
/// draw inset and update (xo, yo)-cache
|
||||||
virtual void draw(PainterInfo & pi, int x, int y) const = 0;
|
virtual void draw(PainterInfo & pi, int x, int y, bool const darkmode = false) const = 0;
|
||||||
|
|
||||||
/// render state, exact meaning of state is render-specific
|
/// render state, exact meaning of state is render-specific
|
||||||
void setRenderState(bool state) { state_ = state; }
|
void setRenderState(bool state) { state_ = state; }
|
||||||
|
@ -54,7 +54,7 @@ void RenderButton::metrics(MetricsInfo & mi, Dimension & dim) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void RenderButton::draw(PainterInfo & pi, int x, int y) const
|
void RenderButton::draw(PainterInfo & pi, int x, int y, bool) const
|
||||||
{
|
{
|
||||||
// Draw it as a box with the LaTeX text
|
// Draw it as a box with the LaTeX text
|
||||||
FontInfo font = inherit_font_ ? pi.base.font : sane_font;
|
FontInfo font = inherit_font_ ? pi.base.font : sane_font;
|
||||||
|
@ -30,7 +30,7 @@ public:
|
|||||||
/// compute the size of the object returned in dim
|
/// compute the size of the object returned in dim
|
||||||
void metrics(MetricsInfo & mi, Dimension & dim) const override;
|
void metrics(MetricsInfo & mi, Dimension & dim) const override;
|
||||||
/// draw inset and update (xo, yo)-cache
|
/// draw inset and update (xo, yo)-cache
|
||||||
void draw(PainterInfo & pi, int x, int y) const override;
|
void draw(PainterInfo & pi, int x, int y, bool const darkmode = false) const override;
|
||||||
|
|
||||||
/// Provide the text for the button
|
/// Provide the text for the button
|
||||||
void update(docstring const &, bool editable,
|
void update(docstring const &, bool editable,
|
||||||
|
@ -187,7 +187,7 @@ void RenderGraphic::metrics(MetricsInfo & mi, Dimension & dim) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void RenderGraphic::draw(PainterInfo & pi, int x, int y) const
|
void RenderGraphic::draw(PainterInfo & pi, int x, int y, bool const darkmode) const
|
||||||
{
|
{
|
||||||
// This will draw the graphics. If the graphics has not been
|
// This will draw the graphics. If the graphics has not been
|
||||||
// loaded yet, we draw just a rectangle.
|
// loaded yet, we draw just a rectangle.
|
||||||
@ -197,7 +197,7 @@ void RenderGraphic::draw(PainterInfo & pi, int x, int y) const
|
|||||||
int const h = dim_.height();
|
int const h = dim_.height();
|
||||||
|
|
||||||
if (displayGraphic(params_) && readyToDisplay(loader_))
|
if (displayGraphic(params_) && readyToDisplay(loader_))
|
||||||
pi.pain.image(x1, y1, w, h, *loader_.image());
|
pi.pain.image(x1, y1, w, h, *loader_.image(), darkmode);
|
||||||
|
|
||||||
else {
|
else {
|
||||||
Color c = pi.change.changed() ? pi.change.color() : Color_foreground;
|
Color c = pi.change.changed() ? pi.change.color() : Color_foreground;
|
||||||
|
@ -31,7 +31,7 @@ public:
|
|||||||
/// compute the size of the object returned in dim
|
/// compute the size of the object returned in dim
|
||||||
void metrics(MetricsInfo & mi, Dimension & dim) const override;
|
void metrics(MetricsInfo & mi, Dimension & dim) const override;
|
||||||
/// draw inset
|
/// draw inset
|
||||||
void draw(PainterInfo & pi, int x, int y) const override;
|
void draw(PainterInfo & pi, int x, int y, bool const darkmode = false) const override;
|
||||||
|
|
||||||
/// Refresh the info about which file to display and how to display it.
|
/// Refresh the info about which file to display and how to display it.
|
||||||
void update(graphics::Params const & params);
|
void update(graphics::Params const & params);
|
||||||
|
@ -154,7 +154,7 @@ void RenderPreview::metrics(MetricsInfo & mi, Dimension & dim) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void RenderPreview::draw(PainterInfo & pi, int x, int y) const
|
void RenderPreview::draw(PainterInfo & pi, int x, int y, bool const) const
|
||||||
{
|
{
|
||||||
LBUFERR(pi.base.bv);
|
LBUFERR(pi.base.bv);
|
||||||
|
|
||||||
@ -280,7 +280,7 @@ void RenderMonitoredPreview::setAbsFile(FileName const & file)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void RenderMonitoredPreview::draw(PainterInfo & pi, int x, int y) const
|
void RenderMonitoredPreview::draw(PainterInfo & pi, int x, int y, bool const) const
|
||||||
{
|
{
|
||||||
RenderPreview::draw(pi, x, y);
|
RenderPreview::draw(pi, x, y);
|
||||||
startMonitoring();
|
startMonitoring();
|
||||||
|
@ -52,7 +52,7 @@ public:
|
|||||||
/// Compute the size of the object, returned in dim
|
/// Compute the size of the object, returned in dim
|
||||||
void metrics(MetricsInfo &, Dimension & dim) const override;
|
void metrics(MetricsInfo &, Dimension & dim) const override;
|
||||||
///
|
///
|
||||||
void draw(PainterInfo & pi, int x, int y) const override;
|
void draw(PainterInfo & pi, int x, int y, bool const darkmode = false) const override;
|
||||||
|
|
||||||
/** Find the PreviewLoader and add a LaTeX snippet to it.
|
/** Find the PreviewLoader and add a LaTeX snippet to it.
|
||||||
* Do not start the loading process.
|
* Do not start the loading process.
|
||||||
@ -112,7 +112,7 @@ class RenderMonitoredPreview : public RenderPreview {
|
|||||||
public:
|
public:
|
||||||
explicit RenderMonitoredPreview(Inset const *);
|
explicit RenderMonitoredPreview(Inset const *);
|
||||||
///
|
///
|
||||||
void draw(PainterInfo & pi, int x, int y) const override;
|
void draw(PainterInfo & pi, int x, int y, bool const darkmode = false) const override;
|
||||||
///
|
///
|
||||||
void setAbsFile(support::FileName const & file);
|
void setAbsFile(support::FileName const & file);
|
||||||
///
|
///
|
||||||
|
Loading…
Reference in New Issue
Block a user