E-book viewer: When displaying popup footnotes use the same writing direction as the main text for the footnote popups size and header. Fixes #1938448 [epub footnote popup not good for vertical writing mode](https://bugs.launchpad.net/calibre/+bug/1938448)

This commit is contained in:
Kovid Goyal 2021-08-09 21:22:13 +05:30
parent e208909664
commit c91be6ed11
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 27 additions and 5 deletions

View File

@ -22,7 +22,7 @@ add_extra_css(def():
style += build_rule(sel, border_radius='8px', border='solid currentColor 2px', margin='1rem', padding='0.5rem', box_shadow='2px 2px 4px currentColor')
sel += ' > div'
style += build_rule(sel, padding_bottom='1ex', margin_bottom='1ex', border_bottom='solid currentColor 2px', display='flex', justify_content='space-between', align_items='center')
style += build_rule(sel, display='flex', justify_content='space-between', align_items='center')
sel += ' > div' # button container
style += build_rule(sel, display='flex', justify_content='space-between', align_items='center')
@ -134,13 +134,31 @@ class ContentPopupOverlay:
if not self.iframe_wrapper:
self.create_iframe()
self.current_footnote_data = data
width = 100 // data.cols_per_screen
c = self.container.firstChild
c.style.width = f'{width}vw'
header = c.firstChild
s = header.style
s.paddingLeft = s.paddingRight = s.paddingBottom = s.paddingTop = '0'
s.marginLeft = s.marginRight = s.marginBottom = s.marginTop = '0'
s.borderBottom = s.borderTop = s.borderLeft = s.borderRight = 'solid currentColor 0'
bs = 'solid currentColor 2px'
if self.current_footnote_data.vertical_writing_mode:
c.style.width = str(50 // data.cols_per_screen) + 'vw'
self.iframe.style.height = '80vh'
c.style.writingMode = 'vertical-rl' if self.current_footnote_data.rtl else 'vertical-lr'
if self.current_footnote_data.rtl:
s.paddingLeft = s.marginLeft = '1ex'
s.borderLeft = bs
else:
s.paddingRight = s.marginRight = '1ex'
s.borderRight = bs
else:
c.style.width = str(100 // data.cols_per_screen) + 'vw'
self.iframe.style.height = '12ex'
c.style.writingMode = 'horizontal-rl' if self.current_footnote_data.rtl else 'horizontal-lr'
s.paddingBottom = s.marginBottom = '1ex'
s.borderBottom = bs
self.create_footnote_header(header)
self.load_doc(data.name, self.show_footnote_item)
self.iframe.style.height = '12ex'
self.iframe_wrapper.send_message('clear', text=_('Loading note, please wait...'))
def show_footnote_item(self, resource_data):

View File

@ -728,7 +728,11 @@ class IframeBoss:
self.send_message('scroll_to_anchor', name=name, frag=frag)
def on_fake_popup_activation(self, data):
self.send_message('show_footnote', name=data.name, frag=data.frag, title=data.title, cols_per_screen=calc_columns_per_screen())
self.send_message(
'show_footnote', name=data.name, frag=data.frag, title=data.title,
cols_per_screen=calc_columns_per_screen(), rtl=scroll_viewport.rtl,
vertical_writing_mode=scroll_viewport.vertical_writing_mode
)
def scroll_to_anchor(self, frag):
if frag: