From e33476996acfa9aa2dab2c6e35c8eda4545100ce Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Mon, 29 Mar 2021 05:12:22 +0200 Subject: [PATCH] Rotation icons: make 'em dynamic. (#7440) Followup to #7306. As discussed there, the only way to make everybody happy is to make 'em context-aware. At which point, trying to make the fact that it's a *device* rotation and not a *content* one come across in the icon design loses its interest, and would actually only further muddy the issue. So, these are similar is spirit to the traditional rotation icons in pretty much anything that can rotate text content, with a special inspiration from the Kindle 4 & PocketBook UI. Fix #7429 --- frontend/ui/data/creoptions.lua | 49 ++++++++--- frontend/ui/data/koptoptions.lua | 41 +++++++-- frontend/ui/widget/configdialog.lua | 13 +-- resources/icons/mdlight/rotation.L.0UR.svg | 89 ++++++++++++++++++++ resources/icons/mdlight/rotation.L.180UD.svg | 89 ++++++++++++++++++++ resources/icons/mdlight/rotation.L.90CCW.svg | 84 ++++++++++++++++++ resources/icons/mdlight/rotation.L.90CW.svg | 84 ++++++++++++++++++ resources/icons/mdlight/rotation.P.0UR.svg | 87 +++++++++++++++++++ resources/icons/mdlight/rotation.P.180UD.svg | 89 ++++++++++++++++++++ resources/icons/mdlight/rotation.P.90CCW.svg | 83 ++++++++++++++++++ resources/icons/mdlight/rotation.P.90CW.svg | 84 ++++++++++++++++++ 11 files changed, 771 insertions(+), 21 deletions(-) create mode 100644 resources/icons/mdlight/rotation.L.0UR.svg create mode 100644 resources/icons/mdlight/rotation.L.180UD.svg create mode 100644 resources/icons/mdlight/rotation.L.90CCW.svg create mode 100644 resources/icons/mdlight/rotation.L.90CW.svg create mode 100644 resources/icons/mdlight/rotation.P.0UR.svg create mode 100644 resources/icons/mdlight/rotation.P.180UD.svg create mode 100644 resources/icons/mdlight/rotation.P.90CCW.svg create mode 100644 resources/icons/mdlight/rotation.P.90CW.svg diff --git a/frontend/ui/data/creoptions.lua b/frontend/ui/data/creoptions.lua index 9e979b6d8..38be22113 100644 --- a/frontend/ui/data/creoptions.lua +++ b/frontend/ui/data/creoptions.lua @@ -22,19 +22,48 @@ local CreOptions = { { name = "rotation_mode", name_text = _("Rotation"), - item_icons = { - "rotation.90CCW", - "rotation.0UR", - "rotation.90CW", - "rotation.180UD", - }, + item_icons_func = function() + if Screen:getRotationMode() == Screen.ORIENTATION_PORTRAIT then + -- P, 0UR + return { + "rotation.P.90CCW", + "rotation.P.0UR", + "rotation.P.90CW", + "rotation.P.180UD", + } + elseif Screen:getRotationMode() == Screen.ORIENTATION_PORTRAIT_ROTATED then + -- P, 180UD + return { + "rotation.P.90CW", + "rotation.P.180UD", + "rotation.P.90CCW", + "rotation.P.0UR", + } + elseif Screen:getRotationMode() == Screen.ORIENTATION_LANDSCAPE then + -- L, 90CW + return { + "rotation.L.90CCW", + "rotation.L.0UR", + "rotation.L.90CW", + "rotation.L.180UD", + } + else + -- L, 90CCW + return { + "rotation.L.90CW", + "rotation.L.180UD", + "rotation.L.90CCW", + "rotation.L.0UR", + } + end + end, -- For Dispatcher's sake labels = {C_("Rotation", "⤹ 90°"), C_("Rotation", "↑ 0°"), C_("Rotation", "⤸ 90°"), C_("Rotation", "↓ 180°")}, alternate = false, values = {Screen.ORIENTATION_LANDSCAPE_ROTATED, Screen.ORIENTATION_PORTRAIT, Screen.ORIENTATION_LANDSCAPE, Screen.ORIENTATION_PORTRAIT_ROTATED}, args = {Screen.ORIENTATION_LANDSCAPE_ROTATED, Screen.ORIENTATION_PORTRAIT, Screen.ORIENTATION_LANDSCAPE, Screen.ORIENTATION_PORTRAIT_ROTATED}, default_arg = 0, - current_func = function() return Device.screen:getRotationMode() end, + current_func = function() return Screen:getRotationMode() end, event = "SetRotationMode", name_text_hold_callback = optionsutil.showValues, }, @@ -50,7 +79,7 @@ local CreOptions = { --[[ Commented out, to have it also available in portrait mode current_func = function() -- If not in landscape mode, shows "1" as selected - if Device.screen:getScreenMode() ~= "landscape" then + if Screen:getScreenMode() ~= "landscape" then return 1 end -- if we return nil, ConfigDialog will pick the one from the @@ -59,7 +88,7 @@ local CreOptions = { ]]-- enabled_func = function(configurable) return optionsutil.enableIfEquals(configurable, "view_mode", 0) -- "page" mode - -- and Device.screen:getScreenMode() == "landscape" + -- and Screen:getScreenMode() == "landscape" end, name_text_hold_callback = optionsutil.showValues, help_text = _([[Render the document on half the screen width and display two pages at once with a single page number. This makes it look like two columns. @@ -602,7 +631,7 @@ Whether enabled or disabled, KOReader's own status bar at the bottom of the scre args = {true, false}, default_arg = nil, event = "ToggleNightmodeImages", - show_func = function() return Device.screen.night_mode end, + show_func = function() return Screen.night_mode end, name_text_hold_callback = optionsutil.showValues, help_text = _([[Disable the automagic inversion of images when nightmode is enabled. Useful if your book contains mainly inlined mathematical content or scene break art.]]), }, diff --git a/frontend/ui/data/koptoptions.lua b/frontend/ui/data/koptoptions.lua index ab7ac3695..53c86662c 100644 --- a/frontend/ui/data/koptoptions.lua +++ b/frontend/ui/data/koptoptions.lua @@ -29,12 +29,41 @@ local KoptOptions = { { name = "rotation_mode", name_text = _("Rotation"), - item_icons = { - "rotation.90CCW", - "rotation.0UR", - "rotation.90CW", - "rotation.180UD", - }, + item_icons_func = function() + if Screen:getRotationMode() == Screen.ORIENTATION_PORTRAIT then + -- P, 0UR + return { + "rotation.P.90CCW", + "rotation.P.0UR", + "rotation.P.90CW", + "rotation.P.180UD", + } + elseif Screen:getRotationMode() == Screen.ORIENTATION_PORTRAIT_ROTATED then + -- P, 180UD + return { + "rotation.P.90CW", + "rotation.P.180UD", + "rotation.P.90CCW", + "rotation.P.0UR", + } + elseif Screen:getRotationMode() == Screen.ORIENTATION_LANDSCAPE then + -- L, 90CW + return { + "rotation.L.90CCW", + "rotation.L.0UR", + "rotation.L.90CW", + "rotation.L.180UD", + } + else + -- L, 90CCW + return { + "rotation.L.90CW", + "rotation.L.180UD", + "rotation.L.90CCW", + "rotation.L.0UR", + } + end + end, -- For Dispatcher's sake labels = {C_("Rotation", "⤹ 90°"), C_("Rotation", "↑ 0°"), C_("Rotation", "⤸ 90°"), C_("Rotation", "↓ 180°")}, alternate = false, diff --git a/frontend/ui/widget/configdialog.lua b/frontend/ui/widget/configdialog.lua index 54eeac302..0701321a6 100644 --- a/frontend/ui/widget/configdialog.lua +++ b/frontend/ui/widget/configdialog.lua @@ -486,8 +486,11 @@ function ConfigOption:init() end -- Icons (ex: columns, text align, with PDF) - if self.options[c].item_icons then - local items_count = #self.options[c].item_icons + local item_icons = self.options[c].item_icons_func and + self.options[c].item_icons_func(self.config.configurable, self.config.document) or + self.options[c].item_icons + if item_icons then + local items_count = #item_icons local icon_max_height = math.min(option_height, max_icon_height) local icon_max_width = math.floor(option_widget_width / items_count) local icon_size = math.min(icon_max_height, icon_max_width) @@ -497,17 +500,17 @@ function ConfigOption:init() -- We don't want the underline to be that far away from the image content, -- so we use some negative padding to eat a bit on their padding. local underline_padding = - math.floor(0.05 * icon_size) - for d = 1, #self.options[c].item_icons do + for d = 1, items_count do local option_item = OptionIconItem:new{ icon = IconWidget:new{ - icon = self.options[c].item_icons[d], + icon = item_icons[d], dim = not enabled, width = icon_size, height = icon_size, }, underline_padding = underline_padding, padding_left = d > 1 and horizontal_half_padding, - padding_right = d < #self.options[c].item_icons and horizontal_half_padding, + padding_right = d < items_count and horizontal_half_padding, color = d == current_item and (enabled and Blitbuffer.COLOR_BLACK or Blitbuffer.COLOR_DARK_GRAY) or Blitbuffer.COLOR_WHITE, enabled = enabled, } diff --git a/resources/icons/mdlight/rotation.L.0UR.svg b/resources/icons/mdlight/rotation.L.0UR.svg new file mode 100644 index 000000000..486e4bc5e --- /dev/null +++ b/resources/icons/mdlight/rotation.L.0UR.svg @@ -0,0 +1,89 @@ + +image/svg+xml + + diff --git a/resources/icons/mdlight/rotation.L.180UD.svg b/resources/icons/mdlight/rotation.L.180UD.svg new file mode 100644 index 000000000..22c1bbe47 --- /dev/null +++ b/resources/icons/mdlight/rotation.L.180UD.svg @@ -0,0 +1,89 @@ + +image/svg+xml + + diff --git a/resources/icons/mdlight/rotation.L.90CCW.svg b/resources/icons/mdlight/rotation.L.90CCW.svg new file mode 100644 index 000000000..66e7c8975 --- /dev/null +++ b/resources/icons/mdlight/rotation.L.90CCW.svg @@ -0,0 +1,84 @@ + +image/svg+xml + + diff --git a/resources/icons/mdlight/rotation.L.90CW.svg b/resources/icons/mdlight/rotation.L.90CW.svg new file mode 100644 index 000000000..b0dcfe6ce --- /dev/null +++ b/resources/icons/mdlight/rotation.L.90CW.svg @@ -0,0 +1,84 @@ + +image/svg+xml + + diff --git a/resources/icons/mdlight/rotation.P.0UR.svg b/resources/icons/mdlight/rotation.P.0UR.svg new file mode 100644 index 000000000..b2363de17 --- /dev/null +++ b/resources/icons/mdlight/rotation.P.0UR.svg @@ -0,0 +1,87 @@ + +image/svg+xml + + diff --git a/resources/icons/mdlight/rotation.P.180UD.svg b/resources/icons/mdlight/rotation.P.180UD.svg new file mode 100644 index 000000000..f9095bdf6 --- /dev/null +++ b/resources/icons/mdlight/rotation.P.180UD.svg @@ -0,0 +1,89 @@ + +image/svg+xml + + diff --git a/resources/icons/mdlight/rotation.P.90CCW.svg b/resources/icons/mdlight/rotation.P.90CCW.svg new file mode 100644 index 000000000..2dcc0f97e --- /dev/null +++ b/resources/icons/mdlight/rotation.P.90CCW.svg @@ -0,0 +1,83 @@ + +image/svg+xml + + diff --git a/resources/icons/mdlight/rotation.P.90CW.svg b/resources/icons/mdlight/rotation.P.90CW.svg new file mode 100644 index 000000000..6ce053ac1 --- /dev/null +++ b/resources/icons/mdlight/rotation.P.90CW.svg @@ -0,0 +1,84 @@ + +image/svg+xml + +