mirror of https://github.com/odrling/Aegisub
Fix RTL painting of the subtitles grid
wx comes very close to just making it work automatically, but it doesn't translate the origin to the top-right corner and wxBufferedPaintDC doesn't handle RTL at all, so reimplement it with some hacks. Closes #1354.
This commit is contained in:
parent
0909d137b0
commit
164ad33753
|
@ -59,6 +59,39 @@
|
|||
#include <wx/scrolbar.h>
|
||||
#include <wx/sizer.h>
|
||||
|
||||
namespace {
|
||||
#ifdef __WXMSW__
|
||||
class PaintDC : public wxBufferedDC {
|
||||
wxPaintDC dc;
|
||||
|
||||
public:
|
||||
PaintDC(wxWindow *window) : dc(window) {
|
||||
dc.SetLayoutDirection(wxLayout_LeftToRight);
|
||||
Init(&dc, window->GetClientSize(), 0);
|
||||
if (window->GetLayoutDirection() == wxLayout_RightToLeft) {
|
||||
SetLayoutDirection(wxLayout_RightToLeft);
|
||||
SetLogicalOrigin(GetSize().GetWidth(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
~PaintDC() {
|
||||
SetLayoutDirection(wxLayout_LeftToRight);
|
||||
SetLogicalOrigin(0, 0);
|
||||
UnMask();
|
||||
}
|
||||
|
||||
void Clear() {
|
||||
auto origin = GetLogicalOrigin();
|
||||
SetLogicalOrigin(0, 0);
|
||||
wxBufferedDC::Clear();
|
||||
SetLogicalOrigin(origin.x, origin.y);
|
||||
}
|
||||
};
|
||||
#else
|
||||
typedef wxAutoBufferedPaintDC PaintDC;
|
||||
#endif
|
||||
}
|
||||
|
||||
enum {
|
||||
GRID_SCROLLBAR = 1730,
|
||||
MENU_SHOW_COL = 1250 // Needs 15 IDs after this
|
||||
|
@ -279,7 +312,7 @@ void BaseGrid::OnPaint(wxPaintEvent &) {
|
|||
GetClientSize(&w,&h);
|
||||
w -= scrollBar->GetSize().GetWidth();
|
||||
|
||||
wxAutoBufferedPaintDC dc(this);
|
||||
PaintDC dc(this);
|
||||
dc.SetFont(font);
|
||||
|
||||
dc.SetBackground(row_colors.Default);
|
||||
|
|
Loading…
Reference in New Issue