Density Independent Pixels?

Hi! I'm considering to use JUCE for Android developing, but I'm concerned about the capabilities of the library of supporting android multiple screen resolutions. I installed the demo app on my nexus 5, and is very difficult to use it, due of high screen resolution (Full HD). 

The text and the GUI doesn't scale to match the real resolution of the phone, and I want to know if the library can support density independent pixels.

Of course - you can adjust the global scale factor, or the scale factor of any specific component.

shouldn't the scale factor have an sensible value from the beginning on, like on windows 

The latest versions of Juce handles it pretty well on Android. What I do is take the DPI of the device and divide that by a relative DPI of my iOS DPI which gives me a scale factor. I then apply that scale factor to my main apps component and set the size of that main app component based on this scale factor.

 

Overall it is quite simple and things just work.  However there are quite a few other things that will need to be coded on Android for it to work reliably. Android is a pain and, imo, Google has done a terrible job in polishing its SDK for developers. Simple things like the GLSurfaceView have a ton of bugs that you have to work around and Juce, by default, does not. However Juce gives you a huge starting point that covers 95% of app development.

 

In my construction of my main window I do

 

juce::Rectangle<int> screenArea = Desktop::getInstance().getDisplays().getMainDisplay().userArea;

    double dpi = Desktop::getInstance().getDisplays().getMainDisplay().dpi;

    double scaleFactor = dpi / 155.0f; //163 is rough actual size of iOS

    int realWidth = screenArea.getWidth() / scaleFactor;

    int realHeight = screenArea.getHeight() / scaleFactor;

    setSize(realWidth, realHeight);

 

then in the initialise function after the main component is created I do

 

//lets consider 320X568 on iOS the default DPI...

    //iphone is 163dpi

    //since the UI is designed for iPhone 5 we can adjust from there.

    

    juce::Rectangle<int> screenArea = Desktop::getInstance().getDisplays().getMainDisplay().userArea;

    double dpi = Desktop::getInstance().getDisplays().getMainDisplay().dpi;

    double scaleFactor = dpi / 155.0f; //163 is actual size

    

    int realWidth = screenArea.getWidth() / scaleFactor;

    int realHeight = screenArea.getHeight() / scaleFactor;

    

    double realScaleWidth = (double) screenArea.getWidth() / (double) realWidth;

    double realScaleheight = (double) screenArea.getHeight() / (double) realHeight;

    

    AffineTransform newTransform = mainAppComponent->getTransform();

    newTransform = newTransform.scale(realScaleWidth, realScaleheight);

    mainAppComponent->setTransform(newTransform);

 

Jules, where is the "global scale factor"?  The technique by vipersnake mentioned above works fine for the main component, but any popup menus are still rendered with no scaling.  

Desktop::setGlobalScaleFactor

I did find it, but it does not seem to be functioning as expected on Android (at least on my galaxy note 3).  I will be investigating.