Commit Graph

66 Commits (859327dea58cfa2b3c634b5ae4ecc1008b8c6f23)

Author SHA1 Message Date
hius07 859327dea5
Input dialogs: keep size in rotation (#8223) 3 years ago
hius07 1a127633c2
InputDialog: add :addWidget(), use it for checkboxes (#8168)
Also: Text editor now closes its keyboard when calling Find
and Go to line (which open their own keyboards) to avoid
conflicts between multiple keyboards.
3 years ago
hius07 68782c3f89
Checkbutton: optimize callback (#8134) 3 years ago
hius07 c8a7f52672
Checkbutton: ensure max width, multiline if needed (#8066) 3 years ago
hius07 7eea2ae7cd
InputText/InputDialog: add case sensitive search (#7966) 3 years ago
hius07 6c35e01acb
InputDialog: manage keyboard hiding (#7908)
Disable keyboard hiding with Tap in some cases.
3 years ago
hius07 5e2d83965b
InputDialog, InputText: a bunch of updates (#7896)
- New way to hide the VirtualKeyboard: to hide the keyboard
  tap any point of the screen outside the inputbox and above
  the keyboard; to show the keyboard tap the inputbox.
  (Removed hacky "holding the arrow-down key" which is no
  longer needed).
- InputDialog windows are movable/translucent by default
- Redesign of the Clipboard dialog
3 years ago
Frans de Jonge 039947886f
Revert "Hyphenation: add custom hyphenation rules (#7746)" (#7785)
This reverts commit f25da5d0d5.
3 years ago
zwim f25da5d0d5
Hyphenation: add custom hyphenation rules (#7746)
The hyphenation of a word can be changed from its default
by long pressing for 3 seconds and selecting 'Hyphenate'.
These overrides are stored in a per-language file, i.e:
koreader/settings/user-German.hyph.
3 years ago
hius07 4973134fb6
VirtualKeyboard: Allow hiding the keyboard with a hold on the down arrow key (#7751)
(And showing it again with a tap on an input field)
3 years ago
Frans de Jonge 6e1950676a
[lang] Fix minor inconsistency (#7714)
It should be "Not found." as in "Find next".
3 years ago
hius07 f3fe643d81
InputDialog: add search (#7701)
Searches for a string in the edited text.
Available in the Text editor and other input dialogs with the navigation bar enabled.

Find first searches from the beginning of the text.
Find next searches from the next to cursor position, used for continious search.
By now, the Search input window is closed after the search. You need to press the Find button again for continious search, the search string is kept in the input.
Is it better to keep the dialog open for the comfortable continious search? And close it with the Cancel only?

Case insensitive. Cursor jumps to the beginning of the found string.
Notifications are shown for better results visibility.

Unfortunately, violated our standartization to "search", couldn't invent better short wordings.
3 years ago
hius07 834feef8cd
InputDialog: add 'Go to line' button (#7673) 3 years ago
NiLuJe fe10d0bce5
Revamp flash_ui handling, once more, with feeling ;) (#7262)
* Simplify flash_ui handling (by handling the unhighlight pre-callback, c.f., #7262 for more details).
* UIManager: Handle translucent window-level widgets (and those wrapped in a translucent MovableContainer) properly in setDirty directly, making sure what's *underneath* them gets repainted to avoid alpha layering glitches. (This was previously handled via localized hacks).
* Update UIManager's documentation, and format it properly for ldoc parsing, making the HTML docs more useful.
* ReaderView: Reinitialize the various page areas when opening a new document, to prevent poisoning from the previous document.
* Event: Handle nils in an event's arguments.
* CheckButton/RadioButton: Switch to simple inversion to handle highlighting
* CheckButton: Make the highlight span the inner frame's width, instead of just the text's width, if possible.
* AlphaContainer: Fix & simplify, given the UIManager alpha handling.
* MovableContainer: When translucent, cache the canvas bb used for composition.
* Avoid spurious refreshes in a few widgets using various dummy *TextWidgets in order to first compute a text height.
* KeyValuePage: Avoid floats in size computations.
3 years ago
NiLuJe df0bbc9db7
Tame some ButtonTable users into re-using Buttontable instances if possible (#7166)
* QuickDictLookup, ImageViewer, NumberPicker: Smarter `update` that will re-use most of the widget's layout instead of re-instantiating all the things.
* SpinWidget/DoubleSpinWidget: The NumberPicker change above renders a hack to preserve alpha on these widgets almost unnecessary. Also fixed said hack to also apply to the center, value button.

* Button: Don't re-instantiate the frame in setText/setIcon when unnecessary (e.g., no change at all, or no layout change).
* Button: Add a refresh method that repaints and refreshes a *specific* Button (provided it's been painted once) all on its lonesome.

* ConfigDialog: Free everything that's going to be re-instatiated on update
 
* A few more post #7118 fixes:
  * SkimTo: Always flag the chapter nav buttons as vsync
  * Button: Fix the highlight on rounded buttons when vsync is enabled (e.g., it's now entirely visible, instead of showing a weird inverted corner glitch).
  * Some more heuristic tweaks in Menu/TouchMenu/Button/IconButton
* ButtonTable: fix the annoying rounding issue I'd noticed in #7054 ;).

* Enable dithering in TextBoxWidget (e.g., in the Wikipedia full view). This involved moving the HW dithering align fixup to base, where it always ought to have been ;).

* Switch a few widgets that were using "partial" on close to "ui", or, more rarely, "flashui". The intent being to limit "partial" purely to the Reader, because it has a latency cost when mixed with other refreshes, which happens often enough in UI ;).

* Minor documentation tweaks around UIManager's `setDirty` to reflect that change.

* ReaderFooter: Force a footer repaint on resume if it is visible (otherwise, just update it).
* ReaderBookmark: In the same vein, don't repaint an invisible footer on bookmark count changes.
3 years ago
NiLuJe 0c76c73e4f
Assorted fixes after #7118 (#7161)
* I'd failed to notice that ButtonTable *also* instantiates seven billion Buttons on each update. Unfortunately, that one is way trickier to fix properly, so, work around its behavior in Button. (This fixes multiple issues with stuff using ButtonTable, which is basically anything with a persistent set of buttons. A good and easy test-case is the dictionary popup, e.g., the Highlight button changes text, and the next/prev dic buttons change state. All that, and more, was broken ;p).

* Handle corner-cases related to VirtualKeyboard (e.g., Terminal & Text Editor), which screwed with both TouchMenu & Button heuristics because it's weird.

* Flag a the dictionary switch buttons as vsync

(They trigger a partial repaint of the dictionary content).

* Flag the ReaderSearch buttons as vsync

They very obviously trigger a partial repaint, much like SkimTo ;p.
3 years ago
poire-z 8f79c662cf Notification: closed by any event, but not consuming it
Make Notification have toast=true, and UIManager deal
specifically with such widget:
a "toast" widget gets closed by any event, and let
the event be handled by a lower widget.
This should allow us to not wait or tap to get rid
of a notification, and just go on with what we're
doing.
Also make them have a default timeout of 2s,
used with all existing ones.
3 years ago
poire-z 85a16d0064 Open with: add Text Editor plugin 4 years ago
NiLuJe 1f994f8ede
Floor dimension computations (mul/div). (#6264)
* floor most every dimension computations involving MUL or DIV
Should avoid passing nonsensical floating point coordinates/dimensions
to the UI code.

* Update base

* https://github.com/koreader/koreader-base/pull/1113
* https://github.com/koreader/koreader-base/pull/1114
* https://github.com/koreader/koreader-base/pull/1115

* Bump android-luajit-launcher

https://github.com/koreader/android-luajit-launcher/pull/230
https://github.com/koreader/android-luajit-launcher/pull/231
4 years ago
poire-z 886b3063e7
Style tweaks: adds "Book-specific tweak" menu item (#6244)
Allows editing a CSS snippet to be applied to this
book only, without the need to create and edit
a User style tweak.
Allows copying any other tweak CSS by just taping
on it (and pasting into this with Hold).
Limit User style tweaks nb of items per menu page
to 6 (like we try to do for other tweaks menus).
4 years ago
poire-z d6d49a64a7 [RTL UI] use auto or LTR text direction in some specific cases
Allow TextBoxWidget new text direction/lang parameters to be
set on upper widgets, and propagate them all the way to it
(ScrollTextWidget, InputText, InputDialog, TextViewer).

Use specific non-default ones in some specific cases:
- Force LTR text direction when showing HTML and CSS, and
  configuration files (in some plugins).
- Use Wikipedia server language and text direction when
  showing an article.
- Use auto with Dictionary results, as we don't know the
  dictionary language, and they may contain mixed content.
- Force LTR when showing some paths (still needs more of them)

TextEditor plugin: add 2 new options "Auto paragraph direction"
and "Force paragraph direction LTR".

Footnotes popup: grab HTML direction, and forward it
to MuPDF for proper display.
4 years ago
poire-z 397211644d Keyboard: properly handle keyboard layout height change
The japanese keyboard being taller than the others, when
switching to/from it from/to another layout:
- re-init InputDialog for proper sizing and positionning
- refresh the whole screen, to remove any trace of
  a previous taller keyboard

Also add calls to :free() here and there to free keyboard
keys' TextWidgets' XText C objects without waiting for GC.
4 years ago
poire-z f05e62c1fb
TextWidget: small refactoring, better handle max_width (#5503)
Lots of code was doing some renderText calls to get the size
of some text string, and truncate it to some width if needed,
with or without an added ellipsis, before instantiating
a TextWidget with that tweaked text string.

This PR fixes/adds some properties and methods to TextWidget
so all that can be done by it. It makes the calling code
simpler, as they don't need to use RenderText directly.
(Additionally, when we go at using Harfbuzz for text rendering,
we'll just have to update or replace textwidget.lua without
the need to update any higher level code.)

Also:
- RenderText: removed the space added by truncateTextByWidth
  after the ellipsis, as it doesn't feel needed, and break
  right alignment of the ellipsis with other texts.
- KeyValuePage: fix some subtle size and alignment issues.
- NumberPickerWidget: fix font size (provided font size was
  not used)
5 years ago
Frans de Jonge 761f332d47
[doc] Update InputDialog example (#5510)
Make it work out of the box, add some cross-references, and update a few minor things.

In response to @dontcrash.

Cf. <https://gitter.im/koreader/koreader?at=5dac431978e4974ace8c4213>.
5 years ago
Frans de Jonge 2968f558eb
[fix, UX] Ignore first hold release when keyboard opened with hold (#5011)
Fixes #4902.
5 years ago
NiLuJe 8189945be9
A few graphics fixes after #4541 (#4554)
* Various FocusManager related tweaks to limit its usage to devices with a DPad, and prevent initial button highlights in Dialogs on devices where it makes no sense (i.e., those without a DPad. And even on DPad devices, I'm not even sure how we'd go about making one of those pop up anyway, because no Touch ;)!).
* One mysterious fix to text-only Buttons so that the flash_ui highlight always works, and always honors `FrameContainer`'s pill shape. (Before that, an unhighlight on a text button with a callback that didn't repaint anything [say, the find first/find last buttons in the Reader's search bar when you're already on the first/last match] would do a square black highlight, and a white pill-shaped unhighlight (leaving the black corners visible)).
The workaround makes *absolutely* no sense to me (as `self[1] -> self.frame`, AFAICT), but it works, and ensures all highlights/unhighlights are pill-shaped, so at least we're not doing maths for rounded corners for nothing ;).
5 years ago
poire-z 850be52177
Keep some menus open when Tap or Hold (#4189)
TouchMenu: added options to menu items with the following defaults:
    keep_menu_open = false
    hold_keep_menu_open = true
So, default for Tap callback is to close menu, and for Hold callback
to keep menu open.
In both cases, provide the TouchMenu instance as the 1st argument to
the callback functions (instead of a refresh_menu_func I added in #3941)
so the callback can do more things, like closing, refreshing,
changing menu items text and re-ordering...

ReaderZooming: show symbol for default (like it was done for
ReaderFont, ReaderHyphenation...)
TextEditor plugin: update the previously opened files list in real
time, so the menu can be kept open and used as the TextEditor main
interface.
SSH plugin: keep menu open and update the Start/Stop state in real time
ReadTimer plugin: tried to do what feels right (but I don't use it)

Also remove forgotten cp in the move/paste file code
6 years ago
poire-z adceda15b7
TextEditor: allow scrolling by lines with Pan (#4145)
Feature of ScrollTextWidget, only used for now by TextEditor.
Pan is like Swipe, but wait a bit at end of gesture to release:
the line on which Pan was started will be moved to where Pan is
released.

May conflict with MovableContainer (so not enabled for DictQuickLookup,
where it could have been nice - but it would work only with text
dictionaries, not with HTML ones, as ScrollHtmlWidget can't really
do that).
6 years ago
poire-z 6e35e683dd
Text editor plugin, InputDialog enhancements (#4135)
This plugin mostly sets up a "Text editor>" submenu, that allows
browsing files, creating a new file, and managing a history of
previously opened file for easier re-opening.
It restore previous scroll and cursor positions on re-opening.
Additional "Check lua" syntax button is added when editing
a .lua file, and prevent saving if errors.
The text editing is mainly provided by the enhanced InputDialog.

InputDialog: added a few more options, the main one being
'save_callback', which will add a Save and Close buttons
and manage saving/discarding/exiting.
If "fullscreen" and "add_nav_bar", will add a show/hide keyboard
button to it.
Moved the preset buttons setup code in their own InputDialog
methods for clarity of the main init code.
Buttons are now enabled/disabled depending on context for feedback
(eg: Save is disabled as long as text has not been modified).

Added util.checkLuaSyntax(lua_string), might be useful elsewhere.
6 years ago
poire-z 620542b055
Text input related fixes & enhancements (#4124)
InputText: checks whether provided content can be given
back unaltered, which may not be the case after it is
splitted to UTF8 chars if the text is binary content.
Prevent editing text if that is the case.
Adds InputText and InputDialog :isEditable() and :isEdited()
methods.
Also accounts for the scrollbar width when measuring text
to prevent it from being displayed when not needed.
Also ensure a minimal size of the scrollbar thumb so it is
rendered when huge text with many lines is displayed.

Virtual keyboard: Hold on Backspace: delete from cursor
to start of line instead of clearing all text content.
6 years ago
poire-z 0d66ea7555
Text input fixes and enhancements (#4084)
InputText, ScrollTextWidget, TextBoxWidget:
- proper line scrolling when moving cursor or inserting/deleting text
  to behave like most text editors do
- fix cursor navigation, optimize refreshes when moving only the cursor,
  don't recreate the textwidget when moving cursor up/down
- optimize refresh areas, stick to "ui" to avoid a "partial" black
  flash every 6 appended or deleted chars

InputText:
- fix issue when toggling Show password multiple times
- new option: InputText.cursor_at_end (default: true)
- if no InputText.height provided, measure the text widget height
  that we would start with, and use a ScrollTextWidget with that
  fixed height, so widget does not overflow container if we extend
  the text and increase the number of lines
- as we are using "ui" refreshes while text editing, allows refreshing
  the InputText with a diagonal swipe on it (actually, refresh the
  whole screen, which allows refreshing the keyboard too if needed)

ScrollTextWidget:
- properly align scrollbar with its TextBoxWidget

TextBoxWidget:
- some cleanup (added new properties to avoid many method calls), added
  proxy methods for upper widgets to get them
- reordered/renamed/refactored the *CharPos* methods for easier reading
  (sorry for the diff that won't help reviewing, but that was needed)

InputDialog:
- new options:
   allow_newline = false, -- allow entering new lines
   cursor_at_end = true, -- starts with cursor at end of text, ready to append
   fullscreen = false, -- adjust to full screen minus keyboard
   condensed = false, -- true will prevent adding air and balance between elements
   add_scroll_buttons = false, -- add scroll Up/Down buttons to first row of buttons
   add_nav_bar = false, -- append a row of page navigation buttons
- find the most adequate text height, when none provided or fullscreen, to
  not overflow screen (and not be stuck with Cancel/Save buttons hidden)
- had to disable the use of a MovableContainer (many issues like becoming
  transparent when a PathChooser comes in front, Hold to paste from
  clipboard, moving the InputDialog under the keyboard and getting stuck...)

GestureRange: fix possible crash (when event processed after widget
destruction ?)

LoginDialog: fix some ui stack increase and possible crash when switching
focus many times.
6 years ago
onde2rock e502bf04d3 [feat, UX] Support the virtualKeyboard on non touch-device (#3796)
* [VirtualKeyboard] Add support for keynaviguation

Also rename the variable "layout" to "keyboard_layout" because conflict
with the layout from the focusmanager

* Make the goto dialog compatible with key naviguation

My solution is to change the order of the widget. The last one will the
virtualkeybard so it catch all the keybinding, and below it, make the
dialog "is_always_active = true" so it can receive touch event.

* Correctly show the virtual keyboard on dpad devices

* change the order to call the virtualKeyboard so it end up on top

* Handle the multi input dialog

* Support reopening the virtualKeyboard by the Press key

* add check focusmanager

* Fix https://github.com/koreader/koreader/issues/3797

* MultiInputDialog : Now work on non touch-device

* Set the virtualkeyboard to be a modal widget

* Fix the layout in multiinputwidget

* Fix for the various combination of
hasKeys,hasDpad,isTouchDevice

* [Focusmanager] Better handling of malformed layout
6 years ago
poire-z 43a6cf4b2e Add MovableContainer: allow moving some widgets (#3636) 6 years ago
poire-z 9443098e98 Normalize some widgets appearance (those using ButtonTable)
This makes button heights similar in all uses of ButtonTable.
It depended on how the ButtonTable was used in each widget
(previously, first and last row may have different sizes than
the others).

buttontable.lua: more even buttons height whether zero_sep or not
framecontainer.lua: added padding_top/bottom/left/right (similar to
what was done for iconbutton)

The following widgets have been adapted for this, with some
additional fixes:

buttondialog.lua
buttondialogtitle.lua: wider title with adequate padding
confirmbox.lua + multiconfirmbox.lua: dismissable via tap outside
inputdialog.lua + multiinputdialog.lua: more even vertical padding between elements
imageviewer.lua
textviewer.lua
datewidget.lua
timewidget.lua

Additionaly: frontlightwidget.lua: fixed width of progress bar that
was exceeding window width since the Size scaling adjustements
7 years ago
Frans de Jonge a6be301695 Added Size module 7 years ago
Frans de Jonge 9eb073a524 [travis] Add protection against unscaled sizes
As pointed out by @poire-z

* [fix, UX] SkimToWidget scaling

* [fix] Button scaling

* [fix, UX] Scale ProgressWidget

* [fix, UX] Scale confirmbox

* [fix, UX] Scale just about everything
7 years ago
Frans de Jonge 63241a20ea [UX] Add CheckButton and use it for show password
Normal textinputs stay the same, password textinputs automatically gain a show password checkbutton underneath.

Thanks to @robert00s for the idea.
7 years ago
Robert b883979fba Option to make password visible when entering (#3040)
* Option to make password visible when entering
7 years ago
Frans de Jonge e1aa57f27e Font: unify font styling 7 years ago
Frans de Jonge e9df73f6dc Developer documentation improvements
* Fixed up all of util and added when absent
* Updated widget examples to new coding style
7 years ago
Frans de Jonge 1c25d0fd1b Language: improve confirmboxes
Generic "OK" buttons should be avoided. Thanks to @lightonflux for pointing this out https://github.com/koreader/koreader/issues/2555#issuecomment-291039945
7 years ago
Hzj_jie ed461c7f30 InputDialog is broken by #2672 (#2690)
This change also adds a tap_input_func in both TouchMenu and Button.
7 years ago
Hzj_jie 0318a048b4 Read timer plugin (#2672)
A countdown timer to notify user.
7 years ago
Qingping Hou f95ad00b9e feat: add logger module & rewrite kobo suspend script in lua 7 years ago
Qingping Hou ca21ab4be5 fix(defaults): type casting for user input 8 years ago
Qingping Hou 20eb36a03d feat: add network management UI for kobo 8 years ago
Qingping Hou 476e35708d inputdialog(feat): add is_enter_default attribute to buttons 8 years ago
Qingping Hou 60587e08c6 defaults(refactor): remove global hack in filemanagersetdefaults
also added screensaver folder setting dialog for kobo
8 years ago
Qingping Hou 4598284bbb fix(readerfontlight): crash in toggle 8 years ago
Alex Pletnev 0f9bfbf147 #1730 Create complete book feature 8 years ago