summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-11-03 16:16:45 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-11-03 16:16:45 +0900
commit2be56cd8da7ae656f37f3894c1e5a6f66ff9f4b2 (patch)
treec3dff9c370d53cf6979d49756da6ef59861d69a1 /src/modules
parentd4ea0987fe6ad2c704b3fa7488968072b4d63ab6 (diff)
shot - add a padded screenshot so it can also grab shadows/surrounds
nice to get a shot that also has the shadows etc. add as menu and param options @feature
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/shot/e_mod_main.c89
1 files changed, 65 insertions, 24 deletions
diff --git a/src/modules/shot/e_mod_main.c b/src/modules/shot/e_mod_main.c
index 9929dd6..fd0599a 100644
--- a/src/modules/shot/e_mod_main.c
+++ b/src/modules/shot/e_mod_main.c
@@ -605,6 +605,7 @@ _save_dialog_show(E_Zone *zone, E_Client *ec, const char *params, void *dst, int
605 Evas_Modifier_Mask mask; 605 Evas_Modifier_Mask mask;
606 E_Radio_Group *rg; 606 E_Radio_Group *rg;
607 int w, h; 607 int w, h;
608 char smode[128], squal[128], sscreen[128];
608 609
609 win = elm_win_add(NULL, NULL, ELM_WIN_BASIC); 610 win = elm_win_add(NULL, NULL, ELM_WIN_BASIC);
610 611
@@ -768,27 +769,23 @@ _save_dialog_show(E_Zone *zone, E_Client *ec, const char *params, void *dst, int
768 evas_object_size_hint_min_set(win, w, h); 769 evas_object_size_hint_min_set(win, w, h);
769 evas_object_size_hint_max_set(win, 99999, 99999); 770 evas_object_size_hint_max_set(win, 99999, 99999);
770 771
771 if (params) 772 if ((params) &&
773 (sscanf(params, "%100s %100s %100s", smode, squal, sscreen) == 3))
772 { 774 {
773 char smode[128], squal[128], sscreen[128]; 775 screen = -1;
774 776 if ((zone) && (!strcmp(sscreen, "current"))) screen = zone->num;
775 if (sscanf(params, "%100s %100s %100s", smode, squal, sscreen) == 3) 777 else if (!strcmp(sscreen, "all")) screen = -1;
776 { 778 else screen = atoi(sscreen);
777 screen = -1; 779
778 if ((zone) && (!strcmp(sscreen, "current"))) screen = zone->num; 780 quality = 90;
779 else if (!strcmp(sscreen, "all")) screen = -1; 781 if (!strcmp(squal, "perfect")) quality = 100;
780 else screen = atoi(sscreen); 782 else if (!strcmp(squal, "high")) quality = 90;
781 783 else if (!strcmp(squal, "medium")) quality = 70;
782 quality = 90; 784 else if (!strcmp(squal, "low")) quality = 50;
783 if (!strcmp(squal, "perfect")) quality = 100; 785 else quality = atoi(squal);
784 else if (!strcmp(squal, "high")) quality = 90; 786
785 else if (!strcmp(squal, "medium")) quality = 70; 787 if (!strcmp(smode, "save")) _win_save_cb(NULL, NULL);
786 else if (!strcmp(squal, "low")) quality = 50; 788 else if (!strcmp(smode, "share")) _win_share_cb(NULL, NULL);
787 else quality = atoi(squal);
788
789 if (!strcmp(smode, "save")) _win_save_cb(NULL, NULL);
790 else if (!strcmp(smode, "share")) _win_share_cb(NULL, NULL);
791 }
792 } 789 }
793 else 790 else
794 { 791 {
@@ -832,7 +829,22 @@ _shot_now(E_Zone *zone, E_Client *ec, const char *params)
832 } 829 }
833 else 830 else
834 { 831 {
835 x = ec->x, y = ec->y, w = ec->w, h = ec->h; 832 int pad = 0;
833
834 if (params)
835 {
836 const char *p = strstr(params, "pad ");
837
838 if (p)
839 {
840 pad = atoi(p + 4);
841 if (pad < 0) pad = 0;
842 }
843 }
844 x = ec->x - pad;
845 y = ec->y - pad;
846 w = ec->w + (pad * 2);
847 h = ec->h + (pad * 2);
836 x = E_CLAMP(x, 0, e_comp->w); 848 x = E_CLAMP(x, 0, e_comp->w);
837 y = E_CLAMP(y, 0, e_comp->h); 849 y = E_CLAMP(y, 0, e_comp->h);
838 w = E_CLAMP(w, 1, e_comp->w); 850 w = E_CLAMP(w, 1, e_comp->w);
@@ -876,6 +888,18 @@ _shot_delay_border(void *data)
876 return EINA_FALSE; 888 return EINA_FALSE;
877} 889}
878 890
891static Eina_Bool
892_shot_delay_border_padded(void *data)
893{
894 char buf[128];
895
896 border_timer = NULL;
897 snprintf(buf, sizeof(buf), "pad %i", (int)(64 * e_scale));
898 _shot_now(NULL, data, buf);
899
900 return EINA_FALSE;
901}
902
879static void 903static void
880_shot_border(E_Client *ec) 904_shot_border(E_Client *ec)
881{ 905{
@@ -884,6 +908,13 @@ _shot_border(E_Client *ec)
884} 908}
885 909
886static void 910static void
911_shot_border_padded(E_Client *ec)
912{
913 if (border_timer) ecore_timer_del(border_timer);
914 border_timer = ecore_timer_loop_add(1.0, _shot_delay_border_padded, ec);
915}
916
917static void
887_shot(E_Zone *zone) 918_shot(E_Zone *zone)
888{ 919{
889 if (timer) ecore_timer_del(timer); 920 if (timer) ecore_timer_del(timer);
@@ -897,13 +928,19 @@ _e_mod_menu_border_cb(void *data, E_Menu *m EINA_UNUSED, E_Menu_Item *mi EINA_UN
897} 928}
898 929
899static void 930static void
931_e_mod_menu_border_padded_cb(void *data, E_Menu *m EINA_UNUSED, E_Menu_Item *mi EINA_UNUSED)
932{
933 _shot_border_padded(data);
934}
935
936static void
900_e_mod_menu_cb(void *data EINA_UNUSED, E_Menu *m, E_Menu_Item *mi EINA_UNUSED) 937_e_mod_menu_cb(void *data EINA_UNUSED, E_Menu *m, E_Menu_Item *mi EINA_UNUSED)
901{ 938{
902 if (m->zone) _shot(m->zone); 939 if (m->zone) _shot(m->zone);
903} 940}
904 941
905static void 942static void
906_e_mod_action_border_cb(E_Object *obj EINA_UNUSED, const char *params EINA_UNUSED) 943_e_mod_action_border_cb(E_Object *obj EINA_UNUSED, const char *params)
907{ 944{
908 E_Client *ec; 945 E_Client *ec;
909 946
@@ -914,7 +951,7 @@ _e_mod_action_border_cb(E_Object *obj EINA_UNUSED, const char *params EINA_UNUSE
914 ecore_timer_del(border_timer); 951 ecore_timer_del(border_timer);
915 border_timer = NULL; 952 border_timer = NULL;
916 } 953 }
917 _shot_now(NULL, ec, NULL); 954 _shot_now(NULL, ec, params);
918} 955}
919 956
920typedef struct 957typedef struct
@@ -985,6 +1022,10 @@ _bd_hook(void *d EINA_UNUSED, E_Client *ec)
985 e_menu_item_label_set(mi, _("Take Shot")); 1022 e_menu_item_label_set(mi, _("Take Shot"));
986 e_util_menu_item_theme_icon_set(mi, "screenshot"); 1023 e_util_menu_item_theme_icon_set(mi, "screenshot");
987 e_menu_item_callback_set(mi, _e_mod_menu_border_cb, ec); 1024 e_menu_item_callback_set(mi, _e_mod_menu_border_cb, ec);
1025 mi = e_menu_item_new_relative(m, mi);
1026 e_menu_item_label_set(mi, _("Take Padded Shot"));
1027 e_util_menu_item_theme_icon_set(mi, "screenshot");
1028 e_menu_item_callback_set(mi, _e_mod_menu_border_padded_cb, ec);
988} 1029}
989 1030
990static void 1031static void
@@ -1032,7 +1073,7 @@ e_modapi_init(E_Module *m)
1032 border_act->func.go = _e_mod_action_border_cb; 1073 border_act->func.go = _e_mod_action_border_cb;
1033 e_action_predef_name_set(N_("Window : Actions"), N_("Take Shot"), 1074 e_action_predef_name_set(N_("Window : Actions"), N_("Take Shot"),
1034 "border_shot", NULL, 1075 "border_shot", NULL,
1035 "syntax: [share|save perfect|high|medium|low|QUALITY all|current]", 1); 1076 "syntax: [share|save perfect|high|medium|low|QUALITY all|current] [pad N]", 1);
1036 } 1077 }
1037 maug = e_int_menus_menu_augmentation_add_sorted 1078 maug = e_int_menus_menu_augmentation_add_sorted
1038 ("main/2", _("Take Screenshot"), _e_mod_menu_add, NULL, NULL, NULL); 1079 ("main/2", _("Take Screenshot"), _e_mod_menu_add, NULL, NULL, NULL);