| 123 | } |
| 124 | |
| 125 | void ImageCarousel::UpdateButtons() |
| 126 | { |
| 127 | wxSize clientSize = GetClientSize(); |
| 128 | const wxBitmap& bmp = m_snapshots[m_currentIndex].bitmap; |
| 129 | // Use logical (point) sizes so button placement matches the painted image |
| 130 | // location on HiDPI displays. |
| 131 | const int bmpW = static_cast<int>(bmp.GetScaledWidth()); |
| 132 | const int bmpH = static_cast<int>(bmp.GetScaledHeight()); |
| 133 | int x = (clientSize.GetWidth() - bmpW) / 2; |
| 134 | int y = (clientSize.GetHeight() - bmpH) / 2 - 20; |
| 135 | |
| 136 | m_btnLeft->SetPosition(wxPoint(x - m_btnLeft->GetSize().GetWidth() - 36, y + bmpH / 2 - 24)); |
| 137 | m_btnRight->SetPosition(wxPoint(x + bmpW + 36, y + bmpH / 2 - 24)); |
| 138 | |
| 139 | const auto translated = m_snapshots[m_currentIndex].buttonText.Translation(); |
| 140 | m_btnMiddle->SetLabel(translated); |
| 141 | #if defined(__WXMSW__) |
| 142 | wxFont labelFont(11, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); |
| 143 | #elif defined(__WXOSX__) |
| 144 | wxFont labelFont(14, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); |
| 145 | #endif |
| 146 | |
| 147 | #if defined(__WXMSW__) || defined(__WXOSX__) |
| 148 | m_btnMiddle->SetFont(labelFont); |
| 149 | #endif |
| 150 | |
| 151 | m_btnLeft->SetToolTip(_("Previous slide")); |
| 152 | m_btnLeft->SetName(_("Previous slide")); // for screen readers |
| 153 | m_btnRight->SetToolTip(_("Next slide")); |
| 154 | m_btnRight->SetName(_("Next slide")); // for screen readers |
| 155 | if (m_snapshots[m_currentIndex].imageText.empty()) { |
| 156 | // for screen readers |
| 157 | m_btnMiddle->SetName(wxString::Format(_("Slide %d of %d, %s. %s"), |
| 158 | m_currentIndex + 1, |
| 159 | static_cast<int>(m_snapshots.size()), |
| 160 | m_snapshots[m_currentIndex].title.Translation(), |
| 161 | translated)); |
| 162 | } else { |
| 163 | // for screen readers |
| 164 | m_btnMiddle->SetName(wxString::Format(_("Slide %d of %d, %s, %s. %s"), |
| 165 | m_currentIndex + 1, |
| 166 | static_cast<int>(m_snapshots.size()), |
| 167 | m_snapshots[m_currentIndex].title.Translation(), |
| 168 | m_snapshots[m_currentIndex].imageText.Translation(), |
| 169 | translated)); |
| 170 | } |
| 171 | |
| 172 | wxSize btnSize = m_btnMiddle->GetBestSize(); |
| 173 | #if defined(__WXMSW__) |
| 174 | m_btnMiddle->SetSize(wxSize(btnSize.GetWidth() + 30, btnSize.GetHeight() + 20)); |
| 175 | #else |
| 176 | m_btnMiddle->SetSize(wxSize(btnSize.GetWidth() + 30, btnSize.GetHeight() + 15)); |
| 177 | #endif |
| 178 | |
| 179 | #if defined(__WXMSW__) || defined(__WXOSX__) |
| 180 | m_btnMiddle->SetPosition(wxPoint(x + bmpW / 2 - m_btnMiddle->GetSize().GetWidth() / 2 , y + bmpH + 22)); |
| 181 | #else |
| 182 | m_btnMiddle->SetPosition(wxPoint(x + bmpW / 2 - m_btnMiddle->GetSize().GetWidth() / 2 , y + bmpH + FromDIP(10))); |
nothing calls this directly
no test coverage detected