From c71c6ce0ac854e2fdf1e8b4d7ea016518e36dcb5 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Wed, 11 Apr 2018 23:58:15 +0200 Subject: [PATCH] colorchooser.cpp/h: add separate init method If color setup having already been used and after that user has done changed some other settings (e.g. font settings), graphical errors or crashes are possible. The relocation of the initialization should prevent this. Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/d2ab30f7af77ef11d160e16004b0f4ae449acf7d Author: Thilo Graf Date: 2018-04-11 (Wed, 11 Apr 2018) Origin message was: ------------------ colorchooser.cpp/h: add separate init method If color setup having already been used and after that user has done changed some other settings (e.g. font settings), graphical errors or crashes are possible. The relocation of the initialization should prevent this. ------------------ This commit was generated by Migit --- src/gui/widget/colorchooser.cpp | 22 ++++++++++++++-------- src/gui/widget/colorchooser.h | 2 ++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/gui/widget/colorchooser.cpp b/src/gui/widget/colorchooser.cpp index 2f65ca6ce..04aa52457 100644 --- a/src/gui/widget/colorchooser.cpp +++ b/src/gui/widget/colorchooser.cpp @@ -2,6 +2,7 @@ Based up Neutrino-GUI - Tuxbox-Project Copyright (C) 2001 Steffen Hehn 'McClean' + Copyright (C) 2018 Thilo Graf License: GPL @@ -54,14 +55,23 @@ static const neutrino_locale_t colorchooser_names[VALUES] = }; CColorChooser::CColorChooser(const neutrino_locale_t Name, unsigned char *R, unsigned char *G, unsigned char *B, unsigned char* A, CChangeObserver* Observer) +{ + observer = Observer; + name = Name; + + value[VALUE_R] = R; + value[VALUE_G] = G; + value[VALUE_B] = B; + value[VALUE_A] = A; +} + +void CColorChooser::Init() { frameBuffer = CFrameBuffer::getInstance(); header_height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight(); font = g_Font[SNeutrinoSettings::FONT_TYPE_WINDOW_GENERAL]; item_height = font->getHeight(); - observer = Observer; - name = Name; - + // calculate max width of locals text_width = 0; for (int i = 0; i < VALUES; i++) @@ -95,11 +105,6 @@ CColorChooser::CColorChooser(const neutrino_locale_t Name, unsigned char *R, uns preview_x = x + text_width + bar_full + 3*OFFSET_INNER_MID; preview_y = y + header_height + OFFSET_INNER_SMALL; - value[VALUE_R] = R; - value[VALUE_G] = G; - value[VALUE_B] = B; - value[VALUE_A] = A; - chooser_gradient = gradient_none; } @@ -154,6 +159,7 @@ fb_pixel_t CColorChooser::getColor() int CColorChooser::exec(CMenuTarget* parent, const std::string &) { + Init(); neutrino_msg_t msg; neutrino_msg_data_t data; diff --git a/src/gui/widget/colorchooser.h b/src/gui/widget/colorchooser.h index 06b32fcf7..d0d489ec9 100644 --- a/src/gui/widget/colorchooser.h +++ b/src/gui/widget/colorchooser.h @@ -2,6 +2,7 @@ Based up Neutrino-GUI - Tuxbox-Project Copyright (C) 2001 Steffen Hehn 'McClean' + Copyright (C) 2018 Thilo Graf License: GPL @@ -68,6 +69,7 @@ class CColorChooser : public CMenuTarget CChangeObserver* observer; Font * font; + void Init(); void paint(); void setColor(); void paintSlider(int x, int y, unsigned char *spos, const neutrino_locale_t text, const char * const iconname, const bool selected);