Skip to content

Commit 1b2df46

Browse files
committed
Grid Hi-DPI
1 parent 4293864 commit 1b2df46

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/base_grid.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ void BaseGrid::UpdateStyle() {
181181
dc.SetFont(font);
182182

183183
// Set line height
184-
lineHeight = dc.GetCharHeight() + 4;
184+
lineHeight = dc.GetCharHeight() + FromDIP(4);
185185

186186
// Set row brushes
187187
row_colors.Default.SetColour(to_wx(OPT_GET("Colour/Subtitle Grid/Background/Background")->GetColor()));
@@ -319,13 +319,13 @@ void BaseGrid::OnPaint(wxPaintEvent &) {
319319
dc.SetPen(*wxTRANSPARENT_PEN);
320320

321321
auto paint_text = [&](wxString const& str, int x, int y, int col) {
322-
int left = x + 4;
322+
int left = x + FromDIP(4);
323323
if (columns[col]->Centered()) {
324324
wxSize ext = dc.GetTextExtent(str);
325-
left += (columns[col]->Width() - 6 - ext.GetWidth()) / 2;
325+
left += (columns[col]->Width() - FromDIP(6) - ext.GetWidth()) / 2;
326326
}
327327

328-
dc.DrawText(str, left, y + 2);
328+
dc.DrawText(str, left, y + FromDIP(2));
329329
};
330330

331331
// Paint header

src/grid_column.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ void GridColumn::UpdateWidth(const agi::Context *c, WidthHelper &helper) {
9090
void GridColumn::Paint(wxDC &dc, int x, int y, const AssDialogue *d, const agi::Context *c) const {
9191
wxString str = Value(d, c);
9292
if (Centered())
93-
x += (width - 6 - dc.GetTextExtent(str).GetWidth()) / 2;
94-
dc.DrawText(str, x + 4, y + 2);
93+
x += (width - dc.FromDIP(6) - dc.GetTextExtent(str).GetWidth()) / 2;
94+
dc.DrawText(str, x + dc.FromDIP(4), y + dc.FromDIP(2));
9595
}
9696

9797
namespace {
@@ -335,12 +335,12 @@ class GridColumnCPS final : public GridColumn {
335335
double alpha = std::min((double)(cps - cps_min + 1) / (cps_max - cps_min + 1), 1.0);
336336
dc.SetBrush(wxBrush(blend(to_wx(bg_color->GetColor()), dc.GetBrush().GetColour(), alpha)));
337337
dc.SetPen(*wxTRANSPARENT_PEN);
338-
dc.DrawRectangle(x, y + 1, width, ext.GetHeight() + 3);
338+
dc.DrawRectangle(x, y + 1, width, ext.GetHeight() + dc.FromDIP(4) - 1);
339339
dc.SetTextForeground(blend(*wxBLACK, tc, alpha));
340340
}
341341

342-
x += (width + 2 - ext.GetWidth()) / 2;
343-
dc.DrawText(str, x, y + 2);
342+
x += (width + dc.FromDIP(2) - ext.GetWidth()) / 2;
343+
dc.DrawText(str, x, y + dc.FromDIP(2));
344344
dc.SetTextForeground(tc);
345345
}
346346
};

0 commit comments

Comments
 (0)