Search code examples
samsung-mobiletizentizen-wearable-sdktizen-native-app

How could I rotate my watches display to a variable degree?


I would like to rotate my watches display to a variable degree like a compass does in real life? So far I have only discovered this function within the samsung API

screen.lockOrientation("portrait-secondary");

I would like more control than this, if that means using the native API, that's fine but I need help on where to look.


Solution

  • You may try using evas_map_util_rotate() function to rotate an object. It rotates the map based on an angle and the center coordinates of the rotation (the rotation point). A positive angle rotates the map clockwise, while a negative angle rotates the map counter-clockwise.

    Please have a look into Modifying a Map with Utility Functions section of this link. It contains an example which shows how to rotate an object around its center point by 45 degrees clockwise.

    You may also use below sample code snippet.

     @param[in] object_to_rotate The object you want to rotate
     @param[in] degree The degree you want to rotate
     @param[in] cx The rotation's center horizontal position
     @param[in] cy The rotation's center vertical position
    
    void view_rotate_object(Evas_Object *object_to_rotate, double degree, Evas_Coord cx, Evas_Coord cy)
    {
        Evas_Map *m = NULL;
    
        if (object_to_rotate == NULL) {
            dlog_print(DLOG_ERROR, LOG_TAG, "object  is NULL");
            return;
        }
    
        m = evas_map_new(4);
        evas_map_util_points_populate_from_object(m, object_to_rotate);
        evas_map_util_rotate(m, degree, cx, cy);
        evas_object_map_set(object_to_rotate, m);
        evas_object_map_enable_set(object_to_rotate, EINA_TRUE);
        evas_map_free(m);
    }
    

    Hope it'll help.