You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by vm...@fastmail.com on 2015/03/03 09:53:21 UTC

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.

Re: UI zooming and buttons detection in Apache Pivot at program start

Posted by vm...@fastmail.com.
Just to update this thread status.

Correct way to achieve the zooming is to use a command line parameter
--scale=x or programmatically use

    display.getDisplayHost().setScale(2.0d);
    window.open(display);

For fore information, see
https://issues.apache.org/jira/browse/PIVOT-966?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14534177#comment-14534177.


Re: UI zooming and buttons detection in Apache Pivot at program start

Posted by vm...@fastmail.com.
Hi,

I wonder is it possible to use some kind a workaround for this? Is is
possible to simulate Ctrl,Shift,+ key combinations programmatically
after the application has been started to make effect of automatic
zooming... I have tried couple of ways but no sucess yet.

Any suggestions?

Re: UI zooming and buttons detection in Apache Pivot at program start

Posted by vm...@fastmail.com.
Hello,

I have created an issue report into JIRA with id PIVOT-966.

Yes, I have used version 2.0.4. I also tested trunk version with the
same results.

VM

RE: UI zooming and buttons detection in Apache Pivot at program start

Posted by Roger Whitcomb <Ro...@actian.com>.
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: vmuukka@fastmail.com [mailto:vmuukka@fastmail.com] 
Sent: Tuesday, March 03, 2015 12:53 AM
To: user@pivot.apache.org
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.