Esempio n. 1
0
def command_refresh(refresh_img, screen, files, file):
    "reset image to its original state"
    wait_cursor()
    new_img = refresh_img
    rect = get_center(screen, new_img)
    cur_filename = ""
    if len(gl.files) > 1:
        cur_filename = gl.files[file]
    else:
        normal_cursor()
        return (new_img, new_img, get_center(screen, new_img), file)
    if gl.SHRUNK and len(gl.files) > 1:
        # reload shrunk images to their true size
        gl.SKIP_FIT = 1
        refresh_img = load_img(gl.files[file])
        rect = get_center(screen, refresh_img)
        adjust_files(gl.SUBDIRS)
        if cur_filename in gl.files:
            file = gl.files.index(cur_filename)  # go back if new images were loaded
        my_update_screen(refresh_img, rect, file)
        normal_cursor()
        return (refresh_img, new_img, rect, file)
    adjust_files(gl.SUBDIRS)
    if cur_filename in gl.files and len(gl.files) > 1:
        file = gl.files.index(cur_filename)  # go back if new images were loaded
    my_update_screen(refresh_img, rect, file)
    normal_cursor()
    return (new_img, new_img, get_center(screen, new_img), file)
Esempio n. 2
0
File: thumb.py Progetto: rkulla/imgv
def command_thumbs(screen, new_img, file):
    normal_cursor()
    gl.THUMBING = 1

    screen_width = screen.get_width()
    if gl.THUMB_VAL.upper() == "AUTO" or gl.USING_THUMB_DEFAULT:
        gl.USING_THUMB_DEFAULT = 1
        if screen_width == 640:
            gl.THUMB_VAL = "85x90"
        elif screen_width == 800:
            gl.THUMB_VAL = "108x114"
        elif screen_width == 1024:
            gl.THUMB_VAL = "108x104"
        else:
            gl.THUMB_VAL = "100x100"

    if not gl.TOGGLE_FULLSCREEN_SET:
        screen = set_mode(screen.get_size())  # take away resize priviledges
    paint_screen(gl.IMGV_COLOR)
    set_caption("imgv")
    (new_img, new_img, new_img, file) = thumbs_engine(screen, new_img, file)
    if not gl.TOGGLE_FULLSCREEN_SET:
        screen = set_mode(screen.get_size(), RESIZABLE)  # restore resize priviledges
    rect = get_center(screen, new_img)
    my_update_screen(new_img, rect, file)
    normal_cursor()
    gl.THUMBING = 0
    return (new_img, new_img, new_img, file, rect)
Esempio n. 3
0
def show_slideshow_img(screen, new_img, file, num_imgs, speed):
    start = start_timer()
    wait_cursor()
    new_img = next_img(file, new_img, screen)
    rect = get_center(screen, new_img)
    ns = check_timer(start)
    my_update_screen(new_img, screen, rect, file, num_imgs, ns)
    normal_cursor()
    if speed > 0:
        for i in range(speed):
            # trick delay into letting you escape anytime
            event = pygame.event.poll()
            pygame.time.wait(1)
            if event.type == KEYDOWN and event.key not in (K_LALT, K_RALT, K_LCTRL, K_RCTRL,\
                K_p, K_PAUSE, K_TAB, K_SPACE, K_BACKSPACE):
                stopped_msg(screen)
                my_update_screen(new_img, screen, rect, file, len(gl.files))
                return (new_img, file, rect, 1)
            if hit_key(event, K_p) or hit_key(event, K_PAUSE):
                pause(screen)
                my_update_screen(new_img, screen, rect, file, len(gl.files))
            if hit_key(event, K_SPACE):
                # skip forward an image immediately
                file = file + 1
                return (new_img, file, rect, 0)
            if hit_key(event, K_BACKSPACE):
                # skip backward an image immediately
                file = file - 1
                return (new_img, file, rect, 0)
            pygame.time.delay(1000) # check every second
    file = file + 1
    return (new_img, file, rect, 0)
Esempio n. 4
0
def fade_in(screen, image):
    paint_screen(screen, gl.IMGV_COLOR)
    for darken in range(50):
        image.set_alpha(darken)
        r = screen.blit(image, get_center(screen, image))
        pygame.display.update(r)
    image.set_alpha(255)
Esempio n. 5
0
def command_hide(screen, new_img, rect, file, num_imgs):
    "hide the image by making the screen blank"
    (screen, before_winsize, not_accepted) = adjust_screen(screen, NOFRAME)
    set_caption("")
    hide(screen)
    screen = restore_screen(screen, before_winsize, not_accepted, new_img, file, num_imgs, rect)
    rect = get_center(screen, new_img)
    my_update_screen(new_img, screen, rect, file, num_imgs)
Esempio n. 6
0
def command_rotate_left(new_img, screen, file, rect):
    "rotate counter clockwise"
    wait_cursor()
    new_img = rotate(new_img, 90)
    rect = get_center(screen, new_img)
    my_update_screen(new_img, rect, file)
    normal_cursor()
    return (new_img, new_img, rect)
Esempio n. 7
0
def command_shuffle(new_img, img, screen, rect, file):
    "randomize the images"
    wait_cursor()
    shuffle(gl.files)
    new_img = load_img(gl.files[file])
    rect = get_center(screen, new_img)
    my_update_screen(new_img, rect, file)
    normal_cursor()
    return (new_img, new_img, new_img, rect)
Esempio n. 8
0
def command_rotate_left(new_img, screen, file, num_imgs, rect):
    "rotate counter clockwise"
    wait_cursor()
    start = start_timer()
    new_img = rotate(new_img, 90)
    rect = get_center(screen, new_img)
    my_update_screen(new_img, screen, rect, file, num_imgs, check_timer(start))
    normal_cursor()
    return (new_img, new_img, rect)
Esempio n. 9
0
def command_custom_res(screen, new_img, file, num_imgs, rect, resolution):
    "switch to customxcustom"
    wait_cursor()
    screen = set_mode(resolution, RESIZABLE)
    rect = get_center(screen, new_img)
    my_update_screen(new_img, screen, rect, file, num_imgs)
    if gl.TOGGLE_FULLSCREEN_SET:
        my_toggle_fullscreen()
    return rect
Esempio n. 10
0
def command_help(screen, new_img, file, rect, num_imgs):
    (screen, before_winsize, not_accepted) = adjust_screen(screen)

    set_caption("Help [imgv v3.1.6]")
    help(screen)

    screen = restore_screen(screen, before_winsize, not_accepted, new_img, file, num_imgs, rect)

    rect = get_center(screen, new_img)
    my_update_screen(new_img, screen, rect, file, len(gl.files))
Esempio n. 11
0
File: help.py Progetto: rkulla/imgv
def command_help(screen, new_img, file, rect):
    (screen, before_winsize, not_accepted) = adjust_screen(screen)

    set_caption("Help [imgv v%s]" % gl.IMGV_VERSION)
    help(screen)

    screen = restore_screen(screen, before_winsize, not_accepted, new_img, file, rect)

    rect = get_center(screen, new_img)
    my_update_screen(new_img, rect, file)
Esempio n. 12
0
File: four.py Progetto: rkulla/imgv
def command_four(screen, file, new_img):
    gl.MULTI_VIEWING = 1
    paint_screen(gl.IMGV_COLOR)
    set_caption("Four at a time - imgv")
    (file, new_img) = four(screen, file, new_img)
    rect = get_center(screen, new_img)
    my_update_screen(new_img, rect, file)
    pygame.event.set_blocked(MOUSEMOTION) # without this the hovers don't work right
    gl.MULTI_VIEWING = 0
    return (file, new_img, new_img, new_img, rect)
Esempio n. 13
0
File: imgv.py Progetto: rkulla/imgv
    def start(self):
        # start with menu open
        self.gfx = command_main_menu(self.gfx)

        # main loop
        while 1:
            self.event = pygame.event.poll()
            pygame.time.wait(1)  # so pygame doesn't use 100% CPU
            cursor = pygame.mouse.get_pos()
            self.last_rect = Rect(self.gfx['rect'])

            # drag image code:
            if gl.HAND_TOOL:
                if left_click(self.event):  # calculate drag coordinates:
                    if gl.IMG_BORDER:
                        self.border_fix()  # erase the current border
                    grab_hand_cursor()
                    self.minus1 = cursor[0] - self.gfx['rect'][0]
                    self.minus2 = cursor[1] - self.gfx['rect'][1]
                    gl.DO_DRAG = 1
                if self.event.type == MOUSEMOTION and gl.DO_DRAG:  # move the image when dragged:
                    grab_hand_cursor()
                    self.gfx['rect'][0] = cursor[0] - self.minus1
                    self.gfx['rect'][1] = cursor[1] - self.minus2
                    self.gfx['screen'].fill(gl.IMGV_COLOR, self.last_rect)
                    self.gfx['screen'].blit(self.gfx['new_img'], self.gfx['rect'])
                    update(self.gfx['rect'].union(self.last_rect))
                if self.event.type == MOUSEBUTTONUP:  # released mouse button, redisplay status bars:
                    drag_hand_cursor()
                    my_update_screen(self.gfx['new_img'], self.gfx['rect'], self.gfx['file'])
                    gl.DO_DRAG = 0

            if self.event.type == VIDEORESIZE:
                self.gfx['screen'] = pygame.display.set_mode(self.event.dict['size'], RESIZABLE)
                self.gfx['rect'] = get_center(self.gfx['screen'], self.gfx['new_img'])
                my_update_screen(self.gfx['new_img'], self.gfx['rect'], self.gfx['file'])
            if self.event.type == KEYDOWN:
                gl.HAND_TOOL = 0
                if self.event.key not in (K_DOWN, K_UP, K_RIGHT, K_LEFT):
                    normal_cursor()  # stop displaying hand tool
                (self.gfx, self.last_rect) = handle_keyboard(self.event, self.gfx, self.last_rect)
            if self.event.type == KEYUP:
                self.stop_auto_repeat()
            check_quit(self.event)

            if self.event.type == MOUSEBUTTONDOWN and right_click(self.event):
                self.open_main_menu()

            # Re-open the purposely closed window that frees up RAM
            if (gl.KEEP_MENU_OPEN == "1" and gl.COUNT_CLICKS == 1) or gl.JUST_RESIZED:
                gl.COUNT_CLICKS = 0
                gl.JUST_RESIZED = 0
                self.gfx = command_main_menu(self.gfx)

            self.start_auto_repeat()
Esempio n. 14
0
File: res.py Progetto: rkulla/imgv
def command_800x600(new_img, file, rect):
    "switch to 800x600"
    gl.MAX_SCREEN_FILES = gl.MAX_SF["800x600"]
    wait_cursor()
    resolution = 800, 600
    screen = set_mode(resolution, RESIZABLE)
    rect = get_center(screen, new_img)
    my_update_screen(new_img, rect, file)
    if gl.TOGGLE_FULLSCREEN_SET:
        my_toggle_fullscreen()
    return rect
Esempio n. 15
0
File: res.py Progetto: rkulla/imgv
def command_1280x1024(new_img, file, rect):
    "switch to 1280x1024"
    gl.MAX_SCREEN_FILES = gl.MAX_SF["1280x1024"]
    wait_cursor()
    resolution = 1280, 1024
    screen = set_mode(resolution, RESIZABLE)
    rect = get_center(screen, new_img)
    my_update_screen(new_img, rect, file)
    if gl.TOGGLE_FULLSCREEN_SET:
        my_toggle_fullscreen()
    return rect
Esempio n. 16
0
def command_first_img(new_img, screen, file, num_imgs, rect):
    "jump to the first image"
    wait_cursor()
    start = start_timer()
    file = 0
    new_img = load_img(gl.files[file], screen)
    rect = get_center(screen, new_img)
    ns = check_timer(start)
    my_update_screen(new_img, screen, rect, file, num_imgs, ns)
    normal_cursor()
    return (new_img, new_img, new_img, file, rect)
Esempio n. 17
0
def command_unshuffle(new_img, img, screen, rect, file):
    "un-randomize the images"
    was_on = gl.files[file]
    wait_cursor()
    gl.files.sort(lambda x, y: cmp(x.lower(), y.lower()))
    file = gl.files.index(was_on)
    new_img = load_img(gl.files[file])
    rect = get_center(screen, new_img)
    my_update_screen(new_img, rect, file)
    normal_cursor()
    return (new_img, new_img, new_img, rect, file)
Esempio n. 18
0
def command_shuffle(new_img, img, screen, rect, file, num_imgs):
    "randomize the images"
    wait_cursor()
    start = start_timer()
    shuffle(gl.files)
    new_img = load_img(gl.files[file], screen)
    rect = get_center(screen, new_img)
    ns = check_timer(start)
    my_update_screen(new_img, screen, rect, file, num_imgs, ns)
    normal_cursor()
    return (new_img, new_img, new_img, rect)
Esempio n. 19
0
def command_1024x768(new_img, file, num_imgs, rect):
    "switch to 1024x768"
    gl.MAX_SCREEN_FILES = gl.MAX_SF["1024x768"]
    wait_cursor()
    resolution = 1024, 768
    screen = set_mode(resolution, RESIZABLE)
    rect = get_center(screen, new_img)
    my_update_screen(new_img, screen, rect, file, num_imgs)
    if gl.TOGGLE_FULLSCREEN_SET:
        my_toggle_fullscreen()
    return rect
Esempio n. 20
0
def command_verbose_info(screen, new_img, rect, file):
    gl.ORIG_WINSIZE = "%sx%s" % (screen.get_width(), screen.get_height())
    (screen, before_winsize, not_accepted) = adjust_screen(screen)
    paint_screen(gl.BLACK)
    if gl.REMOTE:
        remote_img_details(screen, new_img, rect, file)
    else:
        verbose_info(screen, new_img, file)
    screen = restore_screen(screen, before_winsize, not_accepted, new_img, file, rect)
    rect = get_center(screen, new_img)
    my_update_screen(new_img, rect, file)
Esempio n. 21
0
def command_img_names(screen, new_img, img, file, rect):
    num_imgs = len(gl.files)
    (screen, before_winsize, not_accepted) = adjust_screen(screen)
    paint_screen(gl.BLACK)
    normal_cursor()
    gl.SORT_HIT = 0
    (list_names, filename, x, my_string) = command_file_master(screen, gl.files,\
    "(%d Images)" % len(gl.files), 15, 0, 1, 0)
    wait_cursor()
    screen = restore_screen(screen, before_winsize, not_accepted, new_img, file, rect)
    if not filename == None:
        if num_imgs > 1:
            file = gl.files.index(filename)
        new_img = load_img(gl.files[file])
        rect = get_center(screen, new_img)
        my_update_screen(new_img, rect, file)
    normal_cursor()
    rect = get_center(screen, new_img)
    my_update_screen(new_img, rect, file)
    return (new_img, new_img, new_img, file, rect)
Esempio n. 22
0
def command_prev_img(new_img, screen, file, num_imgs, rect):
    "jump to previous image"
    wait_cursor()
    start = start_timer()
    if file > 0:
        file = file - 1
        new_img = previous_img(file, new_img, screen)
        rect = get_center(screen, new_img)
        ns = check_timer(start)
        my_update_screen(new_img, screen, rect, file, num_imgs, ns)
    normal_cursor()
    return (new_img, new_img, new_img, file, rect)
Esempio n. 23
0
def command_next_img(new_img, screen, file, num_imgs, rect):
    "jump to next image"
    wait_cursor()
    start = start_timer()
    if not gl.WRAP:
        if file < (num_imgs - 1):
            file = file + 1
            new_img = next_img(file, new_img, screen)
            rect = get_center(screen, new_img)
            ns = check_timer(start)
            my_update_screen(new_img, screen, rect, file, num_imgs, ns)
    else:
        file = file + 1
        if file > (num_imgs - 1):
            file = 0
        if num_imgs > 1:
            new_img = next_img(file, new_img, screen)
            rect = get_center(screen, new_img)
            ns = check_timer(start)
            my_update_screen(new_img, screen, rect, file, num_imgs, ns)    
    normal_cursor()
    return (new_img, new_img, new_img, file, rect)
Esempio n. 24
0
def command_zoom_out(new_img, new_img_width, new_img_height, img, screen, file, num_imgs, rect, zoom_type):
    wait_cursor()
    start = start_timer()
    if new_img.get_width() >= gl.MIN_WIDTH and new_img.get_height() >= gl.MIN_HEIGHT:
        gl.ZOOM_EXP -= 1
        if zoom_type == "normal":
            gl.ZOOM_DOUBLE = 0
            new_img = scale(img, (new_img.get_width() / 1.1, new_img.get_height() / 1.1))
        else:
            gl.ZOOM_DOUBLE = 1
            new_img = scale(img, (new_img.get_width() / 2, new_img.get_height() / 2))
        rect = get_center(screen, new_img)
        my_update_screen(new_img, screen, rect, file, num_imgs, check_timer(start))
    normal_cursor()
    return (new_img, img, rect)
Esempio n. 25
0
def command_four(screen, file, new_img, ns):
    gl.MULTI_VIEWING = 1
    orig_ns = ns
    paint_screen(screen, gl.IMGV_COLOR)
    set_caption("Four at a time - imgv")
    (file, new_img, start) = four(screen, file, new_img, ns)
    rect = get_center(screen, new_img)
    num_imgs = len(gl.files)
    if start != orig_ns:
        ns = check_timer(start)
        my_update_screen(new_img, screen, rect, file, num_imgs, ns)
    else:
        my_update_screen(new_img, screen, rect, file, num_imgs)
    pygame.event.set_blocked(MOUSEMOTION) # without this the hovers don't work right
    gl.MULTI_VIEWING = 0
    return (file, new_img, new_img, new_img, rect)
Esempio n. 26
0
def command_zoom_in(new_img, new_img_width, new_img_height, img, screen, files, file, num_imgs, rect, zoom_type):
    wait_cursor()
    start = start_timer()
    gl.ZOOM_EXP += 1
    if zoom_type == "normal":
        gl.ZOOM_DOULBE = 0
        new_img = scale(img, (new_img.get_width() * 1.1, new_img.get_height() * 1.1))
    if zoom_type == "double":
        gl.ZOOM_DOUBLE = 1
        new_img = scale(img, (new_img.get_width() * 2, new_img.get_height() * 2))
    if zoom_type == "scale2x":
        gl.ZOOM_DOUBLE = 1
        new_img = scale2x(img) # don't alias simple solid color images (ie., black & white GIFs)
    rect = get_center(screen, new_img)
    my_update_screen(new_img, screen, rect, file, num_imgs, check_timer(start))
    normal_cursor()
    return (new_img, img, rect)
Esempio n. 27
0
def command_play_list_options(screen, file):
    paint_screen(gl.BLACK)
    old_file = file
    (file, msg) = play_list_options(screen, file)
    if (msg != None and file != "rclicked" and file != "deleteit"):
        play_list_options_msg(screen, msg)
    if (file == "rclicked"):
        edit_play_list(screen, msg)
        file = old_file
    if (file == "deleteit"):
        delete_play_list(msg)
        file = old_file
    new_img = load_img(gl.files[file])
    rect = get_center(screen, new_img)
    my_update_screen(new_img, rect, file)
    normal_cursor()
    return (new_img, new_img, new_img, file, rect)
Esempio n. 28
0
File: zoom.py Progetto: rkulla/imgv
def command_zoom_out(new_img, img, file, rect, zoom_type):
    wait_cursor()
    screen = get_surface()
    new_img_width = new_img.get_width()
    new_img_height = new_img.get_height()
    if new_img_width >= gl.MIN_WIDTH and new_img_height >= gl.MIN_HEIGHT:
        gl.ZOOM_EXP -= 1
        if zoom_type == "normal":
            gl.ZOOM_DOUBLE = 0
            new_img = scale(img, (int(new_img_width / 1.1), int(new_img_height / 1.1)))
        else:
            gl.ZOOM_DOUBLE = 1
            new_img = scale(img, (new_img_width / 2, new_img_height / 2))
        rect = get_center(screen, new_img)
        my_update_screen(new_img, rect, file)
    normal_cursor()
    return (new_img, img, rect)
Esempio n. 29
0
def command_remove_img(new_img, screen, file, rect):
    "Don't display the image anymore during the session"
    wait_cursor()
    num_imgs = len(gl.files)
    # only remove file if its not the only one:
    if not num_imgs < 2:
        gl.files.remove(gl.files[file])
        # go to the next image if there is one
        if file < (num_imgs - 1):
            new_img = next_img(file, new_img, screen)
        # if not go to the previous image
        else:
            if file > 0:
                file = file - 1
                new_img = previous_img(file, new_img, screen)
        rect = get_center(screen, new_img)
        my_update_screen(new_img, rect, file)
    normal_cursor()
    return (new_img, new_img, new_img, file, rect)
Esempio n. 30
0
File: zoom.py Progetto: rkulla/imgv
def command_zoom_in(new_img, img, file, rect, zoom_type):
    wait_cursor()
    screen = get_surface()
    new_img_width = new_img.get_width()
    new_img_height = new_img.get_height()
    gl.ZOOM_EXP += 1
    if zoom_type == "normal":
        gl.ZOOM_DOULBE = 0
        new_img = scale(img, (int(new_img_width * 1.1), int(new_img_height * 1.1)))
    if zoom_type == "double":
        gl.ZOOM_DOUBLE = 1
        new_img = scale(img, (new_img_width * 2, new_img_height * 2))
    if zoom_type == "scale2x":
        gl.ZOOM_DOUBLE = 1
        new_img = scale2x(img)  # don't alias simple solid color images (ie., black & white GIFs)
    rect = get_center(screen, new_img)
    my_update_screen(new_img, rect, file)
    normal_cursor()
    return (new_img, img, rect)