forked from mia/Aegisub
Cache most of the brushes used in grid painting
Originally committed to SVN as r6391.
This commit is contained in:
parent
cf1425f9d1
commit
0c972886fb
2 changed files with 16 additions and 13 deletions
|
@ -75,7 +75,8 @@ enum RowColor {
|
||||||
COLOR_SELECTION,
|
COLOR_SELECTION,
|
||||||
COLOR_COMMENT,
|
COLOR_COMMENT,
|
||||||
COLOR_VISIBLE,
|
COLOR_VISIBLE,
|
||||||
COLOR_SELECTED_COMMENT
|
COLOR_SELECTED_COMMENT,
|
||||||
|
COLOR_LEFT_COL
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class S1, class S2, class D>
|
template<class S1, class S2, class D>
|
||||||
|
@ -231,6 +232,16 @@ void BaseGrid::UpdateStyle() {
|
||||||
lineHeight = fh + 4;
|
lineHeight = fh + 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set row brushes
|
||||||
|
assert(sizeof(rowColors) / sizeof(rowColors[0]) >= COLOR_LEFT_COL);
|
||||||
|
rowColors[COLOR_DEFAULT].SetColour(lagi_wxColour(OPT_GET("Colour/Subtitle Grid/Background/Background")->GetColour()));
|
||||||
|
rowColors[COLOR_HEADER].SetColour(lagi_wxColour(OPT_GET("Colour/Subtitle Grid/Header")->GetColour()));
|
||||||
|
rowColors[COLOR_SELECTION].SetColour(lagi_wxColour(OPT_GET("Colour/Subtitle Grid/Background/Selection")->GetColour()));
|
||||||
|
rowColors[COLOR_COMMENT].SetColour(lagi_wxColour(OPT_GET("Colour/Subtitle Grid/Background/Comment")->GetColour()));
|
||||||
|
rowColors[COLOR_VISIBLE].SetColour(lagi_wxColour(OPT_GET("Colour/Subtitle Grid/Background/Inframe")->GetColour()));
|
||||||
|
rowColors[COLOR_SELECTED_COMMENT].SetColour(lagi_wxColour(OPT_GET("Colour/Subtitle Grid/Background/Selected Comment")->GetColour()));
|
||||||
|
rowColors[COLOR_LEFT_COL].SetColour(lagi_wxColour(OPT_GET("Colour/Subtitle Grid/Left Column")->GetColour()));
|
||||||
|
|
||||||
// Set column widths
|
// Set column widths
|
||||||
std::vector<bool> column_array(OPT_GET("Subtitle/Grid/Column")->GetListBool());
|
std::vector<bool> column_array(OPT_GET("Subtitle/Grid/Column")->GetListBool());
|
||||||
assert(column_array.size() == (size_t)columns);
|
assert(column_array.size() == (size_t)columns);
|
||||||
|
@ -470,12 +481,12 @@ void BaseGrid::DrawImage(wxDC &dc, bool paint_columns[]) {
|
||||||
|
|
||||||
dc.SetFont(font);
|
dc.SetFont(font);
|
||||||
|
|
||||||
dc.SetBackground(wxBrush(lagi_wxColour(OPT_GET("Colour/Subtitle Grid/Background/Background")->GetColour())));
|
dc.SetBackground(rowColors[COLOR_DEFAULT]);
|
||||||
dc.Clear();
|
dc.Clear();
|
||||||
|
|
||||||
// Draw labels
|
// Draw labels
|
||||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||||
dc.SetBrush(wxBrush(lagi_wxColour(OPT_GET("Colour/Subtitle Grid/Left Column")->GetColour())));
|
dc.SetBrush(rowColors[COLOR_LEFT_COL]);
|
||||||
dc.DrawRectangle(0,lineHeight,colWidth[0],h-lineHeight);
|
dc.DrawRectangle(0,lineHeight,colWidth[0],h-lineHeight);
|
||||||
|
|
||||||
// Visible lines
|
// Visible lines
|
||||||
|
@ -488,15 +499,6 @@ void BaseGrid::DrawImage(wxDC &dc, bool paint_columns[]) {
|
||||||
wxColour text_selection(lagi_wxColour(OPT_GET("Colour/Subtitle Grid/Selection")->GetColour()));
|
wxColour text_selection(lagi_wxColour(OPT_GET("Colour/Subtitle Grid/Selection")->GetColour()));
|
||||||
wxColour text_collision(lagi_wxColour(OPT_GET("Colour/Subtitle Grid/Collision")->GetColour()));
|
wxColour text_collision(lagi_wxColour(OPT_GET("Colour/Subtitle Grid/Collision")->GetColour()));
|
||||||
|
|
||||||
wxBrush rowColors[] = {
|
|
||||||
wxBrush(lagi_wxColour(OPT_GET("Colour/Subtitle Grid/Background/Background")->GetColour())),
|
|
||||||
wxBrush(lagi_wxColour(OPT_GET("Colour/Subtitle Grid/Header")->GetColour())),
|
|
||||||
wxBrush(lagi_wxColour(OPT_GET("Colour/Subtitle Grid/Background/Selection")->GetColour())),
|
|
||||||
wxBrush(lagi_wxColour(OPT_GET("Colour/Subtitle Grid/Background/Comment")->GetColour())),
|
|
||||||
wxBrush(lagi_wxColour(OPT_GET("Colour/Subtitle Grid/Background/Inframe")->GetColour())),
|
|
||||||
wxBrush(lagi_wxColour(OPT_GET("Colour/Subtitle Grid/Background/Selected Comment")->GetColour())),
|
|
||||||
};
|
|
||||||
|
|
||||||
// First grid row
|
// First grid row
|
||||||
wxPen grid_pen(lagi_wxColour(OPT_GET("Colour/Subtitle Grid/Lines")->GetColour()));
|
wxPen grid_pen(lagi_wxColour(OPT_GET("Colour/Subtitle Grid/Lines")->GetColour()));
|
||||||
dc.SetPen(grid_pen);
|
dc.SetPen(grid_pen);
|
||||||
|
@ -581,7 +583,7 @@ void BaseGrid::DrawImage(wxDC &dc, bool paint_columns[]) {
|
||||||
|
|
||||||
// Draw grid columns
|
// Draw grid columns
|
||||||
int dx = 0;
|
int dx = 0;
|
||||||
dc.SetPen(wxPen(lagi_wxColour(OPT_GET("Colour/Subtitle Grid/Lines")->GetColour())));
|
dc.SetPen(grid_pen);
|
||||||
for (int i=0;i<10;i++) {
|
for (int i=0;i<10;i++) {
|
||||||
dx += colWidth[i];
|
dx += colWidth[i];
|
||||||
dc.DrawLine(dx,0,dx,maxH);
|
dc.DrawLine(dx,0,dx,maxH);
|
||||||
|
|
|
@ -70,6 +70,7 @@ class BaseGrid : public wxWindow, public BaseSelectionController<AssDialogue> {
|
||||||
wxFont font; ///< Current grid font
|
wxFont font; ///< Current grid font
|
||||||
wxScrollBar *scrollBar; ///< The grid's scrollbar
|
wxScrollBar *scrollBar; ///< The grid's scrollbar
|
||||||
bool byFrame; ///< Should times be displayed as frame numbers
|
bool byFrame; ///< Should times be displayed as frame numbers
|
||||||
|
wxBrush rowColors[7]; ///< Cached brushes used for row backgrounds
|
||||||
|
|
||||||
/// Row from which the selection shrinks/grows from when selecting via the
|
/// Row from which the selection shrinks/grows from when selecting via the
|
||||||
/// keyboard, shift-clicking or dragging
|
/// keyboard, shift-clicking or dragging
|
||||||
|
|
Loading…
Reference in a new issue