"""
Copyright (c) 2017, CodeLV.
Distributed under the terms of the MIT License.
The full license is in the file LICENSE, distributed with this software.
Created on Aug 25, 2017
@author: jrm
"""
from atom.api import Typed, Bool
from enamlnative.widgets.seek_bar import ProxySeekBar
from .bridge import ObjcMethod, ObjcProperty, ObjcCallback
from .uikit_control import UIControl, UiKitControl
[docs]class UISlider(UIControl):
"""
"""
#: Properties
minimumValue = ObjcProperty('float')
maximumValue = ObjcProperty('float')
continuous = ObjcProperty('bool')
value = ObjcProperty('float')
onTintColor = ObjcProperty('UIColor')
tintColor = ObjcProperty('UIColor')
thumbTintColor = ObjcProperty('UIColor')
onImage = ObjcProperty('UIImage')
offImage = ObjcProperty('UIImage')
#: Methods
#: Works but then doesn't let you change it
setValue = ObjcMethod('float', dict(animated='bool'))
#: Callbacks
onValueChanged = ObjcCallback('float')
[docs]class UiKitSlider(UiKitControl, ProxySeekBar):
""" An UiKit implementation of an Enaml ProxyToolkitObject.
"""
#: A reference to the toolkit widget created by the proxy.
widget = Typed(UISlider)
# -------------------------------------------------------------------------
# Initialization API
# -------------------------------------------------------------------------
self.widget = UISlider()
self.widget.onValueChanged.connect(self.on_checked_changed)
[docs] def init_text(self):
""" A slider has no text!"""
pass
[docs] def on_checked_changed(self, value):
""" See https://stackoverflow.com/questions/19628310/ """
#: Since iOS decides to call this like 100 times for each defer it
d = self.declaration
with self.widget.setValue.suppressed():
d.progress = int(value)
# -------------------------------------------------------------------------
# ProxySlider API
# -------------------------------------------------------------------------
[docs] def set_progress(self, progress):
self.widget.setValue(float(progress), animated=True)
[docs] def set_secondary_progress(self, progress):
raise NotImplementedError
[docs] def set_max(self, value):
self.widget.maximumValue = float(value)
[docs] def set_min(self, value):
self.widget.minimumValue = float(value)
[docs] def set_key_progress_increment(self, value):
raise NotImplementedError
[docs] def set_split_track(self, split):
raise NotImplementedError