summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
e6e30ca)
This does not show the real colors, but the icons are at least readable.
15 files changed:
void point(int, int, Color) override {}
/// draw an image from the image cache
void point(int, int, Color) override {}
/// 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
void text(int, int, docstring const &, FontInfo const &) override {}
/// draw a string
void text(int, int, docstring const &, FontInfo const &) override {}
/// draw an image from the image cache
virtual void image(int x, int y, int w, int h,
/// draw an image from the image cache
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).
virtual void text(int x, int y, docstring const & str, FontInfo const & f) = 0;
/// 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;
-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 =
static_cast<graphics::GuiImage const &>(i);
fillRectangle(x, y, w, h, Color_graphicsbg);
{
graphics::GuiImage const & qlimage =
static_cast<graphics::GuiImage const &>(i);
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 srect = QRectF(0, 0, image.width(), image.height());
// Bilinear filtering is needed on a rare occasion for instant previews when
QRectF const drect = QRectF(x, y, w, h);
QRectF const srect = QRectF(0, 0, image.width(), image.height());
// Bilinear filtering is needed on a rare occasion for instant previews when
/// draw an image from the image cache
void image(int x, int y, int w, int h,
/// draw an image from the image cache
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).
void text(int x, int y, docstring const & str, FontInfo const & f) override;
/// 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 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);
bbox = graphics::BoundingBox(); // bounding box
clip = false; // clip image
bbox = graphics::BoundingBox(); // bounding box
clip = false; // clip image
+ darkModeSensitive = false; // dark mode dependency (InsetInfo)
rotateAngle = "0"; // angle of rotation in degrees
rotateOrigin.erase(); // Origin of rotation
rotateAngle = "0"; // angle of rotation in degrees
rotateOrigin.erase(); // Origin of rotation
bbox = params.bbox;
clip = params.clip;
bbox = params.bbox;
clip = params.clip;
+ darkModeSensitive = params.darkModeSensitive;
rotateAngle = params.rotateAngle;
rotateOrigin = params.rotateOrigin;
rotateAngle = params.rotateAngle;
rotateOrigin = params.rotateOrigin;
left.bbox == right.bbox &&
left.clip == right.clip &&
left.bbox == right.bbox &&
left.clip == right.clip &&
+ left.darkModeSensitive == right.darkModeSensitive &&
left.rotateAngle == right.rotateAngle &&
left.rotateOrigin == right.rotateOrigin &&
left.rotateAngle == right.rotateAngle &&
left.rotateOrigin == right.rotateOrigin &&
/// any userdefined special command
std::string special;
/// any userdefined special command
std::string special;
+ /// Does this need to be handled specifically
+ /// in dark mode? (use by InsetInfo)
+ bool darkModeSensitive;
+
///
InsetGraphicsParams();
///
///
InsetGraphicsParams();
///
igp.lyxscale = percent_scale;
igp.scale = string();
igp.width = Length(1, Length::EM);
igp.lyxscale = percent_scale;
igp.scale = string();
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);
clear();
Font const f(inherit_font, params_.lang);
inset->setParams(igp);
clear();
Font const f(inherit_font, params_.lang);
/// \retval true if the metrics has changed.
virtual void metrics(MetricsInfo & mi, Dimension & dim) const = 0;
/// draw inset and update (xo, yo)-cache
/// \retval true if the metrics has changed.
virtual void metrics(MetricsInfo & mi, Dimension & dim) const = 0;
/// 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
void setRenderState(bool state) { state_ = state; }
/// render state, exact meaning of state is render-specific
void setRenderState(bool state) { state_ = state; }
-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
FontInfo font = inherit_font_ ? pi.base.font : sane_font;
{
// Draw it as a box with the LaTeX text
FontInfo font = inherit_font_ ? pi.base.font : sane_font;
/// compute the size of the object returned in dim
void metrics(MetricsInfo & mi, Dimension & dim) const override;
/// draw inset and update (xo, yo)-cache
/// compute the size of the object returned in dim
void metrics(MetricsInfo & mi, Dimension & dim) const override;
/// 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
void update(docstring const &, bool editable,
/// Provide the text for the button
void update(docstring const &, bool editable,
-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
// loaded yet, we draw just a rectangle.
{
// This will draw the graphics. If the graphics has not been
// loaded yet, we draw just a rectangle.
int const h = dim_.height();
if (displayGraphic(params_) && readyToDisplay(loader_))
int const h = dim_.height();
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 {
Color c = pi.change.changed() ? pi.change.color() : Color_foreground;
else {
Color c = pi.change.changed() ? pi.change.color() : Color_foreground;
/// compute the size of the object returned in dim
void metrics(MetricsInfo & mi, Dimension & dim) const override;
/// draw inset
/// compute the size of the object returned in dim
void metrics(MetricsInfo & mi, Dimension & dim) const override;
/// 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.
void update(graphics::Params const & params);
/// Refresh the info about which file to display and how to display it.
void update(graphics::Params const & params);
-void RenderPreview::draw(PainterInfo & pi, int x, int y) const
+void RenderPreview::draw(PainterInfo & pi, int x, int y, bool const) const
-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);
startMonitoring();
{
RenderPreview::draw(pi, x, y);
startMonitoring();
/// Compute the size of the object, returned in dim
void metrics(MetricsInfo &, Dimension & dim) const override;
///
/// Compute the size of the object, returned in dim
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.
* Do not start the loading process.
/** Find the PreviewLoader and add a LaTeX snippet to it.
* Do not start the loading process.
public:
explicit RenderMonitoredPreview(Inset const *);
///
public:
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);
///