mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Some utility functions to control the viewer position with page numbers in paged mode
This commit is contained in:
parent
2a32abf933
commit
89cc647009
Binary file not shown.
@ -350,6 +350,9 @@ class PagedDisplay
|
|||||||
else
|
else
|
||||||
window.scrollTo(pos, 0)
|
window.scrollTo(pos, 0)
|
||||||
|
|
||||||
|
scroll_to_column: (number) ->
|
||||||
|
this.scroll_to_xpos(number * this.page_width + 10)
|
||||||
|
|
||||||
column_at: (xpos) ->
|
column_at: (xpos) ->
|
||||||
# Return the number of the column that contains xpos
|
# Return the number of the column that contains xpos
|
||||||
return Math.floor(xpos/this.page_width)
|
return Math.floor(xpos/this.page_width)
|
||||||
|
@ -51,6 +51,15 @@ class CalibreUtils
|
|||||||
process.stdout.write(msg + '\n')
|
process.stdout.write(msg + '\n')
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
stack_trace: () -> # {{{
|
||||||
|
currentFunction = arguments.callee.caller
|
||||||
|
while (currentFunction)
|
||||||
|
fn = currentFunction.toString()
|
||||||
|
this.log(fn)
|
||||||
|
currentFunction = currentFunction.caller
|
||||||
|
|
||||||
|
# }}}
|
||||||
|
|
||||||
window_scroll_pos: (win=window) -> # {{{
|
window_scroll_pos: (win=window) -> # {{{
|
||||||
# The current scroll position of the browser window
|
# The current scroll position of the browser window
|
||||||
if typeof(win.pageXOffset) == 'number'
|
if typeof(win.pageXOffset) == 'number'
|
||||||
|
@ -460,6 +460,29 @@ class Document(QWebPage): # {{{
|
|||||||
self.scroll_to(x=self.xpos, y=npos)
|
self.scroll_to(x=self.xpos, y=npos)
|
||||||
return property(fget=fget, fset=fset)
|
return property(fget=fget, fset=fset)
|
||||||
|
|
||||||
|
@dynamic_property
|
||||||
|
def page_number(self):
|
||||||
|
' The page number is the number of the page at the left most edge of the screen (starting from 0) '
|
||||||
|
def fget(self):
|
||||||
|
if self.in_paged_mode:
|
||||||
|
return self.javascript(
|
||||||
|
'ans = 0; if (window.paged_display) ans = window.paged_display.column_boundaries()[0]; ans;', typ='int')
|
||||||
|
def fset(self, val):
|
||||||
|
if self.in_paged_mode and self.loaded_javascript:
|
||||||
|
self.javascript('if (window.paged_display) window.paged_display.scroll_to_column(%d)' % int(val))
|
||||||
|
return True
|
||||||
|
return property(fget=fget, fset=fset)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def page_dimensions(self):
|
||||||
|
if self.in_paged_mode:
|
||||||
|
return self.javascript(
|
||||||
|
'''
|
||||||
|
ans = ''
|
||||||
|
if (window.paged_display)
|
||||||
|
ans = window.paged_display.col_width + ':' + window.paged_display.current_page_height;
|
||||||
|
ans;''', typ='string')
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def hscroll_fraction(self):
|
def hscroll_fraction(self):
|
||||||
try:
|
try:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user