Bug 108751 - Show currently selected color name in color button tooltip
Summary: Show currently selected color name in color button tooltip
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: UI (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium enhancement
Assignee: Jim Raykowski
URL:
Whiteboard: target:6.2.0
Keywords: easyHack, needsDevEval
Depends on:
Blocks: Color-Picker-Widget Toolbars-Tooltips Split-Group-Buttons-Color
  Show dependency treegraph
 
Reported: 2017-06-24 23:18 UTC by Yousuf Philips (jay) (retired)
Modified: 2018-10-30 10:31 UTC (History)
6 users (show)

See Also:
Crash report or crash signature:


Attachments
Proposed image (19.09 KB, image/png)
2018-01-23 13:23 UTC, abstatic
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Yousuf Philips (jay) (retired) 2017-06-24 23:18:04 UTC
From bug 84579 comment 15: 'the current hint "Font Color" would be completed in future by "Font Color (automatic)", "Font Color (Chartreuse)" or "Font Color (#7f9101)", depending on the actual color.'
Comment 1 Heiko Tietze 2018-01-17 17:04:08 UTC
After your brilliant work on bug 60937 how about this ticket, Abhishek?
Currently we have a tooltip "Font Color" or "Highlight Color" when hovering over the toolbar or sidebar button and it would be nice to also get the actual color of the selected object. 

The color widget is defined in svx/uiconfig/ui/colorwindow.ui and svx/source/tbxctrls/tbcontrl.cxx. The color of the current object is a bit more difficult, ask if you need help.
Comment 2 abstatic 2018-01-18 05:49:08 UTC
Heiko, thanks! 

Currently I am in middle of bug 112373, which I think will be done by today. I definitely want to work on this next. I am assigning this to myself!

I will bug you on IRC when I start facing issues on fixing this :D
Comment 3 abstatic 2018-01-21 19:38:06 UTC
Hi,

I am facing an error probably related to glade. I copied the Libreoffice catalog from libreoffice/extras/source/glade/libreoffice-catalog.xml , to another folder and added the environment variable "GLADE_CATALOG_SEARCH_PATH" pointing to this folder.

But on loading the svx/uiconfig/ui/colorwindow.ui , I get errors in glade,

Here is the log - https://pastebin.com/SB7g2w7N

Do I need to have gtk libraries installed too for working on the UI related issues ?
Comment 4 Heiko Tietze 2018-01-21 22:54:13 UTC
(In reply to abstatic from comment #3)
> Hi,
> 
> I am facing an error probably related to glade. I copied the Libreoffice
> catalog from libreoffice/extras/source/glade/libreoffice-catalog.xml , to
> another folder and added the environment variable
> "GLADE_CATALOG_SEARCH_PATH" pointing to this folder.
> 
> But on loading the svx/uiconfig/ui/colorwindow.ui , I get errors in glade,
> 
> Here is the log - https://pastebin.com/SB7g2w7N
> 
> Do I need to have gtk libraries installed too for working on the UI related
> issues ?

Not sure on what libs are required but your catalog reference is not working. Just add the right reference under Edit > Preferences (it's ~/Sources/libreoffice/instdir/share/glade in my case; I never copy/move this file to another place).
Comment 5 abstatic 2018-01-22 14:41:51 UTC
I can't get glade to work on my machine. Unassigning myself.
Comment 6 Heiko Tietze 2018-01-22 15:29:51 UTC
(In reply to abstatic from comment #5)
> I can't get glade to work on my machine. Unassigning myself.

That's a pity. But do you need Glade at all? I mean to dynamically modify a tooltip is rather a question of C++, right?
Comment 7 abstatic 2018-01-23 13:23:05 UTC
Created attachment 139293 [details]
Proposed image
Comment 8 abstatic 2018-01-23 13:24:03 UTC
Comment on attachment 139293 [details]
Proposed image

Did you mean to extend the tooltip to something like this? Where the currently selected color shows up in the side of "Font Color"
Comment 9 Yousuf Philips (jay) (retired) 2018-01-23 14:14:08 UTC
(In reply to abstatic from comment #8)
> Did you mean to extend the tooltip to something like this? Where the
> currently selected color shows up in the side of "Font Color"

No this isnt what is wanted. What is wanted is the changing of just the button tooltip from 'Font Color' to 'Font Color (Red)' if Red is the last selected color from the color picker widget. If the color doesnt have a name from the palette, it would show the hex of the color like so, 'Font Color (#7f9101)".
Comment 10 Heiko Tietze 2018-02-06 12:56:11 UTC
(In reply to abstatic from comment #5)
> I can't get glade to work on my machine. Unassigning myself.

Tested Glade on macOS and install per homebrew is as easy as on Linux. But I did succeed on Windows. Binary installer works but when I try to add the catalog the program crashes. The wiki has a few infos but I suggest a virtual environment if your trouble is caused by the OS.

https://wiki.documentfoundation.org/Development/BuildingOnWindows#Running_Glade_on_Windows
Comment 11 abstatic 2018-02-06 18:44:22 UTC
I was able to run glade on Ubuntu, seems after all it was a distro issue (arch linux).

Status update- Currently I am going through SVX, VCL and how UI works on LO.
Comment 12 abstatic 2018-02-08 22:04:50 UTC
I was able to figure how to get current color, but how do I update the color tooltip? 

I tried this->SetQuickHelpText() , but it didn't update the correct tooltip, i.e. of the button.

I also found out the .xcp file and the slot ids which are used. But I can't figure out how to programmatically update the tooltip whenever the color is changed.

Can I get some hints?
Comment 13 abstatic 2018-02-09 07:39:53 UTC
I was also able to programmatically change the tooltip text using SetQuickHelpText() method, but I was able to do that using toolbar update (tbxcolorupdate.cxx) file and adding an if condition, if the slotid of the toolbar update is SID_ATTR_CHAR_COLOR or SID_ATTR_CHAR_COLOR2 then update the tooltip as well.

This seems like an inefficient way to do it. I am trying to figure a better approach to update the tooltips directly from the SvxColorWindow object in tbcontrol.cxx
Comment 14 Yousuf Philips (jay) (retired) 2018-02-09 20:22:12 UTC
abstatic: would suggest you check with Samuel on irc if you can catch him or maybe Maxim can give you a suggestion.
Comment 15 Heiko Tietze 2018-02-10 09:43:08 UTC
(Replying to question on IRC) Colors are translatable with RID_SVXSTR_COLOR_* linked to static const char* SvxUnoColorNameDefResId[] in svx/source/unodraw/unoprov.cxx. Functions SvxUnogetApiNameForItem() and SvxUnogetInternalNameForItem() in the same file look promising.
Comment 16 Caolán McNamara 2018-02-12 16:30:33 UTC
In...

IMPL_LINK(SvxColorToolBoxControl, SelectedHdl, const NamedColor&, rColor, void)

in svx/source/tbxctrls/tbcontrl.cxx

rColor.second is/(should be I think) the name of the color in the palette when it is selected by the user
Comment 17 abstatic 2018-02-14 12:03:39 UTC
I have posted a patch regarding this, please review.

https://gerrit.libreoffice.org/#/c/49713/
Comment 18 abstatic 2018-02-20 13:59:30 UTC
I have added a translatable strings to get the color names and text (int strings.hrc file), as follows in IMPL_LINK(SvxColorToolBoxControl, SelectedHdl, const NamedColor&, rColor, void) in svx/source/tbxctrls/tbcontrl.cxx-

OUString colorHelpText;
if (m_nSlotId == SID_ATTR_CHAR_COLOR || m_nSlotId == SID_ATTR_CHAR_COLOR2)
    colorHelpText = SvxResId(RID_SVXSTR_CHARCOLOR) + rColor.second;
else
    colorHelpText = SvxResId(RID_SVXSTR_CHARBACKCOLOR) + rColor.second;

But I can't figure out how to add the initial color names (the dark red for font color and the yellow highlight color) 

I also think it would be really great if we could update the font color and highlight color icons based on current focus in the text (this happens in google docs) , which would provide a more concrete feedback on what color is currently active.

For this I figured out it might work by adding some code in 
SvxColorToolBoxControl::statusChanged( const css::frame::FeatureStateEvent& rEvent ) 
method as its the one that gets called up every time color change happens, but how do I get the current color? Not the last selected color, but the one which is currently active. 

And how to figure out the color name in statusChanged method?  One way to do this could be to iterate over the palette?
Comment 19 Maxim Monastirsky 2018-02-20 19:43:08 UTC
(In reply to abstatic from comment #18)
> I have added a translatable strings to get the color names and text (int
> strings.hrc file), as follows in IMPL_LINK(SvxColorToolBoxControl,
> SelectedHdl, const NamedColor&, rColor, void) in
> svx/source/tbxctrls/tbcontrl.cxx-
> 
> OUString colorHelpText;
> if (m_nSlotId == SID_ATTR_CHAR_COLOR || m_nSlotId == SID_ATTR_CHAR_COLOR2)
>     colorHelpText = SvxResId(RID_SVXSTR_CHARCOLOR) + rColor.second;
> else
>     colorHelpText = SvxResId(RID_SVXSTR_CHARBACKCOLOR) + rColor.second;
FYI You can just get the string from officecfg/ like this:

vcl::CommandInfoProvider::GetLabelForCommand( m_aCommandURL, m_sModuleName )

so hopefully we could avoid adding more translatable strings.

> I also think it would be really great if we could update the font color and
> highlight color icons based on current focus in the text (this happens in
> google docs) , which would provide a more concrete feedback on what color is
> currently active.
Please don't. Our toolbar color buttons (unlike google docs) are split buttons, i.e. they have a main  part which applies the last color, and a dropdown part which opens the color picker. Having the button show the color of the currently selected text will make it non-obvious which color will be applied when clicking the main part. (Besides, showing the selected color on the button isn't as useful as a tooltip, as the user can just look at the text itself.)
Comment 20 Heiko Tietze 2018-02-20 22:18:46 UTC
(In reply to Maxim Monastirsky from comment #19)
> ... Having the button show the color
> of the currently selected text will make it non-obvious which color will be
> applied when clicking the main part.

Good point.
Comment 21 abstatic 2018-02-24 22:30:40 UTC
 > Uploaded patch set 2.

I am using translatable strings now. So the everytime the color changes its visible to the user.

But I can't figure out how to add the color name suffix right at the start, when the color is set to default/automatic. Right now it only shows "Font Color" 

For setting the initial help text along with the color name, I tried adding the code to SvxColorToolBoxControl::initialize using "GetAutoColor()" method  but it returned the color name as "Automatic".

Also, how would it work for the sidebar color controls? Would it be okay if I try to follow the same approach as above?
Comment 22 Xisco Faulí 2018-03-27 02:26:59 UTC Comment hidden (obsolete)
Comment 23 Xisco Faulí 2018-04-27 02:29:13 UTC Comment hidden (obsolete)
Comment 24 Heiko Tietze 2018-05-15 07:16:50 UTC
(In reply to abstatic from comment #21)
> But I can't figure out how to add the color name suffix right at the start,
> when the color is set to default/automatic....
> 
> Also, how would it work for the sidebar color controls? Would it be okay if
> I try to follow the same approach as above?

Reviewed and commented on the patch; we could go without "Font (Automatic)" and sidebar controls do work like toolbar right now.
Comment 25 Xisco Faulí 2018-06-15 02:43:03 UTC Comment hidden (obsolete)
Comment 26 Xisco Faulí 2018-07-16 02:40:21 UTC Comment hidden (obsolete)
Comment 27 Xisco Faulí 2018-08-16 02:36:00 UTC Comment hidden (obsolete)
Comment 28 Xisco Faulí 2018-09-16 02:47:06 UTC Comment hidden (obsolete)
Comment 29 Heiko Tietze 2018-09-16 08:02:24 UTC
Trying to continue in https://gerrit.libreoffice.org/#/c/60261/
Comment 30 Xisco Faulí 2018-10-17 02:47:35 UTC Comment hidden (obsolete)
Comment 31 Jim Raykowski 2018-10-18 18:35:02 UTC
Continued here:
https://gerrit.libreoffice.org/#/c/61815/
Comment 32 Commit Notification 2018-10-27 20:44:23 UTC
Jim Raykowski committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=68c73b2cc26313de315e828cb9f8db53d9aeb6bf

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

It will be available in 6.2.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 33 Thomas Lendo 2018-10-30 10:31:16 UTC
This is a really cool nice gimmick.
Thanks all!

Verified in Version: 6.2.0.0.alpha1+ (x64)
Build ID: 59d48c531a5cad27f02b91c9b86278d5ede211a1
CPU threads: 8; OS: Windows 10.0; UI render: GL; VCL: win; 
TinderBox: Win-x86_64@42, Branch:master, Time: 2018-10-29_01:05:52
Locale: de-AT (de_AT); Calc: CL