Make Reader menu theme aware
This commit is contained in:
@@ -158,60 +158,39 @@ void EpubReaderMenuActivity::render(RenderLock&&) {
|
|||||||
|
|
||||||
// Menu Items
|
// Menu Items
|
||||||
const int startY = 75 + contentRect.y;
|
const int startY = 75 + contentRect.y;
|
||||||
constexpr int lineHeight = 30;
|
const int listHeight = contentRect.height - (startY - contentRect.y);
|
||||||
|
|
||||||
for (size_t i = 0; i < menuItems.size(); ++i) {
|
GUI.drawList(
|
||||||
const int displayY = startY + (i * lineHeight);
|
renderer, Rect{contentRect.x, startY, contentRect.width, listHeight}, static_cast<int>(menuItems.size()),
|
||||||
const bool isSelected = (static_cast<int>(i) == selectedIndex);
|
selectedIndex, [this](int index) { return I18N.get(menuItems[index].labelId); }, nullptr, nullptr,
|
||||||
|
[this](int index) {
|
||||||
if (isSelected) {
|
const auto& item = menuItems[index];
|
||||||
// Highlight only the content area so we don't paint over hint gutters.
|
switch (item.action) {
|
||||||
renderer.fillRect(contentRect.x, displayY, contentRect.width - 1, lineHeight, true);
|
case MenuAction::ROTATE_SCREEN:
|
||||||
}
|
return std::string(I18N.get(orientationLabels[pendingOrientation]));
|
||||||
|
case MenuAction::AUTO_PAGE_TURN:
|
||||||
renderer.drawText(UI_10_FONT_ID, contentRect.x + 20, displayY, I18N.get(menuItems[i].labelId), !isSelected);
|
return std::string(pageTurnLabels[selectedPageTurnOption]);
|
||||||
|
case MenuAction::EMBEDDED_STYLE:
|
||||||
if (menuItems[i].action == MenuAction::ROTATE_SCREEN) {
|
|
||||||
// Render current orientation value on the right edge of the content area.
|
|
||||||
const char* value = I18N.get(orientationLabels[pendingOrientation]);
|
|
||||||
const auto width = renderer.getTextWidth(UI_10_FONT_ID, value);
|
|
||||||
renderer.drawText(UI_10_FONT_ID, contentRect.x + contentRect.width - 20 - width, displayY, value, !isSelected);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (menuItems[i].action == MenuAction::AUTO_PAGE_TURN) {
|
|
||||||
// Render current page turn value on the right edge of the content area.
|
|
||||||
const auto value = pageTurnLabels[selectedPageTurnOption];
|
|
||||||
const auto width = renderer.getTextWidth(UI_10_FONT_ID, value);
|
|
||||||
renderer.drawText(UI_10_FONT_ID, contentRect.x + contentRect.width - 20 - width, displayY, value, !isSelected);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (menuItems[i].action == MenuAction::EMBEDDED_STYLE) {
|
|
||||||
const char* value = tr(STR_DEFAULT_VALUE);
|
|
||||||
if (pendingEmbeddedStyleOverride == 1) {
|
if (pendingEmbeddedStyleOverride == 1) {
|
||||||
value = tr(STR_STATE_ON);
|
return std::string(tr(STR_STATE_ON));
|
||||||
} else if (pendingEmbeddedStyleOverride == 0) {
|
} else if (pendingEmbeddedStyleOverride == 0) {
|
||||||
value = tr(STR_STATE_OFF);
|
return std::string(tr(STR_STATE_OFF));
|
||||||
}
|
}
|
||||||
const auto width = renderer.getTextWidth(UI_10_FONT_ID, value);
|
return std::string(tr(STR_DEFAULT_VALUE));
|
||||||
renderer.drawText(UI_10_FONT_ID, contentRect.x + contentRect.width - 20 - width, displayY, value, !isSelected);
|
case MenuAction::IMAGE_RENDERING:
|
||||||
}
|
|
||||||
|
|
||||||
if (menuItems[i].action == MenuAction::IMAGE_RENDERING) {
|
|
||||||
const char* value = tr(STR_DEFAULT_VALUE);
|
|
||||||
if (pendingImageRenderingOverride >= 0 && pendingImageRenderingOverride < imageRenderingLabels.size()) {
|
if (pendingImageRenderingOverride >= 0 && pendingImageRenderingOverride < imageRenderingLabels.size()) {
|
||||||
value = I18N.get(imageRenderingLabels[pendingImageRenderingOverride]);
|
return std::string(I18N.get(imageRenderingLabels[pendingImageRenderingOverride]));
|
||||||
}
|
}
|
||||||
const auto width = renderer.getTextWidth(UI_10_FONT_ID, value);
|
return std::string(tr(STR_DEFAULT_VALUE));
|
||||||
renderer.drawText(UI_10_FONT_ID, contentRect.x + contentRect.width - 20 - width, displayY, value, !isSelected);
|
case MenuAction::TEXT_DARKNESS: {
|
||||||
}
|
|
||||||
|
|
||||||
if (menuItems[i].action == MenuAction::TEXT_DARKNESS) {
|
|
||||||
const uint8_t idx = (pendingTextDarkness < textDarknessLabels.size()) ? pendingTextDarkness : 0;
|
const uint8_t idx = (pendingTextDarkness < textDarknessLabels.size()) ? pendingTextDarkness : 0;
|
||||||
const char* value = I18N.get(textDarknessLabels[idx]);
|
return std::string(I18N.get(textDarknessLabels[idx]));
|
||||||
const auto width = renderer.getTextWidth(UI_10_FONT_ID, value);
|
|
||||||
renderer.drawText(UI_10_FONT_ID, contentRect.x + contentRect.width - 20 - width, displayY, value, !isSelected);
|
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
return std::string();
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
true);
|
||||||
|
|
||||||
// Footer / Hints
|
// Footer / Hints
|
||||||
const auto labels = mappedInput.mapLabels(tr(STR_BACK), tr(STR_SELECT), tr(STR_DIR_UP), tr(STR_DIR_DOWN));
|
const auto labels = mappedInput.mapLabels(tr(STR_BACK), tr(STR_SELECT), tr(STR_DIR_UP), tr(STR_DIR_DOWN));
|
||||||
|
|||||||
@@ -273,7 +273,7 @@ void BaseTheme::drawList(const GfxRenderer& renderer, Rect rect, int itemCount,
|
|||||||
// Draw selection
|
// Draw selection
|
||||||
int contentWidth = rect.width - 5;
|
int contentWidth = rect.width - 5;
|
||||||
if (selectedIndex >= 0) {
|
if (selectedIndex >= 0) {
|
||||||
renderer.fillRect(0, rect.y + selectedIndex % pageItems * rowHeight - 2, rect.width, rowHeight);
|
renderer.fillRect(rect.x, rect.y + selectedIndex % pageItems * rowHeight - 2, rect.width, rowHeight);
|
||||||
}
|
}
|
||||||
// Draw all items
|
// Draw all items
|
||||||
const auto pageStartIndex = selectedIndex / pageItems * pageItems;
|
const auto pageStartIndex = selectedIndex / pageItems * pageItems;
|
||||||
|
|||||||
Reference in New Issue
Block a user