bgrabitmap / bgracontrols

🆗 BGRA Controls is a set of graphical UI elements that you can use with Lazarus LCL applications.
https://bgrabitmap.github.io/bgracontrols/
189 stars 32 forks source link

TBCButton does not honor LineEnding in Caption #84

Closed costel78 closed 4 years ago

costel78 commented 4 years ago

With fpc-3.0.2, lazarus 2.0.10, bgrabitmap 11.2.1.0 and bgracontrols 6.8.0 TBCButton have a small issue. If the Caption contain LineEnding this is not respected, text is render on a single line. Word wrapping is working. Example: BCButton1.Caption:='Row1' + LineEnding + 'Row2' the result is: Row1Row2 Expected result: Row1 Row2

Thank you!

costel78 commented 4 years ago

proposed_solution.txt The above approach fix the problem for TBCButton. No issue observed with others controls, but I am aware that this is a naive fix, not very familiarized with codebase.

lainz commented 4 years ago

Hi thanks for your solution. @circular17 that can be directly included in BGRABitmap? so it works for any text as well?

circular17 commented 4 years ago

Hi,

As far as I understand the code, the line ending is taking into account when the boolean property SingleLine of the font is false. Maybe just setting this property would do.

costel78 commented 4 years ago

Hi, It is working automatically with SingleLine and WordBreak set to false. It is more convenient to have both WordBreak active and LineEnding respected. When translations (po files) are used the length of text can increase/change dramatically.

lainz commented 4 years ago

I'm a bit lost, so I better let you this bug @circular17 , I'm not understanding what's going on.

lainz commented 4 years ago

Anyways, with SingleLine set to false, the height for AutoSize is not calculated properly when there are multiple lines with "LineEnding".

lainz commented 4 years ago

I can't apply the patch, TortoiseGit says is not a valid patch.

circular17 commented 4 years ago

That may be a but in TextRect. I suggest you let the TBCButton code as it is, I will check on BGRABitmap side.

circular17 commented 4 years ago

Ok that's fixed in dev branch of BGRABitmap. There was some case where the line ending would not be handled.

circular17 commented 4 years ago

Note: in BGRABitmap, SingleLine is ignored when WordWrap is on. That's the contrary with the LCL, WordWrap is ignored when SingleLine is on. That's not so important because both are not supposed to be used at the same time and I would prefer to leave it like that to avoid breaking existing code.

circular17 commented 4 years ago

Note2: I've added support for Unicode line endings (br, p, 0085) in BGRABitmap. That's not handled correctly in LCL so that's a difference of result though in this case, If think it is better to avoid the buggy effect (like having multiple lines written at the same location).

lainz commented 4 years ago

Thankyou!

costel78 commented 4 years ago

Thank you for your support! I will ask to include LineEnding in translation, directly, where the length of text could be a problem.

circular17 commented 4 years ago

You're welcome.

Not sure why you would need LineEnding for translation if you have WordWrap enabled.

costel78 commented 4 years ago

Yes, it is unusual. It is about separation between type of info, like Name of service and statistics about it, separated by one, or even two LineEndings. Tooltips and other suggestions were rejected.

lainz commented 4 years ago

Ok, I'm closing it since it was fixed in BGRABitmap repository.