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: 2f96c2653b
Author: Thilo Graf <dbt@novatux.de>
Date: 2015-02-16 (Mon, 16 Feb 2015)



------------------
This commit was generated by Migit
This commit is contained in:
2015-02-16 22:25:32 +01:00
committed by vanhofen
parent 9a426f468e
commit 450e17342e

View File

@@ -1771,25 +1771,33 @@ int CLuaInstance::CWindowNew(lua_State *L)
else { else {
CComponentsFooter* footer = (*udata)->w->getFooterObject(); CComponentsFooter* footer = (*udata)->w->getFooterObject();
if (footer) { if (footer) {
int btnCount = 0; vector<button_label_s> buttons;
if (!btnRed.empty()) btnCount++; if (!btnRed.empty()){
if (!btnGreen.empty()) btnCount++; button_label_s btnSred;
if (!btnYellow.empty()) btnCount++; btnSred.button = NEUTRINO_ICON_BUTTON_RED;
if (!btnBlue.empty()) btnCount++; btnSred.text = btnRed;
if (btnCount) { buttons.push_back(btnSred);
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));
} }
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));
} }
} }