This commit is contained in:
yumoqing 2020-07-12 23:02:07 +08:00
parent e476868041
commit d310b3ad9f
5 changed files with 36 additions and 13 deletions

View File

@ -32,7 +32,14 @@ class BoxViewer(BoxLayout):
self.parenturl = None self.parenturl = None
self.dataloader = None self.dataloader = None
self.initflag = False self.initflag = False
BoxLayout.__init__(self, orientation='vertical') remind = ['toolbar',
'dataloader',
'orientation',
'viewer',
'boxwidth',
'boxheight']
kwargs = {k:v for k,v in options if k not in remind }
BoxLayout.__init__(self, orientation='vertical', **kwargs)
self.selected_data = None self.selected_data = None
self.options = options self.options = options
self.box_width = CSize(options['boxwidth']) self.box_width = CSize(options['boxwidth'])

View File

@ -29,7 +29,7 @@ class NewWidget(Widget):
def getParentColorLevel(self): def getParentColorLevel(self):
if not self.parent: if not self.parent:
self.fcolor, self.bgcolor = getColors(self.color_level): self.fcolor, self.bgcolor = getColors(self.color_level)
def on_color_level(self,o,v=None): def on_color_level(self,o,v=None):
if bgcolor != [] and fcolor != []: if bgcolor != [] and fcolor != []:

View File

@ -4,6 +4,7 @@ from kivy.logger import Logger
class SwipeBehavior(object): class SwipeBehavior(object):
def __init__(self, **kwargs): def __init__(self, **kwargs):
object.__init__(self) object.__init__(self)
self.swipeenable = True
self.register_event_type('on_context_menu') self.register_event_type('on_context_menu')
self.register_event_type('on_swipe_left') self.register_event_type('on_swipe_left')
self.register_event_type('on_swipe_right') self.register_event_type('on_swipe_right')
@ -14,11 +15,17 @@ class SwipeBehavior(object):
self.sb_start_time = None self.sb_start_time = None
self.sb_end_time = None self.sb_end_time = None
self.threshold=20 self.threshold=20
self.threshold_time = 1.5 self.threshold_time = 0.6
self.bind(on_touch_down=self.on_touchdown) self.bind(on_touch_down=self.on_touchdown)
self.bind(on_touch_move=self.on_touchmove) self.bind(on_touch_move=self.on_touchmove)
self.bind(on_touch_up=self.on_touchup) self.bind(on_touch_up=self.on_touchup)
def disable_swipe(self):
self.swipeenable = False
def enable_swipe(self):
self.swipeenable = True
def on_context_menu(self): def on_context_menu(self):
Logger.info('SwipeBehavior:on_context_menu fired') Logger.info('SwipeBehavior:on_context_menu fired')
@ -34,15 +41,21 @@ class SwipeBehavior(object):
def on_swipe_down(self): def on_swipe_down(self):
Logger.info('SwipeBehavior:on_swipe_down fired') Logger.info('SwipeBehavior:on_swipe_down fired')
def on_touchdown(self,o,touch): def on_touchdown(self,o, touch):
if touch.is_mouse_scrolling:
Logger.info('SwipeBehavior:is_mouse_scrolling')
return False
if not self.collide_point(touch.x, touch.y):
return False
Logger.info('SwipeBehavior:touch_down fired') Logger.info('SwipeBehavior:touch_down fired')
if self.collide_point(*touch.pos): if self.swipeenable:
Logger.info('SwipeBehavior:touch_down fired') Logger.info('SwipeBehavior:touch_down fired')
self.sb_start_point = touch.pos self.sb_start_point = touch.pos
self.sb_start_time = time.time() self.sb_start_time = time.time()
def on_touchmove(self,o,touch): def on_touchmove(self,o,touch):
if self.collide_point(*touch.pos): if self.collide_point(*touch.pos) and self.swipeenable:
Logger.info('SwipeBehavior:touch_move fired') Logger.info('SwipeBehavior:touch_move fired')
if self.sb_start_point is None: if self.sb_start_point is None:
self.sb_start_point = touch.pos self.sb_start_point = touch.pos
@ -50,7 +63,7 @@ class SwipeBehavior(object):
self.sb_end_point = touch.pos self.sb_end_point = touch.pos
def on_touchup(self,o,touch): def on_touchup(self,o,touch):
if self.collide_point(*touch.pos): if self.collide_point(*touch.pos) and self.swipeenable:
Logger.info('SwipeBehavior:touch_up fired') Logger.info('SwipeBehavior:touch_up fired')
self.sb_end_point = touch.pos self.sb_end_point = touch.pos
self.sb_end_time = time.time() self.sb_end_time = time.time()
@ -66,7 +79,10 @@ class SwipeBehavior(object):
return return
if not self.sb_end_time: if not self.sb_end_time:
return return
if self.sb_end_time - self.sb_start_time > self.threshold_time: period_time = self.sb_end_time - self.sb_start_time
Logger.info('SwipeBehavior:period_time=%f,threshold_time=%f',
period_time, self.threshold_time)
if period_time >= self.threshold_time:
self.dispatch('on_context_menu') self.dispatch('on_context_menu')
def check_swipe(self): def check_swipe(self):

View File

@ -431,7 +431,7 @@ class PopupMenu(BoxLayout):
def __init__(self,target,menudesc,**opts): def __init__(self,target,menudesc,**opts):
self.target = target self.target = target
self.menudesc = menudesc self.menudesc = menudesc
BoxLayout.__init__(self, size_hint=(0.5,0.5)) BoxLayout.__init__(self, size_hint=(0.5,0.5), **opts)
self.menu_tree = TextTree(**menudesc) self.menu_tree = TextTree(**menudesc)
self.add_widget(self.menu_tree) self.add_widget(self.menu_tree)
self.menu_tree.bind(on_press=self.onMenuItemTouch) self.menu_tree.bind(on_press=self.onMenuItemTouch)

View File

@ -1,6 +1,8 @@
import os import os
import sys import sys
import time import time
from appPublic.sockPackage import get_free_local_addr
from kivy.utils import platform from kivy.utils import platform
from traceback import print_exc from traceback import print_exc
from kivy.core.window import Window from kivy.core.window import Window
@ -22,7 +24,7 @@ from pythonosc import dispatcher, osc_server
from ffpyplayer.tools import set_log_callback from ffpyplayer.tools import set_log_callback
from .utils import * from .utils import *
from .paging import PageLoader from .paging import PageLoader
from .baseWidget import PressableImage, get_local_addr from .baseWidget import PressableImage
from .swipebehavior import SwipeBehavior from .swipebehavior import SwipeBehavior
desktopOSs=[ desktopOSs=[
@ -235,11 +237,9 @@ class Swipe_VPlayer(BaseVPlayer, SwipeBehavior):
class OSC_VPlayer(BaseVPlayer): class OSC_VPlayer(BaseVPlayer):
def __init__(self,vfile=None, loop=False, mute=False): def __init__(self,vfile=None, loop=False, mute=False):
self.ip = ip
self.port = port
self.dispatcher = dispatcher.Dispatcher() self.dispatcher = dispatcher.Dispatcher()
addr = get_local_addr addr = get_local_addr
self.ip,self.port = get_local_addr() self.ip,self.port = get_free_local_addr()
self.server = osc_server.ThreadingOSCUDPServer( (self.ip,self.port), self.server = osc_server.ThreadingOSCUDPServer( (self.ip,self.port),
self.dispatcher) self.dispatcher)
BaseVPlayer.__init__(self,vfile=vfile, loop=loop, mute=mute) BaseVPlayer.__init__(self,vfile=vfile, loop=loop, mute=mute)