Skip to content

Add scaling for themed fonts and graphics (hires displays) #2776

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed

Add scaling for themed fonts and graphics (hires displays) #2776

wants to merge 2 commits into from

Conversation

PaulStoffregen
Copy link
Contributor

This pull request adds a "gui.scalePercent" parameter in lib/theme/theme.txt, which can scale most of the currently fixed size graphics and fonts. This allows adjusting Arduino for 4K and other high res screens. It should mostly solve issue #2532 .

Forum user "the-fallen" deserves much of the credit for this patch. He created the original version, posted to the forum. I added automatic font and graphic scaling, and changed it to percentage for finer control.

Discussion is here:

http://forum.arduino.cc/index.php?topic=263838.0

@PaulStoffregen
Copy link
Contributor Author

@ArduinoBot build this please

1 similar comment
@ffissore
Copy link
Contributor

@ArduinoBot build this please

@ArduinoBot
Copy link
Contributor

Build failed.

@ffissore
Copy link
Contributor

The GUI tests fail. Reported error is

java.lang.ExceptionInInitializerError
    at processing.app.AbstractGUITest.startUpTheIDE(AbstractGUITest.java:21)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:78)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:212)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
Caused by: java.lang.NumberFormatException: null
    at java.lang.Integer.parseInt(Integer.java:443)
    at java.lang.Integer.parseInt(Integer.java:514)
    at processing.app.Theme.getInteger(Theme.java:82)
    at processing.app.Preferences.<clinit>(Preferences.java:208)
    ... 28 more

You can run the tests with ant clean build test. If you're on a multi monitor setup, switch the others off, and stay with one monitor only, otherwise the tests will hang (yeah, pretty annoying)

@PaulStoffregen
Copy link
Contributor Author

I see what's wrong. Using Theme inside Preferences breaks the tests. I've just committed a fix.

@PaulStoffregen
Copy link
Contributor Author

@ArduinoBot build this please

@PaulStoffregen
Copy link
Contributor Author

Looks like a minor change for the about dialog broke this pull request.

But of the dozen or so people who've wished for this feature on the forum and another issue, none have bothered to download the build above and provide any feedback... so maybe they don't really care or want this feature much?

@luc-github
Copy link

I have tested the http://arduino.cc/download.php?f=/javaide/pull_requests/arduino-PR-2776-BUILD-221-windows.zip
in my laptop windows 8.1 resolution 3840X2160
If I compare with 1.5.8 :
1.5.8 : splash screen has correct rendering - about box has very small rendering - text is very small
1.6.2 experimental : splash screen/about box have very small rendering - text is very small (same as 1.5.8 actually)

I am not sure if I test well but actually, it looks worse with experimental
My HDPI setting is big size for all elements

image

Edit : if need to redo more tests, or give more details about my configuration, just let me know, I would be happy to feedback

@elFallino
Copy link

I tested arduino-PR-2776-BUILD-221 on Windows 8.1, 64 Bit 15.6inch UHD Display.
Tested with 100%, 150%, 200% and 250% scaling factor.
Starts and displays fine, button "animations" are as expected.

Splashscreen on that one is very small (not scaled at all I guess). About-Screen looks fine.

g.setColor(Color.white);
g.drawString(BaseNoGui.VERSION_NAME, 50, 30);
g.drawString(BaseNoGui.VERSION_NAME, 50 * scale / 100, 30 * scale / 100);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PaulStoffregen PR doesn't merge any more because I've changed splashscreen and had to change version string position
When resolving merge, take your version and change
g.drawString(BaseNoGui.VERSION_NAME, 50 * scale / 100, 30 * scale / 100);
to
g.drawString(BaseNoGui.VERSION_NAME, 33 * scale / 100, 20 * scale / 100);

@PaulStoffregen
Copy link
Contributor Author

@luc-github When you tested PR-2776-BUILD-221, did you edit lib/theme/theme.txt? From the screenshot you posted, gui.scalePercent appears to still at the default 100 value.

This change does NOT cause automatic scaling. You must manually edit lib/theme/theme.txt. This pull request adds the ability for Arduino to scale many things from that single setting. Perhaps someday in the future, when/if Oracle updates Java with the ability to reliably report screen pixel density, this setting might become automatic. But for now, this pull request requires manual editing of theme.txt.

@luc-github
Copy link

Ok that the part I missed, sorry, I though it was automatic
After editing the theme.txt and set the scalePercent to 250 , and set font size in Arduino preferences to 40, only first splash screen is small, About dialog and IDE have correct rendering.

Thank you

@PaulStoffregen
Copy link
Contributor Author

Thanks for trying again. Good to hear it's mostly working.

The splash screen code was added very recently, and unfortunately it doesn't load the image the using the same API as everything else. I'm not sure how much more time I'm going to put into this scaling stuff. At the moment, I don't actually have high-dpi screen.

@ilmtr
Copy link

ilmtr commented Mar 21, 2015

Seems to look better now with these settings. Splash is small and icons look upconverted, not true high-dpi / vector graphics based.

untitled

@PaulStoffregen
Copy link
Contributor Author

The icons look upconverted, because they are upconverted.

There's a "TODO" comment in the code where I intend to add the ability to use higher res icons. But 2 things need to happen first: this pull request needs to be merged, and someone would need to actually draw the icons at double size.

Long term, I believe everyone understands 150 to 200 dpi screens are the future. That's why I put several hours into the pull request, even though I do not yet personally own such a screen. But with so few people using such screens today, this feature may be a really low priority for the Arduino devs?

@loverso
Copy link

loverso commented Mar 28, 2015

Thanks for this. I'm using the test nightly build today on my Asus UX303L during an Arduino day event.

@cmaglie cmaglie added feature request A request to make an enhancement (not a bug fix) Component: IDE user interface The Arduino IDE's user interface labels Apr 15, 2015
@luc-github
Copy link

Hi - any time frame for implement this ? even graphics are upconverted, it is fine I think, because at least it can be used.
I would suggest functional first and then nice looking - just my 2 cents

@TheronRogers
Copy link

I just grabbed this and it made Arduino much more usable for me. Even a 50% increase made a huge difference. Here's 150% scale on the left and 100% scale on the right.
arduino150v100

@neslekkim
Copy link

Very good, set the scalePercent to 180, and the fontsize to 25, and that seems to be good values on my 28" 4K monitor.
Does this mean that this need to be tweaked later also?, I know the javatools from jetbrains also did not scale well, but they fixed that so it works fine.

@juj
Copy link

juj commented Apr 24, 2015

Thanks for working on this! Would it be possible to make the feature not need to manually edit a configuration file? It would be more seamless if the Windows DPI setting was directly read into scalePercent and the UI scaled according to that by default.

@PaulStoffregen
Copy link
Contributor Author

Will this happen?

Soon, probably not. As far as I know, nobody is working on this right now. I've been busy lately with a paid project, which hasn't left much time for unpaid open source contributions. Eventually I'll get back to working on Arduino stuff... but my contribution activity happens in cycles and right now is a down time. I can't speak for "the-fallen" (from the forum), but every appearance is he's no longer working on this ether.

Unfortunately, this work was done shortly before Arduino 1.6.2, where a tremendous amount of new code the Arduino Team privately developed was added suddenly to the public code base. It broke this pull request. It also added numerous new GUI pieces that don't seem to use the theme system.

Windows 10 is due to release in just a couple weeks. Perhaps it will be much the same as 8.1 for scaling, or maybe not? Right now hardly seems like a great time to revisit this work.

Eventually, someone will probably pick this up and work on it again. Much more work is needed.

Federico and the Arduino Team also really need to decide if they wish to use the theme system or some other approach for new GUI development, and whether they will actually test Arduino on Windows with high res displays. Before 1.6.2 the path seemed clear to use theme.txt. Now the direction is not so clear cut.

@scottosx
Copy link

Thanks for the update, Paul. As you mentioned there has been a tremendous amount of functionality added since this build. The Boards Manager especially...
I suspect that dealing with high rez displays won't become a priority until some of the lead developers actually begin to use one on a day to day basis. Then the need to fix becomes obvious.
I bought the Yoga 2 Pro specifically to test my apps as HDPI is the new standard and will only become more ubiquitous with each new model. When I install Windows 10 upon release then I can report back how it handles theming.

@elFallino
Copy link

I'll try to adapt the patches to the latest Source Code.
I thought that once a code is working, the developers would either merge it or do not for what reason ever (maybe not interested because of the upcoming Arduino Studio).

If I can make it I will need somebody to push the code.

@elFallino
Copy link

Patches still are working - there are just some lines shifted - everything is fine (latest 1.6.6 Code)
I will upload diffs tomorrow. Really need some sleep now.

@elFallino
Copy link

Here are the patches:

http://pastebin.com/AWwdgjMV

@scottosx
Copy link

Thanks for your quick action on this elFallino. I will be happy to test a build generated from these patches. Hopefully it will be rolled in.

@nmaggioni
Copy link

I confirm that the patches are building correctly on the last sources, and setting gui.scalePercent = 200 works fine for my Dell XPS 13 (QHD+ touch model, early 2015). The font dimension must also be doubled though! I did it through the IDE preferences pane, but I guess it could be done as well in the theme.txt file.

@therevoman
Copy link

I tested the windows build on my Lenovo Yoga 3 pro and thought a 250% scaling looked great. What's the status of getting it merged back in to the mainline. I tried to build latest locally, but couldn't get past a runtime error.

@elFallino
Copy link

I would again adapt the patch to the latest code if one oft the Arduino developers come  around and say that they are interested.

@softegg
Copy link

softegg commented Oct 10, 2015

Hey, this patch is wonderful! Could we please release it, already?

@jaybird23
Copy link

Successfully installed and tested on Yoga 2 Pro (13" monitor with resolution settings at 3200 x 1800 and 250% scaling) running Windows 10. Edited the /lib/theme/theme.txt file scale to 250%. Everything looks great. However, after successfully running the official release (1.64 I think), when I Upload a the Blink sketch example using this build, it tells me that the board is "unofficial". I don't know why this happens now (its an official Arduino Uno board). Please PR this patch ASAP. Screenshot included below (without the error/warning message I mentioned above).

screenhunter_10 oct 28 11 17

@HOBI3CAT
Copy link

HOBI3CAT commented Dec 3, 2015

So I see that this issue has not been completely resolved, but I am just getting started with Arduino, and have a laptop with a 4K screen. I tested the version http://arduino.cc/download.php?f=/javaide/pull_requests/arduino-PR-2776-BUILD-221-windows.zip at 200% and 250% and they both rendered correctly as described above by 5YHgB and luc-github. However, as that test version is only 1.6.2, and the current build is 1.6.6. I saw the patches posted by elFallino above, but have no idea how to use them. Would anyone be able to help me out, as I am a newbie and quite inexperienced with this kind of stuff?

@nmaggioni
Copy link

@HOBI3CAT I converted elFallino's patch into a proper commit, copy this Pastebin paste into a file in the root of the cloned repo and run git am ./patch_file, where patch_file obviously is the file where you copied the patch text into. Let me know if that works :)

@nmaggioni
Copy link

@PaulStoffregen @ffissore I confirm that this patch is still working, I have just tested it with a fresh repo clone and my adapted patchset above (Arch Linux, Dell XPS 13). The only glitch is that you have to resize the window when you first start the IDE, but everything else works fine; see attached screenshots.
@elFallino's changes are awesome.

first_start
everything_is_fine

@edovino
Copy link

edovino commented Dec 14, 2015

I applied the patch @nmaggioni prepared to current head/1.6.7, and it still works fine on Fedora 23. Would be great to get this released... If anyone wants to test, it's in the 'hidpi' branch of my fork: https://github.com/edovino/Arduino/tree/hidpi

@lmihalkovic
Copy link

[LMNTS]

@pb66
Copy link

pb66 commented Dec 27, 2015

I assume these patches are only usable with the cloned repo's, is that correct? I use the windows installer and have just bought a yoga 3 14" 2in1 laptop, the Arduino IDE is not only unreadable but the buttons and tabs are way too small for touch, the IDE is totally unusable as it stands on this laptop.
Is it likely that this "fix" will be included in the main build any time soon? If not is there a step-by-step guide anyone can direct me to?
I have never "cloned and built" the arduino environment before so need a bit more guidance than just installing the patch. or would it be easier for me to try and find a different IDE than "hack" this one?
I have to say this is a pretty major weakness, it totally undermines all the advantages of using an otherwise fantastic IDE if you simply cannot see it.
Thanks in advance for any pointers
Paul

@nmaggioni
Copy link

@pb66 Yes, they are only applicable to the cloned repo's code. See my previous comment for how to apply the most recent patch and this wiki page for instructions on how to build the code.
In my opinion patching the original IDE is the best thing to do: it's a pretty straightforward operation that leaves you with a well-documented and supported IDE.

It seems, however, that this issue has been somehow abandoned, even though working patches have been posted repeatedly.

@elFallino
Copy link

I still hope those patches will be applied soon. I do not know why there is no feedback yet.

@cmaglie
Copy link
Member

cmaglie commented Dec 30, 2015

I'm rebasing these changes on top of master, will open another PR to finalize this patch.

@cmaglie cmaglie self-assigned this Dec 30, 2015
@pb66
Copy link

pb66 commented Dec 30, 2015

@nmaggioni, thanks for the response, that is pretty much as I expected. I'm sure the patch would work and involve very little additional work IF already building from source. I had looked at the wiki and at this time I'm just not keen enough to go that route.
I know it will be sometime before this hits the released version (if at all) but I will try to hold out til then or until the need justifies the anticipated headache of building from source.
It is really good to see it's on the radar again though, thanks again.
Paul

@cmaglie
Copy link
Member

cmaglie commented Jan 2, 2016

I'm closing this one, please continue the discussion on #4376

@cmaglie cmaglie closed this Jan 2, 2016
@arduino arduino locked and limited conversation to collaborators Jul 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Component: IDE user interface The Arduino IDE's user interface feature request A request to make an enhancement (not a bug fix)