merge guage pointer patch

This commit is contained in:
lixianjing 2019-05-15 10:45:56 +08:00
parent d3fcefa81e
commit 96c9b15770
3 changed files with 378 additions and 217 deletions

View File

@ -46,63 +46,61 @@ ret_t guage_pointer_set_angle(widget_t* widget, int32_t angle) {
return RET_OK;
}
static bool_t value_is_anchor_px(const char* value) {
bool_t guage_pointer_value_is_anchor_px(const char* value) {
char* tmp = NULL;
size_t len = strlen(value);
char* tmp;
return_value_if_fail(len > ANCHOR_PX_STR_LEN, FALSE);
tmp = value + len - ANCHOR_PX_STR_LEN;
if (tk_str_eq(tmp, "px") != 0 || tk_str_eq(tmp, "Px") != 0 || tk_str_eq(tmp, "pX") != 0 ||
tk_str_eq(tmp, "PX") != 0) {
if (tk_str_eq(tmp, "px") != 0 || tk_str_eq(tmp, "PX") != 0) {
return TRUE;
}
return FALSE;
}
static float_t anchor_set_value(bool_t* is_px, const char* value) {
float_t anchor_;
if (value_is_anchor_px(value)) {
size_t len = strlen(value);
size_t tmp_len = len - ANCHOR_PX_STR_LEN;
char* tmp = (char*)TKMEM_ALLOC(tmp_len);
memcpy(tmp, value, tmp_len);
anchor_ = tk_atof(tmp);
TKMEM_FREE(tmp);
tmp = NULL;
*is_px = TRUE;
} else {
anchor_ = tk_atof(value);
*is_px = FALSE;
}
return anchor_;
}
static ret_t set_anchor(widget_t* widget, const char* str_anchor_, bool_t is_x) {
ret_t guage_pointer_set_anchor_for_str(widget_t* widget, const char* anchor, bool_t is_x) {
float_t max_size = 0.0f;
float_t anchor_tmp = 0.0f;
bool_t is_anchor_px = TRUE;
guage_pointer_t* guage_pointer = GUAGE_POINTER(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
float_t anchor_;
bool_t is_anchor_px;
float_t max_size;
anchor_ = anchor_set_value(&is_anchor_px, str_anchor_);
return_value_if_fail(anchor != NULL, RET_BAD_PARAMS);
return_value_if_fail(guage_pointer != NULL, RET_BAD_PARAMS);
anchor_tmp = tk_atof(anchor);
max_size = is_x ? widget->w : widget->h;
is_anchor_px = guage_pointer_value_is_anchor_px(anchor);
if (is_anchor_px) {
return_value_if_fail(0 <= anchor_ && anchor_ <= max_size, RET_BAD_PARAMS);
return_value_if_fail(0 <= anchor_tmp && anchor_tmp <= max_size, RET_BAD_PARAMS);
} else {
return_value_if_fail(0 <= anchor_ && anchor_ <= 1.0f, RET_BAD_PARAMS);
return_value_if_fail(0 <= anchor_tmp && anchor_tmp <= 1.0f, RET_BAD_PARAMS);
}
if (is_x)
guage_pointer->anchor_x = is_anchor_px ? anchor_ : anchor_ * max_size;
else
guage_pointer->anchor_y = is_anchor_px ? anchor_ : anchor_ * max_size;
if (is_x) {
guage_pointer->anchor_x = is_anchor_px ? anchor_tmp : anchor_tmp * max_size;
} else {
guage_pointer->anchor_y = is_anchor_px ? anchor_tmp : anchor_tmp * max_size;
}
return RET_OK;
}
ret_t guage_pointer_set_anchor(widget_t* widget, const char* str_anchor_x,
const char* str_anchor_y) {
return_value_if_fail(set_anchor(widget, str_anchor_x, TRUE) == RET_OK, RET_BAD_PARAMS);
return_value_if_fail(set_anchor(widget, str_anchor_y, FALSE) == RET_OK, RET_BAD_PARAMS);
ret_t guage_pointer_set_anchor(widget_t* widget, const char* anchor_x, const char* anchor_y) {
float tmp = 0.0f;
guage_pointer_t* guage_pointer = GUAGE_POINTER(widget);
return_value_if_fail(guage_pointer != NULL, RET_BAD_PARAMS);
tmp = guage_pointer->anchor_x;
return_value_if_fail(guage_pointer_set_anchor_for_str(widget, anchor_x, TRUE) == RET_OK,
RET_BAD_PARAMS);
if (guage_pointer_set_anchor_for_str(widget, anchor_y, FALSE) != RET_OK) {
guage_pointer->anchor_x = tmp;
return RET_BAD_PARAMS;
}
return RET_OK;
}
@ -110,7 +108,7 @@ ret_t guage_pointer_set_anchor(widget_t* widget, const char* str_anchor_x,
ret_t guage_pointer_set_image(widget_t* widget, const char* image) {
guage_pointer_t* guage_pointer = GUAGE_POINTER(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return_value_if_fail(image != NULL, RET_BAD_PARAMS);
guage_pointer->image = tk_str_copy(guage_pointer->image, image);
if (guage_pointer->image != NULL) {
const asset_info_t* asset = widget_load_asset(widget, ASSET_TYPE_IMAGE, guage_pointer->image);
@ -137,10 +135,10 @@ static ret_t guage_pointer_get_prop(widget_t* widget, const char* name, value_t*
} else if (tk_str_eq(name, WIDGET_PROP_IMAGE)) {
value_set_str(v, guage_pointer->image);
return RET_OK;
} else if (tk_str_eq(name, GUAGE_POINTER_ANCHOR_X)) {
} else if (tk_str_eq(name, WIDGET_PROP_ANCHOR_X)) {
value_set_int(v, guage_pointer->anchor_x);
return RET_OK;
} else if (tk_str_eq(name, GUAGE_POINTER_ANCHOR_Y)) {
} else if (tk_str_eq(name, WIDGET_PROP_ANCHOR_Y)) {
value_set_int(v, guage_pointer->anchor_y);
return RET_OK;
}
@ -155,10 +153,10 @@ static ret_t guage_pointer_set_prop(widget_t* widget, const char* name, const va
return guage_pointer_set_angle(widget, value_int(v));
} else if (tk_str_eq(name, WIDGET_PROP_IMAGE)) {
return guage_pointer_set_image(widget, value_str(v));
} else if (tk_str_eq(name, GUAGE_POINTER_ANCHOR_X)) {
return set_anchor(widget, value_str(v), TRUE);
} else if (tk_str_eq(name, GUAGE_POINTER_ANCHOR_Y)) {
return set_anchor(widget, value_str(v), FALSE);
} else if (tk_str_eq(name, WIDGET_PROP_ANCHOR_X)) {
return guage_pointer_set_anchor_for_str(widget, value_str(v), TRUE);
} else if (tk_str_eq(name, WIDGET_PROP_ANCHOR_Y)) {
return guage_pointer_set_anchor_for_str(widget, value_str(v), FALSE);
}
return RET_NOT_FOUND;
@ -247,7 +245,7 @@ static ret_t guage_pointer_on_paint_self(widget_t* widget, canvas_t* c) {
}
static const char* s_guage_pointer_properties[] = {GUAGE_POINTER_PROP_ANGLE, WIDGET_PROP_IMAGE,
GUAGE_POINTER_ANCHOR_X, GUAGE_POINTER_ANCHOR_Y,
WIDGET_PROP_ANCHOR_X, WIDGET_PROP_ANCHOR_Y,
NULL};
TK_DECL_VTABLE(guage_pointer) = {.size = sizeof(guage_pointer_t),

View File

@ -1,169 +1,169 @@
/**
* File: guage_pointer.h
* Author: AWTK Develop Team
* Brief: guage_pointer
*
* Copyright (c) 2018 - 2019 Guangzhou ZHIYUAN Electronics Co.,Ltd.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* License file for more details.
*
*/
/**
* History:
* ================================================================
* 2018-09-05 Li XianJing <xianjimli@hotmail.com> created
*
*/
#ifndef TK_GUAGE_POINTER_H
#define TK_GUAGE_POINTER_H
#include "base/widget.h"
BEGIN_C_DECLS
/**
* @class guage_pointer_t
* @parent widget_t
* @annotation ["scriptable","design","widget"]
*
*
* SVG图片
*
* SVG图片的效率比位图高数倍使SVG图片
*
* guage\_pointer\_t是[widget\_t](widget_t.md)widget\_t的函数均适用于guage\_pointer\_t控件
*
* xml中使用"guage\_pointer"
*
* ```xml
* <guage_pointer x="c" y="50" w="24" h="140" value="-128" image="guage_pointer" />
* ```
*
* >
* [guage.xml](https://github.com/zlgopen/awtk/blob/master/demos/assets/raw/ui/guage.xml)
*
* c代码中使用函数guage\_pointer\_create创建仪表指针控件
*
* ```c
* widget_t* guage_pointer = guage_pointer_create(guage, 10, 10, 100, 30);
* guage_pointer_set_image(guage_pointer, "guage_pointer");
* ```
*
* > guage\_pointer\_set\_image设置仪表指针图片
*
*
*/
typedef struct _guage_pointer_t {
widget_t widget;
/**
* @property {int32_t} angle
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
* 120
*/
int32_t angle;
/**
* @property {char*} image
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
*
*
*
*
*/
char* image;
/**
* @property {float_t} center_point_y
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
* x坐标
*/
float_t anchor_x;
/**
* @property {float_t} center_point_y
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
* y坐标
*/
float_t anchor_y;
/*private*/
const asset_info_t* bsvg_asset;
} guage_pointer_t;
/**
* @method guage_pointer_create
* guage_pointer对象
* @annotation ["constructor", "scriptable"]
* @param {widget_t*} parent
* @param {xy_t} x x坐标
* @param {xy_t} y y坐标
* @param {wh_t} w
* @param {wh_t} h
*
* @return {widget_t*}
*/
widget_t* guage_pointer_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h);
/**
* @method guage_pointer_cast
* guage_pointer对象(使)
* @annotation ["cast", "scriptable"]
* @param {widget_t*} widget guage_pointer对象
*
* @return {widget_t*} guage_pointer对象
*/
widget_t* guage_pointer_cast(widget_t* widget);
/**
* @method guage_pointer_set_angle
* 120
* @annotation ["scriptable"]
* @param {widget_t*} widget
* @param {int32_t} angle
*
* @return {ret_t} RET_OK表示成功
*/
ret_t guage_pointer_set_angle(widget_t* widget, int32_t angle);
/**
* @method guage_pointer_set_image
*
* @annotation ["scriptable"]
* @param {widget_t*} widget
* @param {const char*} image
*
* @return {ret_t} RET_OK表示成功
*/
ret_t guage_pointer_set_image(widget_t* widget, const char* image);
/**
* @method guage_pointer_set_image
*
* @annotation ["scriptable"]
* @param {widget_t*} widget
* @param {const char*} anchor_x x(px为像素点px为相对百分比坐标)
* @param {const char*} anchor_y y(px为像素点px为相对百分比坐标)
*
* @return {ret_t} RET_OK表示成功
*/
ret_t guage_pointer_set_anchor(widget_t* widget, const char* str_anchor_x,
const char* str_anchor_y);
#define GUAGE_POINTER_PROP_ANGLE "angle"
#define WIDGET_TYPE_GUAGE_POINTER "guage_pointer"
#define GUAGE_POINTER_ANCHOR_X "anchor_x"
#define GUAGE_POINTER_ANCHOR_Y "anchor_y"
#define GUAGE_POINTER(widget) ((guage_pointer_t*)(guage_pointer_cast(WIDGET(widget))))
/*public for subclass and runtime type check*/
TK_EXTERN_VTABLE(guage_pointer);
END_C_DECLS
#endif /*TK_GUAGE_POINTER_H*/
/**
* File: guage_pointer.h
* Author: AWTK Develop Team
* Brief: guage_pointer
*
* Copyright (c) 2018 - 2019 Guangzhou ZHIYUAN Electronics Co.,Ltd.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* License file for more details.
*
*/
/**
* History:
* ================================================================
* 2018-09-05 Li XianJing <xianjimli@hotmail.com> created
*
*/
#ifndef TK_GUAGE_POINTER_H
#define TK_GUAGE_POINTER_H
#include "base/widget.h"
BEGIN_C_DECLS
/**
* @class guage_pointer_t
* @parent widget_t
* @annotation ["scriptable","design","widget"]
*
*
* SVG图片
*
* SVG图片的效率比位图高数倍使SVG图片
*
* guage\_pointer\_t是[widget\_t](widget_t.md)widget\_t的函数均适用于guage\_pointer\_t控件
*
* xml中使用"guage\_pointer"
*
* ```xml
* <guage_pointer x="c" y="50" w="24" h="140" value="-128" image="guage_pointer" />
* ```
*
* >
* [guage.xml](https://github.com/zlgopen/awtk/blob/master/demos/assets/raw/ui/guage.xml)
*
* c代码中使用函数guage\_pointer\_create创建仪表指针控件
*
* ```c
* widget_t* guage_pointer = guage_pointer_create(guage, 10, 10, 100, 30);
* guage_pointer_set_image(guage_pointer, "guage_pointer");
* ```
*
* > guage\_pointer\_set\_image设置仪表指针图片
*
*
*/
typedef struct _guage_pointer_t {
widget_t widget;
/**
* @property {int32_t} angle
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
* 120
*/
int32_t angle;
/**
* @property {char*} image
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
*
*
*
*
*/
char* image;
/**
* @property {float_t} center_point_y
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
* x坐标
*/
float_t anchor_x;
/**
* @property {float_t} center_point_y
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
* y坐标
*/
float_t anchor_y;
/*private*/
const asset_info_t* bsvg_asset;
} guage_pointer_t;
/**
* @method guage_pointer_create
* guage_pointer对象
* @annotation ["constructor", "scriptable"]
* @param {widget_t*} parent
* @param {xy_t} x x坐标
* @param {xy_t} y y坐标
* @param {wh_t} w
* @param {wh_t} h
*
* @return {widget_t*}
*/
widget_t* guage_pointer_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h);
/**
* @method guage_pointer_cast
* guage_pointer对象(使)
* @annotation ["cast", "scriptable"]
* @param {widget_t*} widget guage_pointer对象
*
* @return {widget_t*} guage_pointer对象
*/
widget_t* guage_pointer_cast(widget_t* widget);
/**
* @method guage_pointer_set_angle
* 120
* @annotation ["scriptable"]
* @param {widget_t*} widget
* @param {int32_t} angle
*
* @return {ret_t} RET_OK表示成功
*/
ret_t guage_pointer_set_angle(widget_t* widget, int32_t angle);
/**
* @method guage_pointer_set_image
*
* @annotation ["scriptable"]
* @param {widget_t*} widget
* @param {const char*} image
*
* @return {ret_t} RET_OK表示成功
*/
ret_t guage_pointer_set_image(widget_t* widget, const char* image);
/**
* @method guage_pointer_set_image
*
* @annotation ["scriptable"]
* @param {widget_t*} widget
* @param {const char*} anchor_x x(px为像素点px为相对百分比坐标)
* @param {const char*} anchor_y y(px为像素点px为相对百分比坐标)
*
* @return {ret_t} RET_OK表示成功
*/
ret_t guage_pointer_set_anchor(widget_t* widget, const char* anchor_x, const char* anchor_y);
#define GUAGE_POINTER_PROP_ANGLE "angle"
#define WIDGET_TYPE_GUAGE_POINTER "guage_pointer"
#define GUAGE_POINTER(widget) ((guage_pointer_t*)(guage_pointer_cast(WIDGET(widget))))
/*public for subclass and runtime type check*/
TK_EXTERN_VTABLE(guage_pointer);
/*public for test*/
ret_t guage_pointer_set_anchor_for_str(widget_t* widget, const char* anchor, bool_t is_x);
END_C_DECLS
#endif /*TK_GUAGE_POINTER_H*/

View File

@ -1,10 +1,173 @@
#include "guage/guage_pointer.h"
#include "awtk.h"
#include "guage/guage_pointer.h"
#include "guage/guage.h"
#include "gtest/gtest.h"
TEST(GuagePointer, cast) {
widget_t* w = guage_pointer_create(NULL, 0, 0, 100, 100);
ASSERT_EQ(w, guage_pointer_cast(w));
EXPECT_EQ(w, guage_pointer_cast(w));
widget_destroy(w);
}
TEST(GuagePointer, set_angle) {
widget_t* w = window_create(NULL, 0, 0, 0, 0);
widget_t* guage_pointer = guage_pointer_create(w, 0, 0, 200, 200);
EXPECT_EQ(guage_pointer, guage_pointer_cast(guage_pointer));
guage_pointer_t* guage_pointer_tmp = GUAGE_POINTER(guage_pointer);
EXPECT_TRUE(guage_pointer_tmp != NULL);
EXPECT_FALSE(guage_pointer_set_angle(NULL, 10) == RET_OK);
EXPECT_TRUE(guage_pointer_set_angle(guage_pointer, 10) == RET_OK);
EXPECT_TRUE(guage_pointer_tmp->angle == 10);
EXPECT_TRUE(guage_pointer_set_angle(guage_pointer, -10) == RET_OK);
EXPECT_TRUE(guage_pointer_set_angle(guage_pointer, 370) == RET_OK);
widget_destroy(w);
}
TEST(GuagePointer, set_image) {
#define IMAGE_NAME "test"
widget_t* w = window_create(NULL, 0, 0, 0, 0);
widget_t* guage_pointer = guage_pointer_create(w, 0, 0, 200, 200);
EXPECT_EQ(guage_pointer, guage_pointer_cast(guage_pointer));
guage_pointer_t* guage_pointer_tmp = GUAGE_POINTER(guage_pointer);
EXPECT_TRUE(guage_pointer_tmp != NULL);
EXPECT_FALSE(guage_pointer_set_image(NULL, IMAGE_NAME) == RET_OK);
EXPECT_FALSE(guage_pointer_set_image(guage_pointer, NULL) == RET_OK);
EXPECT_TRUE(guage_pointer_set_image(guage_pointer, IMAGE_NAME) == RET_OK);
EXPECT_STREQ(guage_pointer_tmp->image, IMAGE_NAME);
widget_destroy(w);
}
TEST(GuagePointer, set_anchor) {
widget_t* w = window_create(NULL, 0, 0, 0, 0);
widget_t* guage_pointer = guage_pointer_create(w, 0, 0, 200, 200);
EXPECT_EQ(guage_pointer, guage_pointer_cast(guage_pointer));
guage_pointer_t* guage_pointer_tmp = GUAGE_POINTER(guage_pointer);
EXPECT_TRUE(guage_pointer_tmp != NULL);
EXPECT_FALSE(guage_pointer_set_anchor_for_str(NULL, "100px", TRUE) == RET_OK);
EXPECT_TRUE(guage_pointer_set_anchor_for_str(guage_pointer, "100px", TRUE) == RET_OK);
EXPECT_TRUE(guage_pointer_tmp->anchor_x == 100);
EXPECT_TRUE(guage_pointer_set_anchor_for_str(guage_pointer, "100PX", TRUE) == RET_OK);
EXPECT_TRUE(guage_pointer_tmp->anchor_x == 100);
EXPECT_FALSE(guage_pointer_set_anchor_for_str(guage_pointer, "300px", TRUE) == RET_OK);
EXPECT_TRUE(guage_pointer_tmp->anchor_x == 100);
EXPECT_FALSE(guage_pointer_set_anchor_for_str(guage_pointer, "-300px", TRUE) == RET_OK);
EXPECT_TRUE(guage_pointer_tmp->anchor_x == 100);
EXPECT_TRUE(guage_pointer_set_anchor_for_str(guage_pointer, "0.4", TRUE) == RET_OK);
EXPECT_TRUE(guage_pointer_tmp->anchor_x == guage_pointer->w * 0.4f);
EXPECT_FALSE(guage_pointer_set_anchor_for_str(guage_pointer, "-0.4", TRUE) == RET_OK);
EXPECT_TRUE(guage_pointer_tmp->anchor_x == guage_pointer->w * 0.4f);
EXPECT_FALSE(guage_pointer_set_anchor_for_str(guage_pointer, "1.4", TRUE) == RET_OK);
EXPECT_TRUE(guage_pointer_tmp->anchor_x == guage_pointer->w * 0.4f);
EXPECT_TRUE(guage_pointer_set_anchor_for_str(guage_pointer, "100px", FALSE) == RET_OK);
EXPECT_TRUE(guage_pointer_tmp->anchor_y == 100);
EXPECT_TRUE(guage_pointer_set_anchor_for_str(guage_pointer, "100PX", FALSE) == RET_OK);
EXPECT_TRUE(guage_pointer_tmp->anchor_y == 100);
EXPECT_FALSE(guage_pointer_set_anchor_for_str(guage_pointer, "300px", FALSE) == RET_OK);
EXPECT_TRUE(guage_pointer_tmp->anchor_y == 100);
EXPECT_FALSE(guage_pointer_set_anchor_for_str(guage_pointer, "-300px", FALSE) == RET_OK);
EXPECT_TRUE(guage_pointer_tmp->anchor_y == 100);
EXPECT_TRUE(guage_pointer_set_anchor_for_str(guage_pointer, "0.4", FALSE) == RET_OK);
EXPECT_TRUE(guage_pointer_tmp->anchor_y == guage_pointer->h * 0.4f);
EXPECT_FALSE(guage_pointer_set_anchor_for_str(guage_pointer, "-0.4", FALSE) == RET_OK);
EXPECT_TRUE(guage_pointer_tmp->anchor_y == guage_pointer->w * 0.4f);
EXPECT_FALSE(guage_pointer_set_anchor_for_str(guage_pointer, "1.4", FALSE) == RET_OK);
EXPECT_TRUE(guage_pointer_tmp->anchor_y == guage_pointer->w * 0.4f);
EXPECT_TRUE(guage_pointer_set_anchor(guage_pointer, "120px", "0.3") == RET_OK);
EXPECT_TRUE(guage_pointer_tmp->anchor_x == 120);
EXPECT_TRUE(guage_pointer_tmp->anchor_y == guage_pointer->h * 0.3f);
EXPECT_TRUE(guage_pointer_set_anchor(guage_pointer, "130PX", "0.2") == RET_OK);
EXPECT_TRUE(guage_pointer_tmp->anchor_x == 130);
EXPECT_TRUE(guage_pointer_tmp->anchor_y == guage_pointer->h * 0.2f);
EXPECT_TRUE(guage_pointer_set_anchor(guage_pointer, "0.2", "0.1") == RET_OK);
EXPECT_TRUE(guage_pointer_tmp->anchor_x == guage_pointer->w * 0.2f);
EXPECT_TRUE(guage_pointer_tmp->anchor_y == guage_pointer->h * 0.1f);
EXPECT_TRUE(guage_pointer_set_anchor(guage_pointer, "0.3", "120px") == RET_OK);
EXPECT_TRUE(guage_pointer_tmp->anchor_x == guage_pointer->w * 0.3f);
EXPECT_TRUE(guage_pointer_tmp->anchor_y == 120);
EXPECT_TRUE(guage_pointer_set_anchor(guage_pointer, "0.4", "130PX") == RET_OK);
EXPECT_TRUE(guage_pointer_tmp->anchor_x == guage_pointer->w * 0.4f);
EXPECT_TRUE(guage_pointer_tmp->anchor_y == 130);
EXPECT_FALSE(guage_pointer_set_anchor(guage_pointer, NULL, "120PX") == RET_OK);
EXPECT_TRUE(guage_pointer_tmp->anchor_x == guage_pointer->w * 0.4f);
EXPECT_TRUE(guage_pointer_tmp->anchor_y == 130);
EXPECT_FALSE(guage_pointer_set_anchor(guage_pointer, NULL, NULL) == RET_OK);
EXPECT_TRUE(guage_pointer_tmp->anchor_x == guage_pointer->w * 0.4f);
EXPECT_TRUE(guage_pointer_tmp->anchor_y == 130);
EXPECT_FALSE(guage_pointer_set_anchor(guage_pointer, "-1", "120PX") == RET_OK);
EXPECT_TRUE(guage_pointer_tmp->anchor_x == guage_pointer->w * 0.4f);
EXPECT_TRUE(guage_pointer_tmp->anchor_y == 130);
EXPECT_FALSE(guage_pointer_set_anchor(guage_pointer, "2", "120PX") == RET_OK);
EXPECT_TRUE(guage_pointer_tmp->anchor_x == guage_pointer->w * 0.4f);
EXPECT_TRUE(guage_pointer_tmp->anchor_y == 130);
EXPECT_FALSE(guage_pointer_set_anchor(guage_pointer, "-120px", "120PX") == RET_OK);
EXPECT_TRUE(guage_pointer_tmp->anchor_x == guage_pointer->w * 0.4f);
EXPECT_TRUE(guage_pointer_tmp->anchor_y == 130);
EXPECT_FALSE(guage_pointer_set_anchor(guage_pointer, "400px", "120PX") == RET_OK);
EXPECT_TRUE(guage_pointer_tmp->anchor_x == guage_pointer->w * 0.4f);
EXPECT_TRUE(guage_pointer_tmp->anchor_y == 130);
EXPECT_FALSE(guage_pointer_set_anchor(guage_pointer, "120px", "-1") == RET_OK);
EXPECT_TRUE(guage_pointer_tmp->anchor_x == guage_pointer->w * 0.4f);
EXPECT_TRUE(guage_pointer_tmp->anchor_y == 130);
EXPECT_FALSE(guage_pointer_set_anchor(guage_pointer, "120px", "2") == RET_OK);
EXPECT_TRUE(guage_pointer_tmp->anchor_x == guage_pointer->w * 0.4f);
EXPECT_TRUE(guage_pointer_tmp->anchor_y == 130);
EXPECT_FALSE(guage_pointer_set_anchor(guage_pointer, "120px", "-120PX") == RET_OK);
EXPECT_TRUE(guage_pointer_tmp->anchor_x == guage_pointer->w * 0.4f);
EXPECT_TRUE(guage_pointer_tmp->anchor_y == 130);
EXPECT_FALSE(guage_pointer_set_anchor(guage_pointer, "120px", "300PX") == RET_OK);
EXPECT_TRUE(guage_pointer_tmp->anchor_x == guage_pointer->w * 0.4f);
EXPECT_TRUE(guage_pointer_tmp->anchor_y == 130);
widget_destroy(w);
}