| 61 | } |
| 62 | |
| 63 | wxBitmap LoadResourceBitmap(const std::string& name, const wxSize& padded_size) |
| 64 | { |
| 65 | const std::string path_base = File::GetSysDirectory() + RESOURCES_DIR + DIR_SEP + name; |
| 66 | std::string path = path_base + ".png"; |
| 67 | double scale_factor = 1.0; |
| 68 | #ifdef __APPLE__ |
| 69 | if (wxTheApp->GetTopWindow()->GetContentScaleFactor() >= 2) |
| 70 | { |
| 71 | const std::string path_2x = path_base + "@2x.png"; |
| 72 | if (File::Exists(path_2x)) |
| 73 | { |
| 74 | path = path_2x; |
| 75 | scale_factor = 2.0; |
| 76 | } |
| 77 | } |
| 78 | #endif |
| 79 | wxImage image(StrToWxStr(path), wxBITMAP_TYPE_PNG); |
| 80 | |
| 81 | if (padded_size != wxSize()) |
| 82 | { |
| 83 | // Add padding if necessary (or crop, but images aren't supposed to be large enough to require that). |
| 84 | // The image will be left-aligned and vertically centered. |
| 85 | const wxSize scaled_padded_size = padded_size * scale_factor; |
| 86 | image.Resize(scaled_padded_size, wxPoint(0, (scaled_padded_size.GetHeight() - image.GetHeight()) / 2)); |
| 87 | } |
| 88 | |
| 89 | #ifdef __APPLE__ |
| 90 | return wxBitmap(image, -1, scale_factor); |
| 91 | #else |
| 92 | return wxBitmap(image); |
| 93 | #endif |
| 94 | } |
| 95 | |
| 96 | wxBitmap CreateDisabledButtonBitmap(const wxBitmap& original) |
| 97 | { |
no test coverage detected