* * *

Author Topic: Lazarus Release Candidate 1 of 1.2  (Read 91347 times)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 4333
    • wiki
Re: Lazarus Release Candidate 1 of 1.2
« Reply #105 on: February 15, 2014, 02:20:32 am »
Quote
notepad paints it one pixel lower than lazarus

You picture is not themed? Why, we were looking at code for themed only until now. Un-themed is handled elsewhere.

As for themed, on my PC notepad and Lazarus are identical. At least placement wise. Notepad paints a 1pixel white border on the left, Lazarus does not.

Anyway differences in Y placement may be explicable, *IF* may observation/assumption on squeezing into a fixed height is correct. IF so, there would have to be a special rule on Y placement.

X placement appears fine though.

Quote
As it is now I have no idea what I'm looking for and why.

Does
Code: [Select]
GetThemeTextExtent(Theme, DC, MENU_BARITEM, 0, PWideChar(W), Length(W),
    DT_SINGLELINE or DT_LEFT or DT_EXPANDTABS, nil, TextRect);

return the correct Value.

E.g
- Say that returns left=0 (left is always 0) and right=20; which means a width of 20 pixels.
- Then you snapshot the menu, zoom and count the amount of visible pixels of that menu caption.

Now if you can see 20 pixels, and the 21st is missing, then painting is fine, and calculation in the code that we looked at is also fine. It means that measuring goes wrong.

Code: [Select]
How can I test for subpixel? I'm assuming here but I would say that all program that use GDI+ instead of GDI do subpixel.
Sorry no idea. Not exactly the area of my expertise.

But, if your systems says that the text "File" is 20.4 pixel width, and Lazarus measures with a method tha gets full pixel only, then what will Lazarus receive?
But again this is speculation. I do not know this part of windows in that much detail..

----------------------
Quote
It might help to add DT_NOCLIP to TextFlags to disable clipping for drawing the text in DrawVistaMenuBar:

Yes, but that is, IF the error is in the drawing part of the code.

If the error is some place else, we should fix it some place else. Only if we exhausted all roads and have not found the place, then may we thing about adding a workaround in the "wrong" place.

engkin

  • Hero Member
  • *****
  • Posts: 1619
Re: Lazarus Release Candidate 1 of 1.2
« Reply #106 on: February 15, 2014, 03:19:46 am »
Quote
It might help to add DT_NOCLIP to TextFlags to disable clipping for drawing the text in DrawVistaMenuBar:

Yes, but that is, IF the error is in the drawing part of the code.

If the error is some place else, we should fix it some place else. Only if we exhausted all roads and have not found the place, then may we thing about adding a workaround in the "wrong" place.
I meant during debugging.

As for subpixel, Taazz has his ClearType anti-aliasing enabled as per his pictures. I don't think he changed his default smoothing value.

Rails

  • Guest
Re: Lazarus Release Candidate 1 of 1.2
« Reply #107 on: February 15, 2014, 04:10:32 am »

it is reported as 96 DPI by windows. No HD it is an old acer laptop around the era of vista


Windows tends to report 96 DPI without regard to the actual value, at least it did back then.
 

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 4333
    • wiki
Re: Lazarus Release Candidate 1 of 1.2
« Reply #108 on: February 15, 2014, 03:05:02 pm »
Quote
As it is now I have no idea what I'm looking for and why.

Does
Code: [Select]
GetThemeTextExtent(Theme, DC, MENU_BARITEM, 0, PWideChar(W), Length(W),
    DT_SINGLELINE or DT_LEFT or DT_EXPANDTABS, nil, TextRect);

return the correct Value.

E.g
- Say that returns left=0 (left is always 0) and right=20; which means a width of 20 pixels.
- Then you snapshot the menu, zoom and count the amount of visible pixels of that menu caption.

Now if you can see 20 pixels, and the 21st is missing, then painting is fine, and calculation in the code that we looked at is also fine. It means that measuring goes wrong.

Add
Code: [Select]
debugln([AMenuItem.Caption, ' ',Result.TextSize.cy,' z ',Result.TextSize.cx]);

in
Code: [Select]
function GetVistaBarMenuMetrics(const AMenuItem: TMenuItem; DC: HDC): TVistaBarMenuMetrics;
.........
  Result.TextSize.cx := TextRect.Right - TextRect.Left;
  Result.TextSize.cy := TextRect.Bottom - TextRect.Top;
debugln([AMenuItem.Caption, ' ',Result.TextSize.cy,' z ',Result.TextSize.cx]);

Then run with log or console.

Then count the pixel that where painted.

taazz

  • Hero Member
  • *****
  • Posts: 4265
Re: Lazarus Release Candidate 1 of 1.2
« Reply #109 on: February 15, 2014, 04:57:39 pm »
as you can see from the attached image the file menu returns a CX size of 16 and truncates the drawing at the 14th pixels O have added a alternate pixel line (red green) on the bottom of the file word for measuring. It seems that the text cropping occures 2 pixels before the end of the rect every time.

Now I'm off to revert to the default  theme and run it again.

Edit: DBG2 is with the theme reverted to default. Now the question is why the cut off letters on the other theme only on lazarus applications?
The only thing that is sure is that this is an lcl problem if the difference was a single pixel I could say that it is some kind of rounding error but 2 pixels is way to much a difference for a rounding error.
« Last Edit: February 15, 2014, 05:20:18 pm by taazz »
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 4333
    • wiki
Re: Lazarus Release Candidate 1 of 1.2
« Reply #110 on: February 15, 2014, 06:53:34 pm »
Never denied it was LCL, but where in LCL?
----------

In both themes (or all themes you tested),
with the current/unfixed LCL,
if you compare the IDE menu, against Notepad:

Both have "File Edit" as the first 2 items.

Is the distance, between the leftmost pixel of "File" (the vertical line in F) and the leftmost pixel of "Edit" the same?

----
What are the "Margin" values in GetVistaBarMenuMetrics
debugln at the same place, but get the value of the magins.

And a bit further down: In "procedure DrawVistaMenuBar"
there is a param "ARect", what are the values of that?

--- EDIT
If you are on it, currently it gets TMT_CONTENTMARGINS

Also get  TMT_CAPTIONMARGINS  and see what they are.



We are not the only ones:
http://social.technet.microsoft.com/Forums/windows/en-US/e986ff2d-64b6-4c5f-b13f-5ac8fbfb00d3/delta-to-menu-bar-item-width-returned-in-wmmeasureitem?forum=itprovistadesktopui
« Last Edit: February 15, 2014, 07:37:50 pm by Martin_fr »

taazz

  • Hero Member
  • *****
  • Posts: 4265
Re: Lazarus Release Candidate 1 of 1.2
« Reply #111 on: February 15, 2014, 10:57:21 pm »
I only tested it with the windows 7 theme and the one I'm having problems.  I'm trying to minimize the problematic theme to the absolutely necessary (ee remove the backgrounds for starters)  before packing it up for distribution and uploaded somewhere.

In any case the problem does not seem to be in the routines tested so far, I'll have a new test session some time tomorrow.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

engkin

  • Hero Member
  • *****
  • Posts: 1619
Re: Lazarus Release Candidate 1 of 1.2
« Reply #112 on: February 15, 2014, 11:36:24 pm »
Never denied it was LCL, but where in LCL?
...

We are not the only ones:
http://social.technet.microsoft.com/Forums/windows/en-US/e986ff2d-64b6-4c5f-b13f-5ac8fbfb00d3/delta-to-menu-bar-item-width-returned-in-wmmeasureitem?forum=itprovistadesktopui
The problem is in using Metrics.ItemMargins. These are *not* the correct margins. You yourself said that:

However, I found this (but don't yet have an explanation)

Code: [Select]
function VistaBarMenuItemSize(AMenuItem: TMenuItem; ADC: HDC): TSize;
....
  // item margins. Seems windows adds that margins itself to our return values

However the margin for y, top/bottom on my PC is 3 each.

The rect received by
Code: [Select]
procedure DrawVistaMenuBar(const AMenuItem: TMenuItem; const AHDC: HDC; const ARect: TRect; const ASelected, ANoAccel: Boolean; const ItemAction, ItemState: UINT);

is only 4 pixel higher than the height that was returned.

This is fixed by
Code: [Select]
  TextRect := ARect;
  inc(TextRect.Left, Metrics.ItemMargins.cxLeftWidth);
  dec(TextRect.Right, Metrics.ItemMargins.cxRightWidth);
  inc(TextRect.Top, Metrics.ItemMargins.cyTopHeight);
  dec(TextRect.Bottom, Metrics.ItemMargins.cyBottomHeight);
....
  TextRect.Top := (TextRect.Top + TextRect.Bottom - Metrics.TextSize.cy) div 2;
  TextRect.Bottom := TextRect.Top + Metrics.TextSize.cy;

So that means whatever windows did add, it was not the same margin that we use.

But I do not know what it does add, so no idea how to get the right value.

Metrics.ItemMargins seemed ok until Taazz enabled his themes. The margins in his themes are smaller than Metrics.ItemMargins which left smaller space for the text. As I suggested before, while looking for the correct margins, to calculate this unknown margin and use it to center menu item contents inside it.

dmytron

  • New member
  • *
  • Posts: 43
Re: Lazarus Release Candidate 1 of 1.2
« Reply #113 on: June 19, 2015, 10:27:12 am »
Any updates on this matter (I mean, MainMenu bug)? Is it possible to make at least temporary fix in the SVN (to add missing 1 pixel)?

BitBangerUSA

  • Full Member
  • ***
  • Posts: 183
Re: Lazarus Release Candidate 1 of 1.2
« Reply #114 on: June 21, 2015, 05:03:08 am »
Any updates on this matter (I mean, MainMenu bug)? Is it possible to make at least temporary fix in the SVN (to add missing 1 pixel)?

AFAIK - it seems unlikely as the current release is 1.4
Lazarus Ver 1.4.0 FPC Ver 2.6.4 SVN 48774 32-bit
Windows 7 U 64-bit

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3086
  • I like bugs.
Re: Lazarus Release Candidate 1 of 1.2
« Reply #115 on: July 01, 2015, 01:23:55 pm »
goomeeru23, nokaw253123 and nong253123 are bots and/or spammers, preparing for something else.
Maybe we should block them (?)

eric

  • Sr. Member
  • ****
  • Posts: 255
Re: Lazarus Release Candidate 1 of 1.2
« Reply #116 on: July 01, 2015, 01:40:09 pm »
Ban them.

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 5644
Re: Lazarus Release Candidate 1 of 1.2
« Reply #117 on: July 01, 2015, 01:43:32 pm »
Please use the Report button for moderator attention. Doing so in the thread leaves traces when the spam is removed.

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus