gui/widget: add class CHourGlass
Provides an hourglass/snake-loader function to visualize running processes. A template xcf-file for Gimp 2.10 is appended. Feel free to edit.
@@ -388,6 +388,7 @@ data/icons/buttons/Makefile
|
||||
data/icons/filetypes/Makefile
|
||||
data/icons/headers/Makefile
|
||||
data/icons/hints/Makefile
|
||||
data/icons/hourglass/Makefile
|
||||
data/icons/locale/Makefile
|
||||
data/icons/movieplayer/Makefile
|
||||
data/icons/radar/Makefile
|
||||
|
@@ -3,6 +3,7 @@ SUBDIRS = \
|
||||
filetypes \
|
||||
headers \
|
||||
hints \
|
||||
hourglass \
|
||||
locale \
|
||||
movieplayer \
|
||||
radar \
|
||||
|
10
data/icons/hourglass/Makefile.am
Normal file
@@ -0,0 +1,10 @@
|
||||
installdir = $(ICONSDIR)
|
||||
|
||||
install_DATA = \
|
||||
hourglass0.png \
|
||||
hourglass1.png \
|
||||
hourglass2.png \
|
||||
hourglass3.png \
|
||||
hourglass4.png \
|
||||
hourglass5.png \
|
||||
hourglass6.png
|
BIN
data/icons/hourglass/hourglass.xcf
Normal file
BIN
data/icons/hourglass/hourglass0.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
data/icons/hourglass/hourglass1.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
data/icons/hourglass/hourglass2.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
data/icons/hourglass/hourglass3.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
data/icons/hourglass/hourglass4.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
data/icons/hourglass/hourglass5.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
data/icons/hourglass/hourglass6.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
@@ -60,6 +60,7 @@
|
||||
#include "widget/msgbox.h"
|
||||
#include "widget/progresswindow.h"
|
||||
#include "widget/termwindow.h"
|
||||
#include "widget/hourglass.h"
|
||||
#include <driver/record.h>
|
||||
#include <zapit/femanager.h>
|
||||
#include <zapit/scan.h>
|
||||
@@ -1119,8 +1120,19 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey)
|
||||
showRecords();
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
else if (actionKey == "hourglass"){
|
||||
CHourGlass hg(20, 20);
|
||||
hg.paint();
|
||||
sleep(10);
|
||||
hg.hide();
|
||||
return res;
|
||||
}
|
||||
else if (actionKey == "hourglass_proc"){
|
||||
CHourGlassProc proc(20, 20, sigc::mem_fun(*this, &CTestMenu::showRecords));
|
||||
proc.exec();
|
||||
return res;
|
||||
}
|
||||
|
||||
return showTestMenu();
|
||||
}
|
||||
|
||||
@@ -1250,6 +1262,10 @@ int CTestMenu::showTestMenu()
|
||||
CKeyboardInput input("Text input", &input_txt, 30, NULL, NULL, "Test");
|
||||
w_test.addItem(new CMenuForwarder("Text input", true, NULL, &input));
|
||||
|
||||
//hourglass
|
||||
w_test.addItem(new CMenuForwarder("Hourglass", true, NULL, this, "hourglass"));
|
||||
w_test.addItem(new CMenuForwarder("Exec process with hourglass!", true, NULL, this, "hourglass_proc"));
|
||||
|
||||
//rate banner
|
||||
w_test.addItem(new CMenuForwarder("Rate banner", true, NULL, this, "rate_banner"));
|
||||
|
||||
|
@@ -22,6 +22,7 @@ libneutrino_gui_widget_a_SOURCES = \
|
||||
colorchooser.cpp \
|
||||
helpbox.cpp \
|
||||
hintbox.cpp \
|
||||
hourglass.cpp \
|
||||
keychooser.cpp \
|
||||
keyboard_input.cpp \
|
||||
listbox.cpp \
|
||||
|
@@ -38,6 +38,7 @@
|
||||
#include <driver/fontrenderer.h>
|
||||
#include <system/debug.h>
|
||||
#include <system/settings.h>
|
||||
#include <gui/widget/hourglass.h>
|
||||
|
||||
#define MSG_FONT g_Font[SNeutrinoSettings::FONT_TYPE_MESSAGE_TEXT]
|
||||
|
||||
@@ -495,9 +496,34 @@ int ShowHintS(const char * const Text, int timeout, bool show_background)
|
||||
{
|
||||
int res = messages_return::none;
|
||||
CHint hint(Text, show_background);
|
||||
CHourGlass hg(CFrameBuffer::getInstance()->getScreenX() + OFFSET_INNER_MID, CFrameBuffer::getInstance()->getScreenY());
|
||||
hint.setTimeOut(timeout, false);
|
||||
|
||||
hint.paint();
|
||||
hg.paint();
|
||||
res = hint.exec();
|
||||
hg.hide();
|
||||
hint.hide();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
int ShowHintS(const char * const Text, const sigc::slot<void> &Slot, int timeout, bool show_background)
|
||||
{
|
||||
int res = messages_return::none;
|
||||
|
||||
sigc::signal<void> OnCall;
|
||||
OnCall.connect(Slot);
|
||||
|
||||
CHint hint(Text, show_background);
|
||||
CHourGlass hg(CFrameBuffer::getInstance()->getScreenX() + OFFSET_INNER_MID, CFrameBuffer::getInstance()->getScreenY());
|
||||
hint.setTimeOut(timeout, false);
|
||||
|
||||
hint.paint();
|
||||
hg.paint();
|
||||
OnCall();
|
||||
res = hint.exec();
|
||||
hg.hide();
|
||||
hint.hide();
|
||||
|
||||
return res;
|
||||
@@ -513,22 +539,6 @@ int ShowHintS(const std::string& Text, int timeout, bool show_background)
|
||||
return ShowHintS(Text.c_str(), timeout, show_background);
|
||||
}
|
||||
|
||||
int ShowHintS(const char * const Text, const sigc::slot<void> &Slot, int timeout, bool show_background)
|
||||
{
|
||||
int res = messages_return::none;
|
||||
|
||||
sigc::signal<void> OnCall;
|
||||
OnCall.connect(Slot);
|
||||
CHint hint(Text, show_background);
|
||||
hint.setTimeOut(timeout, false);
|
||||
hint.paint();
|
||||
OnCall();
|
||||
res = hint.exec();
|
||||
hint.hide();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
int ShowHintS(const neutrino_locale_t Text, const sigc::slot<void> &Slot, int timeout, bool show_background)
|
||||
{
|
||||
return ShowHintS(g_Locale->getText(Text), Slot, timeout, show_background);
|
||||
|
@@ -434,10 +434,10 @@ int ShowHintS(const std::string &Text, int timeout = HINTBOX_DEFAULT_TIMEOUT, bo
|
||||
* @li expects sigc::slot<void>
|
||||
* @li example:
|
||||
* @li sigc::slot<void> sl = sigc::mem_fun(g_Plugins, &CPlugins::loadPlugins);\n
|
||||
* ShowHintS(LOCALE_SERVICEMENU_GETPLUGINS_HINT, 1, true, &sl);
|
||||
* ShowHintS(LOCALE_SERVICEMENU_GETPLUGINS_HINT, sl, 1);
|
||||
* @li or use a function with parameter(s):
|
||||
* sigc::slot<void> sl = sigc::bind(sigc::mem_fun(*this, &CMyClass::foo), arg1, arg2, arg3, arg4);\n
|
||||
* ShowHintS(LOCALE_SERVICEMENU_GETPLUGINS_HINT, 1, true, &sl);
|
||||
* ShowHintS(LOCALE_SERVICEMENU_GETPLUGINS_HINT, sl, 1);
|
||||
* @param[in] timeout
|
||||
* @li optional: expects type int as seconds, default = HINTBOX_DEFAULT_TIMEOUT (get from settings)
|
||||
* @param[in] show_background
|
||||
|
138
src/gui/widget/hourglass.cpp
Normal file
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
Based up Neutrino-GUI - Tuxbox-Project
|
||||
Copyright (C) 2001 by Steffen Hehn 'McClean'
|
||||
|
||||
Hourglass, provides an hourglass/snakeloader function to visualize running processes.
|
||||
Copyright (C) 2021, Thilo Graf 'dbt'
|
||||
|
||||
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 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "hourglass.h"
|
||||
|
||||
#include <global.h>
|
||||
|
||||
#include <system/debug.h>
|
||||
#include <system/helpers.h>
|
||||
#include <neutrinoMessages.h>
|
||||
|
||||
#define MAX_IMAGES 24
|
||||
|
||||
CHourGlass::CHourGlass( const int x_pos,
|
||||
const int y_pos,
|
||||
const int w,
|
||||
const int h,
|
||||
const std::string& image_basename,
|
||||
const int64_t& interval,
|
||||
CComponentsForm *parent,
|
||||
int shadow_mode,
|
||||
fb_pixel_t color_frame,
|
||||
fb_pixel_t color_body,
|
||||
fb_pixel_t color_shadow) : CComponentsShapeSquare(x_pos, y_pos, w, h, parent, shadow_mode, color_frame, color_body, color_shadow)
|
||||
{
|
||||
cc_item_type.name ="wg_hourglass";
|
||||
|
||||
hg_image_basename = image_basename;
|
||||
cc_bg_image = cc_bg_image_old = cc_bg_sel_image = cc_bg_sec_image = "";
|
||||
|
||||
initImageFiles();
|
||||
|
||||
hg_file_num = 0;
|
||||
hg_interval = interval;
|
||||
hg_timer = new CComponentsTimer(hg_interval);
|
||||
hg_timer->OnTimer.connect(sigc::bind(sigc::mem_fun(*this, &CHourGlass::paint), true));
|
||||
}
|
||||
|
||||
CHourGlass::~CHourGlass()
|
||||
{
|
||||
delete hg_timer;
|
||||
hg_timer = NULL;
|
||||
}
|
||||
|
||||
void CHourGlass::initImageFiles()
|
||||
{
|
||||
std::string path = "";
|
||||
std::string filename = "";
|
||||
hg_img_files.clear();
|
||||
|
||||
for(int i = 0; i <= MAX_IMAGES; i++)
|
||||
{
|
||||
filename = hg_image_basename;
|
||||
filename += to_string(i);
|
||||
path = frameBuffer->getIconPath(filename, "png");
|
||||
if (file_exists(path))
|
||||
hg_img_files.push_back(filename);
|
||||
else
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
void CHourGlass::paint(const bool &do_save_bg)
|
||||
{
|
||||
if (hg_img_files.empty())
|
||||
return;
|
||||
|
||||
if (hg_file_num > hg_img_files.size()-1)
|
||||
hg_file_num = 0;
|
||||
|
||||
cc_bg_image = frameBuffer->getIconPath(hg_img_files.at(hg_file_num), "png");
|
||||
|
||||
hide();
|
||||
|
||||
if (!hg_timer->isRun())
|
||||
hg_timer->startTimer();
|
||||
else
|
||||
paintInit(do_save_bg);
|
||||
|
||||
hg_file_num ++;
|
||||
}
|
||||
|
||||
|
||||
CHourGlassProc::CHourGlassProc( const int x_pos,
|
||||
const int y_pos,
|
||||
const sigc::slot<void> &Slot,
|
||||
const int w,
|
||||
const int h,
|
||||
const std::string& image_basename,
|
||||
const int64_t& interval,
|
||||
CComponentsForm *parent,
|
||||
int shadow_mode,
|
||||
fb_pixel_t color_frame,
|
||||
fb_pixel_t color_body,
|
||||
fb_pixel_t color_shadow) : CHourGlass(x_pos, y_pos, w, h, image_basename, interval, parent, shadow_mode, color_frame, color_body, color_shadow)
|
||||
{
|
||||
cc_item_type.name ="wg_hourglass_proc";
|
||||
|
||||
OnRun.connect(Slot);
|
||||
}
|
||||
|
||||
void CHourGlassProc::paint(const bool &do_save_bg)
|
||||
{
|
||||
CHourGlass::paint(do_save_bg);
|
||||
}
|
||||
|
||||
int CHourGlassProc::exec()
|
||||
{
|
||||
paint(true);
|
||||
OnRun();
|
||||
hide();
|
||||
|
||||
return messages_return::handled;
|
||||
}
|
140
src/gui/widget/hourglass.h
Normal file
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
Based up Neutrino-GUI - Tuxbox-Project
|
||||
Copyright (C) 2001 by Steffen Hehn 'McClean'
|
||||
|
||||
Hourglass, provides an hourglass/snakeloader function to visualize running processes.
|
||||
Copyright (C) 2021, Thilo Graf 'dbt'
|
||||
|
||||
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 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __HOURGLASS_H__
|
||||
#define __HOURGLASS_H__
|
||||
|
||||
#include <gui/components/cc.h>
|
||||
#include <gui/components/cc_timer.h>
|
||||
|
||||
//! CHourglass shows a small image chain with timed order to visualize running processes or breaks.
|
||||
/*!
|
||||
CHourglass shows only a timer controlled image chain, CHourglassProc will run an additional process.
|
||||
*/
|
||||
|
||||
class CHourGlass : public CComponentsShapeSquare
|
||||
{
|
||||
private:
|
||||
std::string hg_image_basename;
|
||||
std::vector<std::string> hg_img_files;
|
||||
int64_t hg_interval;
|
||||
CComponentsTimer* hg_timer;
|
||||
size_t hg_file_num;
|
||||
|
||||
void initImageFiles();
|
||||
public:
|
||||
/**CHourGlass Constructor
|
||||
* @param[in] x_pos
|
||||
* @li expects type int, x position on screen
|
||||
* @param[in] y_pos
|
||||
* @li expects type int, y position on screen
|
||||
* @param[in] w
|
||||
* @li optional: expects type int, defines box width, default value = 48
|
||||
* @param[in] h
|
||||
* @li optional: expects type int, defines box height, default value = 48
|
||||
* @param[in] image_basename
|
||||
* @li optional: expects type std::string, basename as name template for the image set, default = "hourglass"
|
||||
* The images should have the png, format recommended dimensions are 48x48px, respectively the same values for width and height (see: arguments w and h),
|
||||
* Different dimensions than arguments cause scaling.
|
||||
* Filenames must have a digit suffix e.g: <image_basename>0.png ... <image_basename>3.png
|
||||
* The max count of images are defined in MAX_IMAGES.
|
||||
* Images must be stored as usual inside the defined icon directories.
|
||||
* @param[in] interval
|
||||
* @li optional: expects type int64_t, defines paint interval, default = 84ms
|
||||
* @param[in] parent
|
||||
* @li optional: expects type CComponentsForm, as a parent container in which this object is embedded, default = NULL (stand alone)
|
||||
* @param[in] shadow_mode
|
||||
* @li optional: expects type int, defines the shadow mode of object, default = CC_SHADOW_OFF (no shadow)
|
||||
* @param[in] color_frame
|
||||
* @li optional: expects type int, defines the frame color of object, default = COL_FRAME_PLUS_0
|
||||
* @param[in] color_body
|
||||
* @li optional: expects type int, defines the body color of object, default = COL_MENUCONTENT_PLUS_0
|
||||
* NOTE: body background is already defined with the image_basename, pure body will only paint if no image is available.
|
||||
* @param[in] color_shadow
|
||||
* @li optional: expects type int, defines the shadow color of object, default = COL_SHADOW_PLUS_0
|
||||
|
||||
* @see class CComponentsShapeSquare()
|
||||
*/
|
||||
CHourGlass( const int x_pos,
|
||||
const int y_pos,
|
||||
const int w = 48,
|
||||
const int h = 48,
|
||||
const std::string& image_basename = "hourglass",
|
||||
const int64_t& interval = 84,
|
||||
CComponentsForm *parent = NULL,
|
||||
int shadow_mode = CC_SHADOW_OFF,
|
||||
fb_pixel_t color_frame = COL_FRAME_PLUS_0,
|
||||
fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0,
|
||||
fb_pixel_t color_shadow = COL_SHADOW_PLUS_0);
|
||||
|
||||
virtual ~CHourGlass();
|
||||
|
||||
void paint(const bool &do_save_bg = CC_SAVE_SCREEN_YES);
|
||||
};
|
||||
|
||||
class CHourGlassProc : public CHourGlass
|
||||
{
|
||||
private:
|
||||
sigc::signal<void> OnRun;
|
||||
|
||||
public:
|
||||
/**CHourGlassProc Constructor
|
||||
* @see CHourGlass() for other parameters
|
||||
* @li CHourGlassProc() have only one additional parameter, see as follows:
|
||||
* @param[in] Slot
|
||||
* @li expects sigc::slot<void>
|
||||
* @li example:
|
||||
* @li sigc::slot<void> sl = sigc::mem_fun(g_Plugins, &CPlugins::loadPlugins);\n
|
||||
* CHourGlassProc proc(20, 20, sl);
|
||||
* int ret = proc.exec();
|
||||
* @li or use a function with parameter(s):
|
||||
* sigc::slot<void> sl = sigc::bind(sigc::mem_fun(*this, &CMyClass::foo), arg1, arg2, arg3, arg4);\n
|
||||
* CHourGlassProc proc(20, 20, sl);
|
||||
* int ret = proc.exec();
|
||||
* @see CTestMenu for more examples.
|
||||
*
|
||||
* @see class CComponentsShapeSquare(), CHourGlass()
|
||||
*/
|
||||
CHourGlassProc( const int x_pos,
|
||||
const int y_pos,
|
||||
const sigc::slot<void> &Slot,
|
||||
const int w = 48,
|
||||
const int h = 48,
|
||||
const std::string& image_basename = "hourglass",
|
||||
const int64_t& interval = 84,
|
||||
CComponentsForm *parent = NULL,
|
||||
int shadow_mode = CC_SHADOW_OFF,
|
||||
fb_pixel_t color_frame = COL_FRAME_PLUS_0,
|
||||
fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0,
|
||||
fb_pixel_t color_shadow = COL_SHADOW_PLUS_0);
|
||||
|
||||
virtual ~CHourGlassProc(){};
|
||||
|
||||
void paint(const bool &do_save_bg = CC_SAVE_SCREEN_YES);
|
||||
|
||||
/// paint and execute process at once, return value = messages_return::handled
|
||||
int exec();
|
||||
};
|
||||
|
||||
#endif //__HOURGLASS_H__
|