Enlightenment CVS committal
Author : tsauerbeck
Project : misc
Module : eplayer
Dir : misc/eplayer/src
Modified Files:
callbacks.c eplayer.h interface.c
Log Message:
Simplified playlist code (thanks to atmos)
===================================================================
RCS file: /cvsroot/enlightenment/misc/eplayer/src/callbacks.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -3 -r1.13 -r1.14
--- callbacks.c 15 Nov 2003 15:45:39 -0000 1.13
+++ callbacks.c 16 Nov 2003 00:02:06 -0000 1.14
@@ -143,30 +143,22 @@
player->cfg.repeat = !player->cfg.repeat;
}
-/**
- * Scrolls the playlist containers.
- *
- * @param player
- * @param direction 1 (up) or -1 (down).
- */
-static void playlist_scroll(ePlayer *player, int direction) {
- int i, val;
-
- for (i = 0; i < 2; i++) {
- /* it's * 3 because we're scrolling 3 elements at once */
- val = player->gui.playlist_font_size[i] * 3 * direction;
- e_container_scroll(player->gui.playlist_col[i], val);
- }
-}
-
void cb_playlist_scroll_up(void *udata, Evas_Object *obj,
const char *emission, const char *src) {
- playlist_scroll(udata, 1);
+ ePlayer *player = udata;
+
+ /* it's * 3 because we're scrolling 3 elements at once */
+ e_container_scroll(player->gui.playlist,
+ player->gui.playlist_font_size * 3);
}
void cb_playlist_scroll_down(void *udata, Evas_Object *obj,
const char *emission, const char *src) {
- playlist_scroll(udata, -1);
+ ePlayer *player = udata;
+
+ /* it's * 3 because we're scrolling 3 elements at once */
+ e_container_scroll(player->gui.playlist,
+ player->gui.playlist_font_size * -3);
}
void cb_seek_forward(void *udata, Evas_Object *obj,
===================================================================
RCS file: /cvsroot/enlightenment/misc/eplayer/src/eplayer.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -3 -r1.12 -r1.13
--- eplayer.h 15 Nov 2003 15:45:39 -0000 1.12
+++ eplayer.h 16 Nov 2003 00:02:07 -0000 1.13
@@ -22,8 +22,8 @@
Evas *evas;
Evas_Object *edje;
Evas_Object *playlist; /* playlist container */
- Evas_Object *playlist_col[2];
- int playlist_font_size[2]; /* 0 -> title, 1 -> length */
+ //Evas_Object *playlist_col[2];
+ int playlist_font_size; /* 0 -> title, 1 -> length */
} Gui;
typedef struct {
===================================================================
RCS file: /cvsroot/enlightenment/misc/eplayer/src/interface.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -3 -r1.13 -r1.14
--- interface.c 15 Nov 2003 15:45:39 -0000 1.13
+++ interface.c 16 Nov 2003 00:02:07 -0000 1.14
@@ -77,16 +77,6 @@
ecore_evas_resize(ee, (int) edje_w, (int) edje_h);
ecore_evas_show(ee);
- /* add the playlist container */
- player->gui.playlist = e_container_new(player->gui.evas);
- e_container_direction_set(player->gui.playlist, 0);
- e_container_spacing_set(player->gui.playlist, 0);
- e_container_fill_policy_set(player->gui.playlist,
- CONTAINER_FILL_POLICY_FILL_Y);
-
- edje_object_part_swallow(player->gui.edje, "playlist",
- player->gui.playlist);
-
/*** Edje Callbacks ***************************/
edje_object_signal_callback_add(player->gui.edje,
"PLAY_PREVIOUS", "previous_button",
@@ -125,51 +115,16 @@
return 1;
}
-static Evas_Object *playlist_column_add(ePlayer *player,
- double width, double height,
- Container_Alignment align) {
- Evas_Object *o = e_container_new(player->gui.evas);
-
- e_container_direction_set(o, 1);
- e_container_spacing_set(o, 0);
- e_container_alignment_set(o, align);
- e_container_fill_policy_set(o, CONTAINER_FILL_POLICY_FILL_X);
-
- evas_object_resize(o, width, height);
-
- return o;
-}
-
static void setup_playlist(ePlayer *player) {
- Evas_Object *o;
- double w, h;
- int i;
-
- for (i = 0; i < 2; i++) {
- /* instantiate the edje object first, to get the width/height */
- o = edje_object_add(player->gui.evas);
-
- edje_object_file_set(o, DATA_DIR "/themes/eplayer.eet",
- "playlist_item_title");
-
- w = h = 0;
- edje_object_size_min_get(o, &w, &h);
- evas_object_del(o);
-
- /* now add the columns */
- evas_object_geometry_get(player->gui.playlist,
- NULL, NULL, NULL, &h);
-
-
- player->gui.playlist_col[i] =
- playlist_column_add(player, w, h,
- i ? CONTAINER_ALIGN_RIGHT
- : CONTAINER_ALIGN_LEFT);
-
- e_container_element_append(player->gui.playlist,
- player->gui.playlist_col[i]);
- }
+ /* add the playlist container */
+ player->gui.playlist = e_container_new(player->gui.evas);
+ e_container_direction_set(player->gui.playlist, 1);
+ e_container_spacing_set(player->gui.playlist, 0);
+ e_container_fill_policy_set(player->gui.playlist,
+ CONTAINER_FILL_POLICY_FILL_X);
+ edje_object_part_swallow(player->gui.edje, "playlist",
+ player->gui.playlist);
edje_object_signal_callback_add(player->gui.edje,
"PLAYLIST_SCROLL_DOWN", "playlist",
cb_playlist_scroll_down, player);
@@ -181,48 +136,45 @@
void show_playlist_item(PlayListItem *pli, void *data) {
ePlayer *player = data;
Evas_Object *o;
- char *title, len[32];
- char *name[] = {"playlist_item_title", "playlist_item_length"};
- double w, h;
- int i, duration;
-
- /* get the information we want to display */
- title = pli->comment[COMMENT_ID_TITLE];
- duration = pli->duration;
-
- snprintf(len, sizeof(len), "%i:%02i", duration / 60,
- duration % 60);
-
- /* add the title/length items to the container */
- for (i = 0; i < 2; i++) {
- o = edje_object_add(player->gui.evas);
-
- edje_object_file_set(o, DATA_DIR "/themes/eplayer.eet",
- name[i]);
-
- edje_object_part_text_set(o, "text", i ? len : title);
-
- w = h = 0;
- edje_object_size_min_get(o, &w, &h);
- evas_object_resize(o, w, h);
+ char len[32];
+ double w = 0, h = 0;
+ int i, j;
+ char *part[] = {"title", "length"};
+ char *signal[] = {"PLAYLIST_SCROLL_UP", "PLAYLIST_SCROLL_DOWN"};
+ void (*cb[])(void *data, Evas_Object *o, const char *emission,
+ const char *source) = {cb_playlist_scroll_up,
+ cb_playlist_scroll_down};
+
+ /* add the item to the container */
+ o = edje_object_add(player->gui.evas);
+
+ edje_object_file_set(o, DATA_DIR "/themes/eplayer.eet",
+ "playlist_item");
+
+ /* set parts text */
+ snprintf(len, sizeof(len), "%i:%02i", pli->duration / 60,
+ pli->duration % 60);
+ edje_object_part_text_set(o, "length", len);
+ edje_object_part_text_set(o, "title",
+ pli->comment[COMMENT_ID_TITLE]);
+
+ /* set parts dimensions */
+ edje_object_size_min_get(o, &w, &h);
+ evas_object_resize(o, w, h);
+
+ /* store font size, we need it later for scrolling
+ * FIXME: we're assuming that the objects minimal height
+ * equals the text size
+ */
+ player->gui.playlist_font_size = h;
- e_container_element_append(player->gui.playlist_col[i], o);
+ e_container_element_append(player->gui.playlist, o);
- /* add playlist callbacks */
- edje_object_signal_callback_add(o,
- "PLAYLIST_SCROLL_UP", "text",
- cb_playlist_scroll_up,
- player);
- edje_object_signal_callback_add(o,
- "PLAYLIST_SCROLL_DOWN", "text",
- cb_playlist_scroll_down,
- player);
-
- /* FIXME: we're assuming that the objects minimal height
- * equals the text size
- */
- player->gui.playlist_font_size[i] = h;
- }
+ /* add playlist item callbacks */
+ for (i = 0; i < 2; i++)
+ for (j = 0; j < 2; j++)
+ edje_object_signal_callback_add(o, signal[i], part[j],
+ cb[i], player);
}
int refresh_volume(void *udata) {
-------------------------------------------------------
This SF. Net email is sponsored by: GoToMyPC
GoToMyPC is the fast, easy and secure way to access your computer from
any Web browser or wireless device. Click here to Try it Free!
https://www.gotomypc.com/tr/OSDN/AW/Q4_2003/t/g22lp?Target=mm/g22lp.tmpl
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs