Description
I have a padding on a child object of around, you can see around 10ish pixels to the left of the white parent box. I expected the lines to be able to hit the edges. I also want this box to be transparent in the end, but I made it visible to try and track down why it wasn’t working as expected.
What MCU/Processor/Board and compiler are you using?
Xilinx Zynq Ultimately, but this is on Mac Simulator VS Code
What LVGL version are you using?
8.0.0
What do you want to achieve?
Remove or know where the padding has come from, I have highlighted in red.
What have you tried so far?
reducing border sizes, padding sizes,
Code to reproduce
Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.
The code block(s) should be formatted like:
#include <stdint.h>
#include "../lvgl/lvgl.h"
#include <stdio.h>
#define H_GUAGE_PADDING 0
static lv_point_t arrow_points[4];
static lv_obj_t * arrow;
//Parent Object
static lv_obj_t * parent;
static uint16_t localWidth;
static int scaleFactor;
void move_horiz_arrow(int16_t position);
void su_horiz_guage(uint16_t posX, uint16_t posY, uint16_t width, uint16_t height, uint16_t screenWidth, uint16_t screenHeight) {
scaleFactor = 65535 / width;
/*Create an array for the points of the line*/
localWidth = width;
//Based on 60 lines
int index;
int numPoints = 61;
int labelSize = 30;
//empty style
static lv_style_t style_empty;
lv_style_init(&style_empty);
//lv_style_set_bg_color(&style_empty, lv_color_black());
//lv_style_set_bg_opa(&style_empty, LV_OPA_100);
//lv_style_set_border_opa(&style_empty, LV_OPA_100);
//lv_style_set_line_width(&style_empty, 1);
//lv_style_set_shadow_width(&style_empty, 0);
//lv_style_set_bg_color(&style, LV_STATE_DEFAULT, LV_COLOR_SILVER);
//lv_style_set_bg_grad_color(&style, LV_STATE_DEFAULT, LV_COLOR_BLUE);
//lv_style_set_bg_grad_dir(&style, LV_STATE_DEFAULT, LV_GRAD_DIR_VER);
/*Add outline*/
//lv_style_set_outline_width(&style_empty, 0);
//lv_style_set_outline_color(&style_empty, lv_color_black());
//lv_style_set_outline_pad(&style_empty, 0);
parent = lv_obj_create(lv_scr_act()); /*Create a parent object on the current screen*/
lv_obj_add_style(parent, &style_empty, 0);
lv_obj_set_size(parent, width, height);
lv_obj_set_pos(parent, posX, posY);
/*Create style*/
static lv_style_t style_line;
lv_style_init(&style_line);
lv_style_set_line_width(&style_line, 3);
lv_style_set_line_color(&style_line, lv_palette_main(LV_PALETTE_BLUE));
lv_style_set_line_rounded(&style_line, true);
/*Create a line and apply the new style*/
arrow = lv_line_create(parent);
lv_line_set_points(arrow, arrow_points, 4); /*Set the points*/
lv_obj_add_style(arrow, &style_line, 0);
//lv_obj_center(line1);
move_horiz_arrow(1000);
static lv_point_t line_points[61][2];// = { {5, 5}, {70, 70}, {120, 10}, {180, 60}, {240, 10} };
for (index = 0; index < numPoints; index++) {
lv_point_t point1;
lv_point_t point2;
point1.x = 0;//H_GUAGE_PADDING + ((((width - H_GUAGE_PADDING)) / numPoints-1) * index);
point2.x = width-40;//H_GUAGE_PADDING + ((((width - H_GUAGE_PADDING)) / numPoints-1) * index);
point1.y = 0;
if (index % 10) {
point2.y = ((height / 8) * 3);
} else {
point2.y = ((height / 8) * 4);
}
line_points[index][0] = point1;
line_points[index][1] = point2;
}
//Create an array for the points of the line
//static lv_point_t line_points[60] = { {5, 5}, {70, 70}, {120, 10}, {180, 60}, {240, 10} };
//Create style
/*static lv_style_t style_line;
lv_style_init(&style_line);
lv_style_set_line_width(&style_line, 4);
lv_style_set_line_color(&style_line, lv_palette_main(LV_PALETTE_BLUE));
lv_style_set_line_rounded(&style_line, true);
*/
//Create a line and apply the new style
lv_obj_t *lines[60];
for (index = 0; index < numPoints; index++) {
lines[0] = lv_line_create(parent);
lv_line_set_points(lines[0], line_points[index], 2); //Set the points
lv_obj_add_style(lines[0], &style_line, 0);
lv_obj_align(lines[0],LV_ALIGN_OUT_TOP_LEFT,-0,0);
if (index % 10 == 0) {
lv_obj_t * label1 = lv_label_create(parent);
int x = H_GUAGE_PADDING + ((((width - H_GUAGE_PADDING )) / numPoints-1) * index) - (labelSize/2);
lv_obj_set_pos(label1, x, 0);
lv_label_set_long_mode(label1, LV_LABEL_LONG_WRAP); //Break the long lines
//lv_label_set_recolor(label1, true); //Enable re-coloring by commands in the text
char text[10];
sprintf(text, "%i", ((index * 3)/2) - 45);
lv_label_set_text(label1, text);
lv_obj_set_width(label1, labelSize); //Set smaller width to make the lines wrap
lv_obj_set_style_text_align(label1, LV_TEXT_ALIGN_CENTER, 0);
//lv_obj_align(label1, LV_ALIGN_BOTTOM_MID, 0, -40);
}
}
}
Screenshot and/or video
If possible, add screenshots and/or videos about the current state.