mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
position selection bar at mouse x during drag
This commit is contained in:
parent
6f919231f1
commit
8a4cc1d7ba
@ -21,7 +21,6 @@ from widgets import create_button
|
|||||||
# Google lookup for selections
|
# Google lookup for selections
|
||||||
# Export all annots as plain text/JSON
|
# Export all annots as plain text/JSON
|
||||||
# Remove lookup and create highlight buttons from chrome
|
# Remove lookup and create highlight buttons from chrome
|
||||||
# position bar at mouse x during drag
|
|
||||||
|
|
||||||
|
|
||||||
class AnnotationsManager:
|
class AnnotationsManager:
|
||||||
|
@ -83,7 +83,6 @@ drag_mouse_position = {'x': None, 'y': None}
|
|||||||
def cancel_drag_scroll():
|
def cancel_drag_scroll():
|
||||||
cancel_drag_scroll_flow()
|
cancel_drag_scroll_flow()
|
||||||
cancel_drag_scroll_paged()
|
cancel_drag_scroll_paged()
|
||||||
drag_mouse_position.x = drag_mouse_position.y = None
|
|
||||||
|
|
||||||
|
|
||||||
class EPUBReadingSystem:
|
class EPUBReadingSystem:
|
||||||
@ -218,6 +217,7 @@ class IframeBoss:
|
|||||||
|
|
||||||
def display(self, data):
|
def display(self, data):
|
||||||
cancel_drag_scroll()
|
cancel_drag_scroll()
|
||||||
|
drag_mouse_position.x = drag_mouse_position.y = None
|
||||||
self.length_before = None
|
self.length_before = None
|
||||||
self.content_ready = False
|
self.content_ready = False
|
||||||
clear_annot_id_uuid_map()
|
clear_annot_id_uuid_map()
|
||||||
@ -582,6 +582,7 @@ class IframeBoss:
|
|||||||
|
|
||||||
def onmouseup(self, evt):
|
def onmouseup(self, evt):
|
||||||
cancel_drag_scroll()
|
cancel_drag_scroll()
|
||||||
|
drag_mouse_position.x = drag_mouse_position.y = None
|
||||||
|
|
||||||
def onkeydown(self, evt):
|
def onkeydown(self, evt):
|
||||||
if current_layout_mode() is not 'flow' and evt.key is 'Tab':
|
if current_layout_mode() is not 'flow' and evt.key is 'Tab':
|
||||||
|
@ -121,7 +121,7 @@ class SelectionBar:
|
|||||||
container = self.container
|
container = self.container
|
||||||
clear(container)
|
clear(container)
|
||||||
cs = self.view.currently_showing.selection
|
cs = self.view.currently_showing.selection
|
||||||
if cs.empty:
|
if not cs or cs.empty:
|
||||||
return self.hide()
|
return self.hide()
|
||||||
|
|
||||||
if not cs.start.onscreen and not cs.end.onscreen:
|
if not cs.start.onscreen and not cs.end.onscreen:
|
||||||
@ -161,5 +161,8 @@ class SelectionBar:
|
|||||||
bar_width = bar.offsetWidth
|
bar_width = bar.offsetWidth
|
||||||
left = end.x - bar_width // 2
|
left = end.x - bar_width // 2
|
||||||
# - 10 ensures we dont cover scroll bar
|
# - 10 ensures we dont cover scroll bar
|
||||||
|
if cs.drag_mouse_position.x?:
|
||||||
|
mouse = map_boundary(cs.drag_mouse_position)
|
||||||
|
left = mouse.x - bar_width // 2
|
||||||
left = max(buffer, min(left, container.offsetWidth - bar_width - buffer - 10))
|
left = max(buffer, min(left, container.offsetWidth - bar_width - buffer - 10))
|
||||||
bar.style.left = left + 'px'
|
bar.style.left = left + 'px'
|
||||||
|
@ -294,7 +294,7 @@ class View:
|
|||||||
self.selection_bar = SelectionBar(self)
|
self.selection_bar = SelectionBar(self)
|
||||||
self.processing_spine_item_display = False
|
self.processing_spine_item_display = False
|
||||||
self.pending_load = None
|
self.pending_load = None
|
||||||
self.currently_showing = {}
|
self.currently_showing = {'selection': {'empty': True}}
|
||||||
self.book_scrollbar.apply_visibility()
|
self.book_scrollbar.apply_visibility()
|
||||||
self.annotations_manager = AnnotationsManager(self)
|
self.annotations_manager = AnnotationsManager(self)
|
||||||
self.create_annotation = CreateAnnotation(self)
|
self.create_annotation = CreateAnnotation(self)
|
||||||
@ -894,7 +894,7 @@ class View:
|
|||||||
idx = spine.indexOf(name)
|
idx = spine.indexOf(name)
|
||||||
self.currently_showing = {
|
self.currently_showing = {
|
||||||
'name':name, 'settings':self.iframe_settings(name), 'initial_position':initial_position,
|
'name':name, 'settings':self.iframe_settings(name), 'initial_position':initial_position,
|
||||||
'loading':True, 'spine_index': idx
|
'loading':True, 'spine_index': idx, 'selection': {'empty': True},
|
||||||
}
|
}
|
||||||
self.show_loading()
|
self.show_loading()
|
||||||
set_current_spine_item(name)
|
set_current_spine_item(name)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user