Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Contributor
scraft
Posts: 44
Registered: ‎01-06-2012
My Device: PlayBook

Orientation

Hi,

 

I am developer games for both PlayBook and BB10. Some games are portrait, others are landscape, none of them support multiple orientations. In terms of making OpenGL render at the correct orientation, and making sure my touch screen input is correct I have had no problems, I am used to having to deal with various hardware orientations from working on multiple different platforms. What I am struggling with is how to ensure the system dialogs are always displayed at the correct orientation.

 

Lets take for example a portrait game, running on the PlayBook, in my bar descriptor XML, I have:

 

<initialWindow>
  <aspectRatio>portrait</aspectRatio>
  <autoOrients>false</autoOrients>
</initialWindow>

 

Then in my code I have:

 

navigator_rotation_lock( true );

 

As I say, GL/input is handled by our engine so this all comes through correctly. If I launch the application from the PlayBook, with the PlayBook already in portrait, it works correctly, system dialogs appear at the same orientation as the game. However, if I launch the game from landscape, the game all functions correctly however system dialogs appear in landscape (despite the game being in portrait). So to try and compat that I started messing around with the following functions (before locking rotation):

 

navigator_set_orientation( 90, NULL );
navigator_set_window_angle( 90 );

 

I have been plugging different rotation values in (90, -90, 270, etc.) and seem to sometimes get builds that orient correctly from one launch angle, but fail in other launch angles. After some messing around I got it working from all launch angles (hurrah!) thank goodness for that I thought. But then I relaunched the application and it once again displayed system dialogs at the wrong orientation. After some messing around, I found that if, whilst on the desktop/OS, I rotate the device left, to portrait, and then back to landscape, then launch the game, sometimes I would get different dialog orientation to if I rotate the device right to portrait, then back to landscape, then launch the game.

 

On top of this, I find sometimes the build is all looking okay, then I'll flick the application to 'card view', rotate the device around a bit whilst in card view, then go back to my application, and the system dialogs then are incorrect.

 

Can anyone help?! What I want to do is actually incredibly simple, I want to just lock my game to either portrait, or landscape. Once locked I never want it to change. Plus I want all system dialogs to also obey the orientation I am using.

 

Hopefully I am over thoroughly over-complicating this and there is a simple solution?!

 

Kind regards,

 

Steven Craft

Paw Print Games Ltd.

BlackBerry Development Advisor (Retired)
mgoulet
Posts: 329
Registered: ‎05-07-2012
My Device: BB Alpha

Re: Orientation

Hi there,

 

Could you show me the snipped of code used to prompt your dialog?

 

Martin

 

Contributor
scraft
Posts: 44
Registered: ‎01-06-2012
My Device: PlayBook

Re: Orientation

For example:

 

// .h

dialog_instance_t m_ActiveDialog;

 

// .cpp

dialog_create_prompt( &m_ActiveDialog );

dialog_set_size( m_ActiveDialog, DIALOG_SIZE_SMALL );

dialog_set_title_text( m_ActiveDialog, "Enter your Scoreloop name" );

dialog_set_prompt_message_text( m_ActiveDialog, "Please choose Scoreloop name");

dialog_set_prompt_input_field( m_ActiveDialog, m_UserLogin );

dialog_add_button( m_ActiveDialog, DIALOG_OK_LABEL, true, NULL, true );

dialog_set_default_button_index( m_ActiveDialog, 0 );

dialog_show( m_ActiveDialog );

 

Contributor
scraft
Posts: 44
Registered: ‎01-06-2012
My Device: PlayBook

Re: Orientation

I should probably also note, it isn't the dialog system which is at fault, the 'card view' gesture (swipe up) also get confused when the orientation goes wrong, as in if the dialog is displaying messages at the wrong orientation, the swipe up gesture will also be wrong (however the swipe up gesture will be the same orientation as the dialog box). Essentially the system believes my game/window/something is at a different orientation to what it actually is.

 

Kind regards,

 

Steve

BlackBerry Development Advisor (Retired)
mgoulet
Posts: 329
Registered: ‎05-07-2012
My Device: BB Alpha

Re: Orientation

The code you are using seems correct. Given that you are able to observe this with the gestures as well strongly suggests a bug.

I would recommend logging an issue in the Issue Tracker by following the link below:
https://www.blackberry.com/jira/secure/Dashboard.jspa

Regards,

Martin

Retired
dtomilovskiy
Posts: 36
Registered: ‎10-26-2011
My Device: RIM Developer

Re: Orientation

Hey scraft.

 

This topic is know to be confusing at first. Have you looked at the GoodCitizen and HelloWorldDisplay samples?

 

It seems that you want to achieve an effect similar to what GoodCitizen does - on a swipe down a menu animation is triggered. In case of locking orientation - it is the same c++ code as in GoodCitizen, but bar-descriptor settings are different.

 

Take a look at the sample code, and if you still have issues - please let myself and anhu (he is another dev. adviser here) know.

 

 

Thank you.