mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-09-01 18:01:13 +02:00
listframe: add posibility to use cc items inside listframe rows
This commit is contained in:
@@ -57,6 +57,7 @@
|
||||
#include <gui/components/cc.h>
|
||||
#include <gui/widget/icons.h>
|
||||
#include <driver/fontrenderer.h>
|
||||
#include <driver/neutrinofonts.h>
|
||||
|
||||
#define MAX_WINDOW_WIDTH (frameBuffer ? frameBuffer->getScreenWidth() - 40:0)
|
||||
#define MAX_WINDOW_HEIGHT (frameBuffer ? frameBuffer->getScreenHeight() - 40:0)
|
||||
@@ -78,7 +79,7 @@
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CListFrame::CListFrame( LF_LINES* lines, Font* font_text, const int pmode,
|
||||
CListFrame::CListFrame( lf_line_types_t* lines, Font* font_text, const int pmode,
|
||||
const CBox* position, const char* textTitle, Font* font_title)
|
||||
{
|
||||
//TRACE("[CListFrame] new\r\n");
|
||||
@@ -127,7 +128,7 @@ CListFrame::CListFrame( LF_LINES* lines, Font* font_text, const int pmode,
|
||||
onNewLineArray();
|
||||
}
|
||||
|
||||
CListFrame::CListFrame( LF_LINES* lines)
|
||||
CListFrame::CListFrame( lf_line_types_t* lines)
|
||||
{
|
||||
//TRACE("[CListFrame] new\r\n");
|
||||
initVar();
|
||||
@@ -158,8 +159,13 @@ CListFrame::CListFrame()
|
||||
|
||||
CListFrame::~CListFrame()
|
||||
{
|
||||
if (m_pLines){
|
||||
for(int row = 0; row < m_pLines->rows; row++)
|
||||
cleanupRow(m_pLines, row);
|
||||
}
|
||||
|
||||
//TRACE("[CListFrame] del\r\n");
|
||||
hide();
|
||||
hide(); //TODO: remove hide here
|
||||
}
|
||||
|
||||
void CListFrame::initVar(void)
|
||||
@@ -177,7 +183,7 @@ void CListFrame::initVar(void)
|
||||
m_nFontHeaderListHeight = m_pcFontHeaderList->getHeight();
|
||||
|
||||
m_pcFontTitle = FONT_TITLE;
|
||||
m_textTitle = "MovieBrowser";
|
||||
m_textTitle = "ListFrame";
|
||||
m_nFontTitleHeight = m_pcFontTitle->getHeight();
|
||||
|
||||
m_nNrOfPages = 1;
|
||||
@@ -298,7 +304,7 @@ void CListFrame::onNewLineArray(void)
|
||||
int maxTextWidth = 0;
|
||||
|
||||
maxTextWidth = 300; // TODO
|
||||
m_nNrOfLines = m_pLines->lineArray[0].size();
|
||||
m_nNrOfLines = m_pLines->lineArray[0].v_text.size();
|
||||
if(m_nNrOfLines > 0 )
|
||||
{
|
||||
/* check if we have to recalculate the window frame size, due to auto width and auto height */
|
||||
@@ -460,13 +466,62 @@ void CListFrame::refreshLine(int line)
|
||||
m_cFrameListRel.iWidth - x + m_cFrameListRel.iX - OFFSET_INNER_MID);
|
||||
if (row > 0)
|
||||
xDiff = 0;
|
||||
m_pcFontList->RenderString(x+m_cFrame.iX+xDiff, y+m_cFrame.iY,
|
||||
width-xDiff, m_pLines->lineArray[row][line].c_str(),
|
||||
color);
|
||||
|
||||
if (!m_pLines->lineArray[row].v_text[line].empty())
|
||||
paintRowText(m_pLines->lineArray[row].v_text[line], m_pcFontList, x+m_cFrame.iX+xDiff, y+m_cFrame.iY, width-xDiff, m_nFontListHeight, color);
|
||||
|
||||
if (m_pLines->lineArray[row].v_ccItem[line] != NULL)
|
||||
{
|
||||
CComponentsItem *item = (m_pLines->lineArray[row].v_ccItem[line]);
|
||||
int h_item = item->getHeight();
|
||||
item->setDimensionsAll(x+m_cFrame.iX+xDiff, y+m_cFrame.iY - m_nFontListHeight/2 - h_item/2, width-xDiff, h_item);
|
||||
item->setColorBody(bgcolor);
|
||||
item->setCorner(0);
|
||||
item->forceRePaint();
|
||||
item->paint(false);
|
||||
}
|
||||
|
||||
x += width + OFFSET_INNER_SMALL;
|
||||
}
|
||||
}
|
||||
|
||||
void CListFrame::paintRowText(const std::string& text, Font* font, const int& x_pos, const int& y_pos, const int& dx, const int& dy, const fb_pixel_t& col)
|
||||
{
|
||||
Font *tmp_font = font;
|
||||
int y_tmp = y_pos;
|
||||
|
||||
if (dx < tmp_font->getRenderWidth(text))
|
||||
{
|
||||
int w_row = dx-OFFSET_INNER_MID;
|
||||
int h_row = dy-OFFSET_INNER_MIN;
|
||||
|
||||
tmp_font = *CNeutrinoFonts::getInstance()->getDynFont(w_row, h_row, text);
|
||||
y_tmp -= (font->getHeight() - tmp_font->getHeight()) >>1 ;
|
||||
}
|
||||
tmp_font->RenderString(x_pos, y_tmp, dx, text.c_str(), col);
|
||||
}
|
||||
|
||||
void CListFrame::addLine2Row(lf_line_types_t* lines, const int& row_num, const std::string& text, CComponentsItem* cc_Item)
|
||||
{
|
||||
lines->lineArray[row_num].v_text.push_back(text);
|
||||
lines->lineArray[row_num].v_ccItem.push_back(cc_Item);
|
||||
}
|
||||
|
||||
void CListFrame::cleanupRow(lf_line_types_t* lines, const int& row_num)
|
||||
{
|
||||
lines->lineArray[row_num].v_text.clear();
|
||||
for(size_t i = 0; i < lines->lineArray[row_num].v_ccItem.size(); i++)
|
||||
{
|
||||
if(lines->lineArray[row_num].v_ccItem[i])
|
||||
{
|
||||
//TRACE("[CListFrame]->cleanupRow: item = %p getItemName() = %s getItemType() = %d\r\n", lines->lineArray[row_num].v_ccItem[i], lines->lineArray[row_num].v_ccItem[i]->getItemName().c_str(), lines->lineArray[row_num].v_ccItem[i]->getItemType());
|
||||
delete lines->lineArray[row_num].v_ccItem[i];
|
||||
lines->lineArray[row_num].v_ccItem[i] = NULL;
|
||||
}
|
||||
}
|
||||
lines->lineArray[row_num].v_ccItem.clear();
|
||||
}
|
||||
|
||||
void CListFrame::refreshHeaderList(void)
|
||||
{
|
||||
//TRACE("[CListFrame]->refreshHeaderList \r\n");
|
||||
@@ -491,9 +546,9 @@ void CListFrame::refreshHeaderList(void)
|
||||
//TRACE(" normalize width to %d , x:%d \r\n",width,x);
|
||||
loop = false;
|
||||
}
|
||||
m_pcFontHeaderList->RenderString(x+m_cFrame.iX, y+m_cFrame.iY,
|
||||
width, m_pLines->lineHeader[row].c_str(),
|
||||
HEADER_LIST_FONT_COLOR);
|
||||
|
||||
paintRowText(m_pLines->lineHeader[row], m_pcFontHeaderList, x+m_cFrame.iX, y+m_cFrame.iY, width, m_nFontHeaderListHeight, HEADER_LIST_FONT_COLOR);
|
||||
|
||||
x += width + OFFSET_INNER_SMALL;
|
||||
}
|
||||
}
|
||||
@@ -561,7 +616,7 @@ void CListFrame::refresh(void)
|
||||
refreshList();
|
||||
}
|
||||
|
||||
bool CListFrame::setLines(LF_LINES* lines)
|
||||
bool CListFrame::setLines(lf_line_types_t* lines)
|
||||
{
|
||||
if(lines == NULL)
|
||||
return(false);
|
||||
|
@@ -55,17 +55,27 @@
|
||||
#include <vector>
|
||||
#include <gui/widget/textbox.h>
|
||||
#include <driver/fb_window.h>
|
||||
#include <gui/components/cc.h>
|
||||
|
||||
#define LF_MAX_ROWS 9
|
||||
typedef struct
|
||||
#define LF_MAX_ROWS 10
|
||||
|
||||
typedef struct lf_row_types_t
|
||||
{
|
||||
std::vector<std::string> v_text;
|
||||
std::vector<CComponentsItem*> v_ccItem;
|
||||
}lf_row_types_struct;
|
||||
|
||||
typedef struct lf_line_types_t
|
||||
{
|
||||
int rows;
|
||||
std::string lineHeader[LF_MAX_ROWS];
|
||||
std::vector<std::string> lineArray[LF_MAX_ROWS];
|
||||
lf_row_types_t lineArray[LF_MAX_ROWS];
|
||||
int rowWidth[LF_MAX_ROWS];
|
||||
std::vector<std::string> Icon;
|
||||
std::vector<bool> marked;
|
||||
}LF_LINES;
|
||||
|
||||
|
||||
}lf_line_types_struct;
|
||||
|
||||
class CListFrame
|
||||
{
|
||||
@@ -81,9 +91,10 @@ class CListFrame
|
||||
void reSizeMainFrameWidth(int maxTextWidth);
|
||||
void reSizeMainFrameHeight(int maxTextHeight);
|
||||
int paintListIcon(int x, int y, int line);
|
||||
void paintRowText(const std::string& text, Font* font, const int& x_pos, const int& y_pos, const int& dx, const int& dy, const fb_pixel_t& col);
|
||||
|
||||
/* Variables */
|
||||
LF_LINES* m_pLines;
|
||||
lf_line_types_t* m_pLines;
|
||||
|
||||
CBox m_cFrame;
|
||||
CBox m_cFrameTitleRel;
|
||||
@@ -122,8 +133,8 @@ class CListFrame
|
||||
public:
|
||||
/* Constructor */
|
||||
CListFrame();
|
||||
CListFrame( LF_LINES* lines);
|
||||
CListFrame( LF_LINES* lines,
|
||||
CListFrame( lf_line_types_t* lines);
|
||||
CListFrame( lf_line_types_t* lines,
|
||||
Font* font_text,
|
||||
const int mode,
|
||||
const CBox* position,
|
||||
@@ -139,7 +150,9 @@ class CListFrame
|
||||
void scrollPageUp(const int pages);
|
||||
void scrollLineDown(const int lines);
|
||||
void scrollLineUp(const int lines);
|
||||
bool setLines(LF_LINES* lines);
|
||||
bool setLines(lf_line_types_t* lines);
|
||||
static void addLine2Row(lf_line_types_t* lines, const int& row_num, const std::string& text, CComponentsItem* cc_Item = NULL);
|
||||
static void cleanupRow(lf_line_types_t* lines, const int& row_num);
|
||||
bool setTitle(char* title);
|
||||
bool setSelectedLine(int selection);
|
||||
void setSelectedMarked(bool enable);
|
||||
|
Reference in New Issue
Block a user