more select hacking
This commit is contained in:
parent
8f30e4e0c1
commit
c936f265b0
23
ChangeLog
23
ChangeLog
@ -1,3 +1,26 @@
|
|||||||
|
2005-05-27 mallum,,, <mallum@openedhand.com>
|
||||||
|
|
||||||
|
* clutter/cltr-animator.c: (cltr_animator_zoom_new),
|
||||||
|
(cltr_animator_move_new), (cltr_animator_fullzoom_new),
|
||||||
|
(cltr_animator_new), (cltr_animator_set_args),
|
||||||
|
(cltr_animator_wrapped_zoom_paint), (cltr_animator_reset),
|
||||||
|
(cltr_animator_timeout_cb), (cltr_animator_run):
|
||||||
|
* clutter/cltr-animator.h:
|
||||||
|
* clutter/cltr-button.c: (cltr_button_set_label),
|
||||||
|
(cltr_button_paint):
|
||||||
|
* clutter/cltr-label.c: (cltr_label_new), (cltr_label_set_text),
|
||||||
|
(cltr_label_get_text), (cltr_label_show),
|
||||||
|
(cltr_label_handle_xevent), (cltr_label_paint):
|
||||||
|
* clutter/cltr-label.h:
|
||||||
|
* clutter/cltr-list.c: (cltr_list_paint):
|
||||||
|
* clutter/cltr-widget.c:
|
||||||
|
* examples/select.c: (usage), (video_ctrl_hide),
|
||||||
|
(video_ctrl_stop_cb), (video_ctrl_play_cb),
|
||||||
|
(video_ctrl_seek_begin_cb), (init_video_ctrl), (show_video_ctrl),
|
||||||
|
(populate), (cell_to_item), (zoom_video_out), (init_show_controls),
|
||||||
|
(handle_xevent), (zoom_out_complete), (zoom_in_complete):
|
||||||
|
More select hacking ...
|
||||||
|
|
||||||
2005-05-23 mallum,,, <mallum@openedhand.com>
|
2005-05-23 mallum,,, <mallum@openedhand.com>
|
||||||
|
|
||||||
* clutter/cltr-button.c: (cltr_button_new_with_label),
|
* clutter/cltr-button.c: (cltr_button_new_with_label),
|
||||||
|
@ -5,6 +5,9 @@
|
|||||||
struct CltrAnimator
|
struct CltrAnimator
|
||||||
{
|
{
|
||||||
CltrWidget *widget;
|
CltrWidget *widget;
|
||||||
|
|
||||||
|
CltrAnimatorType type;
|
||||||
|
|
||||||
gint fps;
|
gint fps;
|
||||||
int n_steps, step;
|
int n_steps, step;
|
||||||
|
|
||||||
@ -15,8 +18,11 @@ struct CltrAnimator
|
|||||||
|
|
||||||
int zoom_end_x1, zoom_end_y1, zoom_end_x2, zoom_end_y2;
|
int zoom_end_x1, zoom_end_y1, zoom_end_x2, zoom_end_y2;
|
||||||
int zoom_start_x1, zoom_start_y1, zoom_start_x2, zoom_start_y2;
|
int zoom_start_x1, zoom_start_y1, zoom_start_x2, zoom_start_y2;
|
||||||
|
|
||||||
|
int move_start_x1, move_start_y1, move_end_x1, move_end_y1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cltr_animator_wrapped_paint(CltrWidget *widget);
|
cltr_animator_wrapped_paint(CltrWidget *widget);
|
||||||
|
|
||||||
@ -33,6 +39,8 @@ cltr_animator_zoom_new(CltrWidget *widget,
|
|||||||
{
|
{
|
||||||
CltrAnimator *anim = g_malloc0(sizeof(CltrAnimator));
|
CltrAnimator *anim = g_malloc0(sizeof(CltrAnimator));
|
||||||
|
|
||||||
|
anim->type = CltrAnimatorZoom;
|
||||||
|
|
||||||
anim->zoom_end_x1 = dst_x1;
|
anim->zoom_end_x1 = dst_x1;
|
||||||
anim->zoom_end_x2 = dst_x2;
|
anim->zoom_end_x2 = dst_x2;
|
||||||
anim->zoom_end_y1 = dst_y1;
|
anim->zoom_end_y1 = dst_y1;
|
||||||
@ -55,6 +63,34 @@ cltr_animator_zoom_new(CltrWidget *widget,
|
|||||||
return anim;
|
return anim;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CltrAnimator*
|
||||||
|
cltr_animator_move_new(CltrWidget *widget,
|
||||||
|
int src_x1,
|
||||||
|
int src_y1,
|
||||||
|
int dst_x1,
|
||||||
|
int dst_y1)
|
||||||
|
{
|
||||||
|
CltrAnimator *anim = g_malloc0(sizeof(CltrAnimator));
|
||||||
|
|
||||||
|
anim->type = CltrAnimatorMove;
|
||||||
|
|
||||||
|
anim->move_start_x1 = src_x1;
|
||||||
|
anim->move_start_y1 = src_y1;
|
||||||
|
anim->move_end_x1 = dst_x1;
|
||||||
|
anim->move_end_y1 = dst_y1;
|
||||||
|
|
||||||
|
anim->wrapped_paint_func = widget->paint;
|
||||||
|
|
||||||
|
anim->widget = widget;
|
||||||
|
widget->anim = anim;
|
||||||
|
|
||||||
|
anim->n_steps = 10;
|
||||||
|
anim->step = 0;
|
||||||
|
anim->fps = 50;
|
||||||
|
|
||||||
|
return anim;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
CltrAnimator*
|
CltrAnimator*
|
||||||
cltr_animator_fullzoom_new(CltrWidget *widget,
|
cltr_animator_fullzoom_new(CltrWidget *widget,
|
||||||
@ -65,6 +101,8 @@ cltr_animator_fullzoom_new(CltrWidget *widget,
|
|||||||
{
|
{
|
||||||
CltrAnimator *anim = g_malloc0(sizeof(CltrAnimator));
|
CltrAnimator *anim = g_malloc0(sizeof(CltrAnimator));
|
||||||
|
|
||||||
|
anim->type = CltrAnimatorFullZoom;
|
||||||
|
|
||||||
anim->zoom_end_x1 = x1;
|
anim->zoom_end_x1 = x1;
|
||||||
anim->zoom_end_x2 = x2;
|
anim->zoom_end_x2 = x2;
|
||||||
anim->zoom_end_y1 = y1;
|
anim->zoom_end_y1 = y1;
|
||||||
@ -101,7 +139,27 @@ cltr_animator_set_args(CltrAnimator *anim)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cltr_animator_wrapped_paint(CltrWidget *widget)
|
cltr_animator_wrapped_move_paint(CltrWidget *widget)
|
||||||
|
{
|
||||||
|
CltrAnimator *anim = widget->anim;
|
||||||
|
int orig_x, orig_y;
|
||||||
|
|
||||||
|
float f = (float)anim->step/anim->n_steps;
|
||||||
|
|
||||||
|
orig_x = widget->x;
|
||||||
|
orig_y = widget->y;
|
||||||
|
|
||||||
|
widget->x = anim->move_start_x1 + ( (anim->move_end_x1 - anim->move_start_x1) * f );
|
||||||
|
widget->x = anim->move_start_y1 + ( (anim->move_end_y1 - anim->move_start_y1) * f );
|
||||||
|
|
||||||
|
anim->wrapped_paint_func(widget);
|
||||||
|
|
||||||
|
widget->x = orig_x;
|
||||||
|
widget->y = orig_y;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cltr_animator_wrapped_zoom_paint(CltrWidget *widget)
|
||||||
{
|
{
|
||||||
CltrAnimator *anim = widget->anim;
|
CltrAnimator *anim = widget->anim;
|
||||||
float tx = 0.0, ty = 0.0;
|
float tx = 0.0, ty = 0.0;
|
||||||
@ -222,7 +280,19 @@ cltr_animator_run(CltrAnimator *anim,
|
|||||||
anim->anim_finish_cb = finish_callback;
|
anim->anim_finish_cb = finish_callback;
|
||||||
anim->anim_finish_data = finish_data;
|
anim->anim_finish_data = finish_data;
|
||||||
|
|
||||||
anim->widget->paint = cltr_animator_wrapped_paint;
|
|
||||||
|
switch (anim->type)
|
||||||
|
{
|
||||||
|
case CltrAnimatorZoom:
|
||||||
|
anim->widget->paint = cltr_animator_wrapped_zoom_paint;
|
||||||
|
break;
|
||||||
|
case CltrAnimatorFullZoom:
|
||||||
|
/* anim->widget->paint = cltr_animator_wrapped_fullzoom_paint; */
|
||||||
|
break;
|
||||||
|
case CltrAnimatorMove:
|
||||||
|
anim->widget->paint = cltr_animator_wrapped_move_paint;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
anim->step = 0;
|
anim->step = 0;
|
||||||
|
|
||||||
|
@ -7,7 +7,9 @@ typedef struct CltrAnimator CltrAnimator;
|
|||||||
|
|
||||||
typedef enum CltrAnimatorType
|
typedef enum CltrAnimatorType
|
||||||
{
|
{
|
||||||
CltrAnimatorFullZoom
|
CltrAnimatorZoom,
|
||||||
|
CltrAnimatorFullZoom,
|
||||||
|
CltrAnimatorMove
|
||||||
}
|
}
|
||||||
CltrAnimatorType;
|
CltrAnimatorType;
|
||||||
|
|
||||||
|
@ -98,13 +98,10 @@ cltr_button_set_label(CltrButton *button,
|
|||||||
|
|
||||||
if (button->label)
|
if (button->label)
|
||||||
{
|
{
|
||||||
cltr_widget_remove_child(CLTR_WIDGET(button),
|
cltr_label_set_text(button->label, text);
|
||||||
CLTR_WIDGET(button->label));
|
|
||||||
|
|
||||||
cltr_widget_unref(CLTR_WIDGET(button));
|
|
||||||
/* XXX free up pre-existing label */
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
button->label = CLTR_LABEL(cltr_label_new(text, font, col));
|
button->label = CLTR_LABEL(cltr_label_new(text, font, col));
|
||||||
|
|
||||||
x = (cltr_widget_width(CLTR_WIDGET(button)) - cltr_widget_width(CLTR_WIDGET(button->label)))/2;
|
x = (cltr_widget_width(CLTR_WIDGET(button)) - cltr_widget_width(CLTR_WIDGET(button->label)))/2;
|
||||||
@ -114,6 +111,7 @@ cltr_button_set_label(CltrButton *button,
|
|||||||
cltr_widget_add_child(CLTR_WIDGET(button),
|
cltr_widget_add_child(CLTR_WIDGET(button),
|
||||||
CLTR_WIDGET(button->label),
|
CLTR_WIDGET(button->label),
|
||||||
x, y);
|
x, y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CltrWidget*
|
CltrWidget*
|
||||||
@ -259,6 +257,10 @@ cltr_button_handle_xevent (CltrWidget *widget, XEvent *xev)
|
|||||||
static void
|
static void
|
||||||
cltr_button_paint(CltrWidget *widget)
|
cltr_button_paint(CltrWidget *widget)
|
||||||
{
|
{
|
||||||
|
PixbufPixel bgcol = { 0xe7, 0xe7, 0xe7, 0xff };
|
||||||
|
PixbufPixel boxcol = { 0xd7, 0xd7, 0xd7, 0xff };
|
||||||
|
PixbufPixel hlfontcol = { 0xe6, 0x99, 0x99, 0xff };
|
||||||
|
|
||||||
CltrButton *button = CLTR_BUTTON(widget);
|
CltrButton *button = CLTR_BUTTON(widget);
|
||||||
|
|
||||||
CLTR_MARK();
|
CLTR_MARK();
|
||||||
@ -270,20 +272,20 @@ cltr_button_paint(CltrWidget *widget)
|
|||||||
switch (button->state)
|
switch (button->state)
|
||||||
{
|
{
|
||||||
case CltrButtonStateFocused:
|
case CltrButtonStateFocused:
|
||||||
glColor4f(1.0, 1.0, 0.0, 1.0);
|
cltr_glu_set_color(&hlfontcol);
|
||||||
break;
|
break;
|
||||||
case CltrButtonStateActive:
|
case CltrButtonStateActive:
|
||||||
glColor4f(1.0, 0.0, 0.0, 1.0);
|
glColor4f(1.0, 1.0, 1.0, 1.0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
glColor4f(1.0, 1.0, 1.0, 1.0);
|
cltr_glu_set_color(&bgcol);
|
||||||
}
|
}
|
||||||
|
|
||||||
cltr_glu_rounded_rect(cltr_widget_abs_x(widget),
|
cltr_glu_rounded_rect(cltr_widget_abs_x(widget),
|
||||||
cltr_widget_abs_y(widget),
|
cltr_widget_abs_y(widget),
|
||||||
cltr_widget_abs_x2(widget),
|
cltr_widget_abs_x2(widget),
|
||||||
cltr_widget_abs_y2(widget),
|
cltr_widget_abs_y2(widget),
|
||||||
2, 5,
|
1, 2,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
|
@ -7,7 +7,7 @@ struct CltrLabel
|
|||||||
|
|
||||||
char *text;
|
char *text;
|
||||||
Pixbuf *pixb;
|
Pixbuf *pixb;
|
||||||
PixbufPixel *col;
|
PixbufPixel col;
|
||||||
CltrFont *font;
|
CltrFont *font;
|
||||||
CltrTexture *texture;
|
CltrTexture *texture;
|
||||||
};
|
};
|
||||||
@ -54,7 +54,8 @@ cltr_label_new(const char *text,
|
|||||||
}
|
}
|
||||||
|
|
||||||
label->font = font; /* XXX Ref The font XXX*/
|
label->font = font; /* XXX Ref The font XXX*/
|
||||||
label->col = col; /* XXX Ref The Col XXX*/
|
|
||||||
|
memcpy(&label->col, col, sizeof(PixbufPixel));
|
||||||
|
|
||||||
label->widget.width = width;
|
label->widget.width = width;
|
||||||
label->widget.height = height;
|
label->widget.height = height;
|
||||||
@ -68,8 +69,10 @@ cltr_label_new(const char *text,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cltr_label_set_text(CltrLabel *label)
|
cltr_label_set_text(CltrLabel *label, char *text)
|
||||||
{
|
{
|
||||||
|
int width,height;
|
||||||
|
|
||||||
if (label->texture)
|
if (label->texture)
|
||||||
cltr_texture_unref(label->texture);
|
cltr_texture_unref(label->texture);
|
||||||
|
|
||||||
@ -79,7 +82,34 @@ cltr_label_set_text(CltrLabel *label)
|
|||||||
if (label->text)
|
if (label->text)
|
||||||
free(label->text);
|
free(label->text);
|
||||||
|
|
||||||
/* XXX TODO */
|
font_get_pixel_size (label->font, text, &width, &height);
|
||||||
|
|
||||||
|
if (width && height)
|
||||||
|
{
|
||||||
|
PixbufPixel bg = { 0x00, 0x00, 0x00, 0x00 };
|
||||||
|
PixbufPixel col = { 0xff, 0xff, 0xff, 0xff };
|
||||||
|
|
||||||
|
label->widget.width = width;
|
||||||
|
label->widget.height = height;
|
||||||
|
|
||||||
|
CLTR_DBG("** setting label to %s ***", text);
|
||||||
|
|
||||||
|
label->text = strdup(text);
|
||||||
|
label->pixb = pixbuf_new(width, height);
|
||||||
|
|
||||||
|
pixbuf_fill_rect(label->pixb, 0, 0, -1, -1, &bg);
|
||||||
|
|
||||||
|
font_draw(label->font,
|
||||||
|
label->pixb,
|
||||||
|
label->text,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
&label->col);
|
||||||
|
|
||||||
|
label->texture = cltr_texture_new(label->pixb);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char*
|
const char*
|
||||||
@ -109,6 +139,7 @@ cltr_label_paint(CltrWidget *widget)
|
|||||||
|
|
||||||
if (label->text)
|
if (label->text)
|
||||||
{
|
{
|
||||||
|
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
|
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
@ -117,7 +148,7 @@ cltr_label_paint(CltrWidget *widget)
|
|||||||
|
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
glColor4f(1.0, 1.0, 1.0, 1.0);
|
/* glColor4f(1.0, 1.0, 1.0, 1.0); */
|
||||||
|
|
||||||
cltr_texture_render_to_gl_quad(label->texture,
|
cltr_texture_render_to_gl_quad(label->texture,
|
||||||
cltr_widget_abs_x(widget),
|
cltr_widget_abs_x(widget),
|
||||||
|
@ -12,5 +12,7 @@ cltr_label_new(const char *text,
|
|||||||
CltrFont *font,
|
CltrFont *font,
|
||||||
PixbufPixel *col);
|
PixbufPixel *col);
|
||||||
|
|
||||||
|
void
|
||||||
|
cltr_label_set_text(CltrLabel *label, char *text);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -386,7 +386,7 @@ cltr_list_paint(CltrWidget *widget)
|
|||||||
PixbufPixel col = { 0xff, 0, 0, 0xff };
|
PixbufPixel col = { 0xff, 0, 0, 0xff };
|
||||||
PixbufPixel bgcol = { 0xe7, 0xe7, 0xe7, 0xff };
|
PixbufPixel bgcol = { 0xe7, 0xe7, 0xe7, 0xff };
|
||||||
PixbufPixel boxcol = { 0xd7, 0xd7, 0xd7, 0xff };
|
PixbufPixel boxcol = { 0xd7, 0xd7, 0xd7, 0xff };
|
||||||
PixbufPixel hlfontcol = { 0xff, 0x33, 0x66, 0xff };
|
PixbufPixel hlfontcol = { 0xe6, 0x99, 0x99, 0xff };
|
||||||
|
|
||||||
CLTR_MARK();
|
CLTR_MARK();
|
||||||
|
|
||||||
@ -475,8 +475,8 @@ cltr_list_paint(CltrWidget *widget)
|
|||||||
cltr_texture_render_to_gl_quad(cell->text_texture,
|
cltr_texture_render_to_gl_quad(cell->text_texture,
|
||||||
vx2 + PAD,
|
vx2 + PAD,
|
||||||
vy1,
|
vy1,
|
||||||
cltr_rect_x2(cell->rect) - PAD,
|
cltr_rect_x2(cell->rect) - (2*PAD),
|
||||||
vy1 + (list->cell_height/2) - PAD);
|
vy1 + (list->cell_height/2) - (2*PAD));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,7 +189,7 @@ cltr_widget_add_child(CltrWidget *widget, CltrWidget *child, int x, int y)
|
|||||||
void
|
void
|
||||||
cltr_widget_remove_child(CltrWidget *widget, CltrWidget *child)
|
cltr_widget_remove_child(CltrWidget *widget, CltrWidget *child)
|
||||||
{
|
{
|
||||||
g_list_remove(widget->children, child);
|
widget->children = g_list_remove(widget->children, child);
|
||||||
|
|
||||||
child->parent = NULL;
|
child->parent = NULL;
|
||||||
child->x = 0;
|
child->x = 0;
|
||||||
|
@ -9,10 +9,16 @@ typedef struct DemoApp
|
|||||||
CltrWidget *list;
|
CltrWidget *list;
|
||||||
CltrWidget *video;
|
CltrWidget *video;
|
||||||
CltrWidget *win;
|
CltrWidget *win;
|
||||||
VideoCtrls *video_ctrls;
|
|
||||||
|
|
||||||
GList *items;
|
GList *items;
|
||||||
|
|
||||||
|
/* video stuff */
|
||||||
|
gboolean paused;
|
||||||
|
VideoCtrls *video_ctrls;
|
||||||
|
|
||||||
|
gboolean ignore_next_xevent_hack;
|
||||||
|
|
||||||
} DemoApp;
|
} DemoApp;
|
||||||
|
|
||||||
struct ItemEntry
|
struct ItemEntry
|
||||||
@ -29,6 +35,9 @@ enum {
|
|||||||
VIDEO_STOP_BTN,
|
VIDEO_STOP_BTN,
|
||||||
VIDEO_REWND_BTN,
|
VIDEO_REWND_BTN,
|
||||||
VIDEO_FFWD_BTN,
|
VIDEO_FFWD_BTN,
|
||||||
|
VIDEO_VOLUP_BTN,
|
||||||
|
VIDEO_VOLDOWN_BTN,
|
||||||
|
VIDEO_BEGIN_BTN,
|
||||||
N_VIDEO_BTNS
|
N_VIDEO_BTNS
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -44,6 +53,12 @@ struct VideoCtrls
|
|||||||
static void
|
static void
|
||||||
zoom_out_complete (CltrAnimator *anim, void *userdata);
|
zoom_out_complete (CltrAnimator *anim, void *userdata);
|
||||||
|
|
||||||
|
static void
|
||||||
|
zoom_video_out(DemoApp *app);
|
||||||
|
|
||||||
|
void
|
||||||
|
handle_xevent(CltrWidget *win, XEvent *xev, void *cookie);
|
||||||
|
|
||||||
int
|
int
|
||||||
usage(char *progname)
|
usage(char *progname)
|
||||||
{
|
{
|
||||||
@ -53,6 +68,71 @@ usage(char *progname)
|
|||||||
|
|
||||||
/* video control buttons */
|
/* video control buttons */
|
||||||
|
|
||||||
|
void
|
||||||
|
video_ctrl_hide(DemoApp *app)
|
||||||
|
{
|
||||||
|
cltr_widget_hide(app->video_ctrls->container);
|
||||||
|
|
||||||
|
cltr_window_focus_widget(CLTR_WINDOW(app->win), app->video);
|
||||||
|
|
||||||
|
app->ignore_next_xevent_hack = TRUE; /* urg */
|
||||||
|
cltr_window_on_xevent(CLTR_WINDOW(app->win), handle_xevent, app);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
video_ctrl_stop_cb(CltrButton *button, void *cookie)
|
||||||
|
{
|
||||||
|
DemoApp *app = (DemoApp*)cookie;
|
||||||
|
|
||||||
|
cltr_widget_hide(app->video_ctrls->container);
|
||||||
|
|
||||||
|
cltr_window_focus_widget(CLTR_WINDOW(app->win), app->list);
|
||||||
|
|
||||||
|
zoom_video_out(app);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
video_ctrl_play_cb(CltrButton *button, void *cookie)
|
||||||
|
{
|
||||||
|
DemoApp *app = (DemoApp*)cookie;
|
||||||
|
VideoCtrls *v = app->video_ctrls;
|
||||||
|
|
||||||
|
PixbufPixel col = { 0xff, 0xff, 0xff, 0xff };
|
||||||
|
|
||||||
|
if (app->paused)
|
||||||
|
{
|
||||||
|
cltr_video_play (CLTR_VIDEO(app->video), NULL);
|
||||||
|
|
||||||
|
cltr_button_set_label(CLTR_BUTTON(v->buttons[VIDEO_PLAY_BTN]),
|
||||||
|
"PAUSE", v->font, &col);
|
||||||
|
|
||||||
|
app->paused = FALSE;
|
||||||
|
|
||||||
|
video_ctrl_hide(app);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cltr_button_set_label(CLTR_BUTTON(v->buttons[VIDEO_PLAY_BTN]),
|
||||||
|
"PLAY", v->font, &col);
|
||||||
|
|
||||||
|
cltr_video_pause (CLTR_VIDEO(app->video));
|
||||||
|
|
||||||
|
app->paused = TRUE;
|
||||||
|
|
||||||
|
cltr_widget_queue_paint(v->buttons[VIDEO_PLAY_BTN]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
video_ctrl_seek_begin_cb(CltrButton *button, void *cookie)
|
||||||
|
{
|
||||||
|
DemoApp *app = (DemoApp*)cookie;
|
||||||
|
|
||||||
|
video_ctrl_hide(app);
|
||||||
|
|
||||||
|
cltr_video_seek (CLTR_VIDEO(app->video), 0.0, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
init_video_ctrl(DemoApp *app)
|
init_video_ctrl(DemoApp *app)
|
||||||
{
|
{
|
||||||
@ -68,55 +148,68 @@ init_video_ctrl(DemoApp *app)
|
|||||||
|
|
||||||
height += 6;
|
height += 6;
|
||||||
|
|
||||||
v->container = cltr_overlay_new(width, height * N_VIDEO_BTNS);
|
v->container = cltr_overlay_new(width, height * 3 /*N_VIDEO_BTNS*/);
|
||||||
|
|
||||||
v->buttons[VIDEO_PLAY_BTN] = cltr_button_new(width, height);
|
v->buttons[VIDEO_PLAY_BTN] = cltr_button_new(width, height-1);
|
||||||
|
|
||||||
cltr_button_set_label(v->buttons[VIDEO_PLAY_BTN],
|
cltr_button_set_label(CLTR_BUTTON(v->buttons[VIDEO_PLAY_BTN]),
|
||||||
"PlAY", v->font, &col);
|
"PAUSE", v->font, &col);
|
||||||
|
|
||||||
|
cltr_button_on_activate(CLTR_BUTTON(v->buttons[VIDEO_PLAY_BTN]),
|
||||||
|
video_ctrl_play_cb, (void *)app);
|
||||||
|
|
||||||
cltr_widget_add_child(v->container,
|
cltr_widget_add_child(v->container,
|
||||||
v->buttons[VIDEO_PLAY_BTN],
|
v->buttons[VIDEO_PLAY_BTN],
|
||||||
x, y);
|
x, y);
|
||||||
y += height;
|
y += height;
|
||||||
|
|
||||||
v->buttons[VIDEO_STOP_BTN] = cltr_button_new(width, height);
|
v->buttons[VIDEO_STOP_BTN] = cltr_button_new(width, height-1);
|
||||||
|
|
||||||
cltr_button_set_label(v->buttons[VIDEO_STOP_BTN],
|
cltr_button_set_label(CLTR_BUTTON(v->buttons[VIDEO_STOP_BTN]),
|
||||||
"STOP",
|
"STOP",
|
||||||
v->font, &col);
|
v->font, &col);
|
||||||
|
|
||||||
|
cltr_button_on_activate(CLTR_BUTTON(v->buttons[VIDEO_STOP_BTN]),
|
||||||
|
video_ctrl_stop_cb, (void *)app);
|
||||||
|
|
||||||
cltr_widget_add_child(v->container,
|
cltr_widget_add_child(v->container,
|
||||||
v->buttons[VIDEO_STOP_BTN],
|
v->buttons[VIDEO_STOP_BTN],
|
||||||
x, y);
|
x, y);
|
||||||
y += height;
|
y += height;
|
||||||
|
|
||||||
|
|
||||||
v->buttons[VIDEO_REWND_BTN] = cltr_button_new(width, height);
|
v->buttons[VIDEO_REWND_BTN] = cltr_button_new(width, height-1);
|
||||||
|
|
||||||
cltr_button_set_label(v->buttons[VIDEO_REWND_BTN],
|
cltr_button_set_label(CLTR_BUTTON(v->buttons[VIDEO_REWND_BTN]),
|
||||||
"RWND",
|
"BEGIN",
|
||||||
v->font, &col);
|
v->font, &col);
|
||||||
|
|
||||||
|
cltr_button_on_activate(CLTR_BUTTON(v->buttons[VIDEO_REWND_BTN]),
|
||||||
|
video_ctrl_seek_begin_cb, (void *)app);
|
||||||
|
|
||||||
cltr_widget_add_child(v->container,
|
cltr_widget_add_child(v->container,
|
||||||
v->buttons[VIDEO_REWND_BTN],
|
v->buttons[VIDEO_REWND_BTN],
|
||||||
x, y);
|
x, y);
|
||||||
|
|
||||||
y += height;
|
y += height;
|
||||||
|
|
||||||
v->buttons[VIDEO_FFWD_BTN] = cltr_button_new(width, height);
|
/*
|
||||||
|
v->buttons[VIDEO_FFWD_BTN] = cltr_button_new(width, height-1);
|
||||||
|
|
||||||
cltr_button_set_label(v->buttons[VIDEO_FFWD_BTN],
|
cltr_button_set_label(CLTR_BUTTON(v->buttons[VIDEO_FFWD_BTN]),
|
||||||
"FFWD",
|
"FFWD",
|
||||||
v->font, &col);
|
v->font, &col);
|
||||||
|
|
||||||
cltr_widget_add_child(v->container,
|
cltr_widget_add_child(v->container,
|
||||||
v->buttons[VIDEO_FFWD_BTN],
|
v->buttons[VIDEO_FFWD_BTN],
|
||||||
x, y);
|
x, y);
|
||||||
|
|
||||||
y += height;
|
y += height;
|
||||||
|
|
||||||
|
*/
|
||||||
cltr_widget_add_child(app->video, v->container, 100, 100);
|
cltr_widget_add_child(app->video, v->container, 100, 100);
|
||||||
|
|
||||||
/* focus */
|
/* focus - URG !*/
|
||||||
|
|
||||||
cltr_widget_set_focus_next(v->buttons[VIDEO_PLAY_BTN],
|
cltr_widget_set_focus_next(v->buttons[VIDEO_PLAY_BTN],
|
||||||
v->buttons[VIDEO_STOP_BTN],
|
v->buttons[VIDEO_STOP_BTN],
|
||||||
@ -126,6 +219,18 @@ init_video_ctrl(DemoApp *app)
|
|||||||
v->buttons[VIDEO_PLAY_BTN],
|
v->buttons[VIDEO_PLAY_BTN],
|
||||||
CLTR_NORTH);
|
CLTR_NORTH);
|
||||||
|
|
||||||
|
cltr_widget_set_focus_next(v->buttons[VIDEO_STOP_BTN],
|
||||||
|
v->buttons[VIDEO_REWND_BTN],
|
||||||
|
CLTR_SOUTH);
|
||||||
|
|
||||||
|
cltr_widget_set_focus_next(v->buttons[VIDEO_REWND_BTN],
|
||||||
|
v->buttons[VIDEO_STOP_BTN],
|
||||||
|
CLTR_NORTH);
|
||||||
|
|
||||||
|
cltr_widget_set_focus_next(v->buttons[VIDEO_REWND_BTN],
|
||||||
|
v->buttons[VIDEO_PLAY_BTN],
|
||||||
|
CLTR_SOUTH);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -168,6 +273,8 @@ populate(DemoApp *app, char *path)
|
|||||||
gint i = 0;
|
gint i = 0;
|
||||||
ItemEntry *new_item;
|
ItemEntry *new_item;
|
||||||
char *img_path;
|
char *img_path;
|
||||||
|
char *seek_path, *seek_data = NULL;
|
||||||
|
gint64 seek_time = 0;
|
||||||
|
|
||||||
/* Eeek! */
|
/* Eeek! */
|
||||||
if (!(g_str_has_suffix (entry, ".mpg") ||
|
if (!(g_str_has_suffix (entry, ".mpg") ||
|
||||||
@ -193,6 +300,13 @@ populate(DemoApp *app, char *path)
|
|||||||
if (i > 0)
|
if (i > 0)
|
||||||
new_item->nice_name[i] = '\0';
|
new_item->nice_name[i] = '\0';
|
||||||
|
|
||||||
|
seek_path = g_strconcat(path, "/", new_item->nice_name, ".seek", NULL);
|
||||||
|
|
||||||
|
if (g_file_get_contents (seek_path, &seek_data, NULL, NULL))
|
||||||
|
{
|
||||||
|
seek_time = atol(seek_data);
|
||||||
|
}
|
||||||
|
|
||||||
img_path = g_strconcat(path, "/", new_item->nice_name, ".png", NULL);
|
img_path = g_strconcat(path, "/", new_item->nice_name, ".png", NULL);
|
||||||
|
|
||||||
pixb = pixbuf_new_from_file(img_path);
|
pixb = pixbuf_new_from_file(img_path);
|
||||||
@ -207,6 +321,8 @@ populate(DemoApp *app, char *path)
|
|||||||
new_item->uri = g_strconcat("file://", path, "/", entry, NULL);
|
new_item->uri = g_strconcat("file://", path, "/", entry, NULL);
|
||||||
new_item->path = g_strdup(path);
|
new_item->path = g_strdup(path);
|
||||||
|
|
||||||
|
new_item->stoptime = seek_time;
|
||||||
|
|
||||||
app->items = g_list_append(app->items, new_item);
|
app->items = g_list_append(app->items, new_item);
|
||||||
|
|
||||||
g_free(img_path);
|
g_free(img_path);
|
||||||
@ -242,39 +358,26 @@ cell_to_item(DemoApp *app, CltrListCell *cell)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
handle_xevent(CltrWidget *win, XEvent *xev, void *cookie)
|
zoom_video_out(DemoApp *app)
|
||||||
{
|
{
|
||||||
KeySym kc;
|
|
||||||
DemoApp *app = (DemoApp*)cookie;
|
|
||||||
|
|
||||||
if (xev->type == KeyPress)
|
|
||||||
{
|
|
||||||
XKeyEvent *xkeyev = &xev->xkey;
|
|
||||||
|
|
||||||
kc = XKeycodeToKeysym(xkeyev->display, xkeyev->keycode, 0);
|
|
||||||
|
|
||||||
switch (kc)
|
|
||||||
{
|
|
||||||
case XK_Return:
|
|
||||||
{
|
|
||||||
ItemEntry *item;
|
ItemEntry *item;
|
||||||
char filename[1024];
|
char filename[1024];
|
||||||
Pixbuf *spixb, *dpixb;
|
Pixbuf *spixb, *dpixb;
|
||||||
int dstx, dsty, dstw, dsth;
|
int dstx, dsty, dstw, dsth;
|
||||||
PixbufPixel col = { 0, 0, 0, 0xff };
|
PixbufPixel col = { 0, 0, 0, 0xff };
|
||||||
int x1, y1, x2, y2;
|
int x1, y1, x2, y2;
|
||||||
|
FILE *fp;
|
||||||
|
|
||||||
cltr_video_pause (CLTR_VIDEO(app->video));
|
cltr_video_pause (CLTR_VIDEO(app->video));
|
||||||
|
|
||||||
item = cell_to_item(app, cltr_list_get_active_cell(app->list));
|
item = cell_to_item(app, cltr_list_get_active_cell(CLTR_LIST(app->list)));
|
||||||
|
|
||||||
item->stoptime = cltr_video_get_time (app->video);
|
item->stoptime = cltr_video_get_time (CLTR_VIDEO(app->video));
|
||||||
|
|
||||||
snprintf(filename, 1024, "%s/%s.png", item->path, item->nice_name);
|
snprintf(filename, 1024, "%s/%s.png", item->path, item->nice_name);
|
||||||
|
|
||||||
spixb = cltr_video_get_pixbuf (app->video);
|
spixb = cltr_video_get_pixbuf (CLTR_VIDEO(app->video));
|
||||||
|
|
||||||
/* fixup pixbuf so scaled like video
|
/* fixup pixbuf so scaled like video
|
||||||
*
|
*
|
||||||
@ -284,8 +387,8 @@ handle_xevent(CltrWidget *win, XEvent *xev, void *cookie)
|
|||||||
|
|
||||||
dstw = spixb->width;
|
dstw = spixb->width;
|
||||||
|
|
||||||
dsth = (spixb->width * cltr_widget_height(win))
|
dsth = (spixb->width * cltr_widget_height(app->win))
|
||||||
/ cltr_widget_width(win) ;
|
/ cltr_widget_width(app->win) ;
|
||||||
|
|
||||||
printf("dsth %i, spixb h %i\n", dsth, spixb->height);
|
printf("dsth %i, spixb h %i\n", dsth, spixb->height);
|
||||||
|
|
||||||
@ -301,11 +404,22 @@ handle_xevent(CltrWidget *win, XEvent *xev, void *cookie)
|
|||||||
|
|
||||||
pixbuf_write_png(dpixb, filename);
|
pixbuf_write_png(dpixb, filename);
|
||||||
|
|
||||||
|
|
||||||
/* reset the viewing pixbuf */
|
/* reset the viewing pixbuf */
|
||||||
|
|
||||||
pixbuf_unref(dpixb);
|
pixbuf_unref(dpixb);
|
||||||
|
|
||||||
|
/* write out the seektime too */
|
||||||
|
|
||||||
|
snprintf(filename, 1024, "%s/%s.seek", item->path, item->nice_name);
|
||||||
|
|
||||||
|
fp = fopen(filename, "w");
|
||||||
|
|
||||||
|
if (fp)
|
||||||
|
{
|
||||||
|
fprintf(fp, "%li", item->stoptime);
|
||||||
|
fclose(fp);
|
||||||
|
}
|
||||||
|
|
||||||
cltr_list_get_active_cell_video_box_co_ords(CLTR_LIST(app->list),
|
cltr_list_get_active_cell_video_box_co_ords(CLTR_LIST(app->list),
|
||||||
&x1, &y1, &x2, &y2);
|
&x1, &y1, &x2, &y2);
|
||||||
|
|
||||||
@ -324,6 +438,57 @@ handle_xevent(CltrWidget *win, XEvent *xev, void *cookie)
|
|||||||
cltr_widget_show(app->list);
|
cltr_widget_show(app->list);
|
||||||
|
|
||||||
cltr_animator_run(app->anim, zoom_out_complete, app);
|
cltr_animator_run(app->anim, zoom_out_complete, app);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
init_show_controls(DemoApp *app)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
app->anim = cltr_animator_move_new(app->video_ctrls->container,
|
||||||
|
-100, 200,
|
||||||
|
100, 200);
|
||||||
|
|
||||||
|
cltr_widget_show_all(app->video_ctrls->container);
|
||||||
|
|
||||||
|
cltr_animator_run(app->anim, NULL, app);
|
||||||
|
*/
|
||||||
|
|
||||||
|
cltr_widget_show_all(app->video_ctrls->container);
|
||||||
|
cltr_window_focus_widget(CLTR_WINDOW(app->win),
|
||||||
|
app->video_ctrls->buttons[VIDEO_PLAY_BTN]);
|
||||||
|
cltr_window_on_xevent(CLTR_WINDOW(app->win), NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
handle_xevent(CltrWidget *win, XEvent *xev, void *cookie)
|
||||||
|
{
|
||||||
|
KeySym kc;
|
||||||
|
DemoApp *app = (DemoApp*)cookie;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* XXX really need to think about not queuing xevents in
|
||||||
|
* the current queue or something :/
|
||||||
|
*/
|
||||||
|
if (app->ignore_next_xevent_hack)
|
||||||
|
{
|
||||||
|
app->ignore_next_xevent_hack = FALSE;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (xev->type == KeyPress)
|
||||||
|
{
|
||||||
|
XKeyEvent *xkeyev = &xev->xkey;
|
||||||
|
|
||||||
|
kc = XKeycodeToKeysym(xkeyev->display, xkeyev->keycode, 0);
|
||||||
|
|
||||||
|
switch (kc)
|
||||||
|
{
|
||||||
|
case XK_Return:
|
||||||
|
{
|
||||||
|
init_show_controls(app);
|
||||||
|
/* zoom_video_out(app); */
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -355,6 +520,8 @@ zoom_in_complete (CltrAnimator *anim, void *userdata)
|
|||||||
|
|
||||||
item = cell_to_item(app, cltr_list_get_active_cell(app->list));
|
item = cell_to_item(app, cltr_list_get_active_cell(app->list));
|
||||||
|
|
||||||
|
app->paused = FALSE;
|
||||||
|
|
||||||
cltr_video_set_source(CLTR_VIDEO(app->video), item->uri);
|
cltr_video_set_source(CLTR_VIDEO(app->video), item->uri);
|
||||||
|
|
||||||
if (item->stoptime)
|
if (item->stoptime)
|
||||||
@ -371,11 +538,12 @@ zoom_in_complete (CltrAnimator *anim, void *userdata)
|
|||||||
cltr_video_seek_time (CLTR_VIDEO(app->video), item->stoptime, NULL);
|
cltr_video_seek_time (CLTR_VIDEO(app->video), item->stoptime, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cltr_widget_show(app->video);
|
cltr_widget_show(app->video);
|
||||||
|
|
||||||
cltr_widget_hide(CLTR_WIDGET(app->list));
|
cltr_widget_hide(CLTR_WIDGET(app->list));
|
||||||
|
|
||||||
show_video_ctrl(app);
|
|
||||||
|
|
||||||
cltr_window_on_xevent(CLTR_WINDOW(app->win), handle_xevent, app);
|
cltr_window_on_xevent(CLTR_WINDOW(app->win), handle_xevent, app);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user