2019-09-06 12:07:13 +00:00
|
|
|
|
#ifndef BAR_H
|
|
|
|
|
#define BAR_H
|
|
|
|
|
|
|
|
|
|
#include <QPainter>
|
|
|
|
|
#include <QPixmap>
|
|
|
|
|
#include <QWidget>
|
|
|
|
|
|
2019-09-08 19:30:31 +00:00
|
|
|
|
typedef enum {
|
2019-09-09 12:15:53 +00:00
|
|
|
|
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,
|
2019-09-08 19:30:31 +00:00
|
|
|
|
|
|
|
|
|
res__max
|
|
|
|
|
}RES_ID;
|
|
|
|
|
|
2019-09-09 12:15:53 +00:00
|
|
|
|
//typedef enum {
|
|
|
|
|
// widget_normal = 0,
|
|
|
|
|
// widget_hover,
|
|
|
|
|
// widget__max
|
|
|
|
|
//}WIDGET_STAT;
|
2019-09-08 19:30:31 +00:00
|
|
|
|
|
2019-09-09 12:15:53 +00:00
|
|
|
|
#define widget_normal 0
|
|
|
|
|
#define widget_hover 1
|
|
|
|
|
#define widget_state_count 2
|
2019-09-08 19:30:31 +00:00
|
|
|
|
|
|
|
|
|
//typedef enum {
|
2019-09-09 12:15:53 +00:00
|
|
|
|
// play_running = 0,
|
|
|
|
|
// play_paused,
|
|
|
|
|
// play__max
|
|
|
|
|
//}PLAY_STAT;
|
|
|
|
|
|
|
|
|
|
#define play_running 0
|
|
|
|
|
#define play_paused 1
|
|
|
|
|
#define play_state_count 2
|
2019-09-08 19:30:31 +00:00
|
|
|
|
|
|
|
|
|
#define speed_1x 0
|
|
|
|
|
#define speed_2x 1
|
|
|
|
|
#define speed_4x 2
|
|
|
|
|
#define speed_8x 3
|
|
|
|
|
#define speed_16x 4
|
|
|
|
|
#define speed_count 5
|
2019-09-06 12:07:13 +00:00
|
|
|
|
|
2019-09-09 12:15:53 +00:00
|
|
|
|
#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
|
|
|
|
|
|
2019-09-06 12:07:13 +00:00
|
|
|
|
class Bar {
|
|
|
|
|
public:
|
|
|
|
|
Bar();
|
|
|
|
|
~Bar();
|
|
|
|
|
|
2019-09-08 19:30:31 +00:00
|
|
|
|
bool init(QWidget* owner);
|
|
|
|
|
void start(uint32_t total_ms, int width);
|
|
|
|
|
void end();
|
2019-09-06 12:07:13 +00:00
|
|
|
|
void draw(QPainter& painter, const QRect& rc);
|
2019-09-08 19:30:31 +00:00
|
|
|
|
void update_passed_time(uint32_t ms);
|
2019-09-06 12:07:13 +00:00
|
|
|
|
|
2019-09-08 19:30:31 +00:00
|
|
|
|
QRect rc(){return m_rc;}
|
2019-09-06 12:07:13 +00:00
|
|
|
|
|
2019-09-08 19:30:31 +00:00
|
|
|
|
void onMouseMove(int x, int y);
|
2019-09-06 12:07:13 +00:00
|
|
|
|
|
2019-09-08 19:30:31 +00:00
|
|
|
|
private:
|
|
|
|
|
void _init_imgages();
|
|
|
|
|
void _ms_to_str(uint32_t ms, QString& str);
|
2019-09-06 12:07:13 +00:00
|
|
|
|
|
2019-09-08 19:30:31 +00:00
|
|
|
|
private:
|
|
|
|
|
QWidget* m_owner;
|
2019-09-06 12:07:13 +00:00
|
|
|
|
|
2019-09-08 19:30:31 +00:00
|
|
|
|
uint32_t m_total_ms; // 录像的总时长
|
|
|
|
|
uint32_t m_passed_ms; // 已经播放了的时长
|
|
|
|
|
int m_percent; // 已经播放了的百分比(0~100)
|
|
|
|
|
int m_percent_last_draw;
|
|
|
|
|
QString m_str_total_time;
|
|
|
|
|
QString m_str_passed_time;
|
|
|
|
|
QString m_str_passed_time_last_draw;
|
2019-09-06 12:07:13 +00:00
|
|
|
|
|
2019-09-08 19:30:31 +00:00
|
|
|
|
bool m_img_ready;
|
2019-09-06 12:07:13 +00:00
|
|
|
|
|
2019-09-08 19:30:31 +00:00
|
|
|
|
// 从资源中加载的原始图像
|
|
|
|
|
QPixmap m_res[res__max];
|
2019-09-09 12:15:53 +00:00
|
|
|
|
QPixmap m_img_progress_pointer[widget_state_count];
|
2019-09-06 12:07:13 +00:00
|
|
|
|
|
2019-09-08 19:30:31 +00:00
|
|
|
|
int m_width;
|
|
|
|
|
int m_height;
|
|
|
|
|
// 此浮动窗相对于父窗口的坐标和大小
|
|
|
|
|
QRect m_rc;
|
|
|
|
|
|
|
|
|
|
// 尺寸和定位(此浮动窗内部的相对坐标)
|
|
|
|
|
QRect m_rc_btn_play;
|
|
|
|
|
QRect m_rc_btn_speed[speed_count];
|
|
|
|
|
QRect m_rc_time_passed;
|
|
|
|
|
QRect m_rc_time_total;
|
|
|
|
|
QRect m_rc_progress;
|
|
|
|
|
QRect m_rc_skip;
|
|
|
|
|
|
|
|
|
|
// 画布,最终输出的图像
|
|
|
|
|
//QPixmap m_canvas;
|
|
|
|
|
|
|
|
|
|
// 合成的图像
|
|
|
|
|
QPixmap m_img_bg;
|
2019-09-09 12:15:53 +00:00
|
|
|
|
QPixmap m_img_btn_play[play_state_count][widget_state_count];
|
|
|
|
|
QPixmap m_img_btn_speed[speed_count][btnspd_state_count];
|
2019-09-08 19:30:31 +00:00
|
|
|
|
QPixmap m_img_progress;
|
2019-09-09 12:15:53 +00:00
|
|
|
|
QPixmap m_img_skip[chkbox_state_count][widget_state_count];
|
2019-09-08 19:30:31 +00:00
|
|
|
|
QPixmap m_img_time_passed;
|
|
|
|
|
QPixmap m_img_time_total;
|
|
|
|
|
|
|
|
|
|
// 各种状态
|
|
|
|
|
bool m_playing; // 0=play, 2=pause
|
2019-09-09 12:15:53 +00:00
|
|
|
|
bool m_play_hover;
|
2019-09-08 19:30:31 +00:00
|
|
|
|
int m_speed_selected;
|
|
|
|
|
int m_speed_hover; // speed__max=no-hover
|
|
|
|
|
bool m_skip_selected;
|
2019-09-09 12:15:53 +00:00
|
|
|
|
bool m_skip_hover;
|
2019-09-06 12:07:13 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // BAR_H
|