언어 설정

Menu
Sites
Language
Cairo Graphic with more_option

I am slowly crazy :-(

I would like to develop an app with cairographic:
To do so, a graphic is to be displayed immediately from sensor data when starting the app
on my Samsung Gear S3.
For this graphic properties like color and line strength should be a possibility to adjust.
The coding of cairo graphic is simple, but how do I get there a more_option property (or an alternative)?
A cairo graphic is displayed in the window and for more_option I need a naviframe. How do I combine this?
Or is there an alternative possibility i.e. to choose a line strength
?

I need a example like "Cairo Show Text" with the possibility i.e. to change the text color.

Pls help!

Responses

3 댓글
K Johnson

So far I could understand from your post, you're looking for an implementation of cue button. To do that you may follow this link . I couldn't get the point of naviframe necessity mentioned in your post and also the relation of cairo drawing with cue button. Please clarify if I'm missing anything.

Vogt

I think I can't explain my problem exactly in english, so I will made a second try.

This is my simple code to start the app

static void create_base_gui(appdata_s *ad)
{
    /*
     * Window
     *  - conform
     *   - layout main
     *    - naviframe */

    /* Window */
    ad->win = elm_win_util_standard_add(PACKAGE, PACKAGE);
    elm_win_conformant_set(ad->win, EINA_TRUE);
    elm_win_autodel_set(ad->win, EINA_TRUE);

    if (elm_win_wm_rotation_supported_get(ad->win)) {
        int rots[4] = { 0, 90, 180, 270 };
        elm_win_wm_rotation_available_rotations_set(ad->win, (const int *)(&rots), 4);
    }

    evas_object_smart_callback_add(ad->win, "delete,request", win_delete_request_cb, NULL);

    /* Conformant */
    ad->conform = elm_conformant_add(ad->win);
    evas_object_size_hint_weight_set(ad->conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
    elm_win_resize_object_add(ad->win, ad->conform);
    evas_object_show(ad->conform);

    /* Base Layout */
    ad->layout = elm_layout_add(ad->conform);
    elm_layout_theme_set(ad->layout, "layout", "application", "default");
    evas_object_size_hint_weight_set(ad->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
    evas_object_show(ad->layout);

    elm_object_content_set(ad->conform, ad->layout);

    /* Create image */
    create_image(ad->nf);

    /* Naviframe */
    ad->nf = elm_naviframe_add(ad->layout);
    elm_object_part_content_set(ad->layout, "elm.swallow.content", ad->nf);
    eext_object_event_callback_add(ad->layout, EEXT_CALLBACK_BACK, win_delete_request_cb, NULL);
    evas_object_event_callback_add(ad->layout, EVAS_CALLBACK_RESIZE, win_resize_cb, NULL);

    eext_more_option_cb (ad, NULL, NULL);

    /* Show window after base gui is set up */
    evas_object_show(ad->win);
}

eext_more_option_cb (ad, NULL, NULL); -> Is the same as the startup from the example UI Components

This starts a black screen with 3 dots on the right side for more_options. At this point it's all perfect!

Now I want to draw a cairo graphic ...
Same procedure with the example of cairo show text

if (s_info.surface) {
    /* Destroy previous cairo canvas */
    cairo_surface_destroy(s_info.surface);
    cairo_destroy(s_info.cairo);
    s_info.surface = NULL;
    s_info.cairo = NULL;
}

/* When window resize event occurred
    If no cairo surface exist or destroyed
    Create cairo surface with resized Window size */
if (!s_info.surface) {
    /* Get screen size */
    evas_object_geometry_get(obj, NULL, NULL, &s_info.width, &s_info.height);

    /* Set image size */
    evas_object_image_size_set(s_info.img, s_info.width, s_info.height);
    evas_object_resize(s_info.img, s_info.width, s_info.height);
    evas_object_show(s_info.img);

    /* Create new cairo canvas for resized window */
    s_info.pixels = (unsigned char*)evas_object_image_data_get(s_info.img, 1);
    s_info.surface = cairo_image_surface_create_for_data(s_info.pixels,
                    CAIRO_FORMAT_ARGB32, s_info.width, s_info.height, s_info.width * 4);
    s_info.cairo = cairo_create(s_info.surface);

    /* Show cairo text */
    start_cairo_drawing();
}

The light gray background with the text and the green point is showing.

BUT HO ARE MY 3 "MORE OPTION DOTS"?

Isn't it possible to draw a cairo grphic with the possibility to show also the 3 more option dots
(of course with the according function) ????

K Johnson

Hello Vogt,

I've tried to implement the requirement you've mentioned above. According to my findings, you may try following workarounds as I couldn't also manage any way to show more options (cue button) on Cairo Canvas. Workarounds you may try are:

1. Try redirecting the user to another page(totally new page, it will not contain Cairo Surface) which contains cue button and give options to apply changes to your cairo drawing, save them and apply on previous drawing.

2. Try changing text color based on back key event of Gear Device. Modify win_back_cb as below:

static void
win_back_cb(void *data, Evas_Object *obj, void *event_info)
{
appdata_s *ad = data;
if(!strcmp(ad->event_info, "clicked")) ad->event_info = "not clicked";
else
	ad->event_info = "clicked";
	evas_object_geometry_get(ad->win, NULL, NULL, &ad->width, &ad->height);
	ad->surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, ad->width, ad->height);
	ad->cairo = cairo_create (ad->surface);
	cairo_drawing(ad);

}

In cairo_drawing() function, change color of drawing according to back key event as below:

if(!strcmp(ad->event_info, "clicked"))
        cairo_set_source_rgba(ad->cairo, 0.0, 1.0, 0.0, 1.0);

else
	cairo_set_source_rgba(ad->cairo, 0.0, 0.0, 1.0, 1.0);