Bug 182874 - [Preferences] The width of the ColorSelector button is too wider than that of other buttons.
Summary: [Preferences] The width of the ColorSelector button is too wider than that of...
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows Vista
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform UI Triaged CLA
QA Contact:
URL:
Whiteboard:
Keywords: polish
Depends on:
Blocks:
 
Reported: 2007-04-18 02:59 EDT by Hiroyuki Inaba CLA
Modified: 2019-09-06 16:06 EDT (History)
2 users (show)

See Also:


Attachments
ColorSelector.PNG (39.90 KB, image/png)
2007-04-18 03:00 EDT, Hiroyuki Inaba CLA
no flags Details
MS_UI_Gothic_9.png (15.48 KB, image/png)
2007-04-29 23:23 EDT, Hiroyuki Inaba CLA
no flags Details
snapshot.png (22.45 KB, image/png)
2007-05-08 03:35 EDT, Hiroyuki Inaba CLA
no flags Details
A workaround fragment(only works for 3.3) (32.95 KB, patch)
2008-04-16 21:54 EDT, Feng Dihai CLA
no flags Details | Diff
Too wide buttons, before and after (125.09 KB, image/png)
2008-04-16 21:56 EDT, Feng Dihai CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Hiroyuki Inaba CLA 2007-04-18 02:59:18 EDT
Build ID: I20070323-1616

Steps To Reproduce:
1. Eclipse launch in Windows Vista (Japanese)
2. Window > preference >
     General > Appearance > Color and Fonts
   "MS UI Gotic" set as the Dialog font,
   and click OK button.
3. After, Window > preference >
     Run/Debug
Comment 1 Hiroyuki Inaba CLA 2007-04-18 03:00:21 EDT
Created attachment 64135 [details]
ColorSelector.PNG

Screen shot: Run/Debug setting page
Comment 2 Hiroyuki Inaba CLA 2007-04-18 03:06:35 EDT
In org.eclipse.jface
/src/org/eclipse/jface/preference/
ColorSelector.java

- The font of the parents composite is not succeeded
  in the constructor.
- DEFAULT_FONT is used to calculate the image size 
  in the computeImageSize method. 
Comment 3 Tod Creasey CLA 2007-04-19 07:57:11 EDT
We should try and do something for 3.3.
Comment 4 Tod Creasey CLA 2007-04-24 10:18:01 EDT
Most of the time the font has not been set when the ColorSelector is created so we should base it off of the dialog font.

Having said that I think the problem might be more subtle. What is your screen resolution?

I have made the dialog font change but I am not convinced I have your case completly covered.
Comment 5 Hiroyuki Inaba CLA 2007-04-24 21:16:54 EDT
> What is your screen resolution?

- Screen size : 1024 x 768 pixel
- Dialog font : MS UI Gothic, Normal, Size 9
- System font : Meiryo, Normal, Size 9

I think that the correction is the following two points. 

1) Inset " fButton.setFont(parent.getFont()); " after
   " fButton = new Button( ... " line
2) Use control font in computeImageSize
   gc.setFint(f) => gc.setFont(window.getFont())
Comment 6 Hiroyuki Inaba CLA 2007-04-24 21:29:51 EDT
It is likely to become the following fix to match 
the color change button of other editors
(Ex: Perference > Java > Editor) to shape. 

- Not insert " fButton.setFont(parent.getFont()); "
- Use DEFAULT_FONT in the computeImageSize method. 

- Not call convertHorizontalDLUsToPlixels
  in ColorFieldEditor.doFillIntoGrid method.
Comment 7 Tod Creasey CLA 2007-04-26 13:16:07 EDT
We can't slam the button font with the parent font because it is wrong on several platforms (such as the Mac) as they will have a default font per parent.

Otherwise what I have released satisfies your suggestions (except that I use the dialog font).

If you could check build >20070426 in 3.3 that would be a big help - I am going to mark this as FIXED
Comment 8 Hiroyuki Inaba CLA 2007-04-29 23:23:00 EDT
Created attachment 65362 [details]
MS_UI_Gothic_9.png

Use eclipse Build id: N20070428-0010
The height of the button are different to the Color Selector of Java > Editor.
Comment 9 Hiroyuki Inaba CLA 2007-04-29 23:32:20 EDT
The reason for this problem is that the font of the parents 
composite is not set to the button of ColorSelector in
ColorFieldEditor.getChangeControl method. 

protected Button getChangeControl(Composite parent) {
	if (colorSelector == null) {
		colorSelector = new ColorSelector(parent);
==>		colorSelector.getButton().setFont(parent.getFont());
		colorSelector.addListener(new IPropertyChangeListener() {
Comment 10 Tod Creasey CLA 2007-04-30 08:25:34 EDT
Inaba-san have you tried this change? My concern is the following

1) We set the font based on the parent control
2) The code sets the font of the ColorSelector later to the dialog font
3) The text of the labels and the buttons are not in proportion.

Either way I think it is too late in the cycle for me to take this any further without any more rigourous testing on other platforms and languages.
Comment 11 Hiroyuki Inaba CLA 2007-05-08 03:35:01 EDT
Created attachment 66246 [details]
snapshot.png

> Inaba-san have you tried this change?

Yes (tried).

New environment;
- Windows Vista Ultimate - English
- Eclipse 3.3 M7 (I20070503-1400)

Steps To Reproduce:
1. Eclipse launch in Windows Vista (English)
2. Window > preference >
     General > Appearance > Color and Fonts
   "MS UI Gotic", "Regular", "9" set as the Dialog font,
   and click OK button.
3. After, Window > preference >
     Run/Debug
Comment 12 Hiroyuki Inaba CLA 2007-05-08 03:39:40 EDT
The problem of #8 is getChangeControl method of the ColorFieldEditor class,
and the font of the parent composite is not set to the button. 
Comment 13 Feng Dihai CLA 2008-04-16 21:53:16 EDT
After upgrade to Vista (Japaneses Edition), if you apply Meiryo as default font in System Preference, every dialog open in Eclipse looks ugly beacuse of too wide buttons. [Meiryo is a new font for VISTA and also a new set of fonts for Chinese/Korean edition. It looks very beautiful than UIGothic/Gothic.]

I have made a workaround by overriding org.eclipse.swt.graphics.GC in a fragment. Here is my solution:

changes in GC.java =>
public FontMetrics getFontMetrics() {
	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
	checkGC(FONT);
	TEXTMETRIC lptm = OS.IsUnicode ? (TEXTMETRIC)new TEXTMETRICW() : new TEXTMETRICA();
	OS.GetTextMetrics(handle, lptm);
	FontMetrics fm = FontMetrics.win32_new(lptm);
	// reported TEXTMETRICS#tmAveCharWidth is much larger for Meiryo
	// because it takes consideration both 8bit and 16bit characters.
	// But Eclipse is expecting only average width of 8bit characters. 
	fm.handle.tmAveCharWidth = computeAverageAsciiCharWidth();
	return fm;
}

private static String sample = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#$%&()*+@`[]{}-:;?,. \'\"\\";
private int computeAverageAsciiCharWidth() {
    return stringExtent(sample).x / sample.length();
}

The fragment works well for Eclipse 3.3(europe), but not for 3.4(gamymede) because org.eclipse.swt_3.4.** is now signed. I hope for a official fix for this problem.

See attached jar file contained source of the fragment, also a PNG show the problem.
Comment 14 Feng Dihai CLA 2008-04-16 21:54:31 EDT
Created attachment 96371 [details]
A workaround fragment(only works for 3.3)
Comment 15 Feng Dihai CLA 2008-04-16 21:56:06 EDT
Created attachment 96372 [details]
Too wide buttons, before and after
Comment 16 Feng Dihai CLA 2008-04-16 21:58:02 EDT
Comment on attachment 96372 [details]
Too wide buttons, before and after

sorry, the annotation should be "it looks better"
Comment 17 Susan McCourt CLA 2009-07-09 19:28:46 EDT
As per http://wiki.eclipse.org/Platform_UI/Bug_Triage_Change_2009
Comment 18 Eclipse Webmaster CLA 2019-09-06 16:06:27 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.