Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About Text area (lv_ta) style #26

Closed
BenQoo opened this issue Sep 12, 2017 · 9 comments
Closed

About Text area (lv_ta) style #26

BenQoo opened this issue Sep 12, 2017 · 9 comments

Comments

@BenQoo
Copy link
Contributor

BenQoo commented Sep 12, 2017

I have some question about lv_ta on website's document

  1. text style

    http://www.gl.littlev.hu/object-types/text-area-lv_ta

    Style usage

    • ...
    • Text style is inherited from the parent page.

    Dose the "parent page" mean lv_ta's parent must be a lv_page object?
    But it seems that the text style can be accessed from label member in lv_ta.

  2. cursor style

    Style usage

    • ...
    • Cursor width and color comes from the parent's ccolor and line_width style properties.

    I try to create a lv_con as the parent of lv_ta, then change its ccolor and line_width, but it doesn't apply to cursor.

Thank you!

@kisvegabor
Copy link
Member

Hi,
maybe I wasn't clear in the documentation. The Text area is a Page too and the Label inherits its style.
For example:

static lv_style_t style;
lv_style_get(LV_STYLE_PRETTY, &style);
style.ccolor = COLOR_RED;          //Red text
style.mcolor = COLOR_GREEN;        //Green color on the top of Text area

lv_obj_t * ta_1 = lv_ta_create(lv_scr_act(), NULL);
lv_obj_set_style(ta_1, &style);

@BenQoo
Copy link
Contributor Author

BenQoo commented Sep 13, 2017

Hi,
Thanks for your reply.
I tested the following example, but style.ccolor not work on cursor and text.
The color of cursor and text is still in black.

    static lv_style_t style;
    lv_style_get(LV_STYLE_PRETTY, &style);
    style.ccolor = COLOR_RED;          //Red text & red cursor?
    style.mcolor = COLOR_GREEN;        //Green color on the top of Text area
    style.line_width = 5 * LV_DOWNSCALE;

    lv_obj_t * ta_1 = lv_ta_create(lv_scr_act(), NULL);
    lv_obj_set_style(ta_1, &style);
    lv_obj_refr_style(ta_1);

text_area

@BenQoo
Copy link
Contributor Author

BenQoo commented Sep 13, 2017

I have tried and found some ways to change the text color.

  • To set a additional style object to label
  • To change ccolor on the parent object of `lv_ta.

For example:

    static lv_style_t style;
    lv_style_get(LV_STYLE_PRETTY, &style);
    style.ccolor = COLOR_RED;          // Red text
    style.mcolor = COLOR_GREEN;        // Green color on the top of Text area
    style.line_width = 5 * LV_DOWNSCALE;

    lv_obj_t * ta_1 = lv_ta_create(lv_scr_act(), NULL);
    lv_obj_set_style(ta_1, &style);

    /* create style for label */
    static lv_style_t txt_style;
    lv_style_get(LV_STYLE_PRETTY, &txt_style);
    txt_style.ccolor = COLOR_YELLOW;

    lv_obj_t * label = lv_ta_get_label(ta_1);
    lv_obj_set_style(label, &txt_style);

I'm not sure whether the two usages are correct or not.
Because it will become failed if I append the following function calls at the end of code.

lv_obj_refr_style(ta_1);

or

lv_page_set_sb_mode(ta_1, LV_PAGE_SB_MODE_OFF);

@kisvegabor
Copy link
Member

Sorry, I forget to say, already there is bugfix related to this. Please, check out lvgl and misc beta.
Your work around is okay too, but "one style" setting will work too in beta.

I'm not sure whether the two usages are correct or not.
Because it will become failed if I append the following function calls at the end of code.
lv_obj_refr_style(ta_1);
or
lv_page_set_sb_mode(ta_1, LV_PAGE_SB_MODE_OFF);

What do you experience? lv_obj_refr_style(ta_1); is not required because lv_obj_set_style() do it as well.

@BenQoo
Copy link
Contributor Author

BenQoo commented Sep 13, 2017

What do you experience? lv_obj_refr_style(ta_1); is not required because lv_obj_set_style() do it as well.

I misunderstood that lv_obj_set_style() have to notify object the style is changed, so I added lv_obj_refr_style() after it. Thanks for your explanation, I get it!

After testing on beta branch, text portion is working fine now, the cursor width and color are not changed by ccolor and line_width.

@kisvegabor
Copy link
Member

Great! :)

lv_obj_refr_style() is required when your program is running and randomly you modify a style. The object need to be notified. However when you set a new style with lv_obj_set_style() then the object will be refreshed to the new style automatically.

Thank you for reporting the issue. As it is working now I close it!

@BenQoo
Copy link
Contributor Author

BenQoo commented Sep 13, 2017

sorry for my unclear.
On the cursor portion, I still can't control its width and color from lv_ta's ccolor and line_width.

@kisvegabor kisvegabor reopened this Sep 13, 2017
@kisvegabor
Copy link
Member

Sorry, I misread it.
It was strange a behavior. I pushed a fix into beta. Now it also uses the Text area style like the text do.

@kisvegabor
Copy link
Member

Fixed in v5.0.0

perimeno pushed a commit to perimeno/lvgl that referenced this issue Apr 10, 2020
[ili9341] Add helper function to turn on and off the display backlight.
kisvegabor added a commit that referenced this issue Aug 19, 2021
font_conv_for_lists: List parameter specific utility
kisvegabor added a commit that referenced this issue Aug 19, 2021
fix: check malloc result before memcpy, not after
kisvegabor added a commit that referenced this issue Aug 19, 2021
Make the example program buildable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants