Multimedia controls for terminology. When a video is playing on the bg you will have...
authordavemds <davemds@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sun, 24 Jun 2012 09:49:23 +0000 (09:49 +0000)
committerdavemds <davemds@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sun, 24 Jun 2012 09:49:23 +0000 (09:49 +0000)
git-svn-id: http://svn.enlightenment.org/svn/e/trunk/terminology@72761 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

data/themes/default.edc
data/themes/images/Makefile.am
data/themes/images/media_bg.png [new file with mode: 0644]
data/themes/images/media_line.png [new file with mode: 0644]
data/themes/images/media_pause.png [new file with mode: 0644]
data/themes/images/media_play.png [new file with mode: 0644]
data/themes/images/media_stop.png [new file with mode: 0644]
data/themes/images/mediactrl.xcf [new file with mode: 0644]
data/themes/images/mediactrl2.xcf [new file with mode: 0644]
src/bin/media.c
src/bin/media.h

index 622a59f..de02cdc 100644 (file)
@@ -544,7 +544,157 @@ collections {
          }
       }
    }
-   
+
+//////////////////////////////////////////////////////////////////////////////
+   //// the multimedia controls
+   group { name: "terminology/mediactrl";
+      images {
+        image: "media_bg.png" COMP;
+        image: "media_play.png" COMP;
+        image: "media_stop.png" COMP;
+        image: "media_pause.png" COMP;
+        image: "media_line.png" COMP;
+      }
+      parts {
+         part { name: "media_clip"; type: RECT;
+            mouse_events: 0;
+            description { state: "default" 0.0;
+               rel1.to: "media_bg";
+               rel2.to: "media_bg";
+            }
+         }
+         part { name: "media_bg";
+            clip_to: "media_clip";
+            description { state: "default" 0.0;
+               image.normal: "media_bg.png";
+               image.border: 11 11 11 11;
+               max: 24 24;
+               align: 0.0 1.0;
+            }
+            description { state: "expanded" 0.0;
+               inherit: "default" 0.0;
+               min: 200 24;
+               max: 200 24;
+            }
+         }
+         part { name: "play";
+            mouse_events: 1;
+            repeat_events: 1;
+            clip_to: "media_clip";
+            description { state: "default" 0.0;
+               image.normal: "media_pause.png";
+               max: 24 24;
+               align: 0.0 1.0;
+            }
+            description { state: "paused" 0.0;
+               inherit: "default" 0.0;
+               image.normal: "media_play.png";
+            }
+         }
+         part { name: "stop";
+            mouse_events: 1;
+            repeat_events: 1;
+            clip_to: "media_clip";
+            description { state: "default" 0.0;
+               image.normal: "media_stop.png";
+               max: 24 24;
+               rel1.to: "play";
+               rel2.to: "play";
+               rel1.offset: 16 0;
+               rel2.offset: 16 0;
+            }
+         }
+         part { name: "volline";
+            mouse_events: 0;
+            repeat_events: 1;
+            clip_to: "media_clip";
+            description { state: "default" 0.0;
+               image.normal: "media_line.png";
+               min: 150 10;
+               max: 150 10;
+               rel1.to: "stop";
+               rel2.to: "stop";
+               rel1.offset: 25 0;
+               rel2.offset: 150 0;
+            }
+         }
+         part { name: "terminology.voldrag"; type: RECT;
+            mouse_events: 1;
+            repeat_events: 1;
+            clip_to: "media_clip";
+            dragable {
+               confine: "volline";
+               x: 1 1 0;
+               y: 0 0 0;
+            }
+            description { state: "default" 0.0;
+               color: 255 0 0 150;
+               min: 10 10;
+               max: 10 10;
+            }
+            description { state: "muted" 0.0;
+               visible: 0;
+            }
+         }
+         programs {
+            program { name: "media_mouse_in";
+               signal: "mouse,in";
+               source: "media_bg";
+               action: STATE_SET "expanded" 0.0;
+               transition: SINUSOIDAL 0.4 CURRENT;
+               target: "media_bg";
+            }
+            program { name: "media_mouse_out";
+               signal: "mouse,out";
+               source: "media_bg";
+               action: STATE_SET "default" 0.0;
+               transition: SINUSOIDAL 0.4 CURRENT;
+               target: "media_bg";
+            }
+            program { name: "media_pause_click";
+               signal: "mouse,up,*";
+               source: "play";
+               filter: "play" "default";
+               action: SIGNAL_EMIT "pause" "";
+            }
+            program { name: "media_play_click";
+               signal: "mouse,up,1";
+               source: "play";
+               filter: "play" "paused";
+               action: SIGNAL_EMIT "play" "";
+            }
+            program { name: "media_stop_click";
+               signal: "mouse,up,1";
+               source: "stop";
+               action: SIGNAL_EMIT "stop" "";
+            }
+            program { name: "media_signal_pause";
+               signal: "pause,set";
+               source: "terminology";
+               action: STATE_SET "paused" 0.0;
+               target: "play";
+            }
+            program { name: "media_signal_play";
+               signal: "play,set";
+               source: "terminology";
+               action: STATE_SET "default" 0.0;
+               target: "play";
+            }
+            program { name: "media_signal_mute";
+               signal: "mute,set";
+               source: "terminology";
+               action: STATE_SET "muted" 0.0;
+               target: "terminology.voldrag";
+            }
+            program { name: "media_signal_unmute";
+               signal: "mute,unset";
+               source: "terminology";
+               action: STATE_SET "default" 0.0;
+               target: "terminology.voldrag";
+            }
+         }
+      }
+   }
 //////////////////////////////////////////////////////////////////////////////
    //// used in the font selection dialog to give a base for black text
    //// previews so they are always visible
index e87ac29..33b285c 100644 (file)
@@ -11,4 +11,9 @@ cr_fill.png \
 cr_key.png \
 cr_out.png \
 cr_pulse.png \
-fn_shadow.png
+fn_shadow.png \
+media_bg.png \
+media_line.png \
+media_pause.png \
+media_play.png \
+media_stop.png
diff --git a/data/themes/images/media_bg.png b/data/themes/images/media_bg.png
new file mode 100644 (file)
index 0000000..68d219c
Binary files /dev/null and b/data/themes/images/media_bg.png differ
diff --git a/data/themes/images/media_line.png b/data/themes/images/media_line.png
new file mode 100644 (file)
index 0000000..ee73548
Binary files /dev/null and b/data/themes/images/media_line.png differ
diff --git a/data/themes/images/media_pause.png b/data/themes/images/media_pause.png
new file mode 100644 (file)
index 0000000..ed5e7ba
Binary files /dev/null and b/data/themes/images/media_pause.png differ
diff --git a/data/themes/images/media_play.png b/data/themes/images/media_play.png
new file mode 100644 (file)
index 0000000..5a924b4
Binary files /dev/null and b/data/themes/images/media_play.png differ
diff --git a/data/themes/images/media_stop.png b/data/themes/images/media_stop.png
new file mode 100644 (file)
index 0000000..727e0e2
Binary files /dev/null and b/data/themes/images/media_stop.png differ
diff --git a/data/themes/images/mediactrl.xcf b/data/themes/images/mediactrl.xcf
new file mode 100644 (file)
index 0000000..ab2df12
Binary files /dev/null and b/data/themes/images/mediactrl.xcf differ
diff --git a/data/themes/images/mediactrl2.xcf b/data/themes/images/mediactrl2.xcf
new file mode 100644 (file)
index 0000000..87af7d3
Binary files /dev/null and b/data/themes/images/mediactrl2.xcf differ
index dad48fb..23fded0 100644 (file)
@@ -11,7 +11,7 @@ typedef struct _Media Media;
 struct _Media
 {
    Evas_Object_Smart_Clipped_Data __clipped_data;
-   Evas_Object *clip, *o_img, *o_tmp;
+   Evas_Object *clip, *o_img, *o_tmp, *o_ctrl;
    Ecore_Timer *anim;
    Ecore_Job *restart_job;
    const char *src;
@@ -364,9 +364,39 @@ _cb_mov_ref(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
 }
 
 static void
+_cb_media_play(void *data, Evas_Object *obj, const char *emission, const char *source)
+{
+   media_play_set(data, EINA_TRUE);
+}
+
+static void
+_cb_media_pause(void *data, Evas_Object *obj, const char *emission, const char *source)
+{
+   media_play_set(data, EINA_FALSE);
+}
+
+static void
+_cb_media_stop(void *data, Evas_Object *obj, const char *emission, const char *source)
+{
+   media_play_set(data, EINA_FALSE);
+   media_position_set(data, 0.0);
+}
+
+static void
+_cb_media_vol(void *data, Evas_Object *obj, const char *emission, const char *source)
+{
+   double vx, vy;
+   Media *sd = evas_object_smart_data_get(data);
+   if (!sd) return;
+   edje_object_part_drag_value_get(sd->o_ctrl, "terminology.voldrag", &vx, &vy);
+   media_volume_set(data, vx + vy);
+}
+
+static void
 _type_mov_init(Evas_Object *obj)
 {
    Evas_Object *o;
+   double vol;
    char *modules[] =
      {
         NULL,
@@ -406,9 +436,26 @@ _type_mov_init(Evas_Object *obj)
    emotion_object_file_set(o, sd->src);
    evas_object_smart_member_add(o, obj);
    evas_object_clip_set(o, sd->clip);
-   emotion_object_position_set(o, 0.0);
-   emotion_object_play_set(o, EINA_TRUE);
-   if (sd->config->mute) emotion_object_audio_mute_set(o, EINA_TRUE);
+
+   o = sd->o_ctrl = edje_object_add(evas_object_evas_get(obj));
+   theme_apply(o, sd->config, "terminology/mediactrl");
+   vol = emotion_object_audio_volume_get(sd->o_img);
+   edje_object_part_drag_value_set(o, "terminology.voldrag", vol, vol);
+   edje_object_signal_callback_add(o, "play", "", _cb_media_play, obj);
+   edje_object_signal_callback_add(o, "pause", "", _cb_media_pause, obj);
+   edje_object_signal_callback_add(o, "stop", "", _cb_media_stop, obj);
+   edje_object_signal_callback_add(o, "drag", "terminology.voldrag", _cb_media_vol, obj);
+   /* TODO where to stack the object in the ui? controls cannot be part of
+    * the 'media smart obj' becouse controls need to be on top of the term obj.
+    * 
+    * I think we need to swallow inside the bg object. but how to
+    * retrive the edje bg object from here?
+    * */
+   evas_object_show(o);
+
+   media_position_set(obj, 0.0);
+   media_play_set(obj, EINA_TRUE);
+   if (sd->config->mute) media_mute_set(obj, EINA_TRUE);
 }
 
 static void
@@ -416,6 +463,10 @@ _type_mov_calc(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_
 {
    Media *sd = evas_object_smart_data_get(obj);
    if (!sd) return;
+
+   evas_object_move(sd->o_ctrl, x, y);
+   evas_object_resize(sd->o_ctrl, w, h);
+
    emotion_object_size_get(sd->o_img, &(sd->iw), &(sd->ih));
    if ((w <= 0) || (h <= 0) || (sd->iw <= 0) || (sd->ih <= 0))
      {
@@ -481,6 +532,7 @@ _smart_del(Evas_Object *obj)
    if (sd->clip) evas_object_del(sd->clip);
    if (sd->o_img) evas_object_del(sd->o_img);
    if (sd->o_tmp) evas_object_del(sd->o_tmp);
+   if (sd->o_ctrl) evas_object_del(sd->o_ctrl);
    if (sd->anim) ecore_timer_del(sd->anim);
    if (sd->restart_job) ecore_job_del(sd->restart_job);
    _meida_sc.del(obj);
@@ -586,7 +638,40 @@ void
 media_mute_set(Evas_Object *obj, Eina_Bool mute)
 {
    Media *sd = evas_object_smart_data_get(obj);
-   if (!sd) return;
-   if (sd->type != TYPE_MOV) return;
+   if ((!sd) || (sd->type != TYPE_MOV)) return;
    emotion_object_audio_mute_set(sd->o_img, mute);
+   if (mute)
+      edje_object_signal_emit(sd->o_ctrl, "mute,set", "terminology");
+   else
+      edje_object_signal_emit(sd->o_ctrl, "mute,unset", "terminology");
+}
+
+void
+media_play_set(Evas_Object *obj, Eina_Bool play)
+{
+   Media *sd = evas_object_smart_data_get(obj);
+   if ((!sd) || (sd->type != TYPE_MOV)) return;
+   emotion_object_play_set(sd->o_img, play);
+   if (play)
+      edje_object_signal_emit(sd->o_ctrl, "play,set", "terminology");
+   else
+      edje_object_signal_emit(sd->o_ctrl, "pause,set", "terminology");
+}
+
+void
+media_position_set(Evas_Object *obj, double pos)
+{
+   Media *sd = evas_object_smart_data_get(obj);
+   if ((!sd) || (sd->type != TYPE_MOV)) return;
+   emotion_object_position_set(sd->o_img, pos);
+   edje_object_part_drag_value_set(sd->o_ctrl, "terminology.posdrag", pos, pos);
+}
+
+void
+media_volume_set(Evas_Object *obj, double vol)
+{
+   Media *sd = evas_object_smart_data_get(obj);
+   if ((!sd) || (sd->type != TYPE_MOV)) return;
+   emotion_object_audio_volume_set(sd->o_img, vol);
+   edje_object_part_drag_value_set(sd->o_ctrl, "terminology.voldrag", vol, vol);
 }
index caaafee..21cf5d7 100644 (file)
@@ -12,5 +12,8 @@
 
 Evas_Object *media_add(Evas_Object *parent, const char *src, const Config *config, int mode, int *type);
 void media_mute_set(Evas_Object *obj, Eina_Bool mute);
+void media_play_set(Evas_Object *obj, Eina_Bool play);
+void media_position_set(Evas_Object *obj, double pos);
+void media_volume_set(Evas_Object *obj, double vol);
 
 #endif