Inactive on lv_obj_t

It would be nice to have an inactive option on the base object.

This would add a small amount of code, but result in speedier operation on inactive objects at runtime.

There are examples in the UI Editor where I want to draw controls but not necessairly have them active for interaction. I suppose I could hide them, but that is not really the answer I’d like. I want them visable, just not active.

So my thinking is this:

  1. Add a flag “inactive” to lv_obj_t
  2. If inactive none of the call backs are called for any reason
  3. If there is already an inactive style for the object, use it, otherwise drop to a default inactive style

It seems lv_obj_set_click(obj, false) makes the majority of the job.
It makes the object unclickable so the user can’t interact with the object. However, if the object is in a group, it still can be used. Maybe the click property can be used in groups too…

Click gets half of it. There needs to be a visual cue as well. Like graying out of the object so you can see that it is inactive.

It’s usually not necessary. For example, labels are usually not clickable but should have “normal” color.
So adding twice much style to everything might be overkill.

So IMO it’s better to add a custom function like slider_inactivate(slider, true) to change the styles as you need.

I disagree for 2 reasons:

  1. This is a standard UI paradigm, having inactive on all objects and having a UI cue to show that an object is indeed inactive. I will agree for controls that do not have user input, it doesnt make as much sense. But some labels could indeed be clickable, if you were doing something like a hyper link

  2. For the incoming LVGL programmer, having a simple method of making an object active/inactive would be very easy to understand

So my thinking would be add two items:

  1. A bool for active/inactive to the lv_obj_t and the necessary function(s) to activate, either set_active(bool) or whatever
  2. A new style, default_inactive or whatever for objects that do not have an inactive style

So, from there two work streams open up

  1. For objects that already support inactive, they would poll the base object inactive flag to know if they are to draw active/inactive
  2. For objects that do not have inactive (Label, using your example). If they are inactive, set the style to the base inactive and draw.

It is a bit of work, but makes every widget (New, old and future) behave in the same way.

I see. And what about the compound objects (what has a lot of styles) like a slider, or tabview?