mirror of https://github.com/tp4a/teleport
.temp.
parent
b70593a65e
commit
4897a6e483
|
@ -6,6 +6,17 @@
|
|||
#define FONT_SIZE_DEFAULT 12
|
||||
#define TIME_STR_PIXEL_SIZE 16
|
||||
#define TEXT_COLOR QColor(255,255,255,153)
|
||||
#define SPEED_BTN_WIDTH 42
|
||||
#define CHKBOX_RIGHT_PADDING 6
|
||||
#define PADDING_TIME_PROGRESS_BAR 10
|
||||
#define SPEED_BTN_PADDING_TOP 8
|
||||
#define SPEED_BTN_PADDING_RIGHT 8
|
||||
#define SKIP_PADDING_TOP 10
|
||||
|
||||
#define BAR_ALIGN_TOP 10
|
||||
#define BAR_PADDING_TOP 18
|
||||
#define BAR_PADDING_LEFT 15
|
||||
#define BAR_PADDING_RIGHT 15
|
||||
|
||||
typedef struct RES_MAP {
|
||||
RES_ID id;
|
||||
|
@ -16,24 +27,25 @@ static RES_MAP img_res[res__max] = {
|
|||
{res_bg_left, "bg-left"},
|
||||
{res_bg_mid, "bg-mid"},
|
||||
{res_bg_right, "bg-right"},
|
||||
{res_bs_left, "btn-left"},
|
||||
{res_bs_mid, "btn-mid"},
|
||||
{res_bs_right, "btn-right"},
|
||||
{res_bsh_left, "btnsel-left"},
|
||||
{res_bsh_mid, "btnsel-mid"},
|
||||
{res_bsh_right, "btnsel-right"},
|
||||
{res_pbh_left, "prgbarh-left"},
|
||||
{res_pbh_mid, "prgbarh-mid"},
|
||||
{res_pb_mid, "prgbar-mid"},
|
||||
{res_pb_right, "prgbar-right"},
|
||||
// {res_pp, "prgpt"},
|
||||
// {res_pph, "prgpt-hover"},
|
||||
{res_cb, "select"},
|
||||
{res_cbh, "selected"},
|
||||
// {res_play, "play"},
|
||||
// {res_play_hover, "play-hover"},
|
||||
// {res_pause, "pause"},
|
||||
// {res_pause_hover, "pause-hover"}
|
||||
{res_btn_normal_left, "btn-normal-left"},
|
||||
{res_btn_normal_mid, "btn-normal-mid"},
|
||||
{res_btn_normal_right, "btn-normal-right"},
|
||||
{res_btn_sel_left, "btn-sel-left"},
|
||||
{res_btn_sel_mid, "btn-sel-mid"},
|
||||
{res_btn_sel_right, "btn-sel-right"},
|
||||
{res_btn_hover_left, "btn-hover-left"},
|
||||
{res_btn_hover_mid, "btn-hover-mid"},
|
||||
{res_btn_hover_right, "btn-hover-right"},
|
||||
|
||||
{res_prgbarh_left, "prgbarh-left"},
|
||||
{res_prgbarh_mid, "prgbarh-mid"},
|
||||
{res_prgbar_mid, "prgbar-mid"},
|
||||
{res_prgbar_right, "prgbar-right"},
|
||||
|
||||
{res_chkbox_normal, "chkbox-normal"},
|
||||
{res_chkbox_hover, "chkbox-hover"},
|
||||
{res_chkbox_sel_normal, "chkbox-sel-normal"},
|
||||
{res_chkbox_sel_hover, "chkbox-sel-hover"},
|
||||
};
|
||||
|
||||
typedef struct SPEED_MAP {
|
||||
|
@ -69,10 +81,11 @@ Bar::Bar() {
|
|||
m_percent_last_draw = -1;
|
||||
|
||||
m_play_hover = false;
|
||||
m_playing = true; // 0=play, 2=pause
|
||||
m_playing = true; // false=paused
|
||||
m_speed_selected = speed_1x;
|
||||
m_speed_hover = speed_count; // speed_count=no-hover
|
||||
m_skip_selected = true;
|
||||
m_skip_selected = false;
|
||||
m_skip_hover = false;
|
||||
}
|
||||
|
||||
Bar::~Bar() {
|
||||
|
@ -92,11 +105,11 @@ bool Bar::init(QWidget* owner) {
|
|||
}
|
||||
|
||||
// 无需合成的图像
|
||||
if(!m_img_btn_play[play_running][widget_normal].load(":/tp-player/res/bar/play.png")
|
||||
if(!m_img_btn_play[play_running][widget_normal].load(":/tp-player/res/bar/play-normal.png")
|
||||
|| !m_img_btn_play[play_running][widget_hover].load(":/tp-player/res/bar/play-hover.png")
|
||||
|| !m_img_btn_play[play_paused][widget_normal].load(":/tp-player/res/bar/pause.png")
|
||||
|| !m_img_btn_play[play_paused][widget_normal].load(":/tp-player/res/bar/pause-normal.png")
|
||||
|| !m_img_btn_play[play_paused][widget_hover].load(":/tp-player/res/bar/pause-hover.png")
|
||||
|| !m_img_progress_pointer[widget_normal].load(":/tp-player/res/bar/prgpt.png")
|
||||
|| !m_img_progress_pointer[widget_normal].load(":/tp-player/res/bar/prgpt-normal.png")
|
||||
|| !m_img_progress_pointer[widget_hover].load(":/tp-player/res/bar/prgpt-hover.png")
|
||||
) {
|
||||
return false;
|
||||
|
@ -120,9 +133,7 @@ void Bar::start(uint32_t total_ms, int width) {
|
|||
_init_imgages();
|
||||
QRect rc = m_owner->rect();
|
||||
m_rc = QRect(0, 0, m_width, m_height);
|
||||
m_rc.moveTo((rc.width() - m_width)/2, 10);
|
||||
//m_rc.moveTo(10, 600);
|
||||
qDebug("m_rc (%d,%d)-(%d,%d)", m_rc.left(), m_rc.top(), m_rc.right(), m_rc.bottom());
|
||||
m_rc.moveTo((rc.width() - m_width)/2, BAR_ALIGN_TOP);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -139,38 +150,44 @@ void Bar::_init_imgages() {
|
|||
|
||||
// 合成背景图像
|
||||
{
|
||||
|
||||
pp.drawPixmap(0, 0, m_res[res_bg_left].width(), m_res[res_bg_left].height(), m_res[res_bg_left]);
|
||||
pp.drawPixmap(m_res[res_bg_left].width(), 0, m_width - m_res[res_bg_left].width() - m_res[res_bg_right].width(), m_height, m_res[res_bg_mid]);
|
||||
pp.drawPixmap(m_width-m_res[res_bg_right].width(), 0, m_res[res_bg_right].width(), m_height, m_res[res_bg_right]);
|
||||
}
|
||||
|
||||
{
|
||||
m_rc_btn_play = QRect(15, (m_height - m_img_btn_play[play_running][widget_normal].height())/2 , m_img_btn_play[play_running][widget_normal].width(), m_img_btn_play[play_running][widget_normal].height());
|
||||
m_rc_btn_play = QRect(BAR_PADDING_LEFT, (m_height - m_img_btn_play[play_running][widget_normal].height())/2 , m_img_btn_play[play_running][widget_normal].width(), m_img_btn_play[play_running][widget_normal].height());
|
||||
}
|
||||
|
||||
// 合成速度按钮
|
||||
{
|
||||
int w = 42, h = m_res[res_bs_left].height();
|
||||
int w = SPEED_BTN_WIDTH, h = m_res[res_btn_normal_left].height();
|
||||
QRect rc(0, 0, w, h);
|
||||
QPixmap btn[widget__max];
|
||||
QPixmap btn[btnspd_state_count];
|
||||
|
||||
// 未选中状态
|
||||
btn[widget_normal] = QPixmap(w, h);
|
||||
btn[widget_normal].fill(Qt::transparent);//用透明色填充
|
||||
QPainter pn(&btn[widget_normal]);
|
||||
pn.drawPixmap(0, 0, m_res[res_bs_left].width(), m_res[res_bs_left].height(), m_res[res_bs_left]);
|
||||
pn.drawPixmap(m_res[res_bs_left].width(), 0, w - m_res[res_bs_left].width() - m_res[res_bs_right].width(), h, m_res[res_bs_mid]);
|
||||
pn.drawPixmap(w-m_res[res_bs_right].width(), 0, m_res[res_bs_right].width(), h, m_res[res_bs_right]);
|
||||
btn[btnspd_normal] = QPixmap(w, h);
|
||||
btn[btnspd_normal].fill(Qt::transparent);//用透明色填充
|
||||
QPainter pn(&btn[btnspd_normal]);
|
||||
pn.drawPixmap(0, 0, m_res[res_btn_normal_left].width(), m_res[res_btn_normal_left].height(), m_res[res_btn_normal_left]);
|
||||
pn.drawPixmap(m_res[res_btn_normal_left].width(), 0, w - m_res[res_btn_normal_left].width() - m_res[res_btn_normal_right].width(), h, m_res[res_btn_normal_mid]);
|
||||
pn.drawPixmap(w-m_res[res_btn_normal_right].width(), 0, m_res[res_btn_normal_right].width(), h, m_res[res_btn_normal_right]);
|
||||
// 选中状态
|
||||
btn[widget_hover] = QPixmap(w, h);
|
||||
btn[widget_hover].fill(Qt::transparent);//用透明色填充
|
||||
QPainter ph(&btn[widget_hover]);
|
||||
ph.drawPixmap(0, 0, m_res[res_bsh_left].width(), m_res[res_bsh_left].height(), m_res[res_bsh_left]);
|
||||
ph.drawPixmap(m_res[res_bsh_left].width(), 0, w - m_res[res_bsh_left].width() - m_res[res_bsh_right].width(), h, m_res[res_bsh_mid]);
|
||||
ph.drawPixmap(w-m_res[res_bsh_right].width(), 0, m_res[res_bsh_right].width(), h, m_res[res_bsh_right]);
|
||||
btn[btnspd_sel] = QPixmap(w, h);
|
||||
btn[btnspd_sel].fill(Qt::transparent);//用透明色填充
|
||||
QPainter ps(&btn[btnspd_sel]);
|
||||
ps.drawPixmap(0, 0, m_res[res_btn_sel_left].width(), m_res[res_btn_sel_left].height(), m_res[res_btn_sel_left]);
|
||||
ps.drawPixmap(m_res[res_btn_sel_left].width(), 0, w - m_res[res_btn_sel_left].width() - m_res[res_btn_sel_right].width(), h, m_res[res_btn_sel_mid]);
|
||||
ps.drawPixmap(w-m_res[res_btn_sel_right].width(), 0, m_res[res_btn_sel_right].width(), h, m_res[res_btn_sel_right]);
|
||||
// 鼠标滑过状态
|
||||
btn[btnspd_hover] = QPixmap(w, h);
|
||||
btn[btnspd_hover].fill(Qt::transparent);//用透明色填充
|
||||
QPainter ph(&btn[btnspd_hover]);
|
||||
ph.drawPixmap(0, 0, m_res[res_btn_hover_left].width(), m_res[res_btn_hover_left].height(), m_res[res_btn_hover_left]);
|
||||
ph.drawPixmap(m_res[res_btn_hover_left].width(), 0, w - m_res[res_btn_hover_left].width() - m_res[res_btn_hover_right].width(), h, m_res[res_btn_hover_mid]);
|
||||
ph.drawPixmap(w-m_res[res_btn_hover_right].width(), 0, m_res[res_btn_hover_right].width(), h, m_res[res_btn_hover_right]);
|
||||
|
||||
for(int i = 0; i < widget__max; ++i) {
|
||||
for(int i = 0; i < btnspd_state_count; ++i) {
|
||||
for(int j = 0; j < speed_count; ++j) {
|
||||
m_img_btn_speed[j][i] = QPixmap(w, h);
|
||||
m_img_btn_speed[j][i].fill(Qt::transparent);
|
||||
|
@ -197,44 +214,49 @@ void Bar::_init_imgages() {
|
|||
|
||||
{
|
||||
int h = fm.height();
|
||||
if(h < m_res[res_cb].height())
|
||||
h = m_res[res_cb].height();
|
||||
m_rc_skip = QRect(0, 0, fm.width("无操作则跳过")+8+m_res[res_cb].width(), h);
|
||||
if(h < m_res[res_chkbox_normal].height())
|
||||
h = m_res[res_chkbox_normal].height();
|
||||
m_rc_skip = QRect(0, 0, fm.width("无操作则跳过") + CHKBOX_RIGHT_PADDING + m_res[res_chkbox_normal].width(), h);
|
||||
}
|
||||
|
||||
int w = m_rc_skip.width();
|
||||
int h = m_rc_skip.height();
|
||||
int chkbox_top = (m_rc_skip.height() - m_res[res_cb].height()) / 2;
|
||||
int text_left = m_res[res_cb].width() + 8;
|
||||
int chkbox_top = (m_rc_skip.height() - m_res[res_chkbox_normal].height()) / 2;
|
||||
int text_left = m_res[res_chkbox_normal].width() + CHKBOX_RIGHT_PADDING;
|
||||
int text_top = (m_rc_skip.height() - fm.height()) / 2;
|
||||
|
||||
{
|
||||
m_img_skip[widget_normal] = QPixmap(w,h);
|
||||
m_img_skip[widget_normal].fill(Qt::transparent);
|
||||
QPainter ps(&m_img_skip[widget_normal]);
|
||||
for(int i = 0; i < chkbox_state_count; ++i) {
|
||||
for(int j = 0; j < widget_state_count; ++j) {
|
||||
m_img_skip[i][j] = QPixmap(w,h);
|
||||
m_img_skip[i][j].fill(Qt::transparent);
|
||||
QPainter ps(&m_img_skip[i][j]);
|
||||
ps.setPen(TEXT_COLOR);
|
||||
QFont font = ps.font();
|
||||
font.setFamily("微软雅黑");
|
||||
font.setPixelSize(FONT_SIZE_DEFAULT);
|
||||
ps.setFont(font);
|
||||
ps.drawPixmap(0, chkbox_top, m_res[res_cb].width(), m_res[res_cb].height(), m_res[res_cb]);
|
||||
ps.drawText(QRect(text_left, text_top, w-text_left, h-text_top), Qt::AlignCenter, "无操作则跳过");
|
||||
}
|
||||
|
||||
{
|
||||
m_img_skip[widget_hover] = QPixmap(w,h);
|
||||
m_img_skip[widget_hover].fill(Qt::transparent);
|
||||
QPainter ps(&m_img_skip[widget_hover]);
|
||||
ps.setPen(TEXT_COLOR);
|
||||
QFont font = ps.font();
|
||||
font.setFamily("微软雅黑");
|
||||
font.setPixelSize(FONT_SIZE_DEFAULT);
|
||||
ps.setFont(font);
|
||||
ps.drawPixmap(0, chkbox_top, m_res[res_cbh].width(), m_res[res_cbh].height(), m_res[res_cbh]);
|
||||
QPixmap* img = nullptr;
|
||||
if(i == chkbox_normal && j == widget_normal)
|
||||
img = &m_res[res_chkbox_normal];
|
||||
else if(i == chkbox_normal && j == widget_hover)
|
||||
img = &m_res[res_chkbox_hover];
|
||||
else if(i == chkbox_selected && j == widget_normal)
|
||||
img = &m_res[res_chkbox_sel_normal];
|
||||
else if(i == chkbox_selected && j == widget_hover)
|
||||
img = &m_res[res_chkbox_sel_hover];
|
||||
|
||||
if(img == nullptr) {
|
||||
qDebug("ERROR: can not load image for check-box.");
|
||||
img = &m_res[res_chkbox_normal];
|
||||
}
|
||||
ps.drawPixmap(0, chkbox_top, img->width(), img->height(), *img);
|
||||
ps.drawText(QRect(text_left, text_top, w-text_left, h-text_top), Qt::AlignCenter, "无操作则跳过");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 定位进度条
|
||||
{
|
||||
// 计算显示时间所需的宽高
|
||||
font.setFamily("consolas");
|
||||
|
@ -259,32 +281,30 @@ void Bar::_init_imgages() {
|
|||
pp.drawText(m_rc_time_total, Qt::AlignLeft, m_str_total_time);
|
||||
|
||||
// 定位时间字符串的位置
|
||||
m_rc_time_passed.moveTo(15+m_img_btn_play[play_running][widget_normal].width()+10, 18);
|
||||
m_rc_time_total.moveTo(m_width - 15 - m_rc_time_total.width(), 18);
|
||||
m_rc_time_passed.moveTo(BAR_PADDING_LEFT+m_img_btn_play[play_running][widget_normal].width()+PADDING_TIME_PROGRESS_BAR, BAR_PADDING_TOP);
|
||||
m_rc_time_total.moveTo(m_width - BAR_PADDING_RIGHT - m_rc_time_total.width(), BAR_PADDING_TOP);
|
||||
|
||||
int prog_width = m_rc_time_total.left() - 10 - 10 - m_rc_time_passed.right();// - m_img_progress_pointer[widget_normal].width();
|
||||
int prog_height = max(m_res[res_pbh_left].height(), m_img_progress_pointer->height());
|
||||
int prog_width = m_rc_time_total.left() - PADDING_TIME_PROGRESS_BAR - PADDING_TIME_PROGRESS_BAR - m_rc_time_passed.right();
|
||||
int prog_height = max(m_res[res_prgbarh_left].height(), m_img_progress_pointer->height());
|
||||
m_rc_progress = QRect(0, 0, prog_width, prog_height);
|
||||
m_rc_progress.moveTo(m_rc_time_passed.right() + 10, m_rc_time_passed.height() + (m_rc_time_passed.height() - prog_height)/2);
|
||||
|
||||
qDebug("prog: %d,%d w:%d,h:%d", m_rc_progress.left(), m_rc_progress.top(), prog_width, prog_height);
|
||||
m_rc_progress.moveTo(m_rc_time_passed.right() + PADDING_TIME_PROGRESS_BAR, m_rc_time_passed.height() + (m_rc_time_passed.height() - prog_height)/2);
|
||||
}
|
||||
|
||||
|
||||
// 定位速度按钮
|
||||
{
|
||||
int left = m_rc_time_passed.right() + 10;
|
||||
int top = m_rc_time_passed.bottom() + 8;
|
||||
int left = m_rc_time_passed.right() + PADDING_TIME_PROGRESS_BAR;
|
||||
int top = m_rc_time_passed.bottom() + SPEED_BTN_PADDING_TOP;
|
||||
for(int i = 0; i < speed_count; i++) {
|
||||
m_rc_btn_speed[i] = QRect(left, top, m_img_btn_speed[i][widget_normal].width(), m_img_btn_speed[i][widget_normal].height());
|
||||
left += m_img_btn_speed[i][widget_normal].width() + 8;
|
||||
left += m_img_btn_speed[i][widget_normal].width() + SPEED_BTN_PADDING_RIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
// 定位跳过选项
|
||||
{
|
||||
int left = m_rc_time_total.left() - m_rc_skip.width() - 10;
|
||||
int top = m_rc_time_passed.bottom() + 10;
|
||||
int left = m_rc_time_total.left() - m_rc_skip.width() - PADDING_TIME_PROGRESS_BAR;
|
||||
int top = m_rc_time_passed.bottom() + SKIP_PADDING_TOP;//m_rc_btn_speed[0].top() + (m_rc_btn_speed[0].height() - m_rc_skip.height())/2;
|
||||
m_rc_skip.moveTo(left, top);
|
||||
}
|
||||
|
||||
|
@ -363,6 +383,14 @@ void Bar::onMouseMove(int x, int y) {
|
|||
}
|
||||
}
|
||||
|
||||
bool skip_hover = m_rc_skip.contains(pt);
|
||||
if(skip_hover != m_skip_hover) {
|
||||
m_skip_hover = skip_hover;
|
||||
m_owner->update(m_rc.left()+m_rc_skip.left(), m_rc.top()+m_rc_skip.top(), m_rc_skip.width(), m_rc_skip.height());
|
||||
}
|
||||
if(skip_hover)
|
||||
return;
|
||||
|
||||
// TODO: more hover detect.
|
||||
}
|
||||
|
||||
|
@ -468,23 +496,23 @@ void Bar::draw(QPainter& painter, const QRect& rc_draw){
|
|||
QPainter pp(&m_img_progress);
|
||||
|
||||
// 进度条
|
||||
int top = (rc.height() - m_res[res_pbh_left].height())/2;
|
||||
int top = (rc.height() - m_res[res_prgbarh_left].height())/2;
|
||||
int passed_width = rc.width() * m_percent / 100; // 已经播放的进度条宽度
|
||||
int remain_width = rc.width() - passed_width; // 剩下未播放的进度条宽度
|
||||
|
||||
if(passed_width >= m_res[res_pbh_left].width())
|
||||
pp.drawPixmap(0, top , m_res[res_pbh_left].width(), m_res[res_pbh_left].height(), m_res[res_pbh_left]);
|
||||
if(passed_width >= m_res[res_prgbarh_left].width())
|
||||
pp.drawPixmap(0, top , m_res[res_prgbarh_left].width(), m_res[res_prgbarh_left].height(), m_res[res_prgbarh_left]);
|
||||
if(passed_width > 0) {
|
||||
//pp.drawPixmap(m_res[res_pbh_left].width(), top, passed_width - m_res[res_pbh_left].width(), m_res[res_pbh_mid].height(), m_res[res_pbh_mid]);
|
||||
if(remain_width > m_res[res_pb_right].width())
|
||||
pp.drawPixmap(m_res[res_pbh_left].width(), top, passed_width - m_res[res_pbh_left].width(), m_res[res_pbh_mid].height(), m_res[res_pbh_mid]);
|
||||
if(remain_width > m_res[res_prgbar_right].width())
|
||||
pp.drawPixmap(m_res[res_prgbarh_left].width(), top, passed_width - m_res[res_prgbarh_left].width(), m_res[res_prgbarh_mid].height(), m_res[res_prgbarh_mid]);
|
||||
else
|
||||
pp.drawPixmap(m_res[res_pbh_left].width(), top, passed_width - m_res[res_pbh_left].width() - m_res[res_pb_right].width(), m_res[res_pbh_mid].height(), m_res[res_pbh_mid]);
|
||||
pp.drawPixmap(m_res[res_prgbarh_left].width(), top, passed_width - m_res[res_prgbarh_left].width() - m_res[res_prgbar_right].width(), m_res[res_prgbarh_mid].height(), m_res[res_prgbarh_mid]);
|
||||
}
|
||||
if(remain_width > 0)
|
||||
pp.drawPixmap(passed_width, top, remain_width - m_res[res_pb_right].width(), m_res[res_pb_mid].height(), m_res[res_pb_mid]);
|
||||
if(remain_width >= m_res[res_pb_right].width())
|
||||
pp.drawPixmap(rc.width() - m_res[res_pb_right].width(), top , m_res[res_pb_right].width(), m_res[res_pb_right].height(), m_res[res_pb_right]);
|
||||
pp.drawPixmap(passed_width, top, remain_width - m_res[res_prgbar_right].width(), m_res[res_prgbar_mid].height(), m_res[res_prgbar_mid]);
|
||||
if(remain_width >= m_res[res_prgbar_right].width())
|
||||
pp.drawPixmap(rc.width() - m_res[res_prgbar_right].width(), top , m_res[res_prgbar_right].width(), m_res[res_prgbar_right].height(), m_res[res_prgbar_right]);
|
||||
|
||||
// 进度位置指示
|
||||
int left = passed_width - m_img_progress_pointer->width() / 2;
|
||||
|
@ -520,10 +548,13 @@ void Bar::draw(QPainter& painter, const QRect& rc_draw){
|
|||
int h = min(rc.bottom(), rc_draw.bottom()) - rc.top() - from_y + 1;
|
||||
int to_x = rc.left() + from_x;
|
||||
int to_y = rc.top() + from_y;
|
||||
if(m_speed_selected == i || m_speed_hover == i)
|
||||
painter.drawPixmap(to_x, to_y, m_img_btn_speed[i][widget_hover], from_x, from_y, w, h);
|
||||
|
||||
if(m_speed_hover == i)
|
||||
painter.drawPixmap(to_x, to_y, m_img_btn_speed[i][btnspd_hover], from_x, from_y, w, h);
|
||||
else if(m_speed_selected == i)
|
||||
painter.drawPixmap(to_x, to_y, m_img_btn_speed[i][btnspd_sel], from_x, from_y, w, h);
|
||||
else
|
||||
painter.drawPixmap(to_x, to_y, m_img_btn_speed[i][widget_normal], from_x, from_y, w, h);
|
||||
painter.drawPixmap(to_x, to_y, m_img_btn_speed[i][btnspd_normal], from_x, from_y, w, h);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -532,6 +563,9 @@ void Bar::draw(QPainter& painter, const QRect& rc_draw){
|
|||
{
|
||||
QRect rc(m_rc_skip);
|
||||
rc.moveTo(m_rc.left()+rc.left(), m_rc.top() + rc.top());
|
||||
|
||||
// painter.fillRect(rc, QColor(255, 255, 255));
|
||||
|
||||
if(rc_draw.intersects(rc)) {
|
||||
int from_x = max(rc_draw.left(), rc.left()) - rc.left();
|
||||
int from_y = max(rc_draw.top(), rc.top()) - rc.top();
|
||||
|
@ -540,10 +574,18 @@ void Bar::draw(QPainter& painter, const QRect& rc_draw){
|
|||
int to_x = rc.left() + from_x;
|
||||
int to_y = rc.top() + from_y;
|
||||
//qDebug("skip (%d,%d), (%d,%d)/(%d,%d)", to_x, to_y, from_x, from_y, w, h);
|
||||
if(m_skip_selected)
|
||||
painter.drawPixmap(to_x, to_y, m_img_skip[widget_hover], from_x, from_y, w, h);
|
||||
if(m_skip_selected) {
|
||||
if(m_skip_hover)
|
||||
painter.drawPixmap(to_x, to_y, m_img_skip[chkbox_selected][widget_hover], from_x, from_y, w, h);
|
||||
else
|
||||
painter.drawPixmap(to_x, to_y, m_img_skip[widget_normal], from_x, from_y, w, h);
|
||||
painter.drawPixmap(to_x, to_y, m_img_skip[chkbox_selected][widget_normal], from_x, from_y, w, h);
|
||||
}
|
||||
else {
|
||||
if(m_skip_hover)
|
||||
painter.drawPixmap(to_x, to_y, m_img_skip[chkbox_normal][widget_hover], from_x, from_y, w, h);
|
||||
else
|
||||
painter.drawPixmap(to_x, to_y, m_img_skip[chkbox_normal][widget_normal], from_x, from_y, w, h);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,51 +6,50 @@
|
|||
#include <QWidget>
|
||||
|
||||
typedef enum {
|
||||
res_bg_left = 0, // 背景左侧
|
||||
res_bg_mid, // 背景中间,拉伸填充
|
||||
res_bg_right, // 背景右侧
|
||||
res_bs_left, // 速度按钮(未选中)左侧
|
||||
res_bs_mid, // 速度按钮(未选中)中间,拉伸填充
|
||||
res_bs_right, // 速度按钮(未选中)右侧
|
||||
res_bsh_left, // 速度按钮(选中)左侧
|
||||
res_bsh_mid, // 速度按钮(选中)中间,拉伸填充
|
||||
res_bsh_right, // 速度按钮(选中)右侧
|
||||
res_pbh_left, // 进度条(已经过)左侧
|
||||
res_pbh_mid, // 进度条(已经过)中间,拉伸填充
|
||||
res_pb_mid, // 进度条(未到达)中间,拉伸填充
|
||||
res_pb_right, // 进度条(未到达)右侧
|
||||
// res_pp, // 进度条上的指示点,未选中
|
||||
// res_pph, // 进度条上的指示点,选中高亮
|
||||
res_cb, // 复选框,未选中
|
||||
res_cbh, // 复选框,已勾选
|
||||
// res_play,
|
||||
// res_play_hover,
|
||||
// res_pause,
|
||||
// res_pause_hover,
|
||||
res_bg_left = 0, // 背景
|
||||
res_bg_mid,
|
||||
res_bg_right,
|
||||
res_btn_normal_left, // 按钮(速度选择),普通状态
|
||||
res_btn_normal_mid,
|
||||
res_btn_normal_right,
|
||||
res_btn_sel_left, // 按钮(速度选择),已选中
|
||||
res_btn_sel_mid,
|
||||
res_btn_sel_right,
|
||||
res_btn_hover_left, // 按钮(速度选择),鼠标滑过
|
||||
res_btn_hover_mid,
|
||||
res_btn_hover_right,
|
||||
|
||||
res_prgbarh_left, // 进度条(已经过)左侧
|
||||
res_prgbarh_mid, // 进度条(已经过)中间,拉伸填充
|
||||
res_prgbar_mid, // 进度条(未到达)中间,拉伸填充
|
||||
res_prgbar_right, // 进度条(未到达)右侧
|
||||
res_chkbox_normal, // 复选框
|
||||
res_chkbox_hover,
|
||||
res_chkbox_sel_normal,
|
||||
res_chkbox_sel_hover,
|
||||
|
||||
res__max
|
||||
}RES_ID;
|
||||
|
||||
typedef enum {
|
||||
widget_normal = 0,
|
||||
widget_hover,
|
||||
widget__max
|
||||
}WIDGET_STAT;
|
||||
//typedef enum {
|
||||
// widget_normal = 0,
|
||||
// widget_hover,
|
||||
// widget__max
|
||||
//}WIDGET_STAT;
|
||||
|
||||
typedef enum {
|
||||
play_running = 0,
|
||||
play_paused,
|
||||
play__max
|
||||
}PLAY_STAT;
|
||||
#define widget_normal 0
|
||||
#define widget_hover 1
|
||||
#define widget_state_count 2
|
||||
|
||||
//typedef enum {
|
||||
// speed_1x = 0,
|
||||
// speed_2x,
|
||||
// speed_4x,
|
||||
// speed_8x,
|
||||
// speed_16x,
|
||||
// speed__max,
|
||||
//}SPEED;
|
||||
// play_running = 0,
|
||||
// play_paused,
|
||||
// play__max
|
||||
//}PLAY_STAT;
|
||||
|
||||
#define play_running 0
|
||||
#define play_paused 1
|
||||
#define play_state_count 2
|
||||
|
||||
#define speed_1x 0
|
||||
#define speed_2x 1
|
||||
|
@ -59,6 +58,15 @@ typedef enum {
|
|||
#define speed_16x 4
|
||||
#define speed_count 5
|
||||
|
||||
#define btnspd_normal 0
|
||||
#define btnspd_sel 1
|
||||
#define btnspd_hover 2
|
||||
#define btnspd_state_count 3
|
||||
|
||||
#define chkbox_normal 0
|
||||
#define chkbox_selected 1
|
||||
#define chkbox_state_count 2
|
||||
|
||||
class Bar {
|
||||
public:
|
||||
Bar();
|
||||
|
@ -93,7 +101,7 @@ private:
|
|||
|
||||
// 从资源中加载的原始图像
|
||||
QPixmap m_res[res__max];
|
||||
QPixmap m_img_progress_pointer[widget__max];
|
||||
QPixmap m_img_progress_pointer[widget_state_count];
|
||||
|
||||
int m_width;
|
||||
int m_height;
|
||||
|
@ -113,20 +121,20 @@ private:
|
|||
|
||||
// 合成的图像
|
||||
QPixmap m_img_bg;
|
||||
QPixmap m_img_btn_play[play__max][widget__max];
|
||||
QPixmap m_img_btn_speed[speed_count][widget__max];
|
||||
QPixmap m_img_btn_play[play_state_count][widget_state_count];
|
||||
QPixmap m_img_btn_speed[speed_count][btnspd_state_count];
|
||||
QPixmap m_img_progress;
|
||||
QPixmap m_img_skip[widget__max];
|
||||
QPixmap m_img_skip[chkbox_state_count][widget_state_count];
|
||||
QPixmap m_img_time_passed;
|
||||
QPixmap m_img_time_total;
|
||||
|
||||
// 各种状态
|
||||
bool m_play_hover;
|
||||
bool m_playing; // 0=play, 2=pause
|
||||
bool m_play_hover;
|
||||
int m_speed_selected;
|
||||
int m_speed_hover; // speed__max=no-hover
|
||||
bool m_skip_selected;
|
||||
//bool m_skip_hover;
|
||||
bool m_skip_hover;
|
||||
};
|
||||
|
||||
#endif // BAR_H
|
||||
|
|
|
@ -72,8 +72,6 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
m_bar_shown = false;
|
||||
memset(&m_pt, 0, sizeof(TS_RECORD_RDP_POINTER));
|
||||
|
||||
qDebug() << m_pt_normal.width() << "x" << m_pt_normal.height();
|
||||
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->centralWidget->setMouseTracking(true);
|
||||
|
@ -95,8 +93,10 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
setWindowFlags(windowFlags()&~Qt::WindowMaximizeButtonHint); // 禁止最大化按钮
|
||||
setFixedSize(m_default_bg.width(), m_default_bg.height()); // 禁止拖动窗口大小
|
||||
|
||||
if(!m_bar.init(this))
|
||||
if(!m_bar.init(this)) {
|
||||
qDebug("bar init failed.");
|
||||
return;
|
||||
}
|
||||
|
||||
connect(&m_thr_play, SIGNAL(signal_update_data(update_data*)), this, SLOT(on_update_data(update_data*)));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue