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
Trusted Contributor
cjonesy
Posts: 160
Registered: ‎09-13-2012
My Device: 9900

Re: How can I create a ui with my code for 2.1

Hi Sean, thanks for your reply, I honestly couldnt find any resources to learn how to render text or image to screen using libscreen and/or opengl. There is a sample for rendering cubes to screen I looked through.

 

This might be standard for a c programmer already, I don't know as I am learning both c and bb ndk at the same time.

 

Anyone have a link so i can learn how to do this?

BlackBerry Development Advisor
smcveigh
Posts: 668
Registered: ‎11-29-2011
My Device: developer

Re: How can I create a ui with my code for 2.1

The HelloWorldDisplay sample shows how to use bbutil.c to render text -- this is opengl stuff, which should interop nicely with your other libscreen code - you can confine opengl to a single window overlaid in front of your video window using transparency and appropriate ZORDER settings.  I believe this sample also loads a png.   bbutil.c is a common helper library of sorts that is used by many of the samples.

 

I know I've also explained how to use libimg on this forum somewhere -- maybe not a complete sample, but you should be able to get the idea from it.  You can use libimg to load up a png, store it in a screen_pixmap_t and then blit it into your window.  I think you're probably somewhat familiar with these concepts. 

 

The gestures sample loads a file using libimg, but it renders directly to a window buffer instead of a pixmap.  Might be a good starting point as well.

 

Of course, using Qt is also an option, as others have mentioned.  If Qt can render transparency in its main window, then you can put your video window behind it and let the UI float in front.  You would have to find out if that is possible, otherwise you will be limited to having your video window on top of the UI.

 

Cheers,

Sean

Contributor
kboone
Posts: 41
Registered: ‎09-14-2012
My Device: Playbook 64Gb

Re: How can I create a ui with my code for 2.1

Although we can't fully integrate low-level screen API calls with Qt, I wonder if we can _alternate_ the use of these strategies? I mean, for example -- if I want to develop (say) a video player, could I deal with the user interface in Qt, and then draw the video itself using the low-level screen API? Of course you'd be painting one set of screen data on top of another but, if you're careful to clear the screen between these different uses, it might just work.

 

What I don't know is whether the use of Qt effectively blocks the use of low-level screen API calls altogether -- I just don't know enough about how Qt is implemented on the playbook. I used a similar strategy in a video player for Archos devices (years ago), and it did kind-of work, although it took a lot of fiddling to ensure that the different screen 'layers' didn't break in on top of one another.

 

By the way, there's generally no problem with using C code with Qt code in C++, so long as you're careful about name mangling. In pratice this generally means declaring your C functions with a particular "C" attribute to ensure that the names are not fiddled about with by the compiler. This is well documented, but feel free to ask me if you're not clear.

 

 

Trusted Contributor
cjonesy
Posts: 160
Registered: ‎09-13-2012
My Device: 9900

Re: How can I create a ui with my code for 2.1

[ Edited ]

Thanks Sean and kboone for your answers, 

 

After struggling with compile errors for the last few hours I have managed to get my c code running using qt creator in a .cpp file instead and linking correctly with ffmpeg, mreed's advice from earlier post was very helpful.

 

I am going to run with qt for a while, kboone what you mention about integrating screen api for the video display and qt for the ui would be ideal for me considering where I am with my code and knowledge currently, it's just that I think somebody told me yesterday that screen api and qt are completely incompatible.

 

I will see what I find with the hope at the end of the day to have more than hello world on my screen!

 

Thanks again.

Contributor
kboone
Posts: 41
Registered: ‎09-14-2012
My Device: Playbook 64Gb

Re: How can I create a ui with my code for 2.1

I'm afraid I know nothing about using the low-level screen API -- all my experience on the PB is with Qt. My gut feeling tells me that mixing Qt and the low-level API will be like writing a Windows program that writes directly to the screen hardware, rather than using Windows API calls. You can certainly do it (with the appropriate privilege level), but unless you're writing the entire screen, it is very ugly.

 

As I said, I had some success with this approach on the Archos devices, when I was porting MPlayer to them -- Qt and mplayer both wrote directly to the Linux framebuffer device. But that works because neither Qt nor the mplayer code had, or required, an exclusive lock on the hardware device. On the PB, I really have no idea at all whether something similar is possible. Screen API calls might just fail immediately if done within a Qt application.

 

I think it needs somebody who knows the guts of the Qt implementation on the PB to answer the question whether the approach is possible. Whether it's _desirable_ is an easier question to answer -- yeuch!

 

Trusted Contributor
cjonesy
Posts: 160
Registered: ‎09-13-2012
My Device: 9900

Re: How can I create a ui with my code for 2.1

I remember scanning through some example code a few days ago when qt was suggested for a ui and it looked like there was references in qt to blit(ing) so maybe painting with qt is the way to go.

 

That's if I can get to that stage.. I have hit another brick wall with qt and probably will require more help because searching google/forums is not getting me anywhere.

 

I'm going to create a thread as this is more specific to QT.

 

Thanks again for your help.

Developer
mmd12
Posts: 117
Registered: ‎03-13-2012
My Device: Playbook, Dev Alpha C, Q10, Z10

Re: How can I create a ui with my code for 2.1

I'm probably late to this party as the OP seems to have moved on to QT, but for what it's worth...

 

I don't know QT and don't like C++ so I stick with straight C.

 

Looking at the playbook and UI, my first question would be: Can a dialog box do the trick?  If you're looking to give the user options to choose, this is an easy way to go.  Text is easy to render in the box and can change depending on the previous options chosen by the user.  Buttons can give options to choose.  And you can create a pick list or multi-pick list.  The dialog example is helpful with this.

 

If this isn't an option, and buttons and text have to be present on the window, I've found what Sean wrote above to be a good way to go.  It's fairly easy to create a button, either through a png file or simply to draw one and blit it to the screen.  If you look at the falling blocks example, it will show you how to respond to a touch event.  If you want to clue the user that they've pressed the button, you can blit a different image over the first one.  Drawing text is very laborius and time consuming to set up, but is doable.  A png file would probably be best for that.

 

Best of luck. 

Contributor
kboone
Posts: 41
Registered: ‎09-14-2012
My Device: Playbook 64Gb

Re: How can I create a ui with my code for 2.1

I guess it depends on how complex the user interface has to be. Hand-coding a few buttons at fixed positions on the screen should be no problem. The thought of implementing (say) a file selection dialog box using OpenGL primitives, etc., would make my heart sink.

BlackBerry Development Advisor
smcveigh
Posts: 668
Registered: ‎11-29-2011
My Device: developer

Re: How can I create a ui with my code for 2.1


kboone wrote:

Although we can't fully integrate low-level screen API calls with Qt, I wonder if we can _alternate_ the use of these strategies? I mean, for example -- if I want to develop (say) a video player, could I deal with the user interface in Qt, and then draw the video itself using the low-level screen API? Of course you'd be painting one set of screen data on top of another but, if you're careful to clear the screen between these different uses, it might just work.

 

No need to even clear the screen.  Screen is a window compositor, so you just render the video window in front of the Qt window.  I believe Qt consumes all navigator and screen events, so you may not be able to query for things like touch in your video window while Qt's event loop is running, but I may be wrong there, or there may be a way to suspend event processing.  Alternately, you can set the foreground video window to pass all events to the window behind it by changing SCREEN_PROPERTY_SENSITIVITY, and then Qt should catch all touch events.

 

Cheers,

Sean

Trusted Contributor
cjonesy
Posts: 160
Registered: ‎09-13-2012
My Device: 9900

Re: How can I create a ui with my code for 2.1

The app is going to require buttons, text boxes, label fields, so after digesting everything im thinking ithe best way to go is with qt which will also then help with learning more about cascades dev further down the line.

 

If only I could get qt going on the device!