Skip to content

Commit d13b554

Browse files
committed
fix(renderer): problem when widget has transparency (#160)
1 parent 5a7e2c0 commit d13b554

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/gui/widget_paint.c

+7-5
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
* POSSIBILITY OF SUCH DAMAGE.
2929
*/
3030

31+
//#define DEBUG
3132
#include <stdio.h>
3233
#include <stdlib.h>
3334
#include <LCUI_Build.h>
@@ -533,8 +534,8 @@ static size_t WidgetRenderer_RenderContent(LCUI_WidgetRenderer that)
533534
if (that->has_content_graph) {
534535
/* create a render context and it's render rectangle is relative
535536
* to this widget canvas */
536-
style.x = -that->style->canvas_box.x;
537-
style.y = -that->style->canvas_box.y;
537+
style.x = that->style->x - that->style->canvas_box.x;
538+
style.y = that->style->y - that->style->canvas_box.y;
538539
paint.rect = that->content_rect;
539540
paint.rect.x -= that->style->canvas_box.x;
540541
paint.rect.y -= that->style->canvas_box.y;
@@ -596,7 +597,8 @@ static size_t WidgetRenderer_Render(LCUI_WidgetRenderer renderer)
596597
if (!that->has_layer_graph) {
597598
if (that->has_content_graph) {
598599
Graph_Mix(&that->paint->canvas, &that->content_graph,
599-
that->content_left, that->content_top, TRUE);
600+
iround(that->content_left),
601+
iround(that->content_top), TRUE);
600602
}
601603
#ifdef DEBUG_FRAME_RENDER
602604
sprintf(filename, "frame-%lu-%s-canvas-L%d.png", frame++,
@@ -649,8 +651,8 @@ size_t Widget_Render(LCUI_Widget w, LCUI_PaintContext paint)
649651
Widget_ComputeActualBorderBox(w, &style);
650652
Widget_ComputeActualCanvasBox(w, &style);
651653
/* reset widget position to relative paint rect */
652-
style.x = -style.canvas_box.x;
653-
style.y = -style.canvas_box.y;
654+
style.x = (float)-style.canvas_box.x;
655+
style.y = (float)-style.canvas_box.y;
654656
Widget_ComputeActualBorderBox(w, &style);
655657
Widget_ComputeActualCanvasBox(w, &style);
656658
Widget_ComputeActualPaddingBox(w, &style);

0 commit comments

Comments
 (0)