CKeyboardInput: Make saveScreen changeable with forceSaveScreen()

This commit is contained in:
M. Liebmann
2016-10-29 08:20:36 +02:00
parent 0e22860ac0
commit 74b0ce7f70
2 changed files with 30 additions and 8 deletions

View File

@@ -199,6 +199,8 @@ CKeyboardInput::CKeyboardInput(const neutrino_locale_t Name, std::string* Value,
caps = 0; caps = 0;
srow = scol = 0; srow = scol = 0;
focus = FOCUS_STRING; focus = FOCUS_STRING;
force_saveScreen = false;
pixBuf = NULL;
} }
CKeyboardInput::CKeyboardInput(const std::string &Name, std::string *Value, int Size, CChangeObserver* Observ, const char * const Icon, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2) CKeyboardInput::CKeyboardInput(const std::string &Name, std::string *Value, int Size, CChangeObserver* Observ, const char * const Icon, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2)
@@ -221,6 +223,8 @@ CKeyboardInput::CKeyboardInput(const std::string &Name, std::string *Value, int
caps = 0; caps = 0;
srow = scol = 0; srow = scol = 0;
focus = FOCUS_STRING; focus = FOCUS_STRING;
force_saveScreen = false;
pixBuf = NULL;
} }
CKeyboardInput::CKeyboardInput(const std::string &Name, std::string *Value, int Size, CChangeObserver* Observ, const char * const Icon, std::string HintText_1, std::string HintText_2) CKeyboardInput::CKeyboardInput(const std::string &Name, std::string *Value, int Size, CChangeObserver* Observ, const char * const Icon, std::string HintText_1, std::string HintText_2)
@@ -243,6 +247,8 @@ CKeyboardInput::CKeyboardInput(const std::string &Name, std::string *Value, int
caps = 0; caps = 0;
srow = scol = 0; srow = scol = 0;
focus = FOCUS_STRING; focus = FOCUS_STRING;
force_saveScreen = false;
pixBuf = NULL;
} }
CKeyboardInput::~CKeyboardInput() CKeyboardInput::~CKeyboardInput()
@@ -515,6 +521,15 @@ std::string &CKeyboardInput::getValue(void)
return *valueString; return *valueString;
} }
void CKeyboardInput::forceSaveScreen(bool enable)
{
force_saveScreen = enable;
if (!enable && pixBuf) {
delete[] pixBuf;
pixBuf = NULL;
}
}
int CKeyboardInput::exec(CMenuTarget* parent, const std::string &) int CKeyboardInput::exec(CMenuTarget* parent, const std::string &)
{ {
neutrino_msg_t msg; neutrino_msg_t msg;
@@ -528,11 +543,12 @@ int CKeyboardInput::exec(CMenuTarget* parent, const std::string &)
std::string oldval = *valueString; std::string oldval = *valueString;
fb_pixel_t * pixbuf = NULL; if (pixBuf)
if (!parent) { delete[] pixBuf;
pixbuf = new fb_pixel_t[(width + OFFSET_SHADOW) * (height + OFFSET_SHADOW)]; if (!parent || force_saveScreen) {
if (pixbuf) pixBuf = new fb_pixel_t[(width + OFFSET_SHADOW) * (height + OFFSET_SHADOW)];
frameBuffer->SaveScreen(x, y, width + OFFSET_SHADOW, height + OFFSET_SHADOW, pixbuf); if (pixBuf)
frameBuffer->SaveScreen(x, y, width + OFFSET_SHADOW, height + OFFSET_SHADOW, pixBuf);
} }
paint(); paint();
@@ -624,10 +640,12 @@ int CKeyboardInput::exec(CMenuTarget* parent, const std::string &)
} }
} }
if (pixbuf) if (pixBuf)
{ {
frameBuffer->RestoreScreen(x, y, width + OFFSET_SHADOW, height + OFFSET_SHADOW, pixbuf); frameBuffer->RestoreScreen(x, y, width + OFFSET_SHADOW, height + OFFSET_SHADOW, pixBuf);
delete[] pixbuf; delete[] pixBuf;
pixBuf = NULL;
frameBuffer->blit();
} else } else
hide(); hide();

View File

@@ -101,6 +101,8 @@ class CKeyboardInput : public CMenuTarget
int selected; int selected;
bool changed; bool changed;
CChangeObserver * observ; CChangeObserver * observ;
bool force_saveScreen;
fb_pixel_t *pixBuf;
virtual void init(); virtual void init();
@@ -133,6 +135,8 @@ class CKeyboardInput : public CMenuTarget
void hide(); void hide();
int exec( CMenuTarget* parent, const std::string & actionKey ); int exec( CMenuTarget* parent, const std::string & actionKey );
virtual std::string &getValue(void); virtual std::string &getValue(void);
void forceSaveScreen(bool enable);
}; };
#endif #endif