diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-11-11 15:52:51 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2022-11-11 20:36:14 +0100 |
commit | c3da84a10260b3260ee42df900e2ff01119e4f7c (patch) | |
tree | 0de88d7f184bd74b14e6fd30393354bb0280d666 /svx/source/tbxctrls | |
parent | c2c37eadf32c80bcd8f168b9fc67f32002b3cb07 (diff) |
Resolves: tdf#151898 get hidpi font/highlight color icons
Most of this wouldn't be necessary if we could solve the split alpha
problem. In the meantime, let Image take a MetaFile as an arg, record
what we want to do in the metafile, and play it back when we need to
generate the bitmap for to render the image. That way we don't have
alpha to worry about during the recording, and we only have one alpha in
the final rendering, as opposed to having two alphas in a source and in
destination VirtualDevice, which is problematic in most backends.
Change-Id: I5b0d7c498473271f4ab2743f75614b1b93a0e9c9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142593
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svx/source/tbxctrls')
-rw-r--r-- | svx/source/tbxctrls/tbxcolorupdate.cxx | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/svx/source/tbxctrls/tbxcolorupdate.cxx b/svx/source/tbxctrls/tbxcolorupdate.cxx index 37c8db06cf50..4e438c3ede9c 100644 --- a/svx/source/tbxctrls/tbxcolorupdate.cxx +++ b/svx/source/tbxctrls/tbxcolorupdate.cxx @@ -27,6 +27,7 @@ #include <utility> #include <vcl/commandinfoprovider.hxx> +#include <vcl/gdimtf.hxx> #include <vcl/svapp.hxx> #include <vcl/toolbox.hxx> #include <vcl/virdev.hxx> @@ -102,15 +103,21 @@ namespace svx void VclToolboxButtonColorUpdater::SetImage(VirtualDevice* pVirDev) { - mpTbx->SetItemImage(mnBtnId, Image(pVirDev->GetBitmapEx(Point(0,0), maBmpSize))); + GDIMetaFile* pMtf = pVirDev->GetConnectMetaFile(); + + assert(pMtf && "should have been set in ToolboxButtonColorUpdaterBase::Update"); + + pMtf->Stop(); + pMtf->WindStart(); + + Graphic aGraphic(*pMtf); + + mpTbx->SetItemImage(mnBtnId, Image(aGraphic.GetXGraphic())); } VclPtr<VirtualDevice> VclToolboxButtonColorUpdater::CreateVirtualDevice() const { - auto xRet = VclPtr<VirtualDevice>::Create(*mpTbx->GetOutDev(), - DeviceFormat::DEFAULT, DeviceFormat::DEFAULT); - xRet->SetBackground(mpTbx->GetControlBackground()); - return xRet; + return VclPtr<VirtualDevice>::Create(*mpTbx->GetOutDev()); } vcl::ImageType VclToolboxButtonColorUpdater::GetImageSize() const @@ -172,6 +179,16 @@ namespace svx pVirDev->SetOutputSizePixel(aItemSize); maBmpSize = aItemSize; + std::unique_ptr<GDIMetaFile> xMetaFile; + if (RecordVirtualDevice()) + { + xMetaFile.reset(new GDIMetaFile); + xMetaFile->SetPrefSize(pVirDev->GetOutputSize()); + xMetaFile->SetPrefMapMode(pVirDev->GetMapMode()); + xMetaFile->Record(pVirDev.get()); + pVirDev->EnableOutput(false); + } + if (maBmpSize.Width() == maBmpSize.Height()) // tdf#84985 align color bar with icon bottom edge; integer arithmetic e.g. 26 - 26/4 <> 26 * 3/4 maUpdRect = tools::Rectangle(Point( 0, maBmpSize.Height() - maBmpSize.Height() / 4), Size(maBmpSize.Width(), maBmpSize.Height() / 4)); |