keychooser: strip unneeded code; use hintbox instead of handcrafted paints

Origin commit data
------------------
Commit: 5370086103
Author: vanhofen <vanhofen@gmx.de>
Date: 2017-09-15 (Fri, 15 Sep 2017)

Origin message was:
------------------
- keychooser: strip unneeded code; use hintbox instead of handcrafted paints
This commit is contained in:
vanhofen
2017-09-15 12:41:06 +02:00
committed by Jacek Jendrzej
parent 2889d6a454
commit b6d05461a8
6 changed files with 39 additions and 156 deletions

View File

@@ -873,8 +873,7 @@ keybindingmenu.volumedown Leiser
keybindingmenu.volumeup Lauter keybindingmenu.volumeup Lauter
keybindingmenu.zaphistory Zapping-History Bouquet keybindingmenu.zaphistory Zapping-History Bouquet
keychooser.head Neue Taste einstellen keychooser.head Neue Taste einstellen
keychooser.text1 Bitte Taste drücken keychooser.text Neue Taste drücken.\nZum Abbrechen ein paar Sekunden warten ...
keychooser.text2 Zum Abbrechen warten ...
keychoosermenu.currentkey Derzeitige Taste keychoosermenu.currentkey Derzeitige Taste
keychoosermenu.setnew Neue Taste einstellen keychoosermenu.setnew Neue Taste einstellen
keychoosermenu.setnone Keine Taste keychoosermenu.setnone Keine Taste

View File

@@ -872,9 +872,8 @@ keybindingmenu.volume Volume
keybindingmenu.volumedown Decrease keybindingmenu.volumedown Decrease
keybindingmenu.volumeup Increase keybindingmenu.volumeup Increase
keybindingmenu.zaphistory Zapping History Bouquet keybindingmenu.zaphistory Zapping History Bouquet
keychooser.head Setup new Key keychooser.head Setup new key
keychooser.text1 Please press the new key keychooser.text Press new key.\nWait a few seconds to abort ...
keychooser.text2 wait a few seconds for abort
keychoosermenu.currentkey current key keychoosermenu.currentkey current key
keychoosermenu.setnew setup new key keychoosermenu.setnew setup new key
keychoosermenu.setnone no key keychoosermenu.setnone no key

View File

@@ -2,31 +2,21 @@
Neutrino-GUI - DBoxII-Project Neutrino-GUI - DBoxII-Project
Copyright (C) 2001 Steffen Hehn 'McClean' Copyright (C) 2001 Steffen Hehn 'McClean'
Homepage: http://dbox.cyberphoria.org/
Kommentar:
Diese GUI wurde von Grund auf neu programmiert und sollte nun vom
Aufbau und auch den Ausbaumoeglichkeiten gut aussehen. Neutrino basiert
auf der Client-Server Idee, diese GUI ist also von der direkten DBox-
Steuerung getrennt. Diese wird dann von Daemons uebernommen.
License: GPL License: GPL
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or
it under the terms of the GNU General Public License as published by modify it under the terms of the GNU General Public
the Free Software Foundation; either version 2 of the License, or License as published by the Free Software Foundation; either
(at your option) any later version. version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
GNU General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program. If not, see <http://www.gnu.org/licenses/>.
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
@@ -38,73 +28,36 @@
#include <global.h> #include <global.h>
#include <neutrino.h> #include <neutrino.h>
#include <gui/color.h> #include <gui/widget/hintbox.h>
#include <driver/screen_max.h>
#include <driver/fontrenderer.h>
class CKeyValue : public CMenuSeparator
{
std::string the_text;
public:
int keyvalue;
CKeyValue(int k) : CMenuSeparator(CMenuSeparator::STRING, LOCALE_KEYCHOOSERMENU_CURRENTKEY)
{
keyvalue = k;
};
virtual const char * getName(void)
{
the_text = g_Locale->getText(LOCALE_KEYCHOOSERMENU_CURRENTKEY);
the_text += ": ";
the_text += CRCInput::getKeyName(keyvalue);
return the_text.c_str();
};
};
CKeyChooser::CKeyChooser(unsigned int * const Key, const neutrino_locale_t title, const std::string & Icon) : CMenuWidget(title, Icon) CKeyChooser::CKeyChooser(unsigned int * const Key, const neutrino_locale_t title, const std::string & Icon) : CMenuWidget(title, Icon)
{ {
frameBuffer = CFrameBuffer::getInstance();
key = Key; key = Key;
keyName = CRCInput::getKeyName(*key); keyName = CRCInput::getKeyName(*key);
keyChooser = new CKeyChooserItem(LOCALE_KEYCHOOSER_HEAD, key);
keyDeleter = new CKeyChooserItemNoKey(key);
addItem(new CKeyValue(*key)); addIntroItems();
addItem(new CMenuForwarder(LOCALE_KEYCHOOSERMENU_SETNEW, true, NULL, new CKeyChooserItem(LOCALE_KEYCHOOSER_HEAD, key)));
addItem(new CMenuForwarder(LOCALE_KEYCHOOSERMENU_SETNONE, true, NULL, new CKeyChooserItemNoKey(key)));
addItem(GenericMenuSeparatorLine); addItem(GenericMenuSeparatorLine);
addItem(GenericMenuBack); addItem(new CMenuForwarder(LOCALE_KEYCHOOSERMENU_CURRENTKEY, false, keyName));
addItem(GenericMenuSeparatorLine);
addItem(new CMenuForwarder(LOCALE_KEYCHOOSERMENU_SETNEW, true, NULL, keyChooser));
addItem(new CMenuForwarder(LOCALE_KEYCHOOSERMENU_SETNONE, true, NULL, keyDeleter));
} }
CKeyChooser::~CKeyChooser() CKeyChooser::~CKeyChooser()
{ {
delete keyChooser;
delete keyDeleter;
} }
void CKeyChooser::paint() void CKeyChooser::paint()
{ {
(((CKeyValue *)(items[0]))->keyvalue) = *key;
keyName = CRCInput::getKeyName(*key); keyName = CRCInput::getKeyName(*key);
CMenuWidget::paint(); CMenuWidget::paint();
} }
//*****************************
CKeyChooserItem::CKeyChooserItem(const neutrino_locale_t Name, unsigned int * Key) CKeyChooserItem::CKeyChooserItem(const neutrino_locale_t Name, unsigned int * Key)
{ {
name = Name; name = Name;
key = Key; key = Key;
x = y = width = height = 0;
} }
int CKeyChooserItem::exec(CMenuTarget* parent, const std::string &) int CKeyChooserItem::exec(CMenuTarget* parent, const std::string &)
{ {
neutrino_msg_t msg; neutrino_msg_t msg;
@@ -117,21 +70,25 @@ int CKeyChooserItem::exec(CMenuTarget* parent, const std::string &)
if (parent) if (parent)
parent->hide(); parent->hide();
paint(); // 10 seconds to choose a new key
int timeout = 10;
CHintBox * hintbox = new CHintBox(name, LOCALE_KEYCHOOSER_TEXT, HINTBOX_MIN_WIDTH, NEUTRINO_ICON_SETTINGS, NEUTRINO_ICON_HINT_KEYS);
//hintbox->setTimeOut(timeout);
hintbox->paint();
CFrameBuffer::getInstance()->blit(); CFrameBuffer::getInstance()->blit();
g_RCInput->clearRCMsg(); g_RCInput->clearRCMsg();
g_RCInput->setLongPressAny(true); g_RCInput->setLongPressAny(true);
timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings timeoutEnd = CRCInput::calcTimeoutEnd(timeout);
::TIMING_MENU]);
get_Message: get_Message:
g_RCInput->getMsgAbsoluteTimeout( &msg, &data, &timeoutEnd ); g_RCInput->getMsgAbsoluteTimeout( &msg, &data, &timeoutEnd );
if (msg != CRCInput::RC_timeout) if (msg != CRCInput::RC_timeout)
{ {
// comparing an unsigned int against >= 0 is senseless!
// if ((msg >= 0) && (msg <= CRCInput::RC_MaxRC))
if ((msg >0 ) && (msg <= CRCInput::RC_MaxRC)) if ((msg >0 ) && (msg <= CRCInput::RC_MaxRC))
*key = msg; *key = msg;
else if (CNeutrinoApp::getInstance()->handleMsg(msg, data) & messages_return::cancel_all) else if (CNeutrinoApp::getInstance()->handleMsg(msg, data) & messages_return::cancel_all)
@@ -141,45 +98,6 @@ int CKeyChooserItem::exec(CMenuTarget* parent, const std::string &)
} }
g_RCInput->setLongPressAny(false); g_RCInput->setLongPressAny(false);
hide(); hintbox->hide();
return res; return res;
} }
void CKeyChooserItem::hide()
{
CFrameBuffer::getInstance()->paintBackgroundBoxRel(x, y, width, height);
CFrameBuffer::getInstance()->blit();
}
void CKeyChooserItem::paint()
{
int hheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight();
int mheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
CFrameBuffer * frameBuffer = CFrameBuffer::getInstance();
int tmp;
width = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(g_Locale->getText(name));
tmp = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(g_Locale->getText(LOCALE_KEYCHOOSER_TEXT1));
if (tmp > width)
width = tmp;
tmp = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(g_Locale->getText(LOCALE_KEYCHOOSER_TEXT2));
if (tmp > width)
width = tmp;
width += 20;
width = w_max(width, 0);
height = h_max(hheight + 2 * mheight, 0);
x = frameBuffer->getScreenX() + ((frameBuffer->getScreenWidth()-width) >> 1);
y = frameBuffer->getScreenY() + ((frameBuffer->getScreenHeight()-height) >> 1);
//frameBuffer->paintBoxRel(x, y , width, hheight , COL_MENUHEAD_PLUS_0 );
//frameBuffer->paintBoxRel(x, y + hheight, width, height - hheight, COL_MENUCONTENT_PLUS_0);
frameBuffer->paintBoxRel(x, y + hheight, width, height - hheight, COL_MENUCONTENT_PLUS_0, RADIUS_LARGE, CORNER_BOTTOM);//round
CComponentsHeader header(x, y, width, hheight, g_Locale->getText(name));
header.paint(CC_SAVE_SCREEN_NO);
//paint msg...
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+ 10, y+ hheight+ mheight, width, g_Locale->getText(LOCALE_KEYCHOOSER_TEXT1), COL_MENUCONTENT_TEXT);
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+ 10, y+ hheight+ mheight* 2, width, g_Locale->getText(LOCALE_KEYCHOOSER_TEXT2), COL_MENUCONTENT_TEXT);
}

View File

@@ -2,55 +2,39 @@
Neutrino-GUI - DBoxII-Project Neutrino-GUI - DBoxII-Project
Copyright (C) 2001 Steffen Hehn 'McClean' Copyright (C) 2001 Steffen Hehn 'McClean'
Homepage: http://dbox.cyberphoria.org/
Kommentar:
Diese GUI wurde von Grund auf neu programmiert und sollte nun vom
Aufbau und auch den Ausbaumoeglichkeiten gut aussehen. Neutrino basiert
auf der Client-Server Idee, diese GUI ist also von der direkten DBox-
Steuerung getrennt. Diese wird dann von Daemons uebernommen.
License: GPL License: GPL
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or
it under the terms of the GNU General Public License as published by modify it under the terms of the GNU General Public
the Free Software Foundation; either version 2 of the License, or License as published by the Free Software Foundation; either
(at your option) any later version. version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
GNU General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program. If not, see <http://www.gnu.org/licenses/>.
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef __keychooser__ #ifndef __keychooser__
#define __keychooser__ #define __keychooser__
#include <string> #include <string>
#include <driver/rcinput.h> #include <driver/rcinput.h>
#include <system/localize.h>
#include "menue.h" #include "menue.h"
class CFrameBuffer; class CFrameBuffer;
class CKeyChooserItem;
class CKeyChooserItemNoKey;
class CKeyChooser : public CMenuWidget class CKeyChooser : public CMenuWidget
{ {
private: private:
CFrameBuffer *frameBuffer;
unsigned int * key; unsigned int * key;
std::string keyName; std::string keyName;
CKeyChooserItem *keyChooser;
CKeyChooserItemNoKey *keyDeleter;
public: public:
CKeyChooser(unsigned int * const Key, const neutrino_locale_t title, const std::string & Icon = ""); CKeyChooser(unsigned int * const Key, const neutrino_locale_t title, const std::string & Icon = "");
@@ -63,43 +47,28 @@ class CKeyChooser : public CMenuWidget
class CKeyChooserItem : public CMenuTarget class CKeyChooserItem : public CMenuTarget
{ {
private: private:
int x;
int y;
int width;
int height;
neutrino_locale_t name; neutrino_locale_t name;
unsigned int * key; unsigned int *key;
void paint();
public: public:
CKeyChooserItem(const neutrino_locale_t Name, unsigned int *Key); CKeyChooserItem(const neutrino_locale_t Name, unsigned int *Key);
void hide();
int exec(CMenuTarget* parent, const std::string & actionKey); int exec(CMenuTarget* parent, const std::string & actionKey);
}; };
class CKeyChooserItemNoKey : public CMenuTarget class CKeyChooserItemNoKey : public CMenuTarget
{ {
unsigned int * key; unsigned int *key;
public: public:
CKeyChooserItemNoKey(unsigned int *Key) CKeyChooserItemNoKey(unsigned int *Key)
{ {
key=Key; key = Key;
}; };
int exec(CMenuTarget* /*parent*/, const std::string & /*actionKey*/) int exec(CMenuTarget* /*parent*/, const std::string & /*actionKey*/)
{ {
*key=(int)CRCInput::RC_nokey; *key = (unsigned int)CRCInput::RC_nokey;
return menu_return::RETURN_REPAINT; return menu_return::RETURN_REPAINT;
} }
}; };

View File

@@ -900,8 +900,7 @@ typedef enum
LOCALE_KEYBINDINGMENU_VOLUMEUP, LOCALE_KEYBINDINGMENU_VOLUMEUP,
LOCALE_KEYBINDINGMENU_ZAPHISTORY, LOCALE_KEYBINDINGMENU_ZAPHISTORY,
LOCALE_KEYCHOOSER_HEAD, LOCALE_KEYCHOOSER_HEAD,
LOCALE_KEYCHOOSER_TEXT1, LOCALE_KEYCHOOSER_TEXT,
LOCALE_KEYCHOOSER_TEXT2,
LOCALE_KEYCHOOSERMENU_CURRENTKEY, LOCALE_KEYCHOOSERMENU_CURRENTKEY,
LOCALE_KEYCHOOSERMENU_SETNEW, LOCALE_KEYCHOOSERMENU_SETNEW,
LOCALE_KEYCHOOSERMENU_SETNONE, LOCALE_KEYCHOOSERMENU_SETNONE,

View File

@@ -900,8 +900,7 @@ const char * locale_real_names[] =
"keybindingmenu.volumeup", "keybindingmenu.volumeup",
"keybindingmenu.zaphistory", "keybindingmenu.zaphistory",
"keychooser.head", "keychooser.head",
"keychooser.text1", "keychooser.text",
"keychooser.text2",
"keychoosermenu.currentkey", "keychoosermenu.currentkey",
"keychoosermenu.setnew", "keychoosermenu.setnew",
"keychoosermenu.setnone", "keychoosermenu.setnone",