Good looking UI design

Hi all,

         I have a SDL screen (1024x768 size), and in that, I'm going 

to display four videos (each of 352x288 size), using SDL_Rect rect at
different x,y values. I have created pthread and in each thread it has
its own rect and changing the values of x and y and so that i’ll get
all four videos on single SDL_Surface.

         Now the problem is, I want control over those video 

running, like ( very basic) pause and play. How can it be done… ? One
way is like mouse and keyboard control. But I want some button kind of
thing, so that it will be looking good and one can easily use it…

         Any idea, how to do that ???

I searched in google images, I got some good images but, I don’t know
how to develop such kind of UI and what i need to use( Earlier I used
GTK and SDL, But I got single sdl_surface and at a time ). So now I’m
using only SDL.

example you can see in this link,

  1. http://assets.nydailynews.com/img/2009/08/13/tl_app_ira-pro.jpg
  2. http://www.lisisoft.com/imglisi/7/ActiveX/133951multivideoplayer.jpg

or you can do search as “multiple video display”, you can see more examples

I’m working on Linux-2.6.21.5 and using SDL-1.2
Is it possible using SDL ??
Do I need any other libs ??

please guide me.–
Lohitha R

how about a nice overlay effect that when the mouse is over a video a
HUD appears and displays controls for that video
something like this

(yeah the title is funny)

bye
VittorioOn Wed, May 26, 2010 at 11:21 AM, Lohitha R <lohitha.r at globaledgesoft.com> wrote:

Hi all,

? ? ? ? ? ?I have a SDL screen (1024x768 size), and in that, I’m going to
display four videos (each of 352x288 size), ?using SDL_Rect rect at
different x,y values. I have created pthread and in each thread it has its
own rect and ?changing the values of x and y and so that i’ll get all four
videos on single SDL_Surface.
? ? ? ? ? ? ? ? ? ? ? Now the problem is, I want control over those video
running, like ( very basic) pause and play. How can it be done… ? One way
is like mouse and keyboard control. But I want some button kind of thing, so
that it will be looking good and one can easily use it…

? ? ? ? ? ?Any idea, how to do that ???

I searched in google images, I got some good images but, I don’t know how to
develop such kind of UI and what i need to use( Earlier ?I used GTK and SDL,
But I got single sdl_surface and at a time ). So now I’m using only SDL.

example you can see in this link,

  1. http://assets.nydailynews.com/img/2009/08/13/tl_app_ira-pro.jpg
  2. http://www.lisisoft.com/imglisi/7/ActiveX/133951multivideoplayer.jpg

or you can do search as “multiple video display”, you can see more examples

I’m working on Linux-2.6.21.5 and using SDL-1.2
Is it possible using SDL ??
Do I need any other libs ??

please guide me.


Lohitha R


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Hi,
Thats really nice… But how to do that …??? any Idea… I’m using C for
developing such player…–
Lohitha R

Vittorio G. wrote:

how about a nice overlay effect that when the mouse is over a video a
HUD appears and displays controls for that video
something like this
http://www.devicemag.com/wp-content/uploads/2009/06/apple-quicktime-x-flash-support.jpg
(yeah the title is funny)

bye
Vittorio

On Wed, May 26, 2010 at 11:21 AM, Lohitha R wrote:

Hi all,

        I have a SDL screen (1024x768 size), and in that, I'm going to

display four videos (each of 352x288 size), using SDL_Rect rect at
different x,y values. I have created pthread and in each thread it has its
own rect and changing the values of x and y and so that i’ll get all four
videos on single SDL_Surface.
Now the problem is, I want control over those video
running, like ( very basic) pause and play. How can it be done… ? One way
is like mouse and keyboard control. But I want some button kind of thing, so
that it will be looking good and one can easily use it…

        Any idea, how to do that ???

I searched in google images, I got some good images but, I don’t know how to
develop such kind of UI and what i need to use( Earlier I used GTK and SDL,
But I got single sdl_surface and at a time ). So now I’m using only SDL.

example you can see in this link,

  1. http://assets.nydailynews.com/img/2009/08/13/tl_app_ira-pro.jpg
  2. http://www.lisisoft.com/imglisi/7/ActiveX/133951multivideoplayer.jpg

or you can do search as “multiple video display”, you can see more examples

I’m working on Linux-2.6.21.5 and using SDL-1.2
Is it possible using SDL ??
Do I need any other libs ??

please guide me.


Lohitha R


SDL mailing list
SDL@lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL@lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Hi,

you will need to draw your UI using SDL, and keep track of where each UI
element is.

Then when the user clicks or presses the keyboard, you will have to track
down what is the current
position (mouse or keyboard navigation) and try to find out if it maps to a
UI element.

There are many ways to do this. One way you could have a Widget struct
containing all the required
information about a widget location and a few function pointers to work as
event handlers:

typedef bool (*EventHandler) (Widget *w);
typedef void (*DrawHandler) (Widget *w, SDLSurface *surface);

typedef struct Widget {
int x, y, width, height;
EventHandler processEvents;
DrawHandler drawWidget;
struct Widget *next;
} Widget;

Then when you validate which UI component was activated, you call its
handlers.

Since you have used GTK before, I would suggest you to have a look at how
GTK components are written.
This will give you some ideas.

Regards,
PauloOn Wed, May 26, 2010 at 11:43 AM, Lohitha R <lohitha.r at globaledgesoft.com>wrote:

Hi,
Thats really nice… But how to do that …??? any Idea… I’m
using C for developing such player…


Lohitha R

Vittorio G. wrote:

how about a nice overlay effect that when the mouse is over a video a
HUD appears and displays controls for that video
something like thishttp://www.devicemag.com/wp-content/uploads/2009/06/apple-quicktime-x-flash-support.jpg
(yeah the title is funny)

bye
Vittorio

On Wed, May 26, 2010 at 11:21 AM, Lohitha R<lohitha.r at globaledgesoft.com> <lohitha.r at globaledgesoft.com> wrote:

Hi all,

       I have a SDL screen (1024x768 size), and in that, I'm going to

display four videos (each of 352x288 size), using SDL_Rect rect at
different x,y values. I have created pthread and in each thread it has its
own rect and changing the values of x and y and so that i’ll get all four
videos on single SDL_Surface.
Now the problem is, I want control over those video
running, like ( very basic) pause and play. How can it be done… ? One way
is like mouse and keyboard control. But I want some button kind of thing, so
that it will be looking good and one can easily use it…

       Any idea, how to do that ???

I searched in google images, I got some good images but, I don’t know how to
develop such kind of UI and what i need to use( Earlier I used GTK and SDL,
But I got single sdl_surface and at a time ). So now I’m using only SDL.

example you can see in this link,

  1. http://assets.nydailynews.com/img/2009/08/13/tl_app_ira-pro.jpg
  2. http://www.lisisoft.com/imglisi/7/ActiveX/133951multivideoplayer.jpg

or you can do search as “multiple video display”, you can see more examples

I’m working on Linux-2.6.21.5 and using SDL-1.2
Is it possible using SDL ??
Do I need any other libs ??

please guide me.


Lohitha R


SDL mailing listSDL at lists.libsdl.orghttp://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

 _______________________________________________

SDL mailing listSDL at lists.libsdl.orghttp://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Grate…!! Thank you Paulo…

and one more, can i have any sdl buttons over there…?? like what i get
in gtk, gtk buttons…?? Because, it should feel like, pressing button
only… why i’m telling this is, i got one example program, in that button
was there but they are not actually buttons… so any idea about placing
buttons, or some graphical image over the sdl_surface…–
Lohitha R

Paulo Pinto wrote:

Hi,

you will need to draw your UI using SDL, and keep track of where each UI
element is.

Then when the user clicks or presses the keyboard, you will have to
track down what is the current
position (mouse or keyboard navigation) and try to find out if it maps
to a UI element.

There are many ways to do this. One way you could have a Widget struct
containing all the required
information about a widget location and a few function pointers to work
as event handlers:

typedef bool (*EventHandler) (Widget *w);
typedef void (*DrawHandler) (Widget *w, SDLSurface *surface);

typedef struct Widget {
int x, y, width, height;
EventHandler processEvents;
DrawHandler drawWidget;
struct Widget *next;
} Widget;

Then when you validate which UI component was activated, you call its
handlers.

Since you have used GTK before, I would suggest you to have a look at
how GTK components are written.
This will give you some ideas.

Regards,
Paulo

On Wed, May 26, 2010 at 11:43 AM, Lohitha R <@Lohitha_R> wrote:

Hi,
Thats really nice.... But how to do that ...??? any Idea.. I'm using C
for developing such player....


Lohitha R

Vittorio G. wrote:

how about a nice overlay effect that when the mouse is over a video a
HUD appears and displays controls for that video
something like this
http://www.devicemag.com/wp-content/uploads/2009/06/apple-quicktime-x-flash-support.jpg
(yeah the title is funny)

bye
Vittorio

On Wed, May 26, 2010 at 11:21 AM, Lohitha R wrote:

Hi all,

        I have a SDL screen (1024x768 size), and in that, I'm going to

display four videos (each of 352x288 size), using SDL_Rect rect at
different x,y values. I have created pthread and in each thread it has its
own rect and changing the values of x and y and so that i’ll get all four
videos on single SDL_Surface.
Now the problem is, I want control over those video
running, like ( very basic) pause and play. How can it be done… ? One way
is like mouse and keyboard control. But I want some button kind of thing, so
that it will be looking good and one can easily use it…

        Any idea, how to do that ???

I searched in google images, I got some good images but, I don’t know how to
develop such kind of UI and what i need to use( Earlier I used GTK and SDL,
But I got single sdl_surface and at a time ). So now I’m using only SDL.

example you can see in this link,

  1. http://assets.nydailynews.com/img/2009/08/13/tl_app_ira-pro.jpg
  2. http://www.lisisoft.com/imglisi/7/ActiveX/133951multivideoplayer.jpg

or you can do search as “multiple video display”, you can see more examples

I’m working on Linux-2.6.21.5 and using SDL-1.2
Is it possible using SDL ??
Do I need any other libs ??

please guide me.


Lohitha R


SDL mailing list
SDL@lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL@lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

_______________________________________________
SDL mailing list
SDL@lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org



------------------------------------------------------------------

SDL mailing list
SDL@lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

You will need to have two images for the buttons, representing the pressed
and not pressed state.

Depending on how the user interacts with the button, you will need to draw
the corresponding image.–
Paulo

On Wed, May 26, 2010 at 1:09 PM, Lohitha R <lohitha.r at globaledgesoft.com>wrote:

Grate…!! Thank you Paulo…

      and one more, can i have any sdl buttons over there....?? like

what i get in gtk, gtk buttons…?? Because, it should feel like, pressing
button only… why i’m telling this is, i got one example program, in that
button was there but they are not actually buttons… so any idea about
placing buttons, or some graphical image over the sdl_surface…


Lohitha R

Paulo Pinto wrote:

Hi,

you will need to draw your UI using SDL, and keep track of where each UI
element is.

Then when the user clicks or presses the keyboard, you will have to track
down what is the current
position (mouse or keyboard navigation) and try to find out if it maps to a
UI element.

There are many ways to do this. One way you could have a Widget struct
containing all the required
information about a widget location and a few function pointers to work as
event handlers:

typedef bool (*EventHandler) (Widget *w);
typedef void (*DrawHandler) (Widget *w, SDLSurface *surface);

typedef struct Widget {
int x, y, width, height;
EventHandler processEvents;
DrawHandler drawWidget;
struct Widget *next;
} Widget;

Then when you validate which UI component was activated, you call its
handlers.

Since you have used GTK before, I would suggest you to have a look at how
GTK components are written.
This will give you some ideas.

Regards,
Paulo

On Wed, May 26, 2010 at 11:43 AM, Lohitha R <lohitha.r at globaledgesoft.com>wrote:

Hi,
Thats really nice… But how to do that …??? any Idea… I’m
using C for developing such player…


Lohitha R

Vittorio G. wrote:

how about a nice overlay effect that when the mouse is over a video a
HUD appears and displays controls for that video
something like thishttp://www.devicemag.com/wp-content/uploads/2009/06/apple-quicktime-x-flash-support.jpg
(yeah the title is funny)

bye
Vittorio

On Wed, May 26, 2010 at 11:21 AM, Lohitha R<lohitha.r at globaledgesoft.com> <lohitha.r at globaledgesoft.com> wrote:

Hi all,

       I have a SDL screen (1024x768 size), and in that, I'm going to

display four videos (each of 352x288 size), using SDL_Rect rect at
different x,y values. I have created pthread and in each thread it has its
own rect and changing the values of x and y and so that i’ll get all four
videos on single SDL_Surface.
Now the problem is, I want control over those video
running, like ( very basic) pause and play. How can it be done… ? One way
is like mouse and keyboard control. But I want some button kind of thing, so
that it will be looking good and one can easily use it…

       Any idea, how to do that ???

I searched in google images, I got some good images but, I don’t know how to
develop such kind of UI and what i need to use( Earlier I used GTK and SDL,
But I got single sdl_surface and at a time ). So now I’m using only SDL.

example you can see in this link,

  1. http://assets.nydailynews.com/img/2009/08/13/tl_app_ira-pro.jpg
  2. http://www.lisisoft.com/imglisi/7/ActiveX/133951multivideoplayer.jpg

or you can do search as “multiple video display”, you can see more examples

I’m working on Linux-2.6.21.5 and using SDL-1.2
Is it possible using SDL ??
Do I need any other libs ??

please guide me.


Lohitha R


SDL mailing list
SDL at lists.libsdl.orghttp://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

 _______________________________________________

SDL mailing listSDL at lists.libsdl.orghttp://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org



SDL mailing listSDL at lists.libsdl.orghttp://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Thank you Paulo,
I’l do it and If i get any problem, i’l get back to you…–
Lohitha R

Paulo Pinto wrote:

You will need to have two images for the buttons, representing the
pressed and not pressed state.

Depending on how the user interacts with the button, you will need to
draw the corresponding image.


Paulo

On Wed, May 26, 2010 at 1:09 PM, Lohitha R <@Lohitha_R> wrote:

Grate...!! Thank you Paulo....

and one more, can i have any sdl buttons over there....?? like what i
get in gtk, gtk buttons.....?? Because, it should feel like, pressing
button only... why i'm telling this is, i got one example program, in
that button was there but they are not actually buttons... so any idea
about placing buttons, or some graphical image over the
sdl_surface....


Lohitha R

Paulo Pinto wrote:

  Hi,

  you will need to draw your UI using SDL, and keep track of where
  each UI element is.

  Then when the user clicks or presses the keyboard, you will have to
  track down what is the current
  position (mouse or keyboard navigation) and try to find out if it
  maps to a UI element.

  There are many ways to do this. One way you could have a Widget
  struct containing all the required
  information about a widget location and a few function pointers to
  work as event handlers:

  typedef bool (*EventHandler) (Widget *w);
  typedef void (*DrawHandler) (Widget *w, SDLSurface *surface);

  typedef struct Widget {
  int x, y, width, height;
  EventHandler processEvents;
  DrawHandler drawWidget;
  struct Widget *next;
  } Widget;

  Then when you validate which UI component was activated, you call
  its handlers.

  Since you have used GTK before, I would suggest you to have a look
  at how GTK components are written.
  This will give you some ideas.

  Regards,
  Paulo

  On Wed, May 26, 2010 at 11:43 AM, Lohitha R <@Lohitha_R> wrote:

    Hi,
    Thats really nice.... But how to do that ...??? any Idea.. I'm
    using C for developing such player....


Lohitha R

    Vittorio G. wrote:

how about a nice overlay effect that when the mouse is over a video a
HUD appears and displays controls for that video
something like this
http://www.devicemag.com/wp-content/uploads/2009/06/apple-quicktime-x-flash-support.jpg
(yeah the title is funny)

bye
Vittorio

On Wed, May 26, 2010 at 11:21 AM, Lohitha R wrote:

Hi all,

        I have a SDL screen (1024x768 size), and in that, I'm going to

display four videos (each of 352x288 size), using SDL_Rect rect at
different x,y values. I have created pthread and in each thread it has its
own rect and changing the values of x and y and so that i’ll get all four
videos on single SDL_Surface.
Now the problem is, I want control over those video
running, like ( very basic) pause and play. How can it be done… ? One way
is like mouse and keyboard control. But I want some button kind of thing, so
that it will be looking good and one can easily use it…

        Any idea, how to do that ???

I searched in google images, I got some good images but, I don’t know how to
develop such kind of UI and what i need to use( Earlier I used GTK and SDL,
But I got single sdl_surface and at a time ). So now I’m using only SDL.

example you can see in this link,

  1. http://assets.nydailynews.com/img/2009/08/13/tl_app_ira-pro.jpg
  2. http://www.lisisoft.com/imglisi/7/ActiveX/133951multivideoplayer.jpg

or you can do search as “multiple video display”, you can see more examples

I’m working on Linux-2.6.21.5 and using SDL-1.2
Is it possible using SDL ??
Do I need any other libs ??

please guide me.


Lohitha R


SDL mailing list

SDL@lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL@lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

    _______________________________________________
    SDL mailing list
    SDL@lists.libsdl.org
    http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

------------------------------------------------------------------

SDL mailing list
SDL@lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

_______________________________________________
SDL mailing list
SDL@lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org



------------------------------------------------------------------

SDL mailing list
SDL@lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Hi, Lohitha,
I was just in the process of writing some code for you and then Paulo posted
stuff for you. I’ve attached a file you can copy and paste whatever code
from there into your own project. You will still need to use Paulo’s
concept of an image for the button. Right now, it just fills a box for a
button, but I allowed code for you to easily implement a SDL_Blit instead of
the SDL_FillRect.

Take care,
-AlexOn Wed, May 26, 2010 at 7:53 AM, Lohitha R <lohitha.r at globaledgesoft.com>wrote:

Thank you Paulo,
I’l do it and If i get any problem, i’l get back to you…


Lohitha R

Paulo Pinto wrote:

You will need to have two images for the buttons, representing the pressed
and not pressed state.

Depending on how the user interacts with the button, you will need to draw
the corresponding image.


Paulo

On Wed, May 26, 2010 at 1:09 PM, Lohitha R <lohitha.r at globaledgesoft.com>wrote:

Grate…!! Thank you Paulo…

      and one more, can i have any sdl buttons over there....?? like

what i get in gtk, gtk buttons…?? Because, it should feel like, pressing
button only… why i’m telling this is, i got one example program, in that
button was there but they are not actually buttons… so any idea about
placing buttons, or some graphical image over the sdl_surface…


Lohitha R

Paulo Pinto wrote:

Hi,

you will need to draw your UI using SDL, and keep track of where each UI
element is.

Then when the user clicks or presses the keyboard, you will have to track
down what is the current
position (mouse or keyboard navigation) and try to find out if it maps to
a UI element.

There are many ways to do this. One way you could have a Widget struct
containing all the required
information about a widget location and a few function pointers to work as
event handlers:

typedef bool (*EventHandler) (Widget *w);
typedef void (*DrawHandler) (Widget *w, SDLSurface *surface);

typedef struct Widget {
int x, y, width, height;
EventHandler processEvents;
DrawHandler drawWidget;
struct Widget *next;
} Widget;

Then when you validate which UI component was activated, you call its
handlers.

Since you have used GTK before, I would suggest you to have a look at how
GTK components are written.
This will give you some ideas.

Regards,
Paulo

On Wed, May 26, 2010 at 11:43 AM, Lohitha R <lohitha.r at globaledgesoft.com wrote:

Hi,
Thats really nice… But how to do that …??? any Idea… I’m
using C for developing such player…


Lohitha R

Vittorio G. wrote:

how about a nice overlay effect that when the mouse is over a video a
HUD appears and displays controls for that video
something like thishttp://www.devicemag.com/wp-content/uploads/2009/06/apple-quicktime-x-flash-support.jpg
(yeah the title is funny)

bye
Vittorio

On Wed, May 26, 2010 at 11:21 AM, Lohitha R<lohitha.r at globaledgesoft.com> <lohitha.r at globaledgesoft.com> wrote:

Hi all,

       I have a SDL screen (1024x768 size), and in that, I'm going to

display four videos (each of 352x288 size), using SDL_Rect rect at
different x,y values. I have created pthread and in each thread it has its
own rect and changing the values of x and y and so that i’ll get all four
videos on single SDL_Surface.
Now the problem is, I want control over those video
running, like ( very basic) pause and play. How can it be done… ? One way
is like mouse and keyboard control. But I want some button kind of thing, so
that it will be looking good and one can easily use it…

       Any idea, how to do that ???

I searched in google images, I got some good images but, I don’t know how to
develop such kind of UI and what i need to use( Earlier I used GTK and SDL,
But I got single sdl_surface and at a time ). So now I’m using only SDL.

example you can see in this link,

  1. http://assets.nydailynews.com/img/2009/08/13/tl_app_ira-pro.jpg
  2. http://www.lisisoft.com/imglisi/7/ActiveX/133951multivideoplayer.jpg

or you can do search as “multiple video display”, you can see more examples

I’m working on Linux-2.6.21.5 and using SDL-1.2
Is it possible using SDL ??
Do I need any other libs ??

please guide me.


Lohitha R


SDL mailing list
SDL at lists.libsdl.orghttp://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

 _______________________________________________

SDL mailing listSDL at lists.libsdl.orghttp://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org



SDL mailing listSDL at lists.libsdl.orghttp://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org



SDL mailing listSDL at lists.libsdl.orghttp://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

-------------- next part --------------
/*

Name : sdl-uibutton.c
Author : Alex Barry
Version :
Copyright : Copyright 2010
Description : SDL User Interface - Button

*/

#include <stdio.h>
#include <stdlib.h>
#include <SDL/SDL.h>

typedef struct UIButton UIButton;
typedef struct UIButtonList UIButtonList;

struct UIButton {
SDL_Surface *surface;
SDL_Rect p;
int state; // 0 = nothing, 1 = hover, 2 = left-click
void (*onClick)(UIButton *);
void (*onDraw)(UIButton *);
};

struct UIButtonList {
UIButton **button;
int num;
};

UIButton *newUIButton( void (*click)(UIButton *), void (*draw)(UIButton *) );
void deleteUIButton( UIButton *btn );
void handleUIButtonMouse( UIButton *btn, int x, int y, int b );

UIButtonList *newUIButtonList( int number );
void deleteUIButtonList( UIButtonList *list );
UIButton *UIButtonListAdd( UIButtonList *list, UIButton *btn, SDL_Rect p );
void UIButtonListDelete( UIButtonList *list, UIButton *btn );
void handleUIButtonListMouse( UIButtonList *list, int x, int y, int b );

SDL_Surface *screen; // global screen

// Definitely change these!
void drawButtonDefault( UIButton *self ) {
// draw the button
if( self == NULL ) return;
SDL_Rect r = self->p;
//printf( “Filling %d x %d -> %d x %d\n”, r.x, r.y, r.w, r.h );
Uint32 colour = SDL_MapRGB( screen->format, 255, 0, 0 );
if( self->state == 1 ) {
colour = SDL_MapRGB( screen->format, 200, 100, 100 );
} else if( self->state == 2 ) {
colour = SDL_MapRGB( screen->format, 50, 200, 50 );
}
SDL_FillRect( screen, &r, colour );
}

void clickButtonDefault( UIButton *self ) {
// click the button
if( self == NULL ) return;
printf(“Button clicked\n”);
}

int inRect( SDL_Rect r, int x, int y ) {
if( (x >= r.x) && (x <= (r.x+r.w)) && (y >= r.y) && (y <= (r.y+r.h)) )
return 1;
return 0;
}

int main(void) {
if ( SDL_Init(SDL_INIT_AUDIO|SDL_INIT_VIDEO) < 0 )
{
printf(“Unable to init SDL: %s\n”, SDL_GetError());
return -1;
}
atexit(SDL_Quit);

screen = SDL_SetVideoMode( 640, 480, 32, SDL_HWSURFACE );
if ( screen == NULL )
{
	printf("Unable to set video: %s\n", SDL_GetError());
	return -1;
}

SDL_Event event;
int done = 0, j;
UIButton *button;
SDL_Rect p;
UIButtonList *buttons = newUIButtonList( 5 );

for( j = 0; j < 5; j++ ) {
	p.x = 10 + (j * 20);	p.y = 50;
	p.w = 10;				p.h = 10;
	button = UIButtonListAdd( buttons, newUIButton(&clickButtonDefault, &drawButtonDefault), p );
}

while(done == 0)
{
	// Simple event loop
	while ( SDL_PollEvent(&event) )
	{
		switch( event.type ) {
		case SDL_QUIT:
			done = 1;
			break;
		case SDL_KEYDOWN:
			if( event.key.keysym.sym == SDLK_ESCAPE ) { done = 1; }
			break;
		case SDL_MOUSEMOTION:
		case SDL_MOUSEBUTTONDOWN:
		case SDL_MOUSEBUTTONUP:
			handleUIButtonListMouse( buttons, event.button.x, event.button.y, event.button.state & SDL_BUTTON(1) );
		}
	}

	SDL_Flip( screen );
}
return EXIT_SUCCESS;

}

UIButton *newUIButton( void (*click)(UIButton *), void (*draw)(UIButton *) ) {
UIButton *btn = (UIButton *)malloc( sizeof(UIButton) );
if( btn == NULL ) return NULL;
btn->surface = NULL;
btn->p.x = 0;
btn->p.y = 0;
btn->state = 0;
btn->onClick = click;
btn->onDraw = draw;
return btn;
}

void deleteUIButton( UIButton *btn ) {
if( btn == NULL ) return;
if( btn->surface != NULL ) SDL_FreeSurface( btn->surface );
free( btn );
btn = NULL;
}

void handleUIButtonMouse( UIButton *btn, int x, int y, int b ) {
// Set state/button information
if( inRect( btn->p, x, y ) ) {
btn->state = 1;
if( b == 1 ) {
btn->state = 2;
void (*click)(UIButton *) = btn->onClick;
(*click)( btn );
}
} else {
btn->state = 0;
}

void (*draw)(UIButton *) = btn->onDraw;
(*draw)( btn );

}

UIButtonList *newUIButtonList( int number ) {
UIButtonList *list = (UIButtonList *)malloc( sizeof( UIButtonList ) );
if( list == NULL ) return NULL;
list->num = number;
list->button = (UIButton **)malloc( sizeof( UIButton * ) * list->num );
int i; for( i = 0; i < list->num; i++ ) {
list->button[i] = NULL;
}
return list;
}

void deleteUIButtonList( UIButtonList *list ) {
int i; for( i = 0; i < list->num; i++ ) {
deleteUIButton( list->button[i] );
}
free( list->button );
free( list );
list = NULL;
}

UIButton *UIButtonListAdd( UIButtonList *list, UIButton *btn, SDL_Rect p ) {
int i; for( i = 0; i < list->num; i++ ) {
if( list->button[i] == NULL ) {
list->button[i] = btn;
list->button[i]->p = p;
return list->button[i];
}
}
deleteUIButton( btn );
return NULL;
}

void UIButtonListDelete( UIButtonList *list, UIButton *btn ) {
int i; for( i = 0; i < list->num; i++ ) {
if( list->button[i] == btn ) {
deleteUIButton( list->button[i] );
list->button[i] = NULL;
}
}
}

void handleUIButtonListMouse( UIButtonList *list, int x, int y, int b ) {
// handle mouse events
int i; for( i = 0; i < list->num; i++ ) {
handleUIButtonMouse( list->button[i], x, y, b );
}
}

Hi Alex,

Thanks a lot…

Now its my time to use your help…–
Lohitha R

Alex Barry wrote:

Hi, Lohitha,
I was just in the process of writing some code for you and then Paulo
posted stuff for you. I’ve attached a file you can copy and paste
whatever code from there into your own project. You will still need to
use Paulo’s concept of an image for the button. Right now, it just fills
a box for a button, but I allowed code for you to easily implement a
SDL_Blit instead of the SDL_FillRect.

Take care,
-Alex

On Wed, May 26, 2010 at 7:53 AM, Lohitha R <@Lohitha_R> wrote:

Thank you Paulo,
I'l do it and If i get any problem, i'l get back to you....


Lohitha R

Paulo Pinto wrote:

  You will need to have two images for the buttons, representing the
  pressed and not pressed state.

  Depending on how the user interacts with the button, you will need
  to draw the corresponding image.

  --
  Paulo

  On Wed, May 26, 2010 at 1:09 PM, Lohitha R <@Lohitha_R> wrote:

    Grate...!! Thank you Paulo....

    and one more, can i have any sdl buttons over there....?? like
    what i get in gtk, gtk buttons.....?? Because, it should feel
    like, pressing button only... why i'm telling this is, i got one
    example program, in that button was there but they are not
    actually buttons... so any idea about placing buttons, or some
    graphical image over the sdl_surface....


Lohitha R

    Paulo Pinto wrote:

      Hi,

      you will need to draw your UI using SDL, and keep track of where
      each UI element is.

      Then when the user clicks or presses the keyboard, you will have
      to track down what is the current
      position (mouse or keyboard navigation) and try to find out if
      it maps to a UI element.

      There are many ways to do this. One way you could have a Widget
      struct containing all the required
      information about a widget location and a few function pointers
      to work as event handlers:

      typedef bool (*EventHandler) (Widget *w);
      typedef void (*DrawHandler) (Widget *w, SDLSurface *surface);

      typedef struct Widget {
      int x, y, width, height;
      EventHandler processEvents;
      DrawHandler drawWidget;
      struct Widget *next;
      } Widget;

      Then when you validate which UI component was activated, you
      call its handlers.

      Since you have used GTK before, I would suggest you to have a
      look at how GTK components are written.
      This will give you some ideas.

      Regards,
      Paulo

      On Wed, May 26, 2010 at 11:43 AM, Lohitha R <@Lohitha_R> wrote:

        Hi,
        Thats really nice.... But how to do that ...??? any Idea.. I'm
        using C for developing such player....


Lohitha R

        Vittorio G. wrote:

how about a nice overlay effect that when the mouse is over a video a
HUD appears and displays controls for that video
something like this
http://www.devicemag.com/wp-content/uploads/2009/06/apple-quicktime-x-flash-support.jpg
(yeah the title is funny)

bye
Vittorio

On Wed, May 26, 2010 at 11:21 AM, Lohitha R wrote:

Hi all,

        I have a SDL screen (1024x768 size), and in that, I'm going to

display four videos (each of 352x288 size), using SDL_Rect rect at
different x,y values. I have created pthread and in each thread it has its
own rect and changing the values of x and y and so that i’ll get all four
videos on single SDL_Surface.
Now the problem is, I want control over those video
running, like ( very basic) pause and play. How can it be done… ? One way
is like mouse and keyboard control. But I want some button kind of thing, so
that it will be looking good and one can easily use it…

        Any idea, how to do that ???

I searched in google images, I got some good images but, I don’t know how to
develop such kind of UI and what i need to use( Earlier I used GTK and SDL,
But I got single sdl_surface and at a time ). So now I’m using only SDL.

example you can see in this link,

  1. http://assets.nydailynews.com/img/2009/08/13/tl_app_ira-pro.jpg
  2. http://www.lisisoft.com/imglisi/7/ActiveX/133951multivideoplayer.jpg

or you can do search as “multiple video display”, you can see more examples

I’m working on Linux-2.6.21.5 and using SDL-1.2
Is it possible using SDL ??
Do I need any other libs ??

please guide me.


Lohitha R


SDL mailing list

SDL@lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL@lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

        _______________________________________________
        SDL mailing list
        SDL@lists.libsdl.org
        http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

------------------------------------------------------------------

SDL mailing list
SDL@lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

    _______________________________________________
    SDL mailing list
    SDL@lists.libsdl.org
    http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

------------------------------------------------------------------

SDL mailing list
SDL@lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

_______________________________________________
SDL mailing list
SDL@lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org



------------------------------------------------------------------

SDL mailing list
SDL@lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org