acid-drop

- Hacking the planet from a LilyGo T-Deck using custom firmware
git clone git://git.acid.vegas/acid-drop.git
Log | Files | Refs | Archive | README | LICENSE

lv_example_scroll_4.py (2161B)

      1 #
      2 # Styling the scrollbars
      3 #
      4 obj = lv.obj(lv.scr_act())
      5 obj.set_size(200, 100)
      6 obj.center()
      7 
      8 label = lv.label(obj)
      9 label.set_text(
     10 """
     11 Lorem ipsum dolor sit amet, consectetur adipiscing elit.
     12 Etiam dictum, tortor vestibulum lacinia laoreet, mi neque consectetur neque, vel mattis odio dolor egestas ligula.
     13 Sed vestibulum sapien nulla, id convallis ex porttitor nec.
     14 Duis et massa eu libero accumsan faucibus a in arcu.
     15 Ut pulvinar odio lorem, vel tempus turpis condimentum quis. Nam consectetur condimentum sem in auctor.
     16 Sed nisl augue, venenatis in blandit et, gravida ac tortor.
     17 Etiam dapibus elementum suscipit.
     18 Proin mollis sollicitudin convallis.
     19 Integer dapibus tempus arcu nec viverra.
     20 Donec molestie nulla enim, eu interdum velit placerat quis.
     21 Donec id efficitur risus, at molestie turpis.
     22 Suspendisse vestibulum consectetur nunc ut commodo.
     23 Fusce molestie rhoncus nisi sit amet tincidunt.
     24 Suspendisse a nunc ut magna ornare volutpat.
     25 """)
     26 
     27 
     28 # Remove the style of scrollbar to have clean start
     29 obj.remove_style(None, lv.PART.SCROLLBAR | lv.STATE.ANY)
     30 
     31 # Create a transition the animate the some properties on state change
     32 props = [lv.STYLE.BG_OPA, lv.STYLE.WIDTH, 0]
     33 trans = lv.style_transition_dsc_t()
     34 trans.init(props, lv.anim_t.path_linear, 200, 0, None)
     35 
     36 # Create a style for the scrollbars
     37 style = lv.style_t()
     38 style.init()
     39 style.set_width(4)               # Width of the scrollbar
     40 style.set_pad_right(5)           # Space from the parallel side
     41 style.set_pad_top(5)             # Space from the perpendicular side
     42 
     43 style.set_radius(2)
     44 style.set_bg_opa(lv.OPA._70)
     45 style.set_bg_color(lv.palette_main(lv.PALETTE.BLUE))
     46 style.set_border_color(lv.palette_darken(lv.PALETTE.BLUE, 3))
     47 style.set_border_width(2)
     48 style.set_shadow_width(8)
     49 style.set_shadow_spread(2)
     50 style.set_shadow_color(lv.palette_darken(lv.PALETTE.BLUE, 1))
     51 
     52 style.set_transition(trans)
     53 
     54 # Make the scrollbars wider and use 100% opacity when scrolled
     55 style_scrolled = lv.style_t()
     56 style_scrolled.init()
     57 style_scrolled.set_width(8)
     58 style_scrolled.set_bg_opa(lv.OPA.COVER)
     59 
     60 obj.add_style(style, lv.PART.SCROLLBAR)
     61 obj.add_style(style_scrolled, lv.PART.SCROLLBAR | lv.STATE.SCROLLED)
     62