Hi,
Thanks for your interest in Pivot! I saw your question on
stackoverflow also, but haven't had the time to give you a proper answer there.
It sounds like a bug (to me). So, I would suggest opening a JIRA issue so we
can track it, and put all your test case information in there. You can do that
here: https://issues.apache.org/jira/browse/PIVOT
I assume you're using the 2.0.4 (latest shipping version) of Pivot?!
Can you try building the "trunk" (version 2.1)? And if so, can you reproduce
the problem in there? I don't think there have been any changes related to
this, but just as a point of reference.
Again, thanks very much for using Pivot, and I hope we can resolve this
issue shortly.
~Roger Whitcomb
-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: Tuesday, March 03, 2015 12:53 AM
To: [email protected]
Subject: UI zooming and buttons detection in Apache Pivot at program start
Hi there,
I have been testing Apache Pivot one week now and I'am very impressed of this
library! It is easy, simple and good looking UI library without any new tool.
Currently I'am trying to use UI scaling (zooming) feature which work nicely
with Ctrl Shift +/- keys (and mouse too), but I cannot make it work right at
program start so that buttons could be detected from correct location. So, I
like to run an application and set some predefined scale so that a user need
not to adjust it at all. This is beacuse I know the target device screen
resolution where the application will be run.
I have tried two different apporaches here:
1) Using ApplicationContext.scaleUp():
ApplicationContext.DisplayHost displayHost = new
ApplicationContext.DisplayHost();
Graphics2D graphics = (Graphics2D) displayHost.getGraphics();
displayHost.setScale( scale );
So this is not working - the code is located at startup method before or after
"window.open(display);" call.
2) Using ScaleDecorator.setScale will scale the UI correctly...:
final ScaleDecorator sd = new ScaleDecorator();
window.getDecorators().add( sd );
sd.setHorizontalAlignment( HorizontalAlignment.LEFT );
sd.setVerticalAlignment( VerticalAlignment.TOP );
sd.setScale( scale );
sd.update();
... but all buttons will be detected as if the UI is using scale factor 1.0. So
all buttons are detected (with mouse) from wrong screen locations (x/y
-coordinates).
This effect can be easily tested with ApachePivot
org.apache.pivot.demos.text.TextPaneDemo by adding the code above just before
window.open(display) call like this:
....
final ScaleDecorator sd = new ScaleDecorator();
window.getDecorators().add( sd );
sd.setHorizontalAlignment( HorizontalAlignment.LEFT );
sd.setVerticalAlignment( VerticalAlignment.TOP );
sd.setScale( 2.0f );
sd.update();
window.open(display);
textPane.requestFocus();
}
The program UI will scale correctly the but buttons will react from wrong
locations.
I have searched through all tutorials, demos, faq, mailing lists, Google and
Stack Overflow but have not found an example or right way to do this. I guess I
have missed something? Any tips will be appreciated.
Thank you.