diff --git a/data/themes/default.edc b/data/themes/default.edc index bf09e36..a3b89b5 100644 --- a/data/themes/default.edc +++ b/data/themes/default.edc @@ -1,5 +1,6 @@ collections { +#define CTRLSIZE 26 group { name: "rage/core"; images.image: "pm_fill.png" COMP; images.image: "vg1.png" COMP; @@ -49,6 +50,17 @@ collections { public novideo; public browser; + public message(Msg_Type:type, id, ...) { + if ((type == MSG_FLOAT) && (id == 1)) { // volume 0.0->1.0 + new Float:val = getfarg(2); + + if (val < 0.0) val = 0.0; + else if (val > 1.0) val = 1.0; + custom_state(PART:"vol_indicator_fg", "default", 0.0); + set_state_val(PART:"vol_indicator_fg", STATE_REL2, val, 1.0); + set_state(PART:"vol_indicator_fg", "custom", 0.0); + } + } public pos_timeout(val) { set_int(pos_timer, 0); if (get_int(pos_visible)) { @@ -633,7 +645,7 @@ collections { rel1.to: "rage.dragable.pos"; rel2.to: "rage.dragable.pos"; align: 0.5 1.0; - min: 20 20; + min: CTRLSIZE CTRLSIZE; } } part { name: "posevent"; type: RECT; @@ -646,7 +658,7 @@ collections { rel1.to: "rage.pos.swallow"; rel2.to: "rage.pos.swallow"; color: 0 0 0 0; - min: 20 20; + min: CTRLSIZE CTRLSIZE; align: 0.5 1.0; } } @@ -658,7 +670,7 @@ collections { rel1.to_y: "dragover_event"; rel2.relative: 0.0 0.0; rel2.to_y: "dragover_event"; - min: 20 20; + min: CTRLSIZE CTRLSIZE; align: 0.0 1.0; } } @@ -672,7 +684,7 @@ collections { rel2.to_x: "rage.pos.prev.swallow"; rel2.to_y: "dragover_event"; rel2.relative: 1.0 0.0; - min: 20 20; + min: CTRLSIZE CTRLSIZE; align: 0.0 1.0; } } @@ -686,19 +698,20 @@ collections { rel2.to_x: "rage.pos.play.swallow"; rel2.to_y: "dragover_event"; rel2.relative: 1.0 0.0; - min: 20 20; + min: CTRLSIZE CTRLSIZE; align: 0.0 1.0; } } part { name: "rage.vol.swallow"; type: SWALLOW; scale: 1; + clip_to: "controlbar_clip"; description { state: "default" 0.0; fixed: 1 1; rel1.to_y: "dragover_event"; rel1.relative: 1.0 0.0; rel2.to_y: "dragover_event"; rel2.relative: 1.0 0.0; - min: 20 20; + min: (CTRLSIZE*4) CTRLSIZE; align: 1.0 1.0; } } @@ -710,7 +723,7 @@ collections { rel1.to: "rage.pos.prev.swallow"; rel2.to: "rage.pos.prev.swallow"; image.normal: "icon_prev.png"; - min: 20 20; max: 20 20; + min: CTRLSIZE CTRLSIZE; max: CTRLSIZE CTRLSIZE; } description { state: "active" 0.0; inherit: "default" 0.0; @@ -754,15 +767,14 @@ collections { } } - part { name: "pos_pause"; - scale: 1; + part { name: "pos_pause"; scale: 1; clip_to: "playpause"; description { state: "default" 0.0; fixed: 1 1; rel1.to: "rage.pos.play.swallow"; rel2.to: "rage.pos.play.swallow"; image.normal: "icon_play.png"; - min: 20 20; max: 20 20; + min: CTRLSIZE CTRLSIZE; max: CTRLSIZE CTRLSIZE; } description { state: "active" 0.0; inherit: "default" 0.0; @@ -788,14 +800,13 @@ collections { target: "pos_pause"; } - part { name: "pos_play"; - scale: 1; + part { name: "pos_play"; scale: 1; clip_to: "playpause2"; description { state: "default" 0.0; fixed: 1 1; rel1.to: "rage.pos.play.swallow"; rel2.to: "rage.pos.play.swallow"; - min: 20 20; max: 20 20; + min: CTRLSIZE CTRLSIZE; max: CTRLSIZE CTRLSIZE; image.normal: "icon_pause.png"; } description { state: "active" 0.0; @@ -835,15 +846,14 @@ collections { target: "playpause2"; } - part { name: "pos_next"; - scale: 1; + part { name: "pos_next"; scale: 1; clip_to: "controlbar_clip"; description { state: "default" 0.0; fixed: 1 1; rel1.to: "rage.pos.next.swallow"; rel2.to: "rage.pos.next.swallow"; image.normal: "icon_next.png"; - min: 20 20; max: 20 20; + min: CTRLSIZE CTRLSIZE; max: CTRLSIZE CTRLSIZE; } description { state: "active" 0.0; inherit: "default" 0.0; @@ -868,14 +878,63 @@ collections { target: "pos_next"; } - part { name: "vol"; scale: 1; + part { name: "volmuteb"; type: RECT; clip_to: "controlbar_clip"; + description { state: "default" 0.0; + visible: 1; + } + description { state: "mute" 0.0; + visible: 0; + } + } + part { name: "volmuteb2"; type: RECT; + clip_to: "controlbar_clip"; + description { state: "default" 0.0; + visible: 0; + } + description { state: "mute" 0.0; + visible: 1; + } + } + program { + signal: "action,mute"; source: "rage"; + action: STATE_SET "mute" 0.0; + target: "volmuteb"; + target: "volmuteb2"; + } + program { + signal: "action,unmute"; source: "rage"; + action: STATE_SET "default" 0.0; + target: "volmuteb"; + target: "volmuteb2"; + } + + part { name: "vol"; scale: 1; + clip_to: "volmuteb"; description { state: "default" 0.0; fixed: 1 1; rel1.to: "rage.vol.swallow"; rel2.to: "rage.vol.swallow"; + rel2.relative: 0.0 1.0; + align: 1.0 0.5; image.normal: "icon_volume.png"; - min: 20 20; max: 20 20; + min: CTRLSIZE CTRLSIZE; max: CTRLSIZE CTRLSIZE; + } + description { state: "active" 0.0; + inherit: "default" 0.0; + color: 160 160 160 255; + } + } + part { name: "vol2"; scale: 1; + clip_to: "volmuteb2"; + description { state: "default" 0.0; + fixed: 1 1; + rel1.to: "rage.vol.swallow"; + rel2.to: "rage.vol.swallow"; + rel2.relative: 0.0 1.0; + align: 1.0 0.5; + image.normal: "icon_mute.png"; + min: CTRLSIZE CTRLSIZE; max: CTRLSIZE CTRLSIZE; } description { state: "active" 0.0; inherit: "default" 0.0; @@ -885,20 +944,26 @@ collections { part { name: "volev"; type: RECT; clip_to: "controlbar_clip"; description { state: "default" 0.0; - rel1.to: "rage.vol.swallow"; - rel2.to: "rage.vol.swallow"; - color: 0 0 0 0; + rel1.to: "vol"; + rel2.to: "vol"; + color: 0 0 0 0; } } program { signal: "mouse,down,1"; source: "volev"; action: STATE_SET "active" 0.0; target: "vol"; + target: "vol2"; } program { signal: "mouse,up,1"; source: "volev"; action: STATE_SET "default" 0.0; target: "vol"; + target: "vol2"; + } + program { + signal: "mouse,clicked,1"; source: "volev"; + action: SIGNAL_EMIT "pos,action,vol" "rage"; } program { @@ -984,11 +1049,11 @@ collections { description { state: "default" 0.0; fixed: 1 1; rel1.to_y: "pos_next"; - rel1.to_x: "vol"; + rel1.to_x: "rage.pos.swallow"; rel1.relative: 0.0 0.0; rel1.offset: -1 0; rel2.to_y: "pos_next"; - rel2.to_x: "vol"; + rel2.to_x: "rage.pos.swallow"; rel2.relative: 0.0 1.0; rel2.offset: -1 -1; color: 255 255 255 255; @@ -1001,19 +1066,19 @@ collections { } } -#define STATE_FADE_PROG(_name) \ +#define STATE_FADE_PROG(_name, _part) \ program { \ signal: "action,"_name; source: "rage"; \ action: STATE_SET "visible" 0.0; \ transition: SINUSOIDAL 0.2 CURRENT; \ - target: _name; \ + target: _part; \ after: _name"2"; \ } \ program { name: _name"2"; \ action: STATE_SET "default" 0.0; \ in: 1.0 0.0; \ transition: SINUSOIDAL 1.0 CURRENT; \ - target: _name""; \ + target: _part; \ } part { name: "mute"; mouse_events: 0; scale: 1; @@ -1034,7 +1099,45 @@ collections { visible: 1; } } - STATE_FADE_PROG("mute") + STATE_FADE_PROG("mute", "mute") + part { name: "vol_indicator_bg"; type: RECT; mouse_events: 0; + clip_to: "vol_indicator"; + scale: 1; + description { state: "default" 0.0; + fixed: 1 1; + rel1.to: "mute"; + rel1.relative: 0.0 1.0; + rel1.offset: 0 4; + rel2.to: "mute"; + rel2.relative: 0.0 1.0; + rel2.offset: 0 4; + align: 0.0 0.0; + min: 40 5; max: 40 5; + color: 255 255 255 128; + offscale; + } + } + part { name: "vol_indicator_fg"; type: RECT; mouse_events: 0; + clip_to: "vol_indicator"; + description { state: "default" 0.0; + fixed: 1 1; + rel.to: "vol_indicator_bg"; + color: 255 255 255 255; + } + } + part { name: "vol_indicator"; type: RECT; mouse_events: 0; + description { state: "default" 0.0; + color: 255 255 255 0; + visible: 0; + } + description { state: "visible" 0.0; + inherit: "default" 0.0; + color: 255 255 255 255; + visible: 1; + } + } + STATE_FADE_PROG("volume_up", "vol_indicator") + STATE_FADE_PROG("volume_down", "vol_indicator") part { name: "unmute"; mouse_events: 0; scale: 1; description { state: "default" 0.0; @@ -1054,7 +1157,7 @@ collections { visible: 1; } } - STATE_FADE_PROG("unmute") + STATE_FADE_PROG("unmute", "unmute") part { name: "loop"; mouse_events: 0; scale: 1; description { state: "default" 0.0; @@ -1078,7 +1181,7 @@ collections { visible: 1; } } - STATE_FADE_PROG("loop") + STATE_FADE_PROG("loop", "loop") part { name: "sequential"; mouse_events: 0; scale: 1; description { state: "default" 0.0; @@ -1102,7 +1205,7 @@ collections { visible: 1; } } - STATE_FADE_PROG("sequential") + STATE_FADE_PROG("sequential", "sequential") part { name: "statusloc"; type: SPACER; description { state: "default" 0.0; @@ -1137,7 +1240,7 @@ collections { visible: 1; } } - STATE_FADE_PROG("play") + STATE_FADE_PROG("play", "play") part { name: "pause"; mouse_events: 0; scale: 1; description { state: "default" 0.0; @@ -1158,7 +1261,7 @@ collections { visible: 1; } } - STATE_FADE_PROG("pause") + STATE_FADE_PROG("pause", "pause") part { name: "stop"; mouse_events: 0; scale: 1; description { state: "default" 0.0; @@ -1179,7 +1282,7 @@ collections { visible: 1; } } - STATE_FADE_PROG("stop") + STATE_FADE_PROG("stop", "stop") part { name: "eject"; mouse_events: 0; scale: 1; description { state: "default" 0.0; @@ -1200,7 +1303,7 @@ collections { visible: 1; } } - STATE_FADE_PROG("eject") + STATE_FADE_PROG("eject", "eject") part { name: "forward"; mouse_events: 0; scale: 1; description { state: "default" 0.0; @@ -1221,7 +1324,7 @@ collections { visible: 1; } } - STATE_FADE_PROG("forward") + STATE_FADE_PROG("forward", "forward") part { name: "next"; mouse_events: 0; scale: 1; description { state: "default" 0.0; @@ -1242,7 +1345,7 @@ collections { visible: 1; } } - STATE_FADE_PROG("next") + STATE_FADE_PROG("next", "next") part { name: "rewind"; mouse_events: 0; scale: 1; description { state: "default" 0.0; @@ -1263,7 +1366,7 @@ collections { visible: 1; } } - STATE_FADE_PROG("rewind") + STATE_FADE_PROG("rewind", "rewind") part { name: "prev"; mouse_events: 0; scale: 1; description { state: "default" 0.0; @@ -1284,7 +1387,7 @@ collections { visible: 1; } } - STATE_FADE_PROG("prev") + STATE_FADE_PROG("prev", "prev") part { name: "rage.options.swallow"; type: SWALLOW; scale: 1; diff --git a/src/bin/controls.c b/src/bin/controls.c index 7187e3c..b0dc7e2 100644 --- a/src/bin/controls.c +++ b/src/bin/controls.c @@ -81,6 +81,23 @@ _cb_win_close(void *data EINA_UNUSED, Evas_Object *obj, const char *emission EIN evas_object_del(elm_object_top_widget_get(obj)); } +static void +_cb_vol(void *data, Evas_Object *obj, void *info EINA_UNUSED) +{ + win_do_volume(data, elm_slider_value_get(obj) / 100.0); +} + +static void +_cb_action_vol(void *data, Evas_Object *obj EINA_UNUSED, const char *emission EINA_UNUSED, const char *source EINA_UNUSED) +{ + Inf *inf = evas_object_data_get(data, "inf"); + video_mute_set(inf->vid, !video_mute_get(inf->vid)); + if (video_mute_get(inf->vid)) + elm_layout_signal_emit(inf->lay, "action,mute", "rage"); + else + elm_layout_signal_emit(inf->lay, "action,unmute", "rage"); +} + static void _time_print(double t, double max, int size, char *buf, Eina_Bool subsec) { @@ -143,6 +160,8 @@ controls_init(Evas_Object *win, Evas_Object *lay) _cb_pos_pause, win); elm_layout_signal_callback_add(lay, "pos,action,options", "rage", _cb_options, win); + elm_layout_signal_callback_add(lay, "pos,action,vol", "rage", + _cb_action_vol, win); elm_layout_signal_callback_add(lay, "list,show", "rage", _cb_list_show, win); elm_layout_signal_callback_add(lay, "list,hide", "rage", @@ -164,13 +183,21 @@ controls_init(Evas_Object *win, Evas_Object *lay) elm_object_part_content_set(lay, _nam, o) FINGER_SIZE("rage.pos.swallow"); - FINGER_SIZE("rage.vol.swallow"); +// FINGER_SIZE("rage.vol.swallow"); FINGER_SIZE("rage.options.swallow"); FINGER_SIZE("rage.win.fullscreen"); FINGER_SIZE("rage.win.close"); FINGER_SIZE("rage.pos.prev.swallow"); FINGER_SIZE("rage.pos.play.swallow"); FINGER_SIZE("rage.pos.next.swallow"); + + o = elm_slider_add(win); + elm_object_focus_allow_set(o, EINA_FALSE); + elm_slider_min_max_set(o, 0, 100); + elm_slider_indicator_format_set(o, "%1.0f"); + evas_object_smart_callback_add(o, "changed", _cb_vol, win); + elm_object_part_content_set(lay, "rage.vol.swallow", o); + evas_object_show(o); } void diff --git a/src/bin/key.c b/src/bin/key.c index 6421efe..5b56678 100644 --- a/src/bin/key.c +++ b/src/bin/key.c @@ -79,9 +79,7 @@ key_handle(Evas_Object *win, Evas_Event_Key_Down *ev) { double vol = video_volume_get(inf->vid) + 0.05; if (vol > 1.0) vol = 1.0; - video_volume_set(inf->vid, vol); - elm_layout_signal_emit(inf->lay, "action,volume_up", "rage"); - mpris_volume_change(); + win_do_volume(win, vol); } } else if ((!strcmp(ev->key, "Down")) || @@ -95,9 +93,7 @@ key_handle(Evas_Object *win, Evas_Event_Key_Down *ev) { double vol = video_volume_get(inf->vid) - 0.05; if (vol < 0.0) vol = 0.0; - video_volume_set(inf->vid, vol); - elm_layout_signal_emit(inf->lay, "action,volume_down", "rage"); - mpris_volume_change(); + win_do_volume(win, vol); } } else if ((!strcmp(ev->key, "space")) || diff --git a/src/bin/video.c b/src/bin/video.c index 35d5a63..7586cc0 100644 --- a/src/bin/video.c +++ b/src/bin/video.c @@ -281,6 +281,7 @@ _cb_play_start(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED Video *sd = evas_object_smart_data_get(data); if (!sd) return; evas_object_smart_callback_call(data, "play_start", NULL); + evas_object_smart_callback_call(data, "audio", NULL); mpris_metadata_change(); } @@ -290,6 +291,7 @@ _cb_play_finish(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSE Video *sd = evas_object_smart_data_get(data); if (!sd) return; evas_object_smart_callback_call(data, "play_finish", NULL); + evas_object_smart_callback_call(data, "audio", NULL); mpris_metadata_change(); } @@ -701,6 +703,7 @@ video_mute_set(Evas_Object *obj, Eina_Bool mute) Video *sd = evas_object_smart_data_get(obj); if (!sd) return; emotion_object_audio_mute_set(sd->o_vid, mute); + evas_object_smart_callback_call(obj, "audio", NULL); } Eina_Bool @@ -885,6 +888,7 @@ video_volume_set(Evas_Object *obj, double vol) Video *sd = evas_object_smart_data_get(obj); if (!sd) return; emotion_object_audio_volume_set(sd->o_vid, vol); + evas_object_smart_callback_call(obj, "audio", NULL); } double diff --git a/src/bin/win.c b/src/bin/win.c index 0a44b24..589d0fc 100644 --- a/src/bin/win.c +++ b/src/bin/win.c @@ -397,6 +397,25 @@ win_do_next(Evas_Object *win) } } +void +win_do_volume(Evas_Object *win, double vol) +{ + Inf *inf = evas_object_data_get(win, "inf"); + Edje_Message_Float msg; + double curvol; + + curvol = video_volume_get(inf->vid); + video_volume_set(inf->vid, vol); + msg.val = vol; + edje_object_message_send(elm_layout_edje_get(inf->lay), + EDJE_MESSAGE_FLOAT, 1, &msg); + mpris_volume_change(); + if (vol < curvol) + elm_layout_signal_emit(inf->lay, "action,volume_down", "rage"); + else + elm_layout_signal_emit(inf->lay, "action,volume_up", "rage"); +} + static void _restart_vid(Evas_Object *win, Evas_Object *lay, Evas_Object *vid, const char *file, const char *sub) { diff --git a/src/bin/win.h b/src/bin/win.h index 1a83e6a..c41ee0e 100644 --- a/src/bin/win.h +++ b/src/bin/win.h @@ -35,6 +35,7 @@ void win_do_pause(Evas_Object *win); void win_do_play_pause(Evas_Object *win); void win_do_prev(Evas_Object *win); void win_do_next(Evas_Object *win); +void win_do_volume(Evas_Object *win, double vol); // lower level controls void win_video_restart(Evas_Object *win); diff --git a/src/bin/winvid.c b/src/bin/winvid.c index 889ed19..939856a 100644 --- a/src/bin/winvid.c +++ b/src/bin/winvid.c @@ -90,6 +90,11 @@ _cb_title(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED) static void _cb_audio(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED) { + Inf *inf = evas_object_data_get(data, "inf"); + Evas_Object *sl = elm_object_part_content_get(inf->lay, "rage.vol.swallow"); + double vol = video_volume_get(inf->vid); + printf("%1.2f\n", vol); + elm_slider_value_set(sl, vol * 100); win_title_update(data); }