-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
208 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from kivy_soil.kb_system.canvas import FocusBehaviorCanvas | ||
from kivy.uix.modalview import ModalView | ||
from kivy_soil import hover_behavior | ||
from kivy_soil.kb_system import keys | ||
from kivy.uix.popup import Popup | ||
from kivy.lang import Builder | ||
|
||
|
||
class AppPopup(hover_behavior.HoverBehavior, FocusBehaviorCanvas, Popup): | ||
'''A special Popup class that integrates with kivy_soil hover_behavior | ||
and increases hover_behavior.min_hover_height when it is opened''' | ||
|
||
hover_height = 20 | ||
grab_keys = [keys.ESC] | ||
|
||
def __init__(self, **kwargs): | ||
super(AppPopup, self).__init__(**kwargs) | ||
self.grab_focus = True | ||
|
||
def open(self): | ||
hover_behavior.min_hover_height = self.hover_height | ||
super(AppPopup, self).open() | ||
self.is_focusable = True | ||
|
||
def dismiss(self): | ||
hover_behavior.min_hover_height = 0 | ||
super(AppPopup, self).dismiss() | ||
self.is_focusable = False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from kivy.uix.scrollview import ScrollView | ||
from kivy_soil.kb_system import keys | ||
|
||
|
||
class AppScrollView(ScrollView): | ||
def on_key_down(self, key, modifier): | ||
if key == keys.UP: | ||
self.scroll_up_slightly() | ||
elif key == keys.DOWN: | ||
self.scroll_down_slightly() | ||
elif key == keys.PAGE_UP: | ||
self.page_up() | ||
elif key == keys.PAGE_DOWN: | ||
self.page_down() | ||
elif key == keys.HOME: | ||
self.scroll_to_start() | ||
elif key == keys.END: | ||
self.scroll_to_end() | ||
|
||
def scroll_to_start(self): | ||
self.scroll_y = 1.0 | ||
self._update_effect_bounds() | ||
|
||
def scroll_to_end(self): | ||
self.scroll_y = 0.0 | ||
self._update_effect_bounds() | ||
|
||
def scroll_up_slightly(self): | ||
'''Scrolls viewport down by it's height * 0.1''' | ||
scroll = ScrollView.convert_distance_to_scroll( | ||
self, 0, self.height)[1] * 0.1 | ||
self.scroll_y = min(self.scroll_y + scroll, 1.0) | ||
self._update_effect_bounds() | ||
|
||
def scroll_down_slightly(self): | ||
'''Scrolls viewport down by it's height * 0.1''' | ||
scroll = ScrollView.convert_distance_to_scroll( | ||
self, 0, self.height)[1] * 0.1 | ||
self.scroll_y = max(self.scroll_y - scroll, 0.0) | ||
self._update_effect_bounds() | ||
|
||
def page_down(self): | ||
'''Scrolls viewport down by it's height * 0.9''' | ||
scroll = ScrollView.convert_distance_to_scroll( | ||
self, 0, self.height)[1] * 0.9 | ||
self.scroll_y = max(self.scroll_y - scroll, 0.0) | ||
self._update_effect_bounds() | ||
|
||
def page_up(self): | ||
'''Scrolls viewport up by it's height * 0.9''' | ||
scroll = ScrollView.convert_distance_to_scroll( | ||
self, 0, self.height)[1] * 0.9 | ||
self.scroll_y = min(self.scroll_y + scroll, 1.0) | ||
self._update_effect_bounds() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
BACKSPACE = 8 | ||
TAB = 9 | ||
RETURN = 13 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from ._base import PluginBase | ||
|
||
|
||
class Plugin(PluginBase): | ||
name = 'hide' | ||
doc = 'Hides this widget' | ||
|
||
def handle_input(self, term_system, term_globals, exec_locals, text): | ||
term_system.term_widget.animate_out() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from kivy_soil.kb_system.compat_widgets.scrollview import AppScrollView | ||
from kivy_soil.kb_system.compat_widgets.popup import AppPopup | ||
from kivy.properties import StringProperty | ||
from kivy.uix.label import Label | ||
|
||
|
||
class PopupLabel(AppPopup): | ||
text = StringProperty() | ||
|
||
def __init__(self, **kwargs): | ||
super(PopupLabel, self).__init__(**kwargs) | ||
scroller = AppScrollView() | ||
lbl = Label( | ||
size_hint_y=None, text_size=(scroller.width, None), text=self.text) | ||
scroller.bind(size=self._update_text_size) | ||
lbl.bind(texture_size=self._update_text_widget_size) | ||
scroller.add_widget(lbl) | ||
self.content, self.lbl = scroller, lbl | ||
|
||
def on_key_down(self, key, modifier): | ||
self.content.on_key_down(key, modifier) | ||
|
||
def _update_text_size(self, _, value): | ||
self.lbl.text_size = (value[0], None) | ||
|
||
def _update_text_widget_size(self, _, value): | ||
self.lbl.size = value | ||
|
||
@staticmethod | ||
def quick_open(text, title): | ||
new = PopupLabel(text=text, title=title) | ||
new.open() | ||
return new |
Oops, something went wrong.