Files
core/svx/source/form/labelitemwindow.cxx
Noel Grandin 87b3b8e699 tdf#166321 Find bar: blank square with gen environment
Regression from
    commit e0d4d178ca
    Author: Noel Grandin <noel.grandin@collabora.co.uk>
    Date:   Mon Jan 13 15:03:05 2025 +0200
    Change alpha behavour of OutputDevice::SetFillColor

Which exposed another place where COL_AUTO is troublesome.

Previouslu, calling set_background(COL_AUTO) used to work
because COL_AUTO has the same value as COL_TRANSPARENT,
and calling
    OutputDevice::setBackground(COL_TRANSPARENT)
would have the same effect as
    OutputDevice::setBackground()

But that is no longer the case, especially when we are drawing to
an OutputDevice which has no alpha layer.
In that case, the alpha value is chopped off the Color object, and
we are left with what is effectively COL_WHITE.

So add some new weld API to make resetting the background to default
less error-prone.

Change-Id: I29987c4c343af40447ed847a617d6b0e9d673f48
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185968
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2025-05-29 11:01:27 +02:00

78 lines
2.5 KiB
C++

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <svx/labelitemwindow.hxx>
#include <vcl/svapp.hxx>
LabelItemWindow::LabelItemWindow(vcl::Window* pParent, const OUString& rLabel)
: InterimItemWindow(pParent, u"svx/ui/labelbox.ui"_ustr, u"LabelBox"_ustr)
, m_xBox(m_xBuilder->weld_box(u"LabelBox"_ustr))
, m_xLabel(m_xBuilder->weld_label(u"label"_ustr))
, m_xImage(m_xBuilder->weld_image(u"image"_ustr))
{
InitControlBase(m_xLabel.get());
m_xLabel->set_label(rLabel);
m_xImage->hide();
m_xImage->set_size_request(24, 24); // vcl/res/infobar.png is 32x32 - too large here
SetOptimalSize();
m_xLabel->set_toolbar_background();
}
void LabelItemWindow::SetOptimalSize()
{
Size aSize(m_xBox->get_preferred_size());
aSize.AdjustWidth(12);
SetSizePixel(aSize);
}
void LabelItemWindow::set_label(const OUString& rLabel, const LabelItemWindowType eType)
{
// hide temporarily, to trigger a11y announcement for SHOWING event for
// the label with NOTIFICATION a11y role when label gets shown again below
if (!rLabel.isEmpty())
m_xLabel->set_visible(false);
m_xLabel->set_label(rLabel);
if ((eType == LabelItemWindowType::Text) || rLabel.isEmpty())
{
m_xImage->hide();
m_xLabel->set_font_color(COL_AUTO);
m_xBox->set_background(); // reset to default
}
else if (eType == LabelItemWindowType::Info)
{
m_xImage->show();
const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
if (rStyleSettings.GetDialogColor().IsDark())
m_xBox->set_background(Color(0x00, 0x56, 0x80));
else
m_xBox->set_background(Color(0xBD, 0xE5, 0xF8)); // same as InfobarType::INFO
}
m_xLabel->set_visible(
true); // always show and not just if !rLabel.isEmpty() to not make the chevron appear
}
OUString LabelItemWindow::get_label() const { return m_xLabel->get_label(); }
void LabelItemWindow::dispose()
{
m_xImage.reset();
m_xLabel.reset();
m_xBox.reset();
InterimItemWindow::dispose();
}
LabelItemWindow::~LabelItemWindow() { disposeOnce(); }
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */