ImpulseAdventure / GUIslice-Builder

Cross-platform drag & drop GUI builder for GUIslice
Other
166 stars 35 forks source link

QUESTION: UTF-8 Support GUI Builder #140

Closed DerZwergGimli closed 3 years ago

DerZwergGimli commented 3 years ago

How or what do I have to type in the GUI-Builder if I want to write some UTF-8 Code into a Text-Field.

UTF-8? -> is enabled Label -> "What do I type in here?" {I would like to write something like char(0x10)}.

The whole reason for this question is that I would like to use the FONT_AWESOME font to display some icons like the "home" icon. (The lib "FONT_AWESOME" see here: font_awesome is included and works as expected.)

Thanks for the support and keep up this amazing work!!!

Pconti31 commented 3 years ago

@DerZwergGimli Good news and some minor bad news. The bad news first.

I have been pushing for UTF8 support inside GUIslice API for some time but its still on the back burner. Currently UTF8 only works on the Linux target platform because that platform supports TrueType fonts with unicode that can be output as UTF8 characters. While platform like Arduino with GFX only supports 7 bit ascii. Now there are solutions here. TFT_eSPI library supports a package U8G2 library that gives UTF8 support but Calvin @ImpulseAdventure hasn't has any time to investigate or extend GUIslice API to use this.

The good news is that Teensy platform supports ILI9341_T3 fonts which are not UTF8 but are 8 bit which gives you extra characters, This is supported by GUIslice API. But you might ask how do you access non ascii characters out of the 7 bit range?

Well, I have been working in my secret laboratory on a new Dialog based upon Windows 10 look and feel called CharacterMap. You simply right click on the "Text" property and a min popup gives you a choice to either clear the text field or bring up the CharacterMap. If you had previously selected the font Awesome you would then see the full character set of Awesome and could then select one at a time the characters you want to use.

One of the issues I've been finishing up on is Code generation. Something like Arduino IDE doesn't like these characters outside of 7 bit ascii. It wants either 7 bit or UTF8 (which directly supports 7 bit ascii). So my solution is to output these characters as HEX strings "\xff".

I'm just about done with my testing and hope to make a release with newly added Awesome font fairly soon.. I'm currently working on updating the User Guide to account for the new feature.

If you are willing to help I could send you a download link to a snapshot release and you could give me your feedback on it.

Paul--

DerZwergGimli commented 3 years ago

Oh this are some some good news.

  1. So first of all I'm on Linux which is UBUNTU 20 and as far as i understand you there should be working UTF-8 support. Which I tested right now and it seems to work! (Previously) I just didn't used the "Ctrl+Shift+U" command to directly type in UTF-8 code in the "Label-Field" in GUISlice-Builder.

  2. I would love to test the new feature to simply select the icons that should be used.

  3. While trying to get UTF-8 working last night I noticed some parsing error with the "%"-symbol. If you type in this as a single char the program crashes and if you try to escape this behavior and type in '%%'(wites '%%') or '\%' (crashes). So I thought the solution is to write UTF-8 code but it turns out the program crashes (while using the '%'-symbol {U+0025}) . I could find a possibility to write a single '%(percentage)'-symbol.

[LOG-FILE.txt]

class java.util.UnknownFormatConversionException: Conversion = 'r'
java.base/java.util.Formatter$FormatSpecifier.conversion(Formatter.java:2839)
java.base/java.util.Formatter$FormatSpecifier.<init>(Formatter.java:2865)
java.base/java.util.Formatter.parse(Formatter.java:2713)
java.base/java.util.Formatter.format(Formatter.java:2655)
java.base/java.util.Formatter.format(Formatter.java:2609)
java.base/java.lang.String.format(String.java:3302)
builder.commands.PropertyCommand.toString(PropertyCommand.java:89)

Thanks DZWG

Pconti31 commented 3 years ago

@DerZwergGimli Hopefully we are on the same wave length here but to make sure. Running the Builder on Linux isn't the same as targeting your App to Linux. That would mean running your generated app on something like a raspberry pi. In that case you can use UTF8 directly as you are doing.

But if your target is actually Teensy using Awesome font characters what you are doing will not work.
Java is using unicode 16 bit characters. Your method is entering unicode 16 bit format (not UTF8). When I do a code gen i convert the unicode 16 bit to utf8 multiple characters which is not something anyone but linux will understand at the moment. If you are using a Teensy or Arduino with a TFT display nonsense will be shown on screen.

Now if you are using a teensy and still want to use awesome and are willing to do some testing for me I'll post a link later today for a download snapshot with my new CharacterMap support. Paul--

Pconti31 commented 3 years ago

@DerZwergGimli Hmmm, Actually I may have misspoke. As long as the unicode character you entered is less than 255 it might actually work out. Let me know. As for the % sign I had already found this issue and I think it will be fixed in the next release.

Pconti31 commented 3 years ago

@DerZwergGimli here is a link to the linux snapshot with character map support. Again, right click text field and select Character map after you pick your font. Also do not forget to press enter after changing your text field or java will ignore your edits. Your Feedback would be really helpful. builder-linux-0.16-SNAPSHOT-1216.tar.gz Paul--

DerZwergGimli commented 3 years ago

Hey @Pconti31, I just tested the SNAPSHOT and works like a charm. The font symbols are displayed in the GUISlice-Builder and with the teensy 3.6 using the ILI9341_T3 lib all symbols are displayed correctly!! Even the "%"-Symbol working as expected!

One more small thing I had to put a:

#define FONTREF_MODE_1 GSLC_FONTREF_MODE_1

at the beginning of the generated "projects_GSLC.h". (I think when I used the Arial-Font in the first place) is this expect or not?

The issue can be closed for me.

DZWG

Pconti31 commented 3 years ago

@DerZwergGimli Thank you for the information. I did not know about FONTREF_MODE_1. I'll have to get an answer from Calvin before doing the release. If you find anything else please post it here. Thanks again! Paul--

DerZwergGimli commented 3 years ago

:smile: @Pconti31 ok, so some small things I have found so far:

DZWG

Pconti31 commented 3 years ago

@DerZwergGimli I have seen it fail to do an update to TFT screen but this mostly happens when we forget to press the enter key. Java is fussy about that. Nevertheless I'll look into it again.

As for page reordering for reasons unclear to me Java works great doing drag and drop between views but its black magic doing drag and drop within the same view, You have no idea how much time and experiments have gone into the tree view. It is however still on my list of things to try again at some point in the future. Paul--

DerZwergGimli commented 3 years ago

@Pconti31

  1. [...]press the enter key[...] - This could be the reason. I will report this if I see it again.

  2. For the treeView maybe try to do a structure like this: (Which I would like even more than the current version) +E_PG_BASE -+E_PG_PAGE2 --+ [..] -+E_PG_PAGE3 -+E_PG_PAGE1

or even deeper: +E_PROJECT_OPTIONS -+E_PG_BASE --+E_PG_PAGE2 --+ [..] --+E_PG_PAGE3 --+ [..] --+E_PG_PAGE1

Maybe this helps.

  1. Could you make the config when you click 'File/Open/OpenProject' project specific. Because wherever I open GUI-Slice I will see the 'old' project folder. (nice to have)

Thanks again DZWG

Pconti31 commented 3 years ago

0.16.b004 with CharacterMap will be released today.