From f2ece5574de7b0267269c59d0c7ecd02d954469f Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Thu, 6 Feb 2020 00:16:05 +0100 Subject: [PATCH] buildinfo: fix and optimize text arrangement and scroll behavior FIXME: behavior of CTextBox scroll is broken with disabled background paint Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/3dc814b0f94c6d37c15847633a9452ae9f23c0eb Author: Thilo Graf Date: 2020-02-06 (Thu, 06 Feb 2020) --- src/gui/buildinfo.cpp | 56 ++++++++++++++++++++++++++++++------------- src/gui/buildinfo.h | 9 ++++--- 2 files changed, 46 insertions(+), 19 deletions(-) diff --git a/src/gui/buildinfo.cpp b/src/gui/buildinfo.cpp index a10ce8388..864b63498 100644 --- a/src/gui/buildinfo.cpp +++ b/src/gui/buildinfo.cpp @@ -3,7 +3,7 @@ Copyright (C) 2001 by Steffen Hehn 'McClean' Copyright (C) 2013, M. Liebmann 'micha-bbg' - Copyright (C) 2013-2017, Thilo Graf 'dbt' + Copyright (C) 2013-2017, 2020, Thilo Graf 'dbt' License: GPL @@ -29,8 +29,8 @@ #include #include -#include -#include +#include "gui/buildinfo.h" +#include "gui/widget/msgbox.h" #include #include @@ -40,7 +40,7 @@ using namespace std; CBuildInfo::CBuildInfo(bool show) : CComponentsWindow(0, 0, CCW_PERCENT 85, CCW_PERCENT 85, LOCALE_BUILDINFO_MENU, NEUTRINO_ICON_INFO) { initVarBuildInfo(); - setBodyBGImage(DATADIR "/neutrino/icons/start.jpg"); +// setBodyBGImage(DATADIR "/neutrino/icons/start.jpg"); if (show) exec(NULL, ""); else @@ -94,6 +94,12 @@ int CBuildInfo::exec(CMenuTarget* parent, const string & /*actionKey*/) res = menu_return::RETURN_EXIT_ALL; break; } + else if ((msg == CRCInput::RC_up) || (msg == CRCInput::RC_page_up)) { + Scroll(false); + } + else if ((msg == CRCInput::RC_down) || (msg == CRCInput::RC_page_down)) { + Scroll(true); + } else if (msg <= CRCInput::RC_MaxRC){ break; } @@ -111,6 +117,18 @@ int CBuildInfo::exec(CMenuTarget* parent, const string & /*actionKey*/) return res; } +void CBuildInfo::Scroll(bool scrollDown) +{ + CTextBox* ctb = static_cast(ccw_body->getCCItem(3))->getTextObject()->getCTextBoxObject(); + ctb->enableBackgroundPaint(true); //FIXME: behavior of CTextBox scroll is broken with disabled background paint + if (ctb) { + if (scrollDown) + ctb->scrollPageDown(1); + else + ctb->scrollPageUp(1); + } +} + void CBuildInfo::setFontType(Font* font_text) { if (font_text == NULL) @@ -128,6 +146,15 @@ bool CBuildInfo::GetData() v_info.push_back(compiler); #endif +#ifdef USED_BUILD + build_info_t build = {BI_TYPE_ID_USED_BUILD , LOCALE_BUILDINFO_COMPILED_ON, USED_BUILD}; + v_info.push_back(build); +#endif + + CComponentsText utext; + build_info_t kernel = {BI_TYPE_ID_USED_KERNEL, LOCALE_BUILDINFO_KERNEL, utext.getTextFromFile("/proc/version")}; + v_info.push_back(kernel); + #ifdef USED_CXXFLAGS string cxxflags = USED_CXXFLAGS; cxxflags = trim(cxxflags); @@ -141,15 +168,6 @@ bool CBuildInfo::GetData() v_info.push_back(flags); #endif -#ifdef USED_BUILD - build_info_t build = {BI_TYPE_ID_USED_BUILD , LOCALE_BUILDINFO_COMPILED_ON, USED_BUILD}; - v_info.push_back(build); -#endif - - CComponentsText utext; - build_info_t kernel = {BI_TYPE_ID_USED_KERNEL, LOCALE_BUILDINFO_KERNEL, utext.getTextFromFile("/proc/version")}; - v_info.push_back(kernel); - #if 0 CConfigFile data ('\t'); data.loadConfig(TARGET_PREFIX "/.version"); @@ -176,15 +194,21 @@ void CBuildInfo::InitInfoItems() //define size and position int x_info = OFFSET_INNER_MID; - int h_info = ccw_body->getHeight()/v_info.size(); //default height + int h_info = 0; //default height int w_info = width-2*x_info; + int y_info = OFFSET_INNER_MID; //init info texts for(size_t i=0; igetText(v_info[i].caption), v_info[i].info_text, NULL, ccw_body); + h_info = v_info[i].type_id != BI_TYPE_ID_USED_CXXFLAGS ? font->getHeight() * 2 + OFFSET_INNER_MID : ccw_body->getHeight() - y_info; + CComponentsExtTextForm *info = new CComponentsExtTextForm(OFFSET_INNER_MID, y_info, w_info, h_info, g_Locale->getText(v_info[i].caption), v_info[i].info_text, NULL, ccw_body); info->setLabelAndTextFont(font); - info->setTextModes(CTextBox::TOP , CTextBox::AUTO_HIGH | CTextBox::TOP | CTextBox::AUTO_LINEBREAK_NO_BREAKCHARS); + if (v_info[i].type_id == BI_TYPE_ID_USED_CXXFLAGS) + info->setTextModes(CTextBox::TOP , CTextBox::TOP | CTextBox::AUTO_WIDTH | CTextBox::SCROLL); + else + info->setTextModes(CTextBox::TOP , CTextBox::TOP | CTextBox::AUTO_LINEBREAK_NO_BREAKCHARS); info->doPaintBg(false); + y_info += h_info; } } diff --git a/src/gui/buildinfo.h b/src/gui/buildinfo.h index 30a1033be..2805b6ea3 100644 --- a/src/gui/buildinfo.h +++ b/src/gui/buildinfo.h @@ -31,8 +31,9 @@ #include #endif -#include -#include +#include "gui/widget/menue.h" +#include "gui/components/cc.h" +#include typedef int info_type_id_t; @@ -44,6 +45,7 @@ typedef struct build_info_t } build_info_struct_t; + class CBuildInfo : public CMenuTarget, public CComponentsWindow { private: @@ -51,7 +53,8 @@ class CBuildInfo : public CMenuTarget, public CComponentsWindow Font* font; void initVarBuildInfo(); void InitInfoItems(); - + void Scroll(bool scrollDown); + bool GetData(); public: