From 450e17342e7ce306d566a9846d10965433bca204 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Mon, 16 Feb 2015 22:25:32 +0100 Subject: [PATCH] CLuaInstance: implement current method for generation of button labels in footer object This controls more effective fontsize and button arrangement. Lua API is not touched. TODO: add more possible buttons. Color buttons for sure are not be enough for some applications. Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/2f96c2653b6cfe231a153097acded36091390f1a Author: Thilo Graf Date: 2015-02-16 (Mon, 16 Feb 2015) ------------------ This commit was generated by Migit --- src/gui/luainstance.cpp | 44 ++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index 505b1a636..ae31a542e 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -1771,25 +1771,33 @@ int CLuaInstance::CWindowNew(lua_State *L) else { CComponentsFooter* footer = (*udata)->w->getFooterObject(); if (footer) { - int btnCount = 0; - if (!btnRed.empty()) btnCount++; - if (!btnGreen.empty()) btnCount++; - if (!btnYellow.empty()) btnCount++; - if (!btnBlue.empty()) btnCount++; - if (btnCount) { - fb_pixel_t col = footer->getColorBody(); - int btnw = (dx-20) / btnCount; - int btnh = footer->getHeight(); - int start = 10; - if (!btnRed.empty()) - footer->addCCItem(new CComponentsButtonRed(start, CC_CENTERED, btnw, btnh, btnRed, 0, false , true, false, col, col)); - if (!btnGreen.empty()) - footer->addCCItem(new CComponentsButtonGreen(start+=btnw, CC_CENTERED, btnw, btnh, btnGreen, 0, false , true, false, col, col)); - if (!btnYellow.empty()) - footer->addCCItem(new CComponentsButtonYellow(start+=btnw, CC_CENTERED, btnw, btnh, btnYellow, 0, false , true, false, col, col)); - if (!btnBlue.empty()) - footer->addCCItem(new CComponentsButtonBlue(start+=btnw, CC_CENTERED, btnw, btnh, btnBlue, 0, false , true, false, col, col)); + vector buttons; + if (!btnRed.empty()){ + button_label_s btnSred; + btnSred.button = NEUTRINO_ICON_BUTTON_RED; + btnSred.text = btnRed; + buttons.push_back(btnSred); } + if (!btnGreen.empty()){ + button_label_s btnSgreen; + btnSgreen.button = NEUTRINO_ICON_BUTTON_GREEN; + btnSgreen.text = btnGreen; + buttons.push_back(btnSgreen); + } + if (!btnYellow.empty()){ + button_label_s btnSyellow; + btnSyellow.button = NEUTRINO_ICON_BUTTON_YELLOW; + btnSyellow.text = btnYellow; + buttons.push_back(btnSyellow); + } + if (!btnBlue.empty()){ + button_label_s btnSblue; + btnSblue.button = NEUTRINO_ICON_BUTTON_YELLOW; + btnSblue.text = btnBlue; + buttons.push_back(btnSblue); + } + if(!buttons.empty()) + footer->setButtonLabels(buttons, dx-20, (dx-20) / (buttons.size()+1)); } }