Files
Michael Weghorn 6296615b8d tdf#173695 svx: Ensure minimum height for ColorWindow
The number of colors displayed in the ColorIconView
in ColorWindow depends on the selected palette.

When the popup is shown for the first time, its
size is calculated based on the size of the
widgets it contains, and the size of the weld::IconView
used for ColorIconView is in turn based on the number
of colors in the initial palette.

If the initial palette has few (or no) colors,
switching to a palette with many colors results
in the need for the weld::IconView to use more
space than previously to show the additional items,
but since the popup doesn't resize, it remains at
its initial size and the selection of colors is
inconvenient or even impossible.

Avoid the problem by ensuring the ColorIconView
has a minimum height of at least 200 pixels.

Before the switch to ColorIconView in

    commit a4d5983b4e
    Author: Michael Weghorn <m.weghorn@posteo.de>
    Date:   Fri Jun 5 11:48:54 2026 +0200

        tdf#130857 Port ColorWindow from SvxColorValueSet to ColorIconView

, the SvxColorValueSet widget in use previously
was always set to a fixed size altogether.

Change-Id: I7b24dd823083891126cf7b4d0ebe1914c1e0cc87
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/211565
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2026-09-29 17:32:27 +02:00

70 lines
1.8 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/.
*/
#pragma once
#include <svx/IColorSet.hxx>
#include <svx/svxdllapi.h>
#include <tools/gen.hxx>
#include <tools/link.hxx>
#include <vcl/vclptr.hxx>
class VirtualDevice;
namespace weld
{
class IconView;
class ItemView;
class TreeIter;
}
class SVXCORE_DLLPUBLIC ColorIconView : public IColorSet
{
std::unique_ptr<weld::IconView> m_pIconView;
Link<int, void> m_aColorActivatedHdl;
Link<const ColorIconView&, void> m_aSelectionChangedHdl;
DECL_LINK(ItemActivatedHdl, const weld::TreeIter&, bool);
DECL_LINK(SelectionChangedHdl, weld::ItemView&, void);
public:
ColorIconView(std::unique_ptr<weld::IconView> pIconView);
virtual ~ColorIconView() = default;
virtual void insert(int nIndex, const Color& rColor, const OUString& rColorName) override;
virtual int getItemCount() const override;
Color getColor(int nIndex) const;
OUString getColorName(int nIndex) const;
int get_selected_index() const;
void select(int nIndex);
void unselect_all();
void remove(int nIndex);
virtual void clear() override;
void grab_focus();
void set_sensitive(bool bSensitive);
void set_size_request(int nWidth, int nHeight);
Size get_size_request() const;
void set_help_id(const OUString& rName);
void setColorActivatedHdl(const Link<int, void>& rLink) { m_aColorActivatedHdl = rLink; }
private:
ScopedVclPtr<VirtualDevice> createIcon(const Color& rColor);
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */