From cf1208e7a595baf9acd7fd2238c7bad70433de99 Mon Sep 17 00:00:00 2001 From: Liu Date: Sun, 16 Feb 2020 20:37:04 +0800 Subject: [PATCH] refactor(gui): add widget_shadow.h BREAKING CHANGE: The widget shadow operation interface has been changed to private --- build/windows/LCUI/LCUI.vcxproj | 1 + build/windows/LCUI/LCUI.vcxproj.filters | 3 ++ include/LCUI/gui/widget_base.h | 19 ----------- src/gui/widget_base.c | 1 + src/gui/widget_paint.c | 1 + src/gui/widget_shadow.c | 3 +- src/gui/widget_shadow.h | 44 +++++++++++++++++++++++++ src/gui/widget_task.c | 1 + 8 files changed, 53 insertions(+), 20 deletions(-) create mode 100644 src/gui/widget_shadow.h diff --git a/build/windows/LCUI/LCUI.vcxproj b/build/windows/LCUI/LCUI.vcxproj index 0a2bae008..358465148 100644 --- a/build/windows/LCUI/LCUI.vcxproj +++ b/build/windows/LCUI/LCUI.vcxproj @@ -354,6 +354,7 @@ + diff --git a/build/windows/LCUI/LCUI.vcxproj.filters b/build/windows/LCUI/LCUI.vcxproj.filters index dfa601123..b7446c0a5 100644 --- a/build/windows/LCUI/LCUI.vcxproj.filters +++ b/build/windows/LCUI/LCUI.vcxproj.filters @@ -333,6 +333,9 @@ 源文件\gui + + 源文件\gui + diff --git a/include/LCUI/gui/widget_base.h b/include/LCUI/gui/widget_base.h index c34e45d09..403bf69c2 100755 --- a/include/LCUI/gui/widget_base.h +++ b/include/LCUI/gui/widget_base.h @@ -403,25 +403,6 @@ LCUI_API void Widget_Destroy(LCUI_Widget w); LCUI_API void Widget_GetOffset(LCUI_Widget w, LCUI_Widget parent, float *offset_x, float *offset_y); -LCUI_API float Widget_GetCanvasWidth(LCUI_Widget widget); - -LCUI_API float Widget_GetCanvasHeight(LCUI_Widget widget); - -LCUI_API float Widget_GetBoxShadowOffsetX(LCUI_Widget w); - -LCUI_API float Widget_GetBoxShadowOffsetY(LCUI_Widget w); - -LCUI_API float Widget_GetCanvasWidth(LCUI_Widget w); - -LCUI_API float Widget_GetCanvasWidth(LCUI_Widget w); - -LCUI_API void Widget_ComputeBoxShadow(LCUI_Widget w, LCUI_BoxShadow *out); - -LCUI_API void Widget_ComputeBoxShadowStyle(LCUI_Widget w); - -LCUI_API void Widget_PaintBoxShadow(LCUI_Widget w, LCUI_PaintContext paint, - LCUI_WidgetActualStyle style); - LCUI_API int Widget_Top(LCUI_Widget w); LCUI_API void Widget_SortChildrenShow(LCUI_Widget w); diff --git a/src/gui/widget_base.c b/src/gui/widget_base.c index 2f5f7eb3f..e2969a79e 100755 --- a/src/gui/widget_base.c +++ b/src/gui/widget_base.c @@ -39,6 +39,7 @@ #include #include "widget_util.h" #include "widget_background.h" +#include "widget_shadow.h" static struct LCUI_WidgetModule { LCUI_Widget root; /**< 根级部件 */ diff --git a/src/gui/widget_paint.c b/src/gui/widget_paint.c index 2cca2f80f..9c51a302b 100644 --- a/src/gui/widget_paint.c +++ b/src/gui/widget_paint.c @@ -37,6 +37,7 @@ #include #include "widget_border.h" #include "widget_background.h" +#include "widget_shadow.h" //#define DEBUG_FRAME_RENDER #define ComputeActualPX(VAL) LCUIMetrics_ComputeActual(VAL, LCUI_STYPE_PX) diff --git a/src/gui/widget_shadow.c b/src/gui/widget_shadow.c index 22223d67e..d69af15ff 100644 --- a/src/gui/widget_shadow.c +++ b/src/gui/widget_shadow.c @@ -1,7 +1,7 @@ /* * widget_shadow.c -- widget shadow style processing module. * - * Copyright (c) 2018, Liu chao All rights reserved. + * Copyright (c) 2018-2020, Liu chao All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -34,6 +34,7 @@ #include #include #include +#include "widget_shadow.h" static float ComputeXMetric(LCUI_Widget w, LCUI_Style s) { diff --git a/src/gui/widget_shadow.h b/src/gui/widget_shadow.h new file mode 100644 index 000000000..0c3f0fe0c --- /dev/null +++ b/src/gui/widget_shadow.h @@ -0,0 +1,44 @@ +/* + * widget_shadow.c -- widget shadow style processing module. + * + * Copyright (c) 2020, Liu chao All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of LCUI nor the names of its contributors may be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +float Widget_GetCanvasWidth(LCUI_Widget widget); + +float Widget_GetCanvasHeight(LCUI_Widget widget); + +float Widget_GetBoxShadowOffsetX(LCUI_Widget w); + +float Widget_GetBoxShadowOffsetY(LCUI_Widget w); + +void Widget_ComputeBoxShadow(LCUI_Widget w, LCUI_BoxShadow *out); + +void Widget_ComputeBoxShadowStyle(LCUI_Widget w); + +void Widget_PaintBoxShadow(LCUI_Widget w, LCUI_PaintContext paint, + LCUI_WidgetActualStyle style); diff --git a/src/gui/widget_task.c b/src/gui/widget_task.c index 58c1d7c77..6cd917748 100644 --- a/src/gui/widget_task.c +++ b/src/gui/widget_task.c @@ -39,6 +39,7 @@ #include "widget_diff.h" #include "widget_border.h" #include "widget_background.h" +#include "widget_shadow.h" typedef struct LCUI_WidgetTaskContextRec_ *LCUI_WidgetTaskContext;