mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
E-book viewer: Fix indication of current section in Table of Contents sometimes wrong after changing font size. Fixes #2033205 [E-book viewer: incorrect ToC highligting after changing font size](https://bugs.launchpad.net/calibre/+bug/2033205)
This commit is contained in:
parent
8271fcff30
commit
e1d8b44561
@ -402,7 +402,7 @@ class IframeBoss:
|
|||||||
if cfi:
|
if cfi:
|
||||||
self.jump_to_cfi('/' + cfi)
|
self.jump_to_cfi('/' + cfi)
|
||||||
self.update_cfi()
|
self.update_cfi()
|
||||||
self.update_toc_position()
|
self.update_toc_position(True)
|
||||||
|
|
||||||
def number_of_columns_changed(self, data):
|
def number_of_columns_changed(self, data):
|
||||||
opts.columns_per_screen = data.columns_per_screen
|
opts.columns_per_screen = data.columns_per_screen
|
||||||
@ -548,8 +548,8 @@ class IframeBoss:
|
|||||||
self.send_message(
|
self.send_message(
|
||||||
'update_progress_frac', progress_frac=pf, file_progress_frac=fpf, page_counts=page_counts())
|
'update_progress_frac', progress_frac=pf, file_progress_frac=fpf, page_counts=page_counts())
|
||||||
|
|
||||||
def update_toc_position(self):
|
def update_toc_position(self, recalculate_toc_anchor_positions):
|
||||||
visible_anchors = update_visible_toc_anchors(self.book.manifest.toc_anchor_map, self.anchor_funcs)
|
visible_anchors = update_visible_toc_anchors(self.book.manifest.toc_anchor_map, self.anchor_funcs, bool(recalculate_toc_anchor_positions))
|
||||||
self.send_message('update_toc_position', visible_anchors=visible_anchors)
|
self.send_message('update_toc_position', visible_anchors=visible_anchors)
|
||||||
|
|
||||||
def onscroll(self):
|
def onscroll(self):
|
||||||
|
@ -198,10 +198,7 @@ def create_toc_panel(book, container, onclick):
|
|||||||
toc_panel.style.flexShrink = '1'
|
toc_panel.style.flexShrink = '1'
|
||||||
toc_panel.style.overflow = 'auto'
|
toc_panel.style.overflow = 'auto'
|
||||||
|
|
||||||
|
def recalculate_toc_anchor_positions(tam, anchor_funcs):
|
||||||
def current_toc_anchor_map(tam, anchor_funcs):
|
|
||||||
current_map = toc_anchor_map()
|
|
||||||
if not (current_map and current_map.layout_mode is current_layout_mode() and current_map.width is scroll_viewport.width() and current_map.height is scroll_viewport.height()):
|
|
||||||
name = current_spine_item().name
|
name = current_spine_item().name
|
||||||
am = {}
|
am = {}
|
||||||
anchors = v'[]'
|
anchors = v'[]'
|
||||||
@ -223,7 +220,16 @@ def current_toc_anchor_map(tam, anchor_funcs):
|
|||||||
return current_map
|
return current_map
|
||||||
|
|
||||||
|
|
||||||
def update_visible_toc_anchors(toc_anchor_map, anchor_funcs):
|
def current_toc_anchor_map(tam, anchor_funcs):
|
||||||
|
current_map = toc_anchor_map()
|
||||||
|
if not (current_map and current_map.layout_mode is current_layout_mode() and current_map.width is scroll_viewport.width() and current_map.height is scroll_viewport.height()):
|
||||||
|
current_map = recalculate_toc_anchor_positions(tam, anchor_funcs)
|
||||||
|
return current_map
|
||||||
|
|
||||||
|
|
||||||
|
def update_visible_toc_anchors(toc_anchor_map, anchor_funcs, recalculate):
|
||||||
|
if recalculate:
|
||||||
|
recalculate_toc_anchor_positions(toc_anchor_map, anchor_funcs)
|
||||||
tam = current_toc_anchor_map(toc_anchor_map, anchor_funcs)
|
tam = current_toc_anchor_map(toc_anchor_map, anchor_funcs)
|
||||||
before = after = None
|
before = after = None
|
||||||
visible_anchors = {}
|
visible_anchors = {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user