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

How can I create a ui with my code for 2.1

Hi all,

 

I have code which uses screen.h currently to display video frames from ffmpeg. I am now trying to create a simple user interface for this code.

 

However it seems its not as simple as it sounds, I still have some questions after a lot of researching. I only need a few buttons, textviews and images but its looking like I might have to recode a lot of it just to have ui controls.

 

Will QT be ok for this? I can't understand if by me using screen.h then does it makes QT unusable for me? (I have no experience with QT - currently cant even build it).

 

Can EGL be used for simple ui controls and is screen.h compatible with EGL?

 

Is there any other advice for my situation?

 

I really appreciate any suggestions.

Please use plain text.
Contributor
mcguire
Posts: 24
Registered: ‎09-10-2012
My Device: Blackberry Dev Alpha

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

Qt and screen.h don't integrate - either you paint your windows with Qt, or with libscreen, but they can't be combined. Mainly because Qt doesn't expose the internal screen resources it uses, like screen_window_t, in any API.

 

You could of course ditch libscreen completely and draw everything with Qt, even the videos.

 

As for building Qt, please see http://qt-project.org/wiki/Blackberry, it has instructions for both Qt4 and Qt5.

Please use plain text.
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

Thanks for your reply mcguire,

 

It was a difficult task learning how to paint the frames from ffmpeg AVPacket to screen.h and it works great so if I can stick with that then great. So what is the way to create a button with screen.h?

 

If no way for screen, would it be difficult do you think to change the painting code to qt for someone who has never touched it before?

 

Also, when cascades comes to playbook, will that work with this screen.h code?

 

Sorry for the questions, it's looking like I have just written weeks of code and now there is no way for a user to do anything with it so I need to be sure before I cry!

Please use plain text.
Contributor
mcguire
Posts: 24
Registered: ‎09-10-2012
My Device: Blackberry Dev Alpha

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

libscreen does not offer any high-level functions to draw widgets. Of course you can draw them yourself using libscreen, by accessing the image data directly and drawing every pixel manually, but that is going to be hard, and will not look nice.

 

If you want to draw a button, use a high-level API like Cascades or Qt to draw it for you.

 

At least Cascades supports the class ForeignWindow, which lets you embed a screen window into the Cascades scene - that would allow you to continue using your existing code.

In Qt, it might be possible to create a window with libscreen yourself, and display that on top of Qt's window, which would also solve your usecase.

 

And the last option, which I mentioned earlier, is to simply draw the video frames with Qt, after getting the frame data from ffmpeg. I can't judge how difficult that would be. Probably just a matter of overriding QWidget::smileytongue:aintEvent() and blitting the video frame there.

Please use plain text.
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

thanks mcgiure, your answers are helping me to fill the gaps in my understanding and will be forever appreciated.

 

so it seems my only option now as cascades doesnt run on playbook is qt, makes me wonder why libscreen was ever put there in the first place!

 

Is qt c or c++? I am 3 weeks into learning c and don't seem to know what the best thing to do is - invest time learning c or c++.

 

Also a concern of mine when thinking about switching to c++ is that you'll end up with libraries written in c that will not be able to be included in c++. (e.g I believe ffmpeg is c).

 

Can you still build playbook apps in momentics when using QT?

 

 

Please use plain text.
Contributor
mcguire
Posts: 24
Registered: ‎09-10-2012
My Device: Blackberry Dev Alpha

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


cjonesy wrote:

thanks mcgiure, your answers are helping me to fill the gaps in my understanding and will be forever appreciated.

 

so it seems my only option now as cascades doesnt run on playbook is qt, makes me wonder why libscreen was ever put there in the first place!

 

Is qt c or c++? I am 3 weeks into learning c and don't seem to know what the best thing to do is - invest time learning c or c++.

 

Also a concern of mine when thinking about switching to c++ is that you'll end up with libraries written in c that will not be able to be included in c++. (e.g I believe ffmpeg is c).

 

Can you still build playbook apps in momentics when using QT?

 

 


 

Please use plain text.
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 am still confused,

 

Is c code I have written  (which has char arrays, sockets, calls ffmpeg library, libbps, strcat and strcpy) a waste of time because no ui is available in c and never will so this code will need to be converted to c++ to have a ui.

 

Is that correct?

Please use plain text.
Developer
mreed
Posts: 1,041
Registered: ‎07-16-2008
My Device: ಠ_ಠ

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

Just an FYI, C++ is relatively easier than C... but theres really not that much of a difference between them (which is why its usually refered to as C/C++). Theres nothing to "convert".

Please use plain text.
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

Thanks mreed, 

 

my question seems stupid when you put it like that. 

 

I'll go away for a while and come back when i'm more clued up with c++!

 

 

Please use plain text.
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

You can certainly create a simple UI using a few image assets blitted to a libscreen window.  eg. load a few PNGs for the buttons you want, display them at the appropriate co-ordinates, and detect touch events within the bounds of each button.  Or get a blank button PNG and render text over them.  Or use whatever primitives OpenGL provides for you.

Lots of ways to do it without resorting to needing Qt.

 

Cheers,

Sean

Please use plain text.