[r80]: trunk / misc / bw / display.srp  Maximize  Restore  History

Download this file

59 lines (53 with data), 2.2 kB

# display.srp -- show notes being played
#
# Roger B. Dannenberg
# Feb, 2014

SD_Y = 5
SD_NAME_WIDTH = 100
SD_GRID_SPACING = 12
SD_BW = 2 * SD_GRID_SPACING // buttons width (2 indicators on left)
SD_COL_WIDTH = SD_NAME_WIDTH + SD_GRID_SPACING * 20
SD_BLACKS = [1, 3, 6, 8, 10, 13, 15]

class State_disp (Canvas)

    def paint(all):
        // draw background
        var x, y
        var bgd_height = len(roster)
        if bgd_height > 50:
            bgd_height = idiv(len(roster) + 1, 2)
        set_brush_color("LIGHT GREY")
        set_pen_color("LIGHT GREY")
        for b in SD_BLACKS
            x = 2 + SD_BW + SD_NAME_WIDTH + b * SD_GRID_SPACING
            draw_rectangle(x, SD_Y,
                           SD_GRID_SPACING, bgd_height * SD_GRID_SPACING)
        if len(roster) > 50:
            for b in SD_BLACKS
                x = 2 + SD_BW + SD_NAME_WIDTH + b * SD_GRID_SPACING + SD_COL_WIDTH
                draw_rectangle(x, SD_Y,
                               SD_GRID_SPACING, bgd_height * SD_GRID_SPACING)

        set_brush_color("GREEN")
        set_pen_color("GREY")
        // use roster to print names and show state
        for entry at i in roster:
            x = 2 + SD_BW + (0 if i < bgd_height else SD_COL_WIDTH)
            y = SD_Y + (i % bgd_height) * SD_GRID_SPACING
            draw_text(x, y, entry[0])
            if ord(play_state[i * 2 + 1]) > 0:
                var p = ord(play_state[i * 2])
                if p >= 60 and p < 78:
                    x = x + (p - 60) * SD_GRID_SPACING + SD_NAME_WIDTH + 1
                    // 3 pixels is offset from top of text
                    draw_rectangle(x, y + 5, 8, 8)

        set_brush_color("GREEN")
        for client in clients.all_clients:
            if client.yes_or_no:
                x = 2
                y = SD_Y + client.index * SD_GRID_SPACING
                draw_rectangle(x, y, SD_GRID_SPACING, SD_GRID_SPACING)
        set_brush_color("BLACK")
        for client in clients.all_clients:
            if client.addr:
                x = 2 + SD_GRID_SPACING
                y = SD_Y + client.index * SD_GRID_SPACING
                draw_rectangle(x, y, SD_GRID_SPACING, SD_GRID_SPACING)

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks