Kaydet (Commit) 68c73b2c authored tarafından Jim Raykowski's avatar Jim Raykowski

tdf#108751 Show currently selected color name in color button tooltip

Based on Heiko Tietze's work in
I26f0500527d2b86049948ca64e636e1ff566f262

Change-Id: I20541dd6ad155a39c0f87361088b44923406064f
Reviewed-on: https://gerrit.libreoffice.org/61815
Tested-by: Jenkins
Reviewed-by: 's avatarHeiko Tietze <tietze.heiko@gmail.com>
Tested-by: 's avatarHeiko Tietze <tietze.heiko@gmail.com>
üst d666b6b1
......@@ -552,6 +552,12 @@
#define RID_SVXSTR_GRAFMODE_GREYS NC_("RID_SVXSTR_GRAFMODE_GREYS", "Grayscale")
#define RID_SVXSTR_GRAFMODE_MONO NC_("RID_SVXSTR_GRAFMODE_MONO", "Black/White")
#define RID_SVXSTR_GRAFMODE_WATERMARK NC_("RID_SVXSTR_GRAFMODE_WATERMARK", "Watermark")
// Default colors
#define RID_SVXSTR_COLOR_DEFAULT_FONT NC_("RID_SVXSTR_COLOR_DEFAULT_FONTCOLOR", "Dark Red 2")
#define RID_SVXSTR_COLOR_DEFAULT_FRAMELINE NC_("RID_SVXSTR_COLOR_DEFAULT_FRAMELINE", "Blue")
#define RID_SVXSTR_COLOR_DEFAULT_HIGHLIGHT NC_("RID_SVXSTR_COLOR_DEFAULT_HIGHLIGHT", "Yellow")
#define RID_SVXSTR_COLOR_DEFAULT_SHAPE_STROKE NC_("RID_SVXSTR_COLOR_DEFAULT_SHAPE_STROKE", "Dark Blue 1")
#define RID_SVXSTR_COLOR_DEFAULT_SHAPE_FILLING NC_("RID_SVXSTR_COLOR_DEFAULT_SHAPE_FILLING", "Light Blue 2")
// Elements of the standard color palette
#define RID_SVXSTR_COLOR_BLACK NC_("RID_SVXSTR_COLOR_BLACK", "Black")
#define RID_SVXSTR_COLOR_GREY NC_("RID_SVXSTR_COLOR_GREY", "Gray")
......
......@@ -26,6 +26,8 @@
#include <tools/color.hxx>
#include <vcl/vclptr.hxx>
#include <svx/Palette.hxx>
class ToolBox;
class VirtualDevice;
......@@ -43,9 +45,11 @@ namespace svx
class SVX_DLLPUBLIC ToolboxButtonColorUpdater
{
public:
ToolboxButtonColorUpdater( sal_uInt16 nSlotId, sal_uInt16 nTbxBtnId, ToolBox* ptrTbx, bool bWideButton = false);
ToolboxButtonColorUpdater( sal_uInt16 nSlotId, sal_uInt16 nTbxBtnId, ToolBox* ptrTbx, bool bWideButton,
const OUString& rCommandLabel );
~ToolboxButtonColorUpdater();
void Update( const NamedColor& rNamedColor );
void Update( const Color& rColor, bool bForceUpdate = false );
Color const & GetCurrentColor() const { return maCurColor; }
......@@ -60,6 +64,7 @@ namespace svx
tools::Rectangle maUpdRect;
Size maBmpSize;
bool mbWasHiContrastMode;
OUString maCommandLabel;
};
......
......@@ -78,8 +78,11 @@ class XLineTransparenceItem;
class XLineWidthItem;
class XSecondaryFillColorItem;
#define COL_DEFAULT_SHAPE_FILLING ::Color(0x729fcf)
#define COL_DEFAULT_SHAPE_STROKE ::Color(0x3465a4)
#define COL_DEFAULT_FONT ::Color(0xC9211E) // dark red 2
#define COL_DEFAULT_FRAMELINE ::Color(0x2A6099) // blue
#define COL_DEFAULT_HIGHLIGHT ::Color(0xFFFF00) // yellow
#define COL_DEFAULT_SHAPE_FILLING ::Color(0x729fcf) // light blue 2
#define COL_DEFAULT_SHAPE_STROKE ::Color(0x3465a4) // dark blue 1
#define XATTR_START 1000
......
......@@ -241,7 +241,6 @@ constexpr ::Color COL_BLUE ( 0x00, 0x00, 0x80 );
constexpr ::Color COL_GREEN ( 0x00, 0x80, 0x00 );
constexpr ::Color COL_CYAN ( 0x00, 0x80, 0x80 );
constexpr ::Color COL_RED ( 0x80, 0x00, 0x00 );
constexpr ::Color COL_RED_FONTCOLOR ( 0xCE, 0x18, 0x1E );
constexpr ::Color COL_MAGENTA ( 0x80, 0x00, 0x80 );
constexpr ::Color COL_BROWN ( 0x80, 0x80, 0x00 );
constexpr ::Color COL_GRAY ( 0x80, 0x80, 0x80 );
......@@ -255,7 +254,6 @@ constexpr ::Color COL_LIGHTRED ( 0xFF, 0x00, 0x00 );
constexpr ::Color COL_LIGHTMAGENTA ( 0xFF, 0x00, 0xFF );
constexpr ::Color COL_LIGHTGRAYBLUE ( 0xE0, 0xE0, 0xFF );
constexpr ::Color COL_YELLOW ( 0xFF, 0xFF, 0x00 );
constexpr ::Color COL_YELLOW_HIGHLIGHT ( 0xFF, 0xF2, 0x00 );
constexpr ::Color COL_WHITE ( 0xFF, 0xFF, 0xFF );
constexpr ::Color COL_TRANSPARENT ( 0xFF, 0xFF, 0xFF, 0xFF );
constexpr ::Color COL_AUTO ( 0xFF, 0xFF, 0xFF, 0xFF );
......
......@@ -96,7 +96,7 @@ void ConditionColorWrapper::dispose()
void ConditionColorWrapper::operator()(const OUString& /*rCommand*/, const NamedColor& rNamedColor)
{
mxControl->ApplyCommand(mnSlotId, rNamedColor.first);
mxControl->ApplyCommand(mnSlotId, rNamedColor);
}
// = Condition
......@@ -161,9 +161,11 @@ Condition::Condition( vcl::Window* _pParent, IConditionalFormatAction& _rAction,
m_nFontDialogId = m_pActions->GetItemId(".uno:FontDialog");
m_pBtnUpdaterBackgroundColor.reset( new svx::ToolboxButtonColorUpdater(
SID_BACKGROUND_COLOR, m_nBackgroundColorId, m_pActions ) );
SID_BACKGROUND_COLOR, m_nBackgroundColorId, m_pActions, false,
m_pActions->GetItemText( m_nBackgroundColorId ) ) );
m_pBtnUpdaterFontColor.reset( new svx::ToolboxButtonColorUpdater(
SID_ATTR_CHAR_COLOR2, m_nFontColorId, m_pActions ) );
SID_ATTR_CHAR_COLOR2, m_nFontColorId, m_pActions, false,
m_pActions->GetItemText( m_nFontColorId ) ) );
Show();
......@@ -238,7 +240,8 @@ IMPL_LINK(Condition, DropdownClick, ToolBox*, pToolBox, void)
IMPL_LINK_NOARG( Condition, OnFormatAction, ToolBox*, void )
{
ApplyCommand(mapToolbarItemToSlotId(m_pActions->GetCurItemId()),COL_AUTO);
ApplyCommand(mapToolbarItemToSlotId(m_pActions->GetCurItemId()),
NamedColor(COL_AUTO, "#" + COL_AUTO.AsRGBHexString()));
}
IMPL_LINK( Condition, OnConditionAction, Button*, _pClickedButton, void )
......@@ -253,14 +256,14 @@ IMPL_LINK( Condition, OnConditionAction, Button*, _pClickedButton, void )
m_rAction.deleteCondition( getConditionIndex() );
}
void Condition::ApplyCommand( sal_uInt16 _nCommandId, const ::Color& _rColor)
void Condition::ApplyCommand( sal_uInt16 _nCommandId, const NamedColor& rNamedColor )
{
if ( _nCommandId == SID_ATTR_CHAR_COLOR2 )
m_pBtnUpdaterFontColor->Update( _rColor );
m_pBtnUpdaterFontColor->Update( rNamedColor );
else if ( _nCommandId == SID_BACKGROUND_COLOR )
m_pBtnUpdaterBackgroundColor->Update( _rColor );
m_pBtnUpdaterBackgroundColor->Update( rNamedColor );
m_rAction.applyCommand( m_nCondIndex, _nCommandId, _rColor );
m_rAction.applyCommand( m_nCondIndex, _nCommandId, rNamedColor.first );
}
void Condition::setImageList(sal_Int16 /*_eBitmapSet*/)
......
......@@ -162,7 +162,7 @@ namespace rptui
/** forward to the parent class
*/
void ApplyCommand(sal_uInt16 _nCommandId, const ::Color& _aColor );
void ApplyCommand( sal_uInt16 _nCommandId, const NamedColor& rNamedColor );
::rptui::OReportController& getController() const { return m_rController; }
......
......@@ -127,7 +127,8 @@ Reference<frame::XToolbarController> ControllerFactory::CreateToolBoxController(
const OUString sTooltip (vcl::CommandInfoProvider::GetTooltipForCommand(
rsCommandName,
rxFrame));
pToolBox->SetQuickHelpText(nItemId, sTooltip);
if (pToolBox->GetQuickHelpText(nItemId).isEmpty())
pToolBox->SetQuickHelpText(nItemId, sTooltip);
pToolBox->EnableItem(nItemId);
}
}
......
......@@ -354,10 +354,10 @@ void PaletteManager::PopupColorPicker(weld::Window* pParent, const OUString& aCo
if (aColorDlg.Execute(pParent) == RET_OK)
{
Color aLastColor = aColorDlg.GetColor();
if (mpBtnUpdater)
mpBtnUpdater->Update(aLastColor);
OUString sColorName = ("#" + aLastColor.AsRGBHexString().toAsciiUpperCase());
NamedColor aNamedColor = std::make_pair(aLastColor, sColorName);
if (mpBtnUpdater)
mpBtnUpdater->Update(aNamedColor);
AddRecentColor(aLastColor, sColorName);
maColorSelectFunction(aCommandCopy, aNamedColor);
}
......
......@@ -3110,7 +3110,9 @@ void SvxColorToolBoxControl::initialize( const css::uno::Sequence<css::uno::Any>
// Sidebar uses wide buttons for those.
m_bSplitButton = typeid( *pToolBox ) != typeid( sfx2::sidebar::SidebarToolBox );
m_xBtnUpdater.reset( new svx::ToolboxButtonColorUpdater( m_nSlotId, nId, pToolBox, !m_bSplitButton ) );
OUString aCommandLabel = vcl::CommandInfoProvider::GetLabelForCommand( getCommandURL(), getModuleName() );
m_xBtnUpdater.reset( new svx::ToolboxButtonColorUpdater( m_nSlotId, nId, pToolBox, !m_bSplitButton, aCommandLabel ) );
pToolBox->SetItemBits( nId, pToolBox->GetItemBits( nId ) | ( m_bSplitButton ? ToolBoxItemBits::DROPDOWN : ToolBoxItemBits::DROPDOWNONLY ) );
}
......@@ -3181,7 +3183,7 @@ VclPtr<vcl::Window> SvxColorToolBoxControl::createPopupWindow( vcl::Window* pPar
IMPL_LINK(SvxColorToolBoxControl, SelectedHdl, const NamedColor&, rColor, void)
{
m_xBtnUpdater->Update(rColor.first);
m_xBtnUpdater->Update(rColor);
}
void SvxColorToolBoxControl::statusChanged( const css::frame::FeatureStateEvent& rEvent )
......
......@@ -28,14 +28,18 @@
#include <vcl/settings.hxx>
#include <tools/debug.hxx>
#include <svx/strings.hrc>
#include <svx/dialmgr.hxx>
namespace svx
{
ToolboxButtonColorUpdater::ToolboxButtonColorUpdater(
sal_uInt16 nSlotId, sal_uInt16 nTbxBtnId, ToolBox* pToolBox, bool bWideButton)
sal_uInt16 nSlotId, sal_uInt16 nTbxBtnId, ToolBox* pToolBox, bool bWideButton, const OUString& rCommandLabel)
: mbWideButton(bWideButton)
, mnBtnId(nTbxBtnId)
, mpTbx(pToolBox)
, maCurColor(COL_TRANSPARENT)
, maCommandLabel(rCommandLabel)
{
DBG_ASSERT(pToolBox, "ToolBox not found :-(");
mbWasHiContrastMode = pToolBox && pToolBox->GetSettings().GetStyleSettings().GetHighContrastMode();
......@@ -43,21 +47,21 @@ namespace svx
{
case SID_ATTR_CHAR_COLOR:
case SID_ATTR_CHAR_COLOR2:
Update(COL_RED_FONTCOLOR);
Update(NamedColor(COL_DEFAULT_FONT, SvxResId(RID_SVXSTR_COLOR_DEFAULT_FONT)));
break;
case SID_FRAME_LINECOLOR:
Update(COL_BLUE);
Update(NamedColor(COL_DEFAULT_FRAMELINE, SvxResId(RID_SVXSTR_COLOR_DEFAULT_FRAMELINE)));
break;
case SID_ATTR_CHAR_COLOR_BACKGROUND:
case SID_ATTR_CHAR_BACK_COLOR:
case SID_BACKGROUND_COLOR:
Update(COL_YELLOW_HIGHLIGHT);
Update(NamedColor(COL_DEFAULT_HIGHLIGHT, SvxResId(RID_SVXSTR_COLOR_DEFAULT_HIGHLIGHT)));
break;
case SID_ATTR_LINE_COLOR:
Update(COL_DEFAULT_SHAPE_STROKE);
Update(NamedColor(COL_DEFAULT_SHAPE_STROKE, SvxResId(RID_SVXSTR_COLOR_DEFAULT_SHAPE_STROKE)));
break;
case SID_ATTR_FILL_COLOR:
Update(COL_DEFAULT_SHAPE_FILLING);
Update(NamedColor(COL_DEFAULT_SHAPE_FILLING, SvxResId(RID_SVXSTR_COLOR_DEFAULT_SHAPE_FILLING)));
break;
default:
Update(COL_TRANSPARENT);
......@@ -67,6 +71,20 @@ namespace svx
ToolboxButtonColorUpdater::~ToolboxButtonColorUpdater()
{}
void ToolboxButtonColorUpdater::Update(const NamedColor &rNamedColor)
{
Update(rNamedColor.first);
if (!mbWideButton && !rNamedColor.second.isEmpty())
{
// Also show the current color as QuickHelpText
OUString colorSuffix = " (%1)";
colorSuffix = colorSuffix.replaceFirst("%1", rNamedColor.second);
OUString colorHelpText = maCommandLabel + colorSuffix;
mpTbx->SetQuickHelpText(mnBtnId, colorHelpText);
}
}
void ToolboxButtonColorUpdater::Update(const Color& rColor, bool bForceUpdate)
{
Image aImage(mpTbx->GetItemImage(mnBtnId));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment