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.zaphistory Zapping-History Bouquet
keychooser.head Neue Taste einstellen
keychooser.text1 Bitte Taste drücken
keychooser.text2 Zum Abbrechen warten ...
keychooser.text Neue Taste drücken.\nZum Abbrechen ein paar Sekunden warten ...
keychoosermenu.currentkey Derzeitige Taste
keychoosermenu.setnew Neue Taste einstellen
keychoosermenu.setnone Keine Taste

View File

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

View File

@@ -2,31 +2,21 @@
Neutrino-GUI - DBoxII-Project
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
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef HAVE_CONFIG_H
@@ -38,73 +28,36 @@
#include <global.h>
#include <neutrino.h>
#include <gui/color.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();
};
};
#include <gui/widget/hintbox.h>
CKeyChooser::CKeyChooser(unsigned int * const Key, const neutrino_locale_t title, const std::string & Icon) : CMenuWidget(title, Icon)
{
frameBuffer = CFrameBuffer::getInstance();
key = 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(GenericMenuBack);
addItem(GenericMenuSeparatorLine);
addItem(new CMenuForwarder(LOCALE_KEYCHOOSERMENU_SETNEW, true, NULL, keyChooser));
addItem(new CMenuForwarder(LOCALE_KEYCHOOSERMENU_SETNONE, true, NULL, keyDeleter));
addItem(new CMenuForwarder(LOCALE_KEYCHOOSERMENU_CURRENTKEY, false, keyName));
}
CKeyChooser::~CKeyChooser()
{
delete keyChooser;
delete keyDeleter;
}
void CKeyChooser::paint()
{
(((CKeyValue *)(items[0]))->keyvalue) = *key;
keyName = CRCInput::getKeyName(*key);
CMenuWidget::paint();
}
//*****************************
CKeyChooserItem::CKeyChooserItem(const neutrino_locale_t Name, unsigned int * Key)
{
name = Name;
key = Key;
x = y = width = height = 0;
}
int CKeyChooserItem::exec(CMenuTarget* parent, const std::string &)
{
neutrino_msg_t msg;
@@ -117,21 +70,25 @@ int CKeyChooserItem::exec(CMenuTarget* parent, const std::string &)
if (parent)
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();
g_RCInput->clearRCMsg();
g_RCInput->setLongPressAny(true);
timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings
::TIMING_MENU]);
timeoutEnd = CRCInput::calcTimeoutEnd(timeout);
get_Message:
g_RCInput->getMsgAbsoluteTimeout( &msg, &data, &timeoutEnd );
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))
*key = msg;
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);
hide();
hintbox->hide();
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
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
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __keychooser__
#define __keychooser__
#include <string>
#include <driver/rcinput.h>
#include <system/localize.h>
#include "menue.h"
class CFrameBuffer;
class CKeyChooserItem;
class CKeyChooserItemNoKey;
class CKeyChooser : public CMenuWidget
{
private:
CFrameBuffer *frameBuffer;
unsigned int * key;
std::string keyName;
CKeyChooserItem *keyChooser;
CKeyChooserItemNoKey *keyDeleter;
public:
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
{
private:
int x;
int y;
int width;
int height;
neutrino_locale_t name;
unsigned int * key;
void paint();
unsigned int *key;
public:
CKeyChooserItem(const neutrino_locale_t Name, unsigned int *Key);
void hide();
int exec(CMenuTarget* parent, const std::string & actionKey);
};
class CKeyChooserItemNoKey : public CMenuTarget
{
unsigned int * key;
unsigned int *key;
public:
CKeyChooserItemNoKey(unsigned int *Key)
{
key=Key;
key = Key;
};
int exec(CMenuTarget* /*parent*/, const std::string & /*actionKey*/)
{
*key=(int)CRCInput::RC_nokey;
*key = (unsigned int)CRCInput::RC_nokey;
return menu_return::RETURN_REPAINT;
}
};

View File

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

View File

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