From: Ji-hoon Lee Date: Fri, 3 Feb 2017 08:38:57 +0000 (+0900) Subject: Add interface for querying geometry of a button X-Git-Tag: accepted/tizen/3.0/common/20170208.145348~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9c9c9bfbfdc9154fb2d1a72439126d09f7a41999;p=platform%2Fcore%2Fuifw%2Flibscl-ui.git Add interface for querying geometry of a button Change-Id: Ib3c96f9e84862aefb3a0558e37a9b976e29f9f08 --- diff --git a/scl/include/sclresourcecache.h b/scl/include/sclresourcecache.h index 548d2b1..8f128a8 100644 --- a/scl/include/sclresourcecache.h +++ b/scl/include/sclresourcecache.h @@ -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); diff --git a/scl/include/sclui.h b/scl/include/sclui.h index 28c9d62..4649a80 100644 --- a/scl/include/sclui.h +++ b/scl/include/sclui.h @@ -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; }; diff --git a/scl/include/scluiimpl.h b/scl/include/scluiimpl.h index 350b657..eb97cff 100644 --- a/scl/include/scluiimpl.h +++ b/scl/include/scluiimpl.h @@ -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; diff --git a/scl/sclresourcecache.cpp b/scl/sclresourcecache.cpp index 7bdc692..56858c5 100644 --- a/scl/sclresourcecache.cpp +++ b/scl/sclresourcecache.cpp @@ -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) { diff --git a/scl/sclui.cpp b/scl/sclui.cpp index 8755ebf..a122648 100644 --- a/scl/sclui.cpp +++ b/scl/sclui.cpp @@ -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 diff --git a/scl/scluiimpl.cpp b/scl/scluiimpl.cpp index 0f7e444..9be28cf 100644 --- a/scl/scluiimpl.cpp +++ b/scl/scluiimpl.cpp @@ -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; +}