Add interface for querying geometry of a button 28/112928/1
authorJi-hoon Lee <dalton.lee@samsung.com>
Fri, 3 Feb 2017 08:38:57 +0000 (17:38 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Fri, 3 Feb 2017 08:38:57 +0000 (17:38 +0900)
Change-Id: Ib3c96f9e84862aefb3a0558e37a9b976e29f9f08

scl/include/sclresourcecache.h
scl/include/sclui.h
scl/include/scluiimpl.h
scl/sclresourcecache.cpp
scl/sclui.cpp
scl/scluiimpl.cpp

index 548d2b1..8f128a8 100644 (file)
@@ -79,6 +79,7 @@ public:
     void clone_keyproperties(SclPrivateKeyProperties* priv, sclbyte input_mode_index, sclbyte layout_index, sclbyte key_index);
 
     void enable_button(const sclchar* custom_id, sclboolean enabled);
+    sclboolean get_button_geometry(const sclchar* custom_id, SclRectangle *rectangle);
 
     void set_string_substitution(const sclchar *original, const sclchar *substitute);
     void unset_string_substitution(const sclchar *original);
index 28c9d62..4649a80 100644 (file)
@@ -444,6 +444,12 @@ public:
      */
     sclboolean process_key_event(const char *key);
 
+    /**
+     * @brief This API request SCL library to return the geometry information of a button with given ID
+     * @param[in] custom_id the name of the key to be queried
+     * @return non-zero value is returned when successful
+     */
+    sclboolean get_button_geometry(const sclchar* custom_id, SclRectangle *rectangle);
 private:
     CSCLUIImpl *m_impl;
 };
index 350b657..eb97cff 100644 (file)
@@ -127,6 +127,7 @@ public:
     void set_autocapital_shift_state(sclboolean flag);
 
     sclboolean process_key_event(const char *key);
+    sclboolean get_button_geometry(const sclchar* custom_id, SclRectangle *rectangle);
 
 private:
     sclboolean m_initialized;
index 7bdc692..56858c5 100644 (file)
@@ -1743,6 +1743,50 @@ void CSCLResourceCache::enable_button(const sclchar *custom_id, sclboolean enabl
     }
 }
 
+/**
+* Get geometry information of a button with given custom_id
+*/
+sclboolean CSCLResourceCache::get_button_geometry(const sclchar* custom_id, SclRectangle *rectangle)
+{
+    SCL_DEBUG();
+
+    CSCLContext *context = CSCLContext::get_instance();
+    SclResParserManager *sclres_manager = SclResParserManager::get_instance();
+
+    if (!context || !sclres_manager) return FALSE;
+
+    sclint loop;
+    if (custom_id && rectangle) {
+        sclbyte layout_index = NOT_USED;
+        PSclLayoutKeyCoordinatePointerTable sclres_layout_key_coordinate_pointer_frame =
+            sclres_manager->get_key_coordinate_pointer_frame();
+        if (!sclres_layout_key_coordinate_pointer_frame) return FALSE;
+
+        if (context) {
+            layout_index = context->get_base_layout();
+        }
+        if (scl_check_arrindex_unsigned(layout_index, MAX_SCL_LAYOUT)) {
+            for (loop = 0;loop < MAX_KEY;loop++) {
+                SclLayoutKeyCoordinatePointer p =
+                    sclres_layout_key_coordinate_pointer_frame[layout_index][loop];
+                if (!p || !(p->valid)) break;
+                if (p->custom_id) {
+                    if (strcmp(p->custom_id, custom_id) == 0) {
+                        rectangle->x = p->x;
+                        rectangle->y = p->y;
+                        rectangle->width = p->width;
+                        rectangle->height = p->height;
+
+                        return TRUE;
+                    }
+                }
+            }
+        }
+    }
+
+    return FALSE;
+}
+
 void
 CSCLResourceCache::set_string_substitution(const sclchar *original, const sclchar *substitute)
 {
index 8755ebf..a122648 100644 (file)
@@ -699,3 +699,12 @@ CSCLUI::process_key_event(const char *key)
     }
     return FALSE;
 }
+
+sclboolean
+CSCLUI::get_button_geometry(const sclchar* custom_id, SclRectangle *rectangle)
+{
+    if (m_impl) {
+        return m_impl->get_button_geometry(custom_id, rectangle);
+    }
+    return FALSE;
+}
\ No newline at end of file
index 0f7e444..9be28cf 100644 (file)
@@ -1170,3 +1170,13 @@ CSCLUIImpl::process_key_event(const char *key)
     }
     return FALSE;
 }
+
+sclboolean
+CSCLUIImpl::get_button_geometry(const sclchar* custom_id, SclRectangle *rectangle)
+{
+    if (m_initialized) {
+        CSCLResourceCache *cache= CSCLResourceCache::get_instance();
+        return cache->get_button_geometry(custom_id, rectangle);
+    }
+    return FALSE;
+}