TizenRefApp-8251 [Gallery] Implement custom image button style 33/121333/2
authorIgor Nazarov <i.nazarov@samsung.com>
Mon, 27 Mar 2017 16:12:06 +0000 (19:12 +0300)
committerIgor Nazarov <i.nazarov@samsung.com>
Tue, 28 Mar 2017 09:09:53 +0000 (12:09 +0300)
- Added custom button style for image items: "gellery_image".

Change-Id: I93fc136e2e64731ee1c210d342d79fa31f06d969

edc/button.edc [new file with mode: 0644]
edc/colors.h [new file with mode: 0644]
res/edje/theme.edc

diff --git a/edc/button.edc b/edc/button.edc
new file mode 100644 (file)
index 0000000..62f62a8
--- /dev/null
@@ -0,0 +1,176 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Copied from default theme in order to inherit
+group{ "elm/button/base/transparent";
+   script {
+      public mouse_down = 0;
+      public multi_down = 0;
+   }
+   parts {
+      spacer { "bg";
+         scale;
+         desc { "default";
+         }
+         desc { "disabled";
+            inherit: "default";
+         }
+      }
+      swallow { "elm.swallow.content";
+         scale;
+         desc { "default";
+         }
+      }
+      rect { "event";
+         scale;
+         repeat;
+         desc { "default";
+            color: 0 0 0 0;
+         }
+      }
+   }
+   programs {
+      program { "pressed";
+         signal: "mouse,down,1*";
+         source: "event";
+         script {
+            if ((get_int(multi_down) == 0) && (get_int(mouse_down) == 0)) {
+               set_int(mouse_down, 1);
+               run_program(PROGRAM:"button_press1");
+            }
+         }
+      }
+      program { "button_press1";
+         script {
+            new st[31];
+            new Float:vl;
+            get_state(PART:"bg", st, 30, vl);
+            if (strcmp(st, "disabled")) {
+               emit("elm,action,press", "");
+            }
+         }
+      }
+      program { "unpressed";
+         signal: "mouse,up,1";
+         source: "event";
+         script {
+            if (get_int(mouse_down) == 1) {
+               set_int(mouse_down, 0);
+               run_program(PROGRAM:"button_unpress1");
+            }
+         }
+      }
+      program { "button_unpress1";
+         script {
+            new st[31];
+            new Float:vl;
+            get_state(PART:"bg", st, 30, vl);
+            if (strcmp(st, "disabled")) {
+               emit("elm,action,unpress", "");
+            }
+         }
+      }
+      program { "touch_snd";
+         signal: "mouse,clicked,1";
+         source: "event";
+         script {
+            new st[31];
+            new Float:vl;
+            if (get_int(multi_down) == 0) {
+               get_state(PART:"bg", st, 30, vl);
+               if (strcmp(st, "disabled")) {
+                  run_program(PROGRAM:"touch_sound");
+                  emit("elm,action,click", "");
+               }
+            }
+         }
+      }
+      program { "touch_sound";
+         action: RUN_PLUGIN "touch_sound";
+      }
+      program { "disable";
+         signal: "elm,state,disabled";
+         source: "elm";
+         action: STATE_SET "disabled";
+         target: "bg";
+      }
+      program { "enable";
+         signal: "elm,state,enabled";
+         source: "elm";
+         action: STATE_SET "default";
+         target: "bg";
+      }
+      program { "multi_down";
+         signal: "elm,action,multi,down";
+         source: "elm";
+         script {
+            set_int(multi_down, 1);
+         }
+      }
+      program { "multi_up";
+         signal: "elm,action,multi,up";
+         source: "elm";
+         script {
+            set_int(multi_down, 0);
+         }
+      }
+   }
+}
+
+group{ "elm/button/base/gallery_image";
+   inherit: "elm/button/base/transparent";
+   parts {
+      rect { "event";
+         desc { "default";
+            color: GALLERY_COLOR_IMG_EF_NORMAL;
+         }
+         desc { "pressed";
+            inherit: "default";
+            color: GALLERY_COLOR_IMG_EF_PRESSED;
+         }
+         desc { "disabled";
+            inherit: "default";
+            color: GALLERY_COLOR_IMG_EF_DISABLED;
+         }
+      }
+   }
+   programs {
+      program { "on_disabled";
+         signal: "elm,state,disabled";
+         source: "elm";
+         action: STATE_SET "disabled";
+         target: "event";
+      }
+      program { "on_enabled";
+         signal: "elm,state,enabled";
+         source: "elm";
+         action: STATE_SET "default";
+         target: "event";
+      }
+      program { "on_press";
+         signal: "elm,action,press";
+         source: "";
+         action: STATE_SET "pressed";
+         target: "event";
+      }
+      program { "on_unpress";
+         signal: "elm,action,unpress";
+         source: "";
+         action: STATE_SET "default";
+         target: "event";
+      }
+   }
+}
diff --git a/edc/colors.h b/edc/colors.h
new file mode 100644 (file)
index 0000000..7675467
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __GALLERY_EDC_COLORS_H__
+#define __GALLERY_EDC_COLORS_H__
+
+#define GALLERY_COLOR_AO0112 0 0 0 0
+#define GALLERY_COLOR_AO0112P 0 0 0 102
+#define GALLERY_COLOR_AO0112D 0 0 0 77
+
+#define GALLERY_COLOR_IMG_EF_NORMAL GALLERY_COLOR_AO0112
+#define GALLERY_COLOR_IMG_EF_PRESSED GALLERY_COLOR_AO0112P
+#define GALLERY_COLOR_IMG_EF_DISABLED GALLERY_COLOR_AO0112D
+
+#endif // __GALLERY_EDC_COLORS_H__
index b31271be0433184e6434e7edd8eaae8a12b49902..c08bd4a4607d440ae5013018d7fe47a9c0b15e9c 100644 (file)
 collections {
    base_scale: 1.3;
 
+   plugins {
+      plugin {
+         name: "touch_sound";
+         source: "feedback";
+         param: "FEEDBACK_TYPE_SOUND FEEDBACK_PATTERN_TAP";
+      }
+   }
+
+   #include "../../edc/colors.h"
    #include "../../edc/image-grid.edc"
+   #include "../../edc/button.edc"
 }