mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-29 00:11:14 +02:00
record_info: add widget class for record info
This commit is contained in:
@@ -59,6 +59,7 @@
|
||||
#include "widget/keyboard_input.h"
|
||||
#include "widget/msgbox.h"
|
||||
#include "widget/progresswindow.h"
|
||||
#include "widget/record_info.h"
|
||||
#include "widget/termwindow.h"
|
||||
#include "widget/hourglass.h"
|
||||
#include <driver/record.h>
|
||||
@@ -1270,6 +1271,14 @@ int CTestMenu::exec(CMenuTarget *parent, const std::string &actionKey)
|
||||
y += dy;
|
||||
}
|
||||
}
|
||||
else if (actionKey == "record_count")
|
||||
{
|
||||
CRecInfo rv(20, 20, 120, 0);
|
||||
rv.paint();
|
||||
sleep(3);
|
||||
rv.hide();
|
||||
return res;
|
||||
}
|
||||
|
||||
return showTestMenu();
|
||||
}
|
||||
@@ -1377,8 +1386,12 @@ int CTestMenu::showTestMenu()
|
||||
// buttons
|
||||
w_test.addItem(new CMenuForwarder("Buttons", true, NULL, this, "buttons"));
|
||||
|
||||
// components
|
||||
CMenuWidget *w_cc = new CMenuWidget("OSD-Components Demo", NEUTRINO_ICON_INFO, width, MN_WIDGET_ID_TESTMENU_COMPONENTS);
|
||||
// record count
|
||||
CMenuForwarder *f_re = new CMenuForwarder("Record count", true, NULL, this, "record_count");
|
||||
w_test.addItem(f_re);
|
||||
|
||||
//components
|
||||
CMenuWidget * w_cc = new CMenuWidget("OSD-Components Demo", NEUTRINO_ICON_INFO, width, MN_WIDGET_ID_TESTMENU_COMPONENTS);
|
||||
w_test.addItem(new CMenuForwarder(w_cc->getName(), true, NULL, w_cc));
|
||||
showCCTests(w_cc);
|
||||
|
||||
|
@@ -32,6 +32,7 @@ libneutrino_gui_widget_a_SOURCES = \
|
||||
mountchooser.cpp \
|
||||
msgbox.cpp \
|
||||
navibar.cpp \
|
||||
record_info.cpp \
|
||||
shellwindow.cpp \
|
||||
stringinput.cpp \
|
||||
stringinput_ext.cpp \
|
||||
|
173
src/gui/widget/record_info.cpp
Normal file
173
src/gui/widget/record_info.cpp
Normal file
@@ -0,0 +1,173 @@
|
||||
/*
|
||||
Based up Neutrino-GUI - Tuxbox-Project
|
||||
Copyright (C) 2001 by Steffen Hehn 'McClean'
|
||||
|
||||
Show record infos.
|
||||
Copyright (C) 2022, 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 <global.h>
|
||||
|
||||
#include "record_info.h"
|
||||
#include <gui/widget/menue_target.h>
|
||||
|
||||
#include <driver/record.h>
|
||||
#include <daemonc/remotecontrol.h>
|
||||
#include <driver/fontrenderer.h>
|
||||
#include <system/helpers.h>
|
||||
|
||||
|
||||
extern CRemoteControl *g_RemoteControl; /* neutrino.cpp */
|
||||
|
||||
CRecInfo::CRecInfo( const int &x_pos,
|
||||
const int &y_pos,
|
||||
const int &w,
|
||||
const int &h,
|
||||
CComponentsForm *parent,
|
||||
const int &shadow_mode,
|
||||
const fb_pixel_t &color_frame,
|
||||
const fb_pixel_t &color_body,
|
||||
const fb_pixel_t &color_shadow) : CComponentsForm(x_pos, y_pos, w, h, parent, shadow_mode, color_frame, color_body, color_shadow)
|
||||
{
|
||||
cc_item_type.name= "record_view";
|
||||
setShadowWidth(OFFSET_SHADOW/2);
|
||||
setCorner(RADIUS_MIN, CORNER_ALL);
|
||||
rv_dx_cached = w;
|
||||
OnBeforePaint.connect(sigc::mem_fun(*this, &CRecInfo::init));
|
||||
init();
|
||||
}
|
||||
|
||||
CRecInfo::~CRecInfo()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CRecInfo::init()
|
||||
{
|
||||
clear();
|
||||
|
||||
// restore cached preset of width, because if preset of width was changed
|
||||
width = rv_dx_cached;
|
||||
|
||||
// init basic objects
|
||||
rv_rec_img = NULL;
|
||||
rv_ts_img = NULL;
|
||||
CRecordManager *crm = CRecordManager::getInstance();
|
||||
bool recordModeActive = crm->RecordingStatus();
|
||||
|
||||
// init text vars
|
||||
std::string rec_icon = "";
|
||||
std::string ts_icon = "";
|
||||
std::string s_records = "0x";
|
||||
|
||||
if (recordModeActive)
|
||||
{
|
||||
// get current channel id
|
||||
t_channel_id cur_chid = g_RemoteControl->current_channel_id;
|
||||
|
||||
// get current record count
|
||||
int records = crm->GetRecordCount();
|
||||
|
||||
// get global record mode
|
||||
int rec_mode = crm->GetRecordMode();
|
||||
|
||||
// get current channel record mode
|
||||
int cur_rec_mode = crm->GetRecordMode(cur_chid);
|
||||
|
||||
// set 'active' icons for record mode
|
||||
if (rec_mode == CRecordManager::RECMODE_REC)
|
||||
{
|
||||
if (cur_rec_mode == CRecordManager::RECMODE_OFF)
|
||||
rec_icon = NEUTRINO_ICON_REC_GRAY;
|
||||
else
|
||||
rec_icon = NEUTRINO_ICON_REC;
|
||||
}
|
||||
else if (rec_mode == CRecordManager::RECMODE_TSHIFT)
|
||||
{
|
||||
// subtract ts
|
||||
records--;
|
||||
if (cur_rec_mode == CRecordManager::RECMODE_OFF)
|
||||
ts_icon = NEUTRINO_ICON_AUTO_SHIFT_GRAY;
|
||||
else
|
||||
ts_icon = NEUTRINO_ICON_AUTO_SHIFT;
|
||||
}
|
||||
else if (rec_mode == CRecordManager::RECMODE_REC_TSHIFT)
|
||||
{
|
||||
rec_icon = NEUTRINO_ICON_REC;
|
||||
ts_icon = NEUTRINO_ICON_AUTO_SHIFT;
|
||||
}
|
||||
|
||||
s_records = to_string(records) + "x";
|
||||
}
|
||||
|
||||
// init images: create image objects, set position dimensions and space for icons inside record box (form)
|
||||
int w_rec_img = 0;
|
||||
int w_ts_img = 0;
|
||||
int h_rec_img = 0;
|
||||
int h_ts_img = 0;
|
||||
int w_icon_space = OFFSET_INNER_MIN;
|
||||
|
||||
if (!rec_icon.empty())
|
||||
{
|
||||
rv_rec_img = new CComponentsPicture(OFFSET_INNER_MIN, 0, rec_icon, this);
|
||||
w_rec_img = rv_rec_img->getWidth();
|
||||
h_rec_img = rv_rec_img->getHeight();
|
||||
w_icon_space += w_rec_img;
|
||||
}
|
||||
|
||||
if (!ts_icon.empty())
|
||||
{
|
||||
rv_ts_img = new CComponentsPicture(w_icon_space + OFFSET_INNER_MIN, 0, ts_icon, this);
|
||||
w_ts_img = rv_ts_img->getWidth();
|
||||
h_ts_img = rv_ts_img->getHeight();
|
||||
w_icon_space += w_ts_img;
|
||||
}
|
||||
|
||||
// set font type for record count text
|
||||
Font *font_rv = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL];
|
||||
|
||||
// init height of record info box
|
||||
int h_min = height;
|
||||
if (height == 0)
|
||||
{
|
||||
int h_img_max = std::max(h_rec_img, h_ts_img);
|
||||
h_min = std::max(h_img_max + 2*OFFSET_INNER_MIN, font_rv->getHeight() + 2*OFFSET_INNER_MIN);
|
||||
height = std::max(h_min, height);
|
||||
}
|
||||
|
||||
// init image positions
|
||||
if (rv_rec_img)
|
||||
rv_rec_img->setYPos(height/2 - h_rec_img/2);
|
||||
if (rv_ts_img)
|
||||
rv_ts_img->setYPos(height/2 - h_ts_img/2);
|
||||
|
||||
// init text
|
||||
int x_txt = w_icon_space + OFFSET_INNER_MIN;
|
||||
rv_text = new CComponentsTextTransp(this, x_txt, 0, font_rv->getRenderWidth(s_records), height, s_records, CTextBox::RIGHT, font_rv);
|
||||
int y_txt = height/2 - rv_text->getHeight()/2;
|
||||
rv_text->setPos(x_txt, y_txt);
|
||||
rv_text->doPaintBg(false);
|
||||
|
||||
// finally set width of record info box (if different to passed parameters or width == 0
|
||||
int w_min = w_icon_space + OFFSET_INNER_MIN + rv_text->getWidth() + OFFSET_INNER_MIN;
|
||||
width = std::max(w_min, width);
|
||||
}
|
51
src/gui/widget/record_info.h
Normal file
51
src/gui/widget/record_info.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
Based up Neutrino-GUI - Tuxbox-Project
|
||||
Copyright (C) 2001 by Steffen Hehn 'McClean'
|
||||
|
||||
Show record infos.
|
||||
Copyright (C) 2022, 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 __REC_INFO_H__
|
||||
#define __REC_INFO_H__
|
||||
|
||||
#include <gui/components/cc.h>
|
||||
|
||||
class CRecInfo : public CComponentsForm
|
||||
{
|
||||
private:
|
||||
CComponentsPicture *rv_rec_img, *rv_ts_img;
|
||||
CComponentsTextTransp *rv_text;
|
||||
int rv_dx_cached;
|
||||
void init();
|
||||
|
||||
public:
|
||||
CRecInfo( const int &x_pos,
|
||||
const int &y_pos,
|
||||
const int &w = 0,
|
||||
const int &h = 0,
|
||||
CComponentsForm *parent = NULL,
|
||||
const int &shadow_mode = CC_SHADOW_OFF,
|
||||
const fb_pixel_t &color_frame = COL_FRAME_PLUS_0,
|
||||
const fb_pixel_t &color_body = COL_MENUCONTENT_PLUS_0,
|
||||
const fb_pixel_t &color_shadow = COL_SHADOW_PLUS_0);
|
||||
|
||||
virtual ~CRecInfo();
|
||||
};
|
||||
#endif
|
Reference in New Issue
Block a user