mirror of https://github.com/odrling/Aegisub
Merge OS X color picker fixes in r3996 and r3997 from 2.1.8. Closes #1114.
Originally committed to SVN as r4724.
This commit is contained in:
parent
2a51ad837e
commit
3f954dadcc
|
@ -619,7 +619,7 @@ void ColorPickerRecent::LoadFromString(const wxString &recent_string)
|
||||||
while (toker.HasMoreTokens()) {
|
while (toker.HasMoreTokens()) {
|
||||||
AssColor color;
|
AssColor color;
|
||||||
color.Parse(toker.NextToken());
|
color.Parse(toker.NextToken());
|
||||||
color.a = wxALPHA_OPAQUE;
|
color.a = 0; // opaque
|
||||||
colors.push_back(color.GetWXColor());
|
colors.push_back(color.GetWXColor());
|
||||||
}
|
}
|
||||||
while ((int)colors.size() < rows*cols) {
|
while ((int)colors.size() < rows*cols) {
|
||||||
|
@ -790,10 +790,19 @@ void ColorPickerScreenDropper::OnMouse(wxMouseEvent &evt)
|
||||||
CaptureMouse();
|
CaptureMouse();
|
||||||
|
|
||||||
} else if (x >= 0 && y >= 0 && x < resx && y < resy) {
|
} else if (x >= 0 && y >= 0 && x < resx && y < resy) {
|
||||||
wxMemoryDC capdc;
|
|
||||||
capdc.SelectObject(capture);
|
|
||||||
wxColour color;
|
wxColour color;
|
||||||
|
#ifdef __WXMAC__
|
||||||
|
// wxMemoryDC::GetPixel() isn't implemented on OS X
|
||||||
|
// Work around it by reading pixel data from the bitmap instead
|
||||||
|
wxAlphaPixelData cappd(capture);
|
||||||
|
wxAlphaPixelData::Iterator cappdi(cappd);
|
||||||
|
cappdi.MoveTo(cappd, x, y);
|
||||||
|
color.Set(cappdi.Red(), cappdi.Green(), cappdi.Blue());
|
||||||
|
#else
|
||||||
|
wxMemoryDC capdc(capture);
|
||||||
capdc.GetPixel(x, y, &color);
|
capdc.GetPixel(x, y, &color);
|
||||||
|
#endif
|
||||||
|
color = wxColour(color.Red(), color.Green(), color.Blue(), wxALPHA_OPAQUE);
|
||||||
AssColor ass(color);
|
AssColor ass(color);
|
||||||
wxCommandEvent evnt(wxDROPPER_SELECT, GetId());
|
wxCommandEvent evnt(wxDROPPER_SELECT, GetId());
|
||||||
evnt.SetString(ass.GetASSFormatted(false, false, false));
|
evnt.SetString(ass.GetASSFormatted(false, false, false));
|
||||||
|
@ -812,8 +821,14 @@ void ColorPickerScreenDropper::OnMouse(wxMouseEvent &evt)
|
||||||
void ColorPickerScreenDropper::OnPaint(wxPaintEvent &evt)
|
void ColorPickerScreenDropper::OnPaint(wxPaintEvent &evt)
|
||||||
{
|
{
|
||||||
wxPaintDC pdc(this);
|
wxPaintDC pdc(this);
|
||||||
wxMemoryDC capdc;
|
|
||||||
capdc.SelectObject(capture);
|
#ifdef __WXMAC__
|
||||||
|
// See OnMouse() above
|
||||||
|
wxAlphaPixelData cappd(capture);
|
||||||
|
wxAlphaPixelData::Iterator cappdi(cappd);
|
||||||
|
#else
|
||||||
|
wxMemoryDC capdc(capture);
|
||||||
|
#endif
|
||||||
|
|
||||||
pdc.SetPen(*wxTRANSPARENT_PEN);
|
pdc.SetPen(*wxTRANSPARENT_PEN);
|
||||||
|
|
||||||
|
@ -822,7 +837,12 @@ void ColorPickerScreenDropper::OnPaint(wxPaintEvent &evt)
|
||||||
if (x==0 && y==0 && integrated_dropper) continue;
|
if (x==0 && y==0 && integrated_dropper) continue;
|
||||||
|
|
||||||
wxColour color;
|
wxColour color;
|
||||||
|
#ifdef __WXMAC__
|
||||||
|
cappdi.MoveTo(cappd, x, y);
|
||||||
|
color.Set(cappdi.Red(), cappdi.Green(), cappdi.Blue());
|
||||||
|
#else
|
||||||
capdc.GetPixel(x, y, &color);
|
capdc.GetPixel(x, y, &color);
|
||||||
|
#endif
|
||||||
pdc.SetBrush(wxBrush(color));
|
pdc.SetBrush(wxBrush(color));
|
||||||
|
|
||||||
pdc.DrawRectangle(x*magnification, y*magnification, magnification, magnification);
|
pdc.DrawRectangle(x*magnification, y*magnification, magnification, magnification);
|
||||||
|
@ -844,15 +864,20 @@ void ColorPickerScreenDropper::OnPaint(wxPaintEvent &evt)
|
||||||
/// @param x
|
/// @param x
|
||||||
/// @param y
|
/// @param y
|
||||||
///
|
///
|
||||||
|
|
||||||
void ColorPickerScreenDropper::DropFromScreenXY(int x, int y)
|
void ColorPickerScreenDropper::DropFromScreenXY(int x, int y)
|
||||||
{
|
{
|
||||||
wxMemoryDC capdc;
|
wxMemoryDC capdc(capture);
|
||||||
capdc.SelectObject(capture);
|
|
||||||
wxScreenDC screen;
|
wxScreenDC screen;
|
||||||
|
|
||||||
|
#ifdef __WXMAC__
|
||||||
|
wxBitmap screenbmp = screen.GetAsBitmap().GetSubBitmap(wxRect(x-resx/2, y-resy/2, resx, resy));
|
||||||
|
capdc.DrawBitmap(screenbmp, 0, 0);
|
||||||
|
#else
|
||||||
screen.StartDrawingOnTop();
|
screen.StartDrawingOnTop();
|
||||||
capdc.Blit(0, 0, resx, resy, &screen, x-resx/2, y-resy/2);
|
capdc.Blit(0, 0, resx, resy, &screen, x-resx/2, y-resy/2);
|
||||||
screen.EndDrawingOnTop();
|
screen.EndDrawingOnTop();
|
||||||
|
#endif
|
||||||
|
|
||||||
Refresh(false);
|
Refresh(false);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue