From 7e874ddf64a4255aa9c9792ab95bc7acce02447d Mon Sep 17 00:00:00 2001 From: Jacek Jendrzej Date: Sun, 21 Aug 2016 16:17:28 +0200 Subject: [PATCH] lua_cc_picture: add cpicture getHeight / getWidth option Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/d5051a100fbc738f344749d30c51a47b6eb551df Author: Jacek Jendrzej Date: 2016-08-21 (Sun, 21 Aug 2016) --- src/gui/lua/lua_cc_picture.cpp | 22 ++++++++++++++++++++++ src/gui/lua/lua_cc_picture.h | 2 ++ 2 files changed, 24 insertions(+) diff --git a/src/gui/lua/lua_cc_picture.cpp b/src/gui/lua/lua_cc_picture.cpp index 926bb520f..b383bd79b 100644 --- a/src/gui/lua/lua_cc_picture.cpp +++ b/src/gui/lua/lua_cc_picture.cpp @@ -57,6 +57,8 @@ void CLuaInstCCPicture::CCPictureRegister(lua_State *L) { "hide", CLuaInstCCPicture::CCPictureHide }, { "setPicture", CLuaInstCCPicture::CCPictureSetPicture }, { "setCenterPos", CLuaInstCCPicture::CCPictureSetCenterPos }, + { "getHeight", CLuaInstCCPicture::CCPictureGetHeight }, + { "getWidth", CLuaInstCCPicture::CCPictureGetWidth }, { "__gc", CLuaInstCCPicture::CCPictureDelete }, { NULL, NULL } }; @@ -126,6 +128,26 @@ int CLuaInstCCPicture::CCPictureNew(lua_State *L) return 1; } +int CLuaInstCCPicture::CCPictureGetHeight(lua_State *L) +{ + CLuaCCPicture *D = CCPictureCheck(L, 1); + if (!D) return 0; + + int h = D->cp->getHeight(); + lua_pushinteger(L, h); + return 1; +} + +int CLuaInstCCPicture::CCPictureGetWidth(lua_State *L) +{ + CLuaCCPicture *D = CCPictureCheck(L, 1); + if (!D) return 0; + + int w = D->cp->getWidth(); + lua_pushinteger(L, w); + return 1; +} + int CLuaInstCCPicture::CCPicturePaint(lua_State *L) { lua_assert(lua_istable(L,1)); diff --git a/src/gui/lua/lua_cc_picture.h b/src/gui/lua/lua_cc_picture.h index 2fb7c3e14..8bbc697ad 100644 --- a/src/gui/lua/lua_cc_picture.h +++ b/src/gui/lua/lua_cc_picture.h @@ -46,6 +46,8 @@ class CLuaInstCCPicture static int CCPictureHide(lua_State *L); static int CCPictureSetPicture(lua_State *L); static int CCPictureSetCenterPos(lua_State *L); + static int CCPictureGetHeight(lua_State *L); + static int CCPictureGetWidth(lua_State *L); static int CCPictureDelete(lua_State *L); };