mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-09-08 06:08:29 +02:00
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.
Origin commit data
------------------
Commit: 0e809c9c76
Author: Thilo Graf <dbt@novatux.de>
Date: 2021-10-09 (Sat, 09 Oct 2021)
This commit is contained in:
138
src/gui/widget/hourglass.cpp
Normal file
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;
|
||||
}
|
Reference in New Issue
Block a user