Esempio n. 1
0
void gui_osd_draw_clock(int x, int y, twoColors cl, int is_osd_edit)
{
    if (conf.show_clock || is_osd_edit)
    {
        static char *ampm[2][3] = { { " AM", "A", " "}, { " PM", "P", "." } };

        struct tm *ttm = get_localtime();

        int w = 0;          // Extra width from AM/PM indicator and seconds (if displayed)

        if ((FG_COLOR(cl) == 0) && (BG_COLOR(cl) == 0)) cl = user_color(conf.osd_color);

        if ((camera_info.state.is_shutter_half_press == 0) || (conf.clock_halfpress == 0) || is_osd_edit)
        {
            unsigned int hour = (ttm->tm_hour);
            char *ampm_ind = "";    // AM / PM indicator

            if (conf.clock_format == CLOCK_FORMAT_12)
            {
                ampm_ind = ampm[hour/12][conf.clock_indicator]; //(hour >= 12) ? pm : am; 
                w = strlen(ampm_ind);
                if (hour == 0)
                    hour = 12;
                else if (hour > 12)
                    hour = hour - 12;
            }

            if ((conf.show_clock != CLOCK_WITHOUT_SEC) || is_osd_edit)
            {
                sprintf(osd_buf, "%2u:%02u:%02u%s", hour, ttm->tm_min, ttm->tm_sec, ampm_ind);
                w += 3;
            }
            else
            {
                sprintf(osd_buf, "%2u:%02u%s", hour, ttm->tm_min, ampm_ind);
            }

            if (x)  // for gui_4wins.c
                draw_string(x, y, osd_buf, cl);
            else
                draw_osd_string(conf.clock_pos, 0, 0, osd_buf, cl, conf.clock_scale);
        }
        else if (camera_info.state.is_shutter_half_press && (conf.clock_halfpress == 1))
        {
            sprintf(osd_buf, "%02u", ttm->tm_sec);
            if (conf.clock_pos.x >= 4*FONT_WIDTH) w = 3;
            draw_osd_string(conf.clock_pos, w*FONT_WIDTH, 0, osd_buf, cl, conf.clock_scale);
        }
    }
}
Esempio n. 2
0
static void gui_osd_draw_single_histo(int hist, coord x, coord y, int small)
{
    twoColors hc = user_color(conf.histo_color);
    twoColors hc2 = user_color(conf.histo_color2);

    register unsigned int i, v, threshold;
    register color cl, cl_over, cl_bg = BG_COLOR(hc);
    coord w=HISTO_WIDTH, h=HISTO_HEIGHT;

    switch (hist) 
    {
        case HISTO_R: 
            cl=COLOR_RED;
            break;
        case HISTO_G: 
            cl=COLOR_GREEN;
            break;
        case HISTO_B:
            cl=COLOR_BLUE;
            break;
        case HISTO_RGB:
        case HISTO_Y:
        default:
            cl=FG_COLOR(hc);
            break;
    }

    if (small) {
        h>>=1; w>>=1;
        for (i=0; i<w; ++i) {
            threshold = (histogram[hist][i<<1]+histogram[hist][(i<<1)+1])>>2;

            for (v=1; v<h-1; ++v)
                draw_pixel(x+1+i, y+h-v, (v<=threshold)?cl:cl_bg);
            cl_over = (threshold==h && conf.show_overexp)?BG_COLOR(hc2):cl;
            for (; v<h; ++v)
                draw_pixel(x+1+i, y+h-v, (v<=threshold)?cl_over:cl_bg);
        }
    } else {
        for (i=0; i<w; ++i) {
Esempio n. 3
0
int point_is_free(int y, int x)
{
	int top;
	chtype oldch;
	int oldfg;
	int oldbg;

	top = y % 2;

	/* Convert to screen coordinates. */
	y = (y - 1) / 2;
	x--;

	/* Get character at position. */
	oldch = mvinch(y, x);
	oldfg = FG_COLOR(oldch);
	oldbg = BG_COLOR(oldch);

	if (top) {
		switch (oldch & 0xff) {
			case 0xdc:
				return (oldbg == BACKGROUND_COLOR);
			case 0xdf:
			case 0xdb:
				return (oldfg == BACKGROUND_COLOR);
			default:
				return 1;
		}
	} else {
		switch (oldch & 0xff) {
			case 0xdf:
				return (oldbg == BACKGROUND_COLOR);
			case 0xdc:
			case 0xdb:
				return (oldfg == BACKGROUND_COLOR);
			default:
				return 1;
		}
	}
}
Esempio n. 4
0
static int draw_edge_overlay()
{
    int shutter_fullpress = kbd_is_key_pressed(KEY_SHOOT_FULL);

    int x, y;
    int x_off, y_off;

    const color cl = FG_COLOR(user_color(conf.edge_overlay_color));
    const int y_slice_min = camera_screen.edge_hmargin+ slice   *slice_height;
    const int y_slice_max = camera_screen.edge_hmargin+(slice+1)*slice_height;
    const int y_min = camera_screen.edge_hmargin;
    const int y_max = camera_screen.edge_hmargin+viewport_height;
    const int x_min = 2;
    const int x_max = (viewport_width - 2);

    if( !is_buffer_ready() ) return 0;

    for (y = y_slice_min; y < y_slice_max; ++y)
    {
        y_off = y + yoffset;
        
        shutter_fullpress |= kbd_is_key_pressed(KEY_SHOOT_FULL);

        if ((unsigned)(y_off-y_min) < (y_max-y_min)) // is the same as ((y_off > y_min) && (y_off < y_max)) // do not draw outside of allowed area
        {
            const int y_edgebuf = (y-y_min) * viewport_width;

            for (x = x_min; x < x_max; ++x)
            {
                x_off = x + xoffset;

                if ((unsigned)(x_off-x_min) < (x_max-x_min)) // is the same as  ((x_off > x_min) && (x_off < x_max)) // do not draw outside of allowed area
                {
                    // Draw a pixel to the screen wherever we detected an edge.
                    // If there is no edge based on the newest data, but there is one painted on the screen
                    // from previous calls, delete it from the screen.
                    const int bEdge = bv_get(edgebuf, y_edgebuf + x);
                    const int bDraw = bEdge || (draw_get_pixel_unrotated(x_off+viewport_xoffset, y_off+viewport_yoffset) == cl);
                    if (bEdge || bDraw)
                        draw_pixel_unrotated(x_off+viewport_xoffset, y_off+viewport_yoffset, bEdge ? cl : 0);
                    
                }
            }   // for x
        }
    }   // for y


    // Drawing the overlay is over.
    // But as a finishing touch we clear up garbage on the screen
    // by clearing those parts that the overlay has left.

    if (xoffset != 0)
    {
        // Cleans up leftover from horizontal motion

        const int x_min_c = (xoffset < 0) ? x_max + xoffset : x_min;
        const int x_max_c = (xoffset > 0) ? x_min + xoffset : x_max;

        for (y = y_min; y < y_max; ++y)
        {
            for (x = x_min_c; x < x_max_c; ++x)
            {
                // if there is an edge drawn on the screen but there is no edge there based on the newest data, delete it from the screen
                if (draw_get_pixel_unrotated(x+viewport_xoffset, y+viewport_yoffset) == cl)
                    draw_pixel_unrotated(x+viewport_xoffset, y+viewport_yoffset, 0 );
            }
        }
    }

    if (yoffset != 0)
    {
        // Cleans up leftover from vertical motion

        const int y_min_c = (yoffset < 0) ? y_max + yoffset : y_min;
        const int y_max_c = (yoffset > 0) ? y_min + yoffset : y_max;

        for (y = y_min_c; y < y_max_c; ++y)
        {
            for (x = x_min; x < x_max; ++x)
            {
                // if there is an edge drawn on the screen but there is no edge there based on the newest data, delete it from the screen
                if (draw_get_pixel_unrotated(x+viewport_xoffset, y+viewport_yoffset) == cl)
                    draw_pixel_unrotated(x+viewport_xoffset, y+viewport_yoffset, 0 );
            }
        }
    }

    return shutter_fullpress;
}
Esempio n. 5
0
void set_point(int y, int x, unsigned char color)
{
	int top;
	chtype oldch;
	int oldfg;
	int oldbg;
	char c;
	int fg;
	int bg;

	top = y % 2;

	/* Convert to screen coordinates. */
	y = (y - 1) / 2;
	x--;

	/* Get character at position. */
	oldch = mvinch(y, x);
	oldfg = FG_COLOR(oldch);
	oldbg = BG_COLOR(oldch);

	if (top) {
		/* Get bottom color. */
		int bottom_color;
		switch (oldch & 0xff) {
			case 0xdf:
				bottom_color = oldbg;
				break;
			case 0xdc:
			case 0xdb:
				bottom_color = oldfg;
				break;
			default:
				bottom_color = BACKGROUND_COLOR;
		}

		if (color == bottom_color) {
			c = (char) 0xdb; /* Top and bottom. */
			fg = color;
			bg = color;
		} else {
			c = (char) 0xdf; /* Top. */
			fg = color;
			bg = bottom_color;
		}
	} else {
		/* Get top color. */
		int top_color;
		switch (oldch & 0xff) {
			case 0xdc:
				top_color = oldbg;
				break;
			case 0xdf:
			case 0xdb:
				top_color = oldfg;
				break;
			default:
				top_color = BACKGROUND_COLOR;
		}

		if (color == top_color) {
			c = (char) 0xdb; /* Top and bottom. */
			fg = color;
			bg = color;
		} else {
			c = (char) 0xdc; /* Bottom. */
			fg = color;
			bg = top_color;
		}
	}

	mvaddch(y, x, MAKE_CHARACTER(c, fg, bg));
}
Esempio n. 6
0
//-------------------------------------------------------------------
// Process button presses when in GUI_MODE_MENU mode
int gui_menu_kbd_process() {

    switch (kbd_get_autoclicked_key() | get_jogdial_direction())
    {
        case KEY_ERASE:
        case KEY_SHOOT_HALF:
            if (!increment_factor())
                int_incr = 1;
            gui_menu_redraw=1;
            break;
        case JOGDIAL_LEFT:
        case KEY_UP:
            gui_menu_updown(-1);
            break;
        case JOGDIAL_RIGHT:
        case KEY_DOWN: 
            gui_menu_updown(1);
            break;
        case FRONTDIAL_LEFT:
        case KEY_LEFT:
            if (gui_menu_curr_item >= 0) {
                switch (curr_menu->menu[gui_menu_curr_item].type & MENUITEM_MASK) {
                    case MENUITEM_INT:
                        update_int_value(&curr_menu->menu[gui_menu_curr_item],-1);
                        break;
                    case MENUITEM_BOOL:
                        update_bool_value(&curr_menu->menu[gui_menu_curr_item]);
                        break;
                    case MENUITEM_ENUM:
                    case MENUITEM_ENUM2:
                        update_enum_value(&curr_menu->menu[gui_menu_curr_item],-1);
                        break;
                    case MENUITEM_UP:
                        gui_menu_back();
                        break;
                    case MENUITEM_STATE_VAL_PAIR:
                        {
                            CMenuItem *c = (CMenuItem*)(curr_menu->menu[gui_menu_curr_item].value);
                            if (*(c[1].value) == 0)
                                update_bool_value(&c[1]);
                            switch (c[0].type & MENUITEM_MASK)
                            {
                                case MENUITEM_INT:
                                    update_int_value(&c[0],-1);
                                    break;
                                case MENUITEM_ENUM:
                                case MENUITEM_ENUM2:
                                    update_enum_value(&c[0],-1);
                                    break;
                            }
                        }
                        break;
                }
            } else {
                gui_menu_back();
            }
            break;
        case FRONTDIAL_RIGHT:
        case KEY_RIGHT:
            if (gui_menu_curr_item >= 0) {
                switch (curr_menu->menu[gui_menu_curr_item].type & MENUITEM_MASK){
                    case MENUITEM_INT:
                        update_int_value(&curr_menu->menu[gui_menu_curr_item],1);
                        break;
                    case MENUITEM_BOOL:
                        update_bool_value(&curr_menu->menu[gui_menu_curr_item]);
                        break;
                    case MENUITEM_ENUM:
                    case MENUITEM_ENUM2:
                        update_enum_value(&curr_menu->menu[gui_menu_curr_item],1);
                        break;
                    case MENUITEM_SUBMENU_PROC:
                        select_proc();
                        break;
                    case MENUITEM_SUBMENU:
                        select_sub_menu();
                        break;
                    case MENUITEM_STATE_VAL_PAIR:
                        {
                            CMenuItem *c = (CMenuItem*)(curr_menu->menu[gui_menu_curr_item].value);
                            if (*(c[1].value) == 0)
                                update_bool_value(&c[1]);
                            switch (c[0].type & MENUITEM_MASK)
                            {
                                case MENUITEM_INT:
                                    update_int_value(&c[0],1);
                                    break;
                                case MENUITEM_ENUM:
                                case MENUITEM_ENUM2:
                                    update_enum_value(&c[0],1);
                                    break;
                            }
                        }
                        break;
                }
            }
            break;
        case KEY_SET:
            if (gui_menu_curr_item >= 0) {
                switch (curr_menu->menu[gui_menu_curr_item].type & MENUITEM_MASK){
                    case MENUITEM_INT:
                        if (camera_info.state.is_shutter_half_press)
                        {
                            *(curr_menu->menu[gui_menu_curr_item].value) = 0;
                            gui_menu_redraw=1;
                        }
                        break;
                    case MENUITEM_BOOL:
                        update_bool_value(&curr_menu->menu[gui_menu_curr_item]);
                        break;
                    case MENUITEM_SUBMENU_PROC:
                    case MENUITEM_PROC:
                        select_proc();
                        break;
                    case MENUITEM_SUBMENU:
                        select_sub_menu();
                        break;
                    case MENUITEM_UP:
                        gui_menu_back();
                        break;
                    case MENUITEM_COLOR_FG:
                    case MENUITEM_COLOR_BG:
                        item_color=((unsigned char*)(curr_menu->menu[gui_menu_curr_item].value)) + (((curr_menu->menu[gui_menu_curr_item].type & MENUITEM_MASK)==MENUITEM_COLOR_BG)?1:0);
                        libpalette->show_palette(PALETTE_MODE_SELECT, FG_COLOR(*item_color), gui_menu_color_selected);
                        gui_menu_redraw=2;
                        break;
                    case MENUITEM_ENUM:
                    case MENUITEM_ENUM2:
                        update_enum_value(&curr_menu->menu[gui_menu_curr_item],1);
                        gui_menu_redraw=1;
                        break;
                    case MENUITEM_STATE_VAL_PAIR:
                        {
                            CMenuItem *c = (CMenuItem*)(curr_menu->menu[gui_menu_curr_item].value);
                            if ((c[1].type & MENUITEM_MASK) == MENUITEM_ENUM)
                                update_enum_value(&c[1],1);
                            else
                                update_bool_value(&c[1]);
                        }
                        break;
                }
            }
            break;

        case KEY_ZOOM_IN:
            if (decrement_factor())
                gui_menu_redraw = 1;
            break;

        case KEY_ZOOM_OUT:
            if (increment_factor())
                gui_menu_redraw = 1;
            break;

        case KEY_DISPLAY:
            if (camera_info.cam_has_zoom_lever)
            {
                gui_menu_back();
            }
            else
            {
                // For cams without zoom lever, DISP adjusts increment factor
                if (!increment_factor())
                    int_incr = 1;
                gui_menu_redraw=1;
            }
            break;
    }

    return 0;
}
Esempio n. 7
0
//-------------------------------------------------------------------
// Function passed to gui_palette_init
// This is called when a new color is selected to update the menu / config value
static void gui_menu_color_selected(color clr)
{
    *item_color = FG_COLOR(clr);
    gui_menu_erase_and_redraw();
}