Recent

Author Topic: Lazarus 2.1.0 svn, TLabel problems in designer  (Read 4579 times)

funlw65

  • Full Member
  • ***
  • Posts: 149
    • Visual Pin Configurator for Nucleo 64pin boards
Lazarus 2.1.0 svn, TLabel problems in designer
« on: January 07, 2021, 09:24:00 am »
I made a video clip that shows the problem, maybe devs know about it already...

https://youtu.be/v-a7QVfvuKU

Edit: I have to add that is Lazarus with Qt5 widgets.
« Last Edit: January 07, 2021, 09:43:18 am by funlw65 »
FreePascal 3.2.2, C 10.2.1, D 1.24 under Linux(init,musl,glibc), DragonflyBSD, NetBSD
gui: gtk2, qt5, raylib4.x+raygui3.x, nanovg 
tui: freevision, tvision2, termbox2+widgets, finalcut
db: typhoon-1.11...

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2032
  • Former Delphi 1-7, 10.2 user
Re: Lazarus 2.1.0 svn, TLabel problems in designer
« Reply #1 on: January 07, 2021, 10:28:12 am »
You really need to log this in the Bugtracker.

wp

  • Hero Member
  • *****
  • Posts: 12909
Re: Lazarus 2.1.0 svn, TLabel problems in designer
« Reply #2 on: January 07, 2021, 10:35:13 am »
I doubt that it ever worked in older versions, and even if it did it will not work in other widgetsets. The TLabel (and TStaticText) simply were not designed having totated text in mind. The rotation occurs around the top/left corner of the text and thus move the text out of the original bounds when the text is put vertically (I don't understand why QT5 does display at least part of the text - it should not).

It is not difficult to fix -- see the attached demo. Instead of modifying the original TLabel I introduced a new TVertLabel which inherits from TLabel and thus has everything you know from TLabel (except for multiple lines and right-to-left). I override the Paint procedure to place the text at the correct position, and I override the CalculatePreferredSize method which does the AutoSize calculation (simly exchange Width and Height here). The TVertLabel also supports the Alignment and Layout properties. There is some ambiguity with what they mean in relation to rotated text. I decided to see them from the text perspective rather than from the screen perspective.

P.S.
Next time when you post a message please don't waste your time creating a video. It is certainly faster to type here all the text what you typed into the video, and when you add one or two screenshots everything is clear. The main objection against the video, however, is that it is stored outside the forum and will certainly be gone after some time. Since all your description is contained in this video the forum post will not be understandable any more for every user seeing your post after the video has disappeared from youtube.

For those user who see this post: The video shows that vertical text is not displayed in a TLabel.
« Last Edit: January 07, 2021, 06:19:10 pm by wp »

funlw65

  • Full Member
  • ***
  • Posts: 149
    • Visual Pin Configurator for Nucleo 64pin boards
Re: Lazarus 2.1.0 svn, TLabel problems in designer
« Reply #3 on: January 07, 2021, 11:26:58 am »
I doubt that it ever worked in older versions, and even if it did it will not work in other widgetsets. The TLabel (and TStaticText) simply were not designed having in mind rotated text. The rotation occurs around the top/left corner of the text and thus move the text out of the original bounds when the text is put vertically.

It is not difficult to fix -- see the attached demo. Instead of modifying the original TLabel I introduced a new TVertLabel which inherits from TLabel and thus has everything you know from TLabel. I override the Paint procedure to place the text at the correct position, and I override the CalculatePreferredSize method which does the AutoSize calculation (simly exchange Width and Height here).

P.S.
Next time when you post a message please don't waste your time creating a video. It is certainly faster to type here all the text what you typed into the video, and when you add one or two screenshots everything is clear. The main objection against the video, however, is that it is stored outside the forum and will certainly be gone after some time. Since all your description is contained in this video the forum post will not be understandable any more for every user seeing your post after the video has disappeared from youtube.

For those user who see this post: The video shows that vertical text is not displayed in a TLabel.

1. Initially, I designed the form using gtk2 layer. It works perfectly in 2.0.10 both in 900 and 2600 rotation - two years of usage. In Lazarus 2.0.10 with Qt5 at least, the vertical labels designed previously in gtk2 are correctly displayed, without clipping the text as it does in 2.1.0. You can also resize the rectangle without the text to be clipped - this seems to be specific only to Lazarus 2.1.0 SVN so there are new bugs introduced. In 2.0.10 using Qt5 is the same problem with alignment (Top, Bottom, Center). Temporary solution is to continue using Lazarus 2.0.10, designing using gtk2 based components and compiling the project for Qt5.

2. Thank you for the code solution, it is highly appreciated and might be of use also to others but I have my reasons to use the visual components as they are (for that specific app of mine), the functionality is already there in those based on gtk2.

3. The movie will stay then, I see your point and this is how I do usually. Somehow, I was afraid that someone already exposed this TLabel bad behavior. But I completely disagree with you regarding the clarity of presentation. It is said that a picture values more than a thousand words, imagine how much value is in an entire animation that shows the problem more accurately. You know, English is not my native language, in video there is presented complex behavior, I would have done a lousy job trying to describe that with my own words and some screenshots (I know how hard is to show people what I want to say - I know, I've already posted two threads :P ). 
« Last Edit: January 07, 2021, 11:29:19 am by funlw65 »
FreePascal 3.2.2, C 10.2.1, D 1.24 under Linux(init,musl,glibc), DragonflyBSD, NetBSD
gui: gtk2, qt5, raylib4.x+raygui3.x, nanovg 
tui: freevision, tvision2, termbox2+widgets, finalcut
db: typhoon-1.11...

funlw65

  • Full Member
  • ***
  • Posts: 149
    • Visual Pin Configurator for Nucleo 64pin boards
Re: Lazarus 2.1.0 svn, TLabel problems in designer
« Reply #4 on: January 07, 2021, 12:22:13 pm »
You really need to log this in the Bugtracker.

I don't even know where to categorize it... LazarusIDE? LCL?
FreePascal 3.2.2, C 10.2.1, D 1.24 under Linux(init,musl,glibc), DragonflyBSD, NetBSD
gui: gtk2, qt5, raylib4.x+raygui3.x, nanovg 
tui: freevision, tvision2, termbox2+widgets, finalcut
db: typhoon-1.11...

balazsszekely

  • Guest
Re: Lazarus 2.1.0 svn, TLabel problems in designer
« Reply #5 on: January 07, 2021, 01:11:24 pm »
@funlw65

Quote
2. Thank you for the code solution, it is highly appreciated and might be of use also to others but I have my reasons to use the visual components as they are (for that specific app of mine), the functionality is already there in those based on gtk2.
Using @wp's solution, create a new component(TLabelEx for example) then add it to a package. After the package is installed into the IDE, with a text editor replace TLabel to TLabelEx (*.dfm). Now you have a new visual component, an extended label with all the functionality you need.

funlw65

  • Full Member
  • ***
  • Posts: 149
    • Visual Pin Configurator for Nucleo 64pin boards
Re: Lazarus 2.1.0 svn, TLabel problems in designer
« Reply #6 on: January 07, 2021, 01:28:10 pm »
Thank you @GetMem this open source project is supposed to use standard components, without forcing the users (that might not know Pascal and Lazarus) to install additional packages. The users will know at least C language, used to program microcontrollers.

There are few reasons why I used procedural programming:
1. Speed. I had to present an working prototype fast, to honor a promise I made on ST Microelectronics forum (I chose Lazarus as it offers a Borland like Visual Component interface which in my opinion is the most advanced in the world);
2. The portability of the entire idea, that could be implemented in any RAD application (no matter the language) so, no specific objectual code.
3. Last time I used pascal objectual programing was with Turbo 7.0 and TurboVision - long time ago.
FreePascal 3.2.2, C 10.2.1, D 1.24 under Linux(init,musl,glibc), DragonflyBSD, NetBSD
gui: gtk2, qt5, raylib4.x+raygui3.x, nanovg 
tui: freevision, tvision2, termbox2+widgets, finalcut
db: typhoon-1.11...

funlw65

  • Full Member
  • ***
  • Posts: 149
    • Visual Pin Configurator for Nucleo 64pin boards
Re: Lazarus 2.1.0 svn, TLabel problems in designer
« Reply #7 on: January 07, 2021, 05:52:32 pm »
The TLabel (and TStaticText) simply were not designed having rotated text in mind.

I've seen this statement two years ago, when I was looking for vertical labels...
I understand that if there already is the basic thing implemented (and by that I mean all the functionality the original TLabel offers), then it does not hurt having also extra properties/behavior.

I mean, I see the meaning of offering support for Delphi programs that must be converted to Lazarus but not the other way around. If you don't play the dominant male game, you will never be the dominant male. I don't know if Embarcadero facilitates any migration from them to whatever alien tool. So I don't see the logic of that statement.

MSEGUI has nice support for vertical labels, it works wonders. So there is native support for a future LCL TLabel based on MSEGUI. That would be awesome if CustomDrawn means too much work.
FreePascal 3.2.2, C 10.2.1, D 1.24 under Linux(init,musl,glibc), DragonflyBSD, NetBSD
gui: gtk2, qt5, raylib4.x+raygui3.x, nanovg 
tui: freevision, tvision2, termbox2+widgets, finalcut
db: typhoon-1.11...

wp

  • Hero Member
  • *****
  • Posts: 12909
Re: Lazarus 2.1.0 svn, TLabel problems in designer
« Reply #8 on: January 07, 2021, 06:24:08 pm »
My Delphi 7 does not even have an Orientation field in TFont. XE2 has it, but the TLabel does not work when the font is rotated, similar to the LCL. Only in the most recent version that I have, XE 10.3, rotation works correctly, even for arbitrary angles, however only for single-line labels. In the multi-line case, it goes crazy again.


JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4599
  • I like bugs.
Re: Lazarus 2.1.0 svn, TLabel problems in designer
« Reply #9 on: January 07, 2021, 06:51:13 pm »
Quote
1. Initially, I designed the form using gtk2 layer. It works perfectly in 2.0.10 both in 900 and 2600 rotation - two years of usage. In Lazarus 2.0.10 with Qt5 at least, the vertical labels designed previously in gtk2 are correctly displayed, without clipping the text as it does in 2.1.0. You can also resize the rectangle without the text to be clipped - this seems to be specific only to Lazarus 2.1.0 SVN so there are new bugs introduced.
I don't even know where to categorize it... LazarusIDE? LCL?
It would be LCL. I understood there is a regression with widgetset QT5. It should be fixed.
When a bug report is for a specific widgetset, it should be mentioned also in the header. Otherwise it may get buried in attributes.
The best scenario is that somebody bisects the guilty revision causing a bug, but that is a laborous process with a long commit history.

Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

funlw65

  • Full Member
  • ***
  • Posts: 149
    • Visual Pin Configurator for Nucleo 64pin boards
Re: Lazarus 2.1.0 svn, TLabel problems in designer
« Reply #10 on: January 07, 2021, 07:57:31 pm »
Thank you Juha in helping me doing my part!
Now I don't know if I did it right, but I did it https://bugs.freepascal.org/view.php?id=38328
FreePascal 3.2.2, C 10.2.1, D 1.24 under Linux(init,musl,glibc), DragonflyBSD, NetBSD
gui: gtk2, qt5, raylib4.x+raygui3.x, nanovg 
tui: freevision, tvision2, termbox2+widgets, finalcut
db: typhoon-1.11...

wp

  • Hero Member
  • *****
  • Posts: 12909
Re: Lazarus 2.1.0 svn, TLabel problems in designer
« Reply #11 on: January 09, 2021, 01:20:19 pm »
I fixed the issue. Please test the new label and close the bug report if it is ok. I tested on Windows, but since it is widgetset-independent code it must work for all widgetsets.

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2032
  • Former Delphi 1-7, 10.2 user
Re: Lazarus 2.1.0 svn, TLabel problems in designer
« Reply #12 on: January 09, 2021, 11:53:45 pm »
Tested OK on macOS (Cocoa widgetset)

wp

  • Hero Member
  • *****
  • Posts: 12909
Re: Lazarus 2.1.0 svn, TLabel problems in designer
« Reply #13 on: January 10, 2021, 01:05:25 am »
Thanks for testing.

jamie

  • Hero Member
  • *****
  • Posts: 6989
Re: Lazarus 2.1.0 svn, TLabel problems in designer
« Reply #14 on: January 10, 2021, 02:37:11 am »
I haven't yet looked but is the label's area using the Sqrt(X^ + Y^) etc for the max reach on the angles?
The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018