Skip to content

Commit

Permalink
feat(gui): add widget border helper
Browse files Browse the repository at this point in the history
  • Loading branch information
lc-soft committed Mar 3, 2019
1 parent fee31b0 commit e8d52df
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 12 deletions.
18 changes: 12 additions & 6 deletions include/LCUI/gui/widget_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,28 @@ LCUI_API void Widget_SetPadding(LCUI_Widget w, float top, float right,
LCUI_API void Widget_SetMargin(LCUI_Widget w, float top, float right,
float bottom, float left);

LCUI_API void Widget_SetBorderColor(LCUI_Widget w, LCUI_Color color);

LCUI_API void Widget_SetBorderWidth(LCUI_Widget w, float width);

LCUI_API void Widget_SetBorderStyle(LCUI_Widget w, float style);

/** 设置边框样式 */
LCUI_API void Widget_SetBorder(LCUI_Widget w, float width,
int style, LCUI_Color clr);
LCUI_API void Widget_SetBorder(LCUI_Widget w, float width, int style,
LCUI_Color clr);

/** 设置阴影样式 */
LCUI_API void Widget_SetBoxShadow(LCUI_Widget w, float x, float y,
float blur, LCUI_Color color);
LCUI_API void Widget_SetBoxShadow(LCUI_Widget w, float x, float y, float blur,
LCUI_Color color);

/** 移动部件位置 */
LCUI_API void Widget_Move(LCUI_Widget w, float left, float top);

/** 调整部件尺寸 */
LCUI_API void Widget_Resize(LCUI_Widget w, float width, float height);

LCUI_API void Widget_ResizeWithSurface(LCUI_Widget w,
float width, float height);
LCUI_API void Widget_ResizeWithSurface(LCUI_Widget w, float width,
float height);

LCUI_API LCUI_Style Widget_GetStyle(LCUI_Widget w, int key);

Expand Down
28 changes: 22 additions & 6 deletions src/gui/widget_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,37 @@ void Widget_SetMargin(LCUI_Widget w, float top, float right,
Widget_UpdateStyle(w, FALSE);
}

void Widget_SetBorder(LCUI_Widget w, float width, int style, LCUI_Color clr)
void Widget_SetBorderColor(LCUI_Widget w, LCUI_Color color)
{
Widget_SetStyle(w, key_border_top_color, color, color);
Widget_SetStyle(w, key_border_right_color, color, color);
Widget_SetStyle(w, key_border_bottom_color, color, color);
Widget_SetStyle(w, key_border_left_color, color, color);
Widget_UpdateStyle(w, FALSE);
}

void Widget_SetBorderWidth(LCUI_Widget w, float width)
{
Widget_SetStyle(w, key_border_top_color, clr, color);
Widget_SetStyle(w, key_border_right_color, clr, color);
Widget_SetStyle(w, key_border_bottom_color, clr, color);
Widget_SetStyle(w, key_border_left_color, clr, color);
Widget_SetStyle(w, key_border_top_width, width, px);
Widget_SetStyle(w, key_border_right_width, width, px);
Widget_SetStyle(w, key_border_bottom_width, width, px);
Widget_SetStyle(w, key_border_left_width, width, px);
Widget_UpdateStyle(w, FALSE);
}

void Widget_SetBorderStyle(LCUI_Widget w, float style)
{
Widget_SetStyle(w, key_border_top_style, style, style);
Widget_SetStyle(w, key_border_right_style, style, style);
Widget_SetStyle(w, key_border_bottom_style, style, style);
Widget_SetStyle(w, key_border_left_style, style, style);
Widget_UpdateStyle(w, FALSE);
}

void Widget_SetBorder(LCUI_Widget w, float width, int style, LCUI_Color color)
{
Widget_SetBorderColor(w, color);
Widget_SetBorderWidth(w, width);
Widget_SetBorderStyle(w, style);
}

void Widget_SetBoxShadow(LCUI_Widget w, float x, float y,
Expand Down

0 comments on commit e8d52df

Please sign in to comment.