mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-27 15:32:59 +02:00
cc_frm_slider: rework slider slider handling
This commit is contained in:
@@ -4,6 +4,7 @@ install_DATA = \
|
||||
slider_alpha.png \
|
||||
slider_blue.png \
|
||||
slider_body.png \
|
||||
slider_body_progress.png \
|
||||
slider_green.png \
|
||||
slider_inactive.png \
|
||||
slider_red.png
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 132 B After Width: | Height: | Size: 187 B |
BIN
data/icons/slider/slider_body_progress.png
Normal file
BIN
data/icons/slider/slider_body_progress.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 228 B |
@@ -24,6 +24,7 @@
|
||||
#include <global.h>
|
||||
#include <neutrino.h>
|
||||
#include "cc_frm_slider.h"
|
||||
#include <system/debug.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -31,7 +32,6 @@ using namespace std;
|
||||
//sub class CComponentsSlider
|
||||
CComponentsSlider::CComponentsSlider( const int& x_pos, const int& y_pos, const int& w, const int& h,
|
||||
const int& current_value,
|
||||
const int& min_value,
|
||||
const int& max_value,
|
||||
CComponentsForm *parent,
|
||||
int shadow_mode,
|
||||
@@ -43,76 +43,31 @@ CComponentsSlider::CComponentsSlider( const int& x_pos, const int& y_pos, const
|
||||
cc_item_type.name = "cc_slider";
|
||||
corner_rad = 0;
|
||||
|
||||
x = x_pos;
|
||||
y = y_pos;
|
||||
width = w;
|
||||
height = h;
|
||||
x = cc_xr = x_old = x_pos;
|
||||
y = cc_yr = y_old = y_pos;
|
||||
width = width_old = w;
|
||||
height = height_old = h;
|
||||
|
||||
csl_current_value = current_value;
|
||||
csl_min_value = min_value;
|
||||
csl_max_value = max_value;
|
||||
|
||||
shadow = shadow_mode;
|
||||
col_frame = color_frame;
|
||||
col_body = color_body;
|
||||
col_body_std = color_body;
|
||||
col_shadow = color_shadow;
|
||||
|
||||
csl_body_obj = NULL;
|
||||
csl_slider_obj = NULL;
|
||||
|
||||
csl_body_icon = NEUTRINO_ICON_SLIDER_BODY;
|
||||
csl_slider_icon =NEUTRINO_ICON_SLIDER_INACTIVE;
|
||||
setBodyBGImageName(NEUTRINO_ICON_SLIDER_BODY);
|
||||
csl_slider_icon = frameBuffer->getIconPath(NEUTRINO_ICON_SLIDER_INACTIVE);
|
||||
|
||||
initCCSlItems();
|
||||
initParent(parent);
|
||||
}
|
||||
|
||||
//set current value
|
||||
void CComponentsSlider::setValuePos(const int& current_value)
|
||||
CComponentsSlider::~CComponentsSlider()
|
||||
{
|
||||
csl_current_value = current_value;
|
||||
if (csl_slider_obj->isPicPainted())
|
||||
csl_slider_obj->hide();
|
||||
initCCSlItems();
|
||||
}
|
||||
|
||||
//set current scale values
|
||||
void CComponentsSlider::setValueScale(const int& min_value, const int& max_value)
|
||||
{
|
||||
csl_min_value = min_value;
|
||||
csl_max_value = max_value;
|
||||
initCCSlItems();
|
||||
}
|
||||
|
||||
//init slider body object and add to container
|
||||
void CComponentsSlider::initCCSlBody()
|
||||
{
|
||||
if (!csl_body_icon.empty()){
|
||||
if (csl_body_obj == NULL){
|
||||
csl_body_obj = new CComponentsPicture(0, 0, width-2*fr_thickness, 16, csl_body_icon);
|
||||
csl_body_obj->setColorBody(this->col_body); //FIXME: Background handling during current instance of slider object
|
||||
csl_body_obj->doPaintBg(true);
|
||||
addCCItem(csl_body_obj);
|
||||
}
|
||||
else
|
||||
csl_body_obj->setPicture(csl_body_icon);
|
||||
}
|
||||
else{
|
||||
printf("[CComponentsSlider] [%s] missing or undefinied slider body icon %s\n", __func__, csl_body_icon.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
//get first icon dimensions
|
||||
int icon_w = csl_body_obj->getWidth();
|
||||
int icon_h = csl_body_obj->getHeight();
|
||||
|
||||
//position of icon default centered
|
||||
int icon_x = width/2-icon_w/2;
|
||||
int icon_y = height/2-icon_h/2;
|
||||
|
||||
if (csl_body_obj){
|
||||
csl_body_obj->setDimensionsAll(icon_x, icon_y, icon_w, icon_h);
|
||||
}
|
||||
}
|
||||
|
||||
//init slider caption object and add to container
|
||||
@@ -120,34 +75,41 @@ void CComponentsSlider::initCCSlSlider()
|
||||
{
|
||||
if (!csl_slider_icon.empty()){
|
||||
if (csl_slider_obj == NULL){
|
||||
csl_slider_obj = new CComponentsPicture(0, 0, csl_slider_icon);
|
||||
csl_slider_obj->setColorBody(this->col_body); //FIXME: Background handling during current instance of slider object
|
||||
csl_slider_obj->doPaintBg(true);
|
||||
addCCItem(csl_slider_obj);
|
||||
int icon_h, icon_w;
|
||||
frameBuffer->getIconSize(csl_slider_icon.c_str(), &icon_w, &icon_h); //current size is required
|
||||
csl_slider_obj = new CComponentsPicture(0, 0, icon_w, icon_h, csl_slider_icon, this);
|
||||
csl_slider_obj->setColorBody(this->col_body_std); //FIXME: Background handling during current instance of slider object
|
||||
csl_slider_obj->doPaintBg(false);
|
||||
csl_slider_obj->enableSaveBg();
|
||||
}
|
||||
else
|
||||
csl_slider_obj->setPicture(csl_slider_icon);
|
||||
csl_slider_obj->setPicture(frameBuffer->getIconPath(csl_slider_icon));
|
||||
}
|
||||
else{
|
||||
printf("[CComponentsSlider] [%s] missing or undefinied slider icon %s\n", __func__, csl_slider_icon.c_str());
|
||||
dprintf(DEBUG_NORMAL, "[CComponentsSlider]\t[%s - %d]: \033[35m WARNING:\033[0m missing or undefinied slider icon %s\n", __func__, __LINE__, csl_slider_icon.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
if (csl_current_value > csl_max_value)
|
||||
dprintf(DEBUG_NORMAL, "[CComponentsSlider]\t[%s - %d]: \033[35m WARNING:\033[0m current slider value [%d] is larger than maximal value of slider scale [%d]\n", __func__, __LINE__, csl_current_value, csl_max_value);
|
||||
|
||||
//get first icon dimensions
|
||||
int slider_w = csl_slider_obj->getWidth();
|
||||
int slider_h = csl_slider_obj->getHeight();
|
||||
|
||||
//position of slider icon
|
||||
int slider_x = csl_body_obj->getXPos() + (csl_body_obj->getWidth()-slider_w) * (abs(csl_min_value) + csl_current_value) / (abs(csl_min_value) + abs(csl_max_value));
|
||||
int slider_y = height/2-slider_h/2;
|
||||
int slider_space = width - slider_w;
|
||||
int slider_x = csl_current_value * slider_space/csl_max_value;
|
||||
printf("[CComponentsSlider] [%s] csl_current_value = %d slider_x = %d csl_max_value = %d \n", __func__, csl_current_value, slider_x, csl_max_value);
|
||||
|
||||
if (csl_slider_obj)
|
||||
csl_slider_obj->setDimensionsAll(slider_x, slider_y, slider_w, slider_h);
|
||||
if (csl_slider_obj){
|
||||
printf("[CComponentsSlider] [%s] width = %d\n", __func__, width);
|
||||
csl_slider_obj->setHeight(height, true);
|
||||
csl_slider_obj->setXPos(slider_x);
|
||||
}
|
||||
}
|
||||
|
||||
void CComponentsSlider::initCCSlItems()
|
||||
{
|
||||
initCCSlBody();
|
||||
initCCSlSlider();
|
||||
}
|
||||
|
||||
@@ -166,3 +128,49 @@ void CComponentsSlider::setSliderIcon(const std::string &icon_name)
|
||||
// paintForm(do_save_bg);
|
||||
// }
|
||||
|
||||
void CComponentsSlider::paint(const bool &do_save_bg)
|
||||
{
|
||||
//prepare items before paint
|
||||
initCCSlItems();
|
||||
|
||||
//paint form contents
|
||||
if (!is_painted)
|
||||
paintForm(do_save_bg);
|
||||
|
||||
if (is_painted)
|
||||
paintMarker();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CComponentsSlider::paintMarker()
|
||||
{
|
||||
if(csl_slider_obj->isPicPainted())
|
||||
csl_slider_obj->hide();
|
||||
// //if (csl_slider_obj->getXPos()>0)
|
||||
// PaintBoxRel(cc_xr, cc_yr, csl_slider_obj->getXPos(), height, COL_GREEN);
|
||||
if(!csl_slider_obj->isPainted())
|
||||
csl_slider_obj->paint();
|
||||
|
||||
}
|
||||
|
||||
//set current value
|
||||
void CComponentsSlider::setValue(const int& current_value, bool enable_paint)
|
||||
{
|
||||
if (csl_current_value == current_value)
|
||||
return;
|
||||
|
||||
csl_current_value = current_value;
|
||||
initCCSlItems();
|
||||
|
||||
if(enable_paint)
|
||||
paintMarker();
|
||||
}
|
||||
|
||||
//set current scale values
|
||||
void CComponentsSlider::setValueMax(const int& max_value)
|
||||
{
|
||||
csl_max_value = max_value;
|
||||
initCCSlItems();
|
||||
}
|
||||
|
||||
|
@@ -40,43 +40,40 @@ class CComponentsSlider : public CComponentsForm
|
||||
{
|
||||
private:
|
||||
///names of slider icons
|
||||
std::string csl_body_icon, csl_slider_icon;
|
||||
std::string csl_slider_icon;
|
||||
|
||||
///property: current value that should be displayed by slider button, see also setValuePos()
|
||||
int csl_current_value;
|
||||
|
||||
///property: minimal scale value, see also setValueScale()
|
||||
int csl_min_value;
|
||||
///property: maximal scale value, see also setValueScale()
|
||||
int csl_max_value;
|
||||
|
||||
///object: image objects for slider button and body
|
||||
CComponentsPicture *csl_body_obj, *csl_slider_obj;
|
||||
CComponentsPicture *csl_slider_obj;
|
||||
void paintMarker();
|
||||
|
||||
///init body image object
|
||||
void initCCSlBody();
|
||||
///init slider image object
|
||||
void initCCSlSlider();
|
||||
///init all items at once
|
||||
void initCCSlItems();
|
||||
|
||||
public:
|
||||
CComponentsSlider( const int& x_pos = 0, const int& y_pos = 0, const int& w = 120+16, const int& h = 32,
|
||||
CComponentsSlider( const int& x_pos = 0, const int& y_pos = 0, const int& w = SLIDER_WIDHT, const int& h = SLIDER_HEIGHT,
|
||||
const int& current_value = 0,
|
||||
const int& min_value = 0,
|
||||
const int& max_value = 100,
|
||||
CComponentsForm *parent = NULL,
|
||||
int shadow_mode = CC_SHADOW_OFF,
|
||||
fb_pixel_t& color_frame = COL_FRAME_PLUS_0,
|
||||
fb_pixel_t& color_body = COL_MENUHEAD_PLUS_0,
|
||||
fb_pixel_t& color_shadow = COL_SHADOW_PLUS_0);
|
||||
// ~CComponentsSlider(); //inherited from CComponentsForm
|
||||
virtual ~CComponentsSlider(); //inherited from CComponentsForm
|
||||
|
||||
void setValuePos(const int& current_value);
|
||||
void setValueScale(const int& min_value, const int& max_value);
|
||||
void setValue(const int& current_value, bool enable_paint = true);
|
||||
int getValue(){return csl_current_value;}
|
||||
void setValueMax(const int& max_value);
|
||||
void setSliderIcon(const std::string &icon_name);
|
||||
|
||||
// void paint(const bool &do_save_bg = CC_SAVE_SCREEN_YES);
|
||||
void paint(const bool &do_save_bg = CC_SAVE_SCREEN_YES);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -122,6 +122,7 @@
|
||||
|
||||
/* sliders */
|
||||
#define NEUTRINO_ICON_SLIDER_BODY "slider_body"
|
||||
#define NEUTRINO_ICON_SLIDER_BODY_PROGRESS "slider_body_progress"
|
||||
#define NEUTRINO_ICON_SLIDER_INACTIVE "slider_inactive"
|
||||
#define NEUTRINO_ICON_SLIDER_RED "slider_red"
|
||||
#define NEUTRINO_ICON_SLIDER_GREEN "slider_green"
|
||||
|
@@ -1219,6 +1219,9 @@ const time_settings_struct_t handling_infobar_setting[SNeutrinoSettings::HANDLIN
|
||||
|
||||
#define SIDEBAR_WIDTH CFrameBuffer::getInstance()->scale2Res(40)
|
||||
|
||||
#define SLIDER_HEIGHT CFrameBuffer::getInstance()->scale2Res(22)
|
||||
#define SLIDER_WIDHT CFrameBuffer::getInstance()->scale2Res(120)
|
||||
|
||||
#define BIGFONT_FACTOR 1.5
|
||||
|
||||
struct SglobalInfo
|
||||
|
Reference in New Issue
Block a user