Ejemplo n.º 1
0
display_driver.getdisplay_landscape()

#
# Create a style transition on a button to act like a gum when clicked
#

# Properties to transition
props = [
    lv.STYLE.TRANSFORM_WIDTH, lv.STYLE.TRANSFORM_HEIGHT,
    lv.STYLE.TEXT_LETTER_SPACE, 0
]

# Transition descriptor when going back to the default state.
# Add some delay to be sure the press transition is visible even if the press was very short*/
transition_dsc_def = lv.style_transition_dsc_t()
transition_dsc_def.init(props, lv.anim_t.path_overshoot, 250, 100, None)

# Transition descriptor when going to pressed state.
# No delay, go to pressed state immediately
transition_dsc_pr = lv.style_transition_dsc_t()
transition_dsc_pr.init(props, lv.anim_t.path_ease_in_out, 250, 0, None)

# Add only the new transition to the default state
style_def = lv.style_t()
style_def.init()
style_def.set_transition(transition_dsc_def)

# Add the transition and some transformation to the presses state.
style_pr = lv.style_t()
style_pr.init()
Ejemplo n.º 2
0
Etiam dapibus elementum suscipit.
Proin mollis sollicitudin convallis.
Integer dapibus tempus arcu nec viverra.
Donec molestie nulla enim, eu interdum velit placerat quis.
Donec id efficitur risus, at molestie turpis.
Suspendisse vestibulum consectetur nunc ut commodo.
Fusce molestie rhoncus nisi sit amet tincidunt.
Suspendisse a nunc ut magna ornare volutpat.
""")

# Remove the style of scrollbar to have clean start
obj.remove_style(None, lv.PART.SCROLLBAR | lv.STATE.ANY)

# Create a transition the animate the some properties on state change
props = [lv.STYLE.BG_OPA, lv.STYLE.WIDTH, 0]
trans = lv.style_transition_dsc_t()
trans.init(props, lv.anim_t.path_linear, 200, 0, None)

# Create a style for the scrollbars
style = lv.style_t()
style.init()
style.set_width(4)  # Width of the scrollbar
style.set_pad_right(5)  # Space from the parallel side
style.set_pad_top(5)  # Space from the perpendicular side

style.set_radius(2)
style.set_bg_opa(lv.OPA._70)
style.set_bg_color(lv.palette_main(lv.PALETTE.BLUE))
style.set_border_color(lv.palette_darken(lv.PALETTE.BLUE, 3))
style.set_border_width(2)
style.set_shadow_width(8)
Ejemplo n.º 3
0
    def createPage(self):
        global anim
        global playedTime
        global durationTime
        global slider
        global audio_src
        global player
        global image
        global music_alive
        global currentMusic
        global albumCover
        global songTitle
        global albumTitle
        global totalTime
        global anim_timeline
        global scr

        print("Enter Music")

        # init scr
        scr = lv.obj()

        win = lv.obj(scr)
        win.set_size(scr.get_width(), scr.get_height())
        win.set_style_border_opa(0, 0)
        win.set_style_radius(0, 0)
        win.set_style_bg_color(lv.color_black(), 0)
        win.clear_flag(lv.obj.FLAG.SCROLLABLE)

        backImg = lv.img(win)
        backImg.set_src(RESOURCES_ROOT + "images/back.png")
        backImg.set_style_align(lv.ALIGN.LEFT_MID, 0)
        backImg.add_flag(lv.obj.FLAG.CLICKABLE)
        backImg.add_event_cb(lambda e: music_back_click_callback(e, win),
                             lv.EVENT.CLICKED, None)
        backImg.add_event_cb(lambda e: music_back_press_callback(e, backImg),
                             lv.EVENT.PRESSED, None)
        backImg.add_event_cb(lambda e: music_back_release_callback(e, backImg),
                             lv.EVENT.RELEASED, None)
        backImg.set_ext_click_area(30)

        albumCover = lv.img(win)
        albumCover.set_style_pad_left(12, 0)
        albumCover.set_style_pad_top(10, 0)

        songTitle = lv.label(win)
        songTitle.set_style_text_font(lv.font_montserrat_20, 0)
        songTitle.set_style_text_color(lv.color_white(), 0)
        songTitle.align_to(albumCover, lv.ALIGN.TOP_LEFT, 130, 3)

        albumTitle = lv.label(win)
        albumTitle.set_style_text_font(lv.font_montserrat_16, 0)
        albumTitle.set_style_text_color(lv.color_make(0xCC, 0xCC, 0xCC), 0)
        albumTitle.align_to(songTitle, lv.ALIGN.OUT_BOTTOM_LEFT, 0, 12)

        props = [lv.STYLE.BG_COLOR, 0]
        transition_dsc = lv.style_transition_dsc_t()
        transition_dsc.init(props, lv.anim_t.path_linear, 300, 0, None)

        style_main = lv.style_t()
        style_indicator = lv.style_t()
        style_pressed_color = lv.style_t()
        style_main.init()
        style_main.set_bg_opa(lv.OPA.COVER)
        style_main.set_bg_color(lv.color_make(0x66, 0x66, 0x66))
        style_main.set_radius(lv.RADIUS.CIRCLE)
        style_main.set_line_dash_width(1)

        style_indicator.init()
        style_indicator.set_bg_opa(lv.OPA.COVER)
        style_indicator.set_bg_color(lv.color_white())
        style_indicator.set_radius(lv.RADIUS.CIRCLE)
        style_indicator.set_transition(transition_dsc)

        style_pressed_color.init()
        style_pressed_color.set_bg_color(lv.color_white())

        # Create a slider and add the style
        slider = lv.slider(win)
        slider.remove_style_all()  # Remove the styles coming from the theme

        slider.add_style(style_main, lv.PART.MAIN)
        slider.add_style(style_indicator, lv.PART.INDICATOR)
        slider.add_style(style_pressed_color,
                         lv.PART.INDICATOR | lv.STATE.PRESSED)
        slider.align_to(albumTitle, lv.ALIGN.OUT_BOTTOM_LEFT, 0, 25)
        slider.set_size(140, 1)

        anim = lv.anim_t()
        anim.init()
        anim.set_var(slider)

        playedTime = lv.label(win)
        setLabelValue(playedTime, 0)
        playedTime.set_style_text_font(lv.font_montserrat_16, 0)
        playedTime.set_style_text_color(lv.color_white(), 0)
        playedTime.align_to(slider, lv.ALIGN.OUT_BOTTOM_LEFT, 0, 15)

        totalTime = lv.label(win)
        totalTime.set_style_text_font(lv.font_montserrat_16, 0)
        totalTime.set_style_text_color(lv.color_white(), 0)
        totalTime.align_to(slider, lv.ALIGN.OUT_BOTTOM_RIGHT, 0, 15)

        func_col_dsc = [80, 80, 80, 80, lv.GRID_TEMPLATE.LAST]
        func_row_dsc = [40, lv.GRID_TEMPLATE.LAST]

        funcContainer = lv.obj(win)
        funcContainer.set_style_bg_opa(0x00, 0)
        funcContainer.set_style_border_opa(0x00, 0)
        funcContainer.set_layout(lv.LAYOUT_GRID.value)
        funcContainer.set_grid_dsc_array(func_col_dsc, func_row_dsc)
        funcContainer.set_grid_align(lv.GRID_ALIGN.SPACE_BETWEEN,
                                     lv.GRID_ALIGN.SPACE_BETWEEN)
        funcContainer.set_align(lv.ALIGN.BOTTOM_MID)
        funcContainer.set_size(320, 70)

        for i in range(4):
            image[i] = lv.img(funcContainer)
            image[i].set_src(functionImage[i])
            image[i].add_flag(lv.obj.FLAG.CLICKABLE)
            image[i].set_ext_click_area(20)
            image[i].set_grid_cell(lv.GRID_ALIGN.CENTER, i, 1,
                                   lv.GRID_ALIGN.CENTER, 0, 1)

            if (i == 0):
                image[i].add_event_cb(lambda e: controller_click_cb(e, "prev"),
                                      lv.EVENT.CLICKED, None)
            elif (i == 1):
                image[i].add_event_cb(lambda e: controller_click_cb(e, "play"),
                                      lv.EVENT.CLICKED, None)
            elif (i == 2):
                image[i].add_event_cb(lambda e: controller_click_cb(e, "next"),
                                      lv.EVENT.CLICKED, None)
            elif (i == 3):
                image[i].add_event_cb(lambda e: controller_click_cb(e, "fav"),
                                      lv.EVENT.CLICKED, None)

        anim.set_custom_exec_cb(lambda a1, val: setSpentTime(slider, val))
        reset_music()

        from smart_panel import needAnimation
        if (needAnimation):
            lv.scr_load_anim(scr, lv.SCR_LOAD_ANIM.MOVE_LEFT, 500, 0, True)
        else:
            lv.scr_load_anim(scr, lv.SCR_LOAD_ANIM.NONE, 0, 0, True)

        music_alive = True