Description
I have a simple 4 colour theme (black, white, grey and one colour) and it’s easier to get the checkbox to behave how I want by removing all styles on it and then adding my own. However, when I do this, the checkmark is non-existent.
What MCU/Processor/Board and compiler are you using?
esp32, custom board
What LVGL version are you using?
8.3.6
What do you want to achieve?
Restore the check mark
What have you tried so far?
Saved the font, deleted the styles on the LV_PART_INDICATOR, added the font back, and set the style on other things that matter. I wrapped the 8.3.6 API in C++ so the code below is in C++, but it’s a direct mapping.
Code to reproduce
chkboxFnt = obj->GetStyleTextFont( LV_PART_INDICATOR );
obj->RemoveStyleAll();
obj->SetStylePadColumn( 5, LV_PART_MAIN );
obj->AddStyle( &txtStyle, LV_PART_MAIN );
obj->AddStyle( &txtEnbldStyle, LV_PART_MAIN );
obj->AddStyle( &txtDsbldStyle, LV_PART_MAIN | LV_STATE_DISABLED );
obj->SetStyleTextFont( &chkboxFnt, LV_PART_INDICATOR | LV_STATE_CHECKED );
obj->SetStyleTextFont( &chkboxFnt, LV_PART_INDICATOR | LV_STATE_CHECKED | LV_STATE_DISABLED );
obj->AddStyle( &txtStyle, LV_PART_INDICATOR | LV_STATE_CHECKED );
obj->AddStyle( &txtStyle, LV_PART_INDICATOR | LV_STATE_DISABLED );
obj->AddStyle( &txtEnbldStyle, LV_PART_INDICATOR | LV_STATE_CHECKED );
obj->AddStyle( &txtDsbldStyle, LV_PART_INDICATOR | LV_STATE_DISABLED );
obj->AddStyle( &brdrBoxStyle, LV_PART_INDICATOR );
obj->AddStyle( &brdrBoxStyle, LV_PART_INDICATOR | LV_STATE_DISABLED );
obj->AddStyle( &brdrBoxEnbldStyle, LV_PART_INDICATOR );
obj->AddStyle( &brdrBoxDsbldStyle, LV_PART_INDICATOR | LV_STATE_DISABLED );
My styles were set up as follows:
txtStyle.SetBGOpa( LV_OPA_0 );
txtStyle.SetTextOpa( LV_OPA_COVER );
txtEnbldStyle.SetTextColor( ColourSchemeToColour());
txtDsbldStyle.SetTextColor( lv_color_hex( 0x333333 ));
brdrBoxStyle.SetBorderWidth( 1 );
brdrBoxStyle.SetRadius( 3 );
brdrBoxStyle.SetBGOpa( LV_OPA_0 );
brdrBoxStyle.SetBGColor(lv_color_hex(0x000000)); // for the dropdown list
brdrBoxEnbldStyle.SetBorderColor( lv_color_hex( 0xFFFFFF ));
brdrBoxDsbldStyle.SetBorderColor(lv_color_hex( 0x333333 ));
brdrBoxInvalidStyle.SetBorderColor(lv_color_hex( 0xFF0000 ));
The checkbox on the left is checked and the one on the right is not checked. The border of the indicator is correct, but no check mark.