Ejemplo n.º 1
0
void draw_thread_popup(struct nk_context *ctx, int *show_thread_popup)
{
	static struct nk_rect s = { 100, 100, 300, 175 };
	static const float ratio[] = { 0.85f, 0.15f };
	if (nk_popup_begin(ctx, NK_POPUP_STATIC, "File Read Error",
			NK_WINDOW_TITLE | NK_WINDOW_NO_SCROLLBAR | NK_WINDOW_BORDER, s))
	{
		nk_layout_row_dynamic(ctx, 25, 1);
		nk_label(ctx, "Cannot read file.", NK_TEXT_CENTERED);
		nk_layout_row_dynamic(ctx, 60, 1);
		nk_label_wrap(ctx, "Make sure the directory isn't write protected OR you are running the program with write permissions.");


		nk_layout_row(ctx, NK_DYNAMIC, 25, 2, ratio);
		nk_spacing(ctx, 1);
		if(nk_button_label(ctx, "OK"))
		{
			*show_thread_popup = nk_false;
			nk_popup_close(ctx);
		}
		nk_popup_end(ctx);
	}

	else
		*show_thread_popup = nk_false;
}
Ejemplo n.º 2
0
void draw_color_popup(struct nk_context *ctx, struct output_tab *output)
{
	static struct nk_rect s = { 250,250,200,230 };
	if (nk_popup_begin(ctx, NK_POPUP_STATIC, "Color Picker", NK_WINDOW_TITLE |NK_WINDOW_NO_SCROLLBAR|NK_WINDOW_BORDER, s))
	{
		nk_layout_row_dynamic(ctx, 160, 1);
		output->color_rgb = nk_color_picker(ctx, output->color_rgb, NK_RGBA);
		
		nk_layout_row_dynamic(ctx, 25, 3);
		nk_spacing(ctx, 1);
		if (nk_button_label(ctx, "OK")) {
			show_color_from_picker = nk_true;
			output->color_popup = nk_false;
			nk_popup_close(ctx);
		}
		nk_spacing(ctx, 1);

		nk_popup_end(ctx);
	}
	else
		output->color_popup = nk_false;
}
/* ===============================================================
 *
 *                          CUSTOM WIDGET
 *
 * ===============================================================*/
static int
ui_piemenu(struct nk_context *ctx, struct nk_vec2 pos, float radius,
            struct nk_image *icons, int item_count)
{
    int ret = -1;
    struct nk_rect total_space;
    struct nk_rect bounds;
    int active_item = 0;

    /* pie menu popup */
    struct nk_color border = ctx->style.window.border_color;
    struct nk_style_item background = ctx->style.window.fixed_background;
    ctx->style.window.fixed_background = nk_style_item_hide();
    ctx->style.window.border_color = nk_rgba(0,0,0,0);

    total_space  = nk_window_get_content_region(ctx);
    ctx->style.window.spacing = nk_vec2(0,0);
    ctx->style.window.padding = nk_vec2(0,0);

    if (nk_popup_begin(ctx, NK_POPUP_STATIC, "piemenu", NK_WINDOW_NO_SCROLLBAR,
        nk_rect(pos.x - total_space.x - radius, pos.y - radius - total_space.y,
        2*radius,2*radius)))
    {
        int i = 0;
        struct nk_command_buffer* out = nk_window_get_canvas(ctx);
        const struct nk_input *in = &ctx->input;

        total_space = nk_window_get_content_region(ctx);
        ctx->style.window.spacing = nk_vec2(4,4);
        ctx->style.window.padding = nk_vec2(8,8);
        nk_layout_row_dynamic(ctx, total_space.h, 1);
        nk_widget(&bounds, ctx);

        /* outer circle */
        nk_fill_circle(out, bounds, nk_rgb(50,50,50));
        {
            /* circle buttons */
            float step = (2 * 3.141592654f) / (float)(MAX(1,item_count));
            float a_min = 0; float a_max = step;

            struct nk_vec2 center = nk_vec2(bounds.x + bounds.w / 2.0f, bounds.y + bounds.h / 2.0f);
            struct nk_vec2 drag = nk_vec2(in->mouse.pos.x - center.x, in->mouse.pos.y - center.y);
            float angle = (float)atan2(drag.y, drag.x);
            if (angle < -0.0f) angle += 2.0f * 3.141592654f;
            active_item = (int)(angle/step);

            for (i = 0; i < item_count; ++i) {
                struct nk_rect content;
                float rx, ry, dx, dy, a;
                nk_fill_arc(out, center.x, center.y, (bounds.w/2.0f),
                    a_min, a_max, (active_item == i) ? nk_rgb(45,100,255): nk_rgb(60,60,60));

                /* separator line */
                rx = bounds.w/2.0f; ry = 0;
                dx = rx * (float)cos(a_min) - ry * (float)sin(a_min);
                dy = rx * (float)sin(a_min) + ry * (float)cos(a_min);
                nk_stroke_line(out, center.x, center.y,
                    center.x + dx, center.y + dy, 1.0f, nk_rgb(50,50,50));

                /* button content */
                a = a_min + (a_max - a_min)/2.0f;
                rx = bounds.w/2.5f; ry = 0;
                content.w = 30; content.h = 30;
                content.x = center.x + ((rx * (float)cos(a) - ry * (float)sin(a)) - content.w/2.0f);
                content.y = center.y + (rx * (float)sin(a) + ry * (float)cos(a) - content.h/2.0f);
                nk_draw_image(out, content, &icons[i], nk_rgb(255,255,255));
                a_min = a_max; a_max += step;
            }
        }
        {
            /* inner circle */
            struct nk_rect inner;
            inner.x = bounds.x + bounds.w/2 - bounds.w/4;
            inner.y = bounds.y + bounds.h/2 - bounds.h/4;
            inner.w = bounds.w/2; inner.h = bounds.h/2;
            nk_fill_circle(out, inner, nk_rgb(45,45,45));

            /* active icon content */
            bounds.w = inner.w / 2.0f;
            bounds.h = inner.h / 2.0f;
            bounds.x = inner.x + inner.w/2 - bounds.w/2;
            bounds.y = inner.y + inner.h/2 - bounds.h/2;
            nk_draw_image(out, bounds, &icons[active_item], nk_rgb(255,255,255));
        }
        nk_layout_space_end(ctx);
        if (!nk_input_is_mouse_down(&ctx->input, NK_BUTTON_RIGHT)) {
            nk_popup_close(ctx);
            ret = active_item;
        }
    } else ret = -2;
    ctx->style.window.spacing = nk_vec2(4,4);
    ctx->style.window.padding = nk_vec2(8,8);
    nk_popup_end(ctx);

    ctx->style.window.fixed_background = background;
    ctx->style.window.border_color = border;
    return ret;
}
/* ===============================================================
 *
 *                          BASIC DEMO
 *
 * ===============================================================*/
static void
basic_demo(struct nk_context *ctx, struct media *media)
{
    static int image_active;
    static int check0 = 1;
    static int check1 = 0;
    static size_t prog = 80;
    static int selected_item = 0;
    static int selected_image = 3;
    static int selected_icon = 0;
    static const char *items[] = {"Item 0","item 1","item 2"};
    static int piemenu_active = 0;
    static struct nk_vec2 piemenu_pos;

    int i = 0;
    nk_style_set_font(ctx, &media->font_20->handle);
    nk_begin(ctx, "Basic Demo", nk_rect(320, 50, 275, 610),
        NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_TITLE);

    /*------------------------------------------------
     *                  POPUP BUTTON
     *------------------------------------------------*/
    ui_header(ctx, media, "Popup & Scrollbar & Images");
    ui_widget(ctx, media, 35);
    if (nk_button_image_label(ctx, media->dir, "Images", NK_TEXT_CENTERED))
        image_active = !image_active;

    /*------------------------------------------------
     *                  SELECTED IMAGE
     *------------------------------------------------*/
    ui_header(ctx, media, "Selected Image");
    ui_widget_centered(ctx, media, 100);
    nk_image(ctx, media->images[selected_image]);

    /*------------------------------------------------
     *                  IMAGE POPUP
     *------------------------------------------------*/
    if (image_active) {
        struct nk_panel popup;
        if (nk_popup_begin(ctx, NK_POPUP_STATIC, "Image Popup", 0, nk_rect(265, 0, 320, 220))) {
            nk_layout_row_static(ctx, 82, 82, 3);
            for (i = 0; i < 9; ++i) {
                if (nk_button_image(ctx, media->images[i])) {
                    selected_image = i;
                    image_active = 0;
                    nk_popup_close(ctx);
                }
            }
            nk_popup_end(ctx);
        }
    }
    /*------------------------------------------------
     *                  COMBOBOX
     *------------------------------------------------*/
    ui_header(ctx, media, "Combo box");
    ui_widget(ctx, media, 40);
    if (nk_combo_begin_label(ctx, items[selected_item], nk_vec2(nk_widget_width(ctx), 200))) {
        nk_layout_row_dynamic(ctx, 35, 1);
        for (i = 0; i < 3; ++i)
            if (nk_combo_item_label(ctx, items[i], NK_TEXT_LEFT))
                selected_item = i;
        nk_combo_end(ctx);
    }

    ui_widget(ctx, media, 40);
    if (nk_combo_begin_image_label(ctx, items[selected_icon], media->images[selected_icon], nk_vec2(nk_widget_width(ctx), 200))) {
        nk_layout_row_dynamic(ctx, 35, 1);
        for (i = 0; i < 3; ++i)
            if (nk_combo_item_image_label(ctx, media->images[i], items[i], NK_TEXT_RIGHT))
                selected_icon = i;
        nk_combo_end(ctx);
    }

    /*------------------------------------------------
     *                  CHECKBOX
     *------------------------------------------------*/
    ui_header(ctx, media, "Checkbox");
    ui_widget(ctx, media, 30);
    nk_checkbox_label(ctx, "Flag 1", &check0);
    ui_widget(ctx, media, 30);
    nk_checkbox_label(ctx, "Flag 2", &check1);

    /*------------------------------------------------
     *                  PROGRESSBAR
     *------------------------------------------------*/
    ui_header(ctx, media, "Progressbar");
    ui_widget(ctx, media, 35);
    nk_progress(ctx, &prog, 100, nk_true);

    /*------------------------------------------------
     *                  PIEMENU
     *------------------------------------------------*/
    if (nk_input_is_mouse_click_down_in_rect(&ctx->input, NK_BUTTON_RIGHT,
        nk_window_get_bounds(ctx),nk_true)){
        piemenu_pos = ctx->input.mouse.pos;
        piemenu_active = 1;
    }

    if (piemenu_active) {
        int ret = ui_piemenu(ctx, piemenu_pos, 140, &media->menu[0], 6);
        if (ret == -2) piemenu_active = 0;
        if (ret != -1) {
            fprintf(stdout, "piemenu selected: %d\n", ret);
            piemenu_active = 0;
        }
    }
    nk_style_set_font(ctx, &media->font_14->handle);
    nk_end(ctx);
}
Ejemplo n.º 5
0
void draw_network_popup(struct nk_context *ctx, struct network_popup *network_settings)
{
	const float save_ok_ratio[] = { 0.8f,0.1f,0.1f };
	const float udp_tcp_ratio[] = { 0.45f,0.1f,0.45f };
	static char udp_ipv4_buffer[30];
	static int udp_ipv4_len[30];
	static char tcp_pass_buf[30];
	static int tcp_pass_len[30];
	static char tcp_desc_buf[30];
	static int tcp_desc_len[30];
	static char send_port_buf[30];
	static int send_port_len[30];
	static char send_host_buf[30];
	static int send_host_len[30];
	const char network_attr[][30] = { "-udp port:", "-udp [host:]port:","-sendto host[:port]:","-tcp port:","-tcppassword password:"******"-tcpdesc description:" };
	static struct nk_rect s = { 20,30,480,500 };
	if (nk_popup_begin(ctx, NK_POPUP_STATIC, "Network Settings", NK_WINDOW_CLOSABLE|NK_WINDOW_NO_SCROLLBAR, s))
	{
		nk_layout_row_dynamic(ctx, 220, 1);
		if(nk_group_begin(ctx, "Receive", NK_WINDOW_TITLE ))
		{
			nk_layout_row(ctx, NK_DYNAMIC, 21, 3, udp_tcp_ratio);
			nk_spacing(ctx, 1);
			nk_label(ctx, "UDP:", NK_TEXT_CENTERED);
			nk_layout_row_static(ctx, 20, 200, 2);
			nk_label(ctx, "Hostname/IPv4 Address:", NK_TEXT_LEFT);
			nk_edit_string(ctx, NK_EDIT_SIMPLE, network_settings->udp_ipv4, &network_settings->udp_ipv4_len, 50, nk_filter_default);

			nk_layout_row(ctx, NK_DYNAMIC, 21, 3, udp_tcp_ratio);
			nk_spacing(ctx, 1);
			nk_label(ctx, "TCP:", NK_TEXT_CENTERED);
			nk_layout_row_static(ctx, 20, 200, 2);
			nk_label(ctx, "Password:"******"Description:", NK_TEXT_LEFT);
			nk_edit_string(ctx, NK_EDIT_SIMPLE, network_settings->tcp_desc, &network_settings->tcp_desc_len, 25, nk_filter_default);

			nk_group_end(ctx);
		}

		nk_layout_row_dynamic(ctx, 200, 1);
		if (nk_group_begin(ctx, "Send", NK_WINDOW_TITLE ))
		{
			nk_layout_row(ctx, NK_DYNAMIC, 21, 3, udp_tcp_ratio);
			nk_spacing(ctx, 1);
			nk_label(ctx, "Send to:", NK_TEXT_CENTERED);
			nk_layout_row_static(ctx, 20, 200, 2);
			nk_label(ctx, "Port:", NK_TEXT_LEFT);
			nk_edit_string(ctx, NK_EDIT_SIMPLE, network_settings->send_port, &network_settings->send_port_len, 25, nk_filter_default);
			nk_layout_row_static(ctx, 20, 200, 2);
			nk_label(ctx, "Host:", NK_TEXT_LEFT);
			nk_edit_string(ctx, NK_EDIT_SIMPLE, network_settings->send_host, &network_settings->send_host_len, 25, nk_filter_default);

			nk_group_end(ctx);
		}

		/*nk_layout_row_static(ctx, 20, 200, 2);
		nk_label(ctx, network_attr[5], NK_TEXT_LEFT);
		nk_edit_string(ctx, NK_EDIT_SIMPLE, text_buffer[5], &text_len[5], 50, nk_filter_default);*/
	
		//OK Button
		nk_layout_row(ctx, NK_DYNAMIC, 27, 3, save_ok_ratio);
		nk_spacing(ctx, 1);
		if (nk_button_label(ctx, "Save")) {
			network_settings->save_network_settings = nk_true;
			network_settings->show_network_settings = nk_false;
			nk_popup_close(ctx);
		}
		if (nk_button_label(ctx, "OK")) {
			network_settings->save_network_settings = nk_false;
			network_settings->show_network_settings = nk_false;
			nk_popup_close(ctx);
		}

		nk_popup_end(ctx);
	}
	else
		network_settings->show_network_settings = nk_false;
}
Ejemplo n.º 6
0
void draw_about_ccx_popup(struct nk_context *ctx, int *show_about_ccx, struct nk_user_font *droid_big, struct nk_user_font *droid_head)
{
	const float ccx_ratio[] = { 0.3f,0.4f,0.3f };
	const float ok_ratio[] = { 0.9f,0.1f };
	static struct nk_rect s = { 20,30,480,500};
	if (nk_popup_begin(ctx, NK_POPUP_STATIC, "About CCExtractor", NK_WINDOW_CLOSABLE|NK_WINDOW_NO_SCROLLBAR, s))
	{
		nk_style_push_font(ctx, droid_big);
		nk_layout_row(ctx, NK_DYNAMIC, 30, 3, ccx_ratio);
		nk_spacing(ctx, 1);
		nk_label_wrap(ctx, "About CCExtractor"/*, NK_TEXT_LEFT*/);
		nk_style_pop_font(ctx);

		nk_layout_row_dynamic(ctx, 390, 1);
		if (nk_group_begin(ctx, "About CCExtractor", NK_WINDOW_BACKGROUND))
		{
			nk_style_push_font(ctx, droid_head);
			nk_layout_row_dynamic(ctx, 23, 1);
			nk_label_wrap(ctx, "What's CCExtractor?");
			nk_style_pop_font(ctx);

			nk_layout_row_dynamic(ctx, 65, 1);
			nk_label_wrap(ctx, "A tool that analyzes video files and produces independent subtitle files from the closed captions data. CCExtractor is portable, small, and very fast. It works in Linux, Windows, and OSX.");

			nk_style_push_font(ctx, droid_head);
			nk_layout_row_dynamic(ctx, 23, 1);
			nk_label_wrap(ctx, "What kind of closed captions does CCExtractor support?");
			nk_style_pop_font(ctx);

			nk_layout_row_dynamic(ctx, 47, 1);
			nk_label_wrap(ctx, "American TV captions (CEA-608 is well supported, and CEA-708 is starting to look good) and Teletext based European subtitles.");

			nk_style_push_font(ctx, droid_head);
			nk_layout_row_dynamic(ctx, 23, 1);
			nk_label_wrap(ctx, "How easy is it to use CCExtractor?");
			nk_style_pop_font(ctx);

			nk_layout_row_dynamic(ctx, 30, 1);
			nk_label_wrap(ctx, "Very. Just tell it what file to process and it does everything for you.");

			nk_style_push_font(ctx, droid_head);
			nk_layout_row_dynamic(ctx, 23, 1);
			nk_label_wrap(ctx, "CCExtractor integration with other tools");
			nk_style_pop_font(ctx);

			nk_layout_row_dynamic(ctx, 147, 1);
			nk_label_wrap(ctx, "It is possible to integrate CCExtractor in a larger process. A couple of tools already call CCExtractor as part their video process - this way they get subtitle support for free. Starting in 0.52, CCExtractor is very front - end friendly.Front - ends can easily get real - time status information.The GUI source code is provided and can be used for reference. Any tool, commercial or not, is specifically allowed to use CCExtractor for any use the authors seem fit. So if your favourite video tools still lacks captioning tool, feel free to send the authors here.");

			nk_style_push_font(ctx, droid_head);
			nk_layout_row_dynamic(ctx, 50, 1);
			nk_label_wrap(ctx, "What's the point of generating separate files for subtitles, if they are already in the source file?");
			nk_style_pop_font(ctx);

			nk_layout_row_dynamic(ctx, 367, 1);
			nk_label_wrap(ctx, "There are several reasons to have subtitles separated from the video file, including: - Closed captions never survive MPEG processing. If you take a MPEG file and encode it to any format (such as divx), your result file will not have closed captions. This means that if you want to keep the subtitles, you need to keep the original file. This is hardly practical if you are archiving HDTV shows for example. - Subtitles files are small - so small (around 250 Kb for a movie) that you can quickly download them, or email them, etc, in case you have a recording without subtitles. - Subtitles files are indexable: You can have a database with all your subtitles if you want (there are many available), so you can search the dialogs. - Subtitles files are a de-facto standard: Almost every player can use them. In fact, many setbox players accept subtitles files in .srt format - so you can have subtitles in your divx movies and not just in your original DVDs. - Closed captions are stored in many different formats by capture cards. Upgrading to a new card, if it comes with a new player, may mean that you can't use your previously recorded closed captions, even if the audio/video are fine. - Closed captions require a closed caption decoder. All US TV have one (it's a legal requirement), but no European TV does, since there are not closed captions in Europe (teletext is used instead). Basically this means that if you buy a DVD in the US which has closed captions but no DVD subtitles, you are out of luck. This is a problem with many (most) old TV shows DVDs, which only come with closed captions. DVD producers don't bother doing DVD subs, since it's another way to segment the market, same as with DVD regions. ");

			nk_style_push_font(ctx, droid_head);
			nk_layout_row_dynamic(ctx, 23, 1);
			nk_label_wrap(ctx, "How I do use subtitles once they are in a separate file?");
			nk_style_pop_font(ctx);

			nk_layout_row_dynamic(ctx, 80, 1);
			nk_label_wrap(ctx, "CCExtractor generates files in the two most common formats: .srt (SubRip) and .smi (which is a Microsoft standard). Most players support at least .srt natively. You just need to name the .srt file as the file you want to play it with, for example sample.avi and sample.srt.");

			nk_style_push_font(ctx, droid_head);
			nk_layout_row_dynamic(ctx, 23, 1);
			nk_label_wrap(ctx, "What kind of files can I extract closed captions from?");
			nk_style_pop_font(ctx);

			nk_layout_row_dynamic(ctx, 20, 1);
			nk_label_wrap(ctx, "CCExtractor currently handles:");
			nk_layout_row_dynamic(ctx, 20, 1);
			nk_label_wrap(ctx, "- DVDs.");
			nk_layout_row_dynamic(ctx, 20, 1);
			nk_label_wrap(ctx, "- Most HDTV captures(where you save the Transport Stream).");
			nk_layout_row_dynamic(ctx, 52, 1);
			nk_label_wrap(ctx, "- Captures where captions are recorded in bttv format.The number of cards that use this card is huge.My test samples came from a Hauppage PVR - 250. You can check the complete list here:");
			nk_layout_row_dynamic(ctx, 40, 1);
			nk_label_colored_wrap(ctx, "http://linuxtv.org/hg/v4l-dvb/file/tip/linux/Documentation/video4linux/CARDLIST.bttv", nk_rgb(61, 117, 206));
			nk_layout_row_dynamic(ctx, 20, 1);
			nk_label_wrap(ctx, "- DVR - MS(microsoft digital video recording).");
			nk_layout_row_dynamic(ctx, 20, 1);
			nk_label_wrap(ctx, "- Tivo files");
			nk_layout_row_dynamic(ctx, 20, 1);
			nk_label_wrap(ctx, "- ReplayTV files");
			nk_layout_row_dynamic(ctx, 20, 1);
			nk_label_wrap(ctx, "- Dish Network files");
			nk_layout_row_dynamic(ctx, 80, 1);
			nk_label_wrap(ctx, "Usually, if you record a TV show with your capture card and CCExtractor produces the expected result, it will work for your all recordings.If it doesn't, which means that your card uses a format CCExtractor can't handle, please contact me and we'll try to make it work."); 

			nk_style_push_font(ctx, droid_head);
			nk_layout_row_dynamic(ctx, 23, 1);
			nk_label_wrap(ctx, "Can I edit the subtitles? ");
			nk_style_pop_font(ctx);

			nk_layout_row_dynamic(ctx, 43, 1);
			nk_label_wrap(ctx, ".srt files are just text files, with time information (when subtitles are supposed to be shown and for how long) and some basic formatting (use italics, bold, etc). So you can edit them with any text editor. If you need to do serious editing (such as adjusting timing), you can use subtitle editing tools - there are many available.");

			nk_style_push_font(ctx, droid_head);
			nk_layout_row_dynamic(ctx, 23, 1);
			nk_label_wrap(ctx, "Can CCExtractor generate other subtitles formats?");
			nk_style_pop_font(ctx);

			nk_layout_row_dynamic(ctx, 23, 1);
			nk_label_wrap(ctx, "At this time, CCExtractor can generate .srt, .smi and raw and bin files.");

			nk_style_push_font(ctx, droid_head);
			nk_layout_row_dynamic(ctx, 23, 1);
			nk_label_wrap(ctx, "How I can contact the author?");
			nk_style_pop_font(ctx);

			nk_layout_row_dynamic(ctx, 23, 1);
			nk_label_wrap(ctx, "Send me an email: [email protected]");


			nk_group_end(ctx);
		}

		nk_layout_row(ctx, NK_DYNAMIC, 27, 2, ok_ratio);
		nk_spacing(ctx,1);
		if (nk_button_label(ctx, "OK")) {
			*show_about_ccx = nk_false;
			nk_popup_close(ctx);
		}
		nk_popup_end(ctx);
	}
	else
		*show_about_ccx = nk_false;
}