Skip to content

Show / Hide / Enable / Disable widgets #125

Closed

Description

@redtide

I haven't found any function that can make some element to be visible or not, neither to enable or disable, is there some way currently?

Activity

  1. Xeverous commented on May 30, 2020

    @Xeverous
    Contributor

    popup? If not, you can always make your own by inheriting from the desired element and overriding draw. If you want the disable element to also not occupy space, override limits aswell.

  2. djowel commented on May 30, 2020

    @djowel
    Member

    I haven't found any function that can make some element to be visible or not, neither to enable or disable, is there some way currently?

    Good point. It's very easy to add a proxy class that allows it to inhibit the drawing of its subject. That is the way to do it. And yes, it should be part of the library. The visibility state should probably be a callback function like the one in basic_menu_item_element:

    https://github.com/cycfi/elements/blob/master/lib/include/elements/element/menu.hpp#L113

  3. djowel commented on May 30, 2020

    @djowel
    Member

    Maybe something like this usage:

    auto e = share(hidable(some_element));
    e-> is_visible = []{ return show_my_element_function(); /*return show-or-hide-state*/ }
  4. djowel commented on May 30, 2020

    @djowel
    Member

    If you want the disable element to also not occupy space, override limits aswell.

    Perhaps we also want a collapsible proxy for that.

  5. redtide commented on May 30, 2020

    @redtide
    ContributorAuthor

    Thank you for the quick replies and suggestions! I'll try them soon. Do I keep this issue open for a future implementation in the library?

  6. Xeverous commented on May 30, 2020

    @Xeverous
    Contributor

    Do I keep this issue open for a future implementation in the library?

    I would keep it. So far all of the issues were only closed when the topic was fully exhausted (by a PR or detailed "wontfix" explanation).

  7. djowel commented on May 30, 2020

    @djowel
    Member

    Thank you for the quick replies and suggestions! I'll try them soon. Do I keep this issue open for a future implementation in the library?

    Yes, please keep it open. These are very easy to add. I'll see if I can add them as soon as I can.

  8. djowel commented on May 30, 2020

    @djowel
    Member

    I got bored... I added hidable:

    https://github.com/cycfi/elements/blob/develop/lib/include/elements/element/misc.hpp#L216-L246

    and hcollapsible and vcollapsible:

    https://github.com/cycfi/elements/blob/develop/lib/include/elements/element/size.hpp#L655-L725

    More on ... "enable"-ability later... It's a bit more involved.

  9. Xeverous commented on Jun 10, 2020

    @Xeverous
    Contributor

    Will these block eg a button? That is, if I hide or collapse a button will it still be able to receive events?

  10. djowel commented on Jun 10, 2020

    @djowel
    Member

    Will these block eg a button? That is, if I hide or collapse a button will it still be able to receive events?

    yes they will. if you want it not to, that should probably be the enable proxy, which is doable now that we have event based receivers and senders. (btw, layer based buttons are completely removed in the use-basic_button branch)

  11. Xeverous commented on Jun 10, 2020

    @Xeverous
    Contributor

    Will these block eg a button? That is, if I hide or collapse a button will it still be able to receive events?

    yes they will.

    My two questions have opposite meaning so I find your answer to be ambiguous.

    Nonetheless, I think I can currently easily workaround my use case by swapping empty box or another element in the same place.

  12. djowel commented on Jun 11, 2020

    @djowel
    Member

    My two questions have opposite meaning so I find your answer to be ambiguous.

    Simply: you can have it either way. Swapping empty box is of course another way.

  13. Xeverous commented on Jun 11, 2020

    @Xeverous
    Contributor

    Swapping empty box is of course another way.

    Actually the deck is what I want. I want the swapped element to occupy the same space and replace it with something different depending on some runtime condition. deck::select is what I actually need.

  14. jpcima commented on Jun 14, 2020

    @jpcima
    Contributor

    Thanks I would like to use vcollapsible, but the component draws even when collapsed.
    Should not draw be overriden also ?

  15. Xeverous commented on Jun 14, 2020

    @Xeverous
    Contributor

    What is the difference between hidden and collapsed elements?

    • hidden - occupies space but is not beign drawn?
    • collapsed - does not occupy any space, as if it did not exist?

    Am I right?

  16. jpcima commented on Jun 14, 2020

    @jpcima
    Contributor

    @Xeverous This is how I understand it also.

    As illustration of the problem, there is a collapsed button.
    You can see the slider thumb will overlap it.

    Capture du 2020-06-14 18-59-02

  17. djowel commented on Jun 14, 2020

    @djowel
    Member

    Thanks I would like to use vcollapsible, but the component draws even when collapsed.
    Should not draw be overriden also ?

    I would imagine that the element will not draw if it has zero space, so there must be a bug somewhere. Admittedly, the collapsible thingies haven't been tested yet. Can you make an MCVE that I can use to try this? I am guessing that the minimum limits of the element being collapsed (a button?) is being violated, so it's not as simple as I originally thought (perhaps the collapsible's subject should be swapped out with an empty element when collapsed).

  18. jpcima commented on Jun 14, 2020

    @jpcima
    Contributor

    Based on the example SpriteSlidersAndKnobs
    sfztools@13bd7d0

    The issue is present here although not as pronounced, and I don't find how to make it so as much as illustrated above.

    It has a small observable amount of overlap between button and thumb.
    Enabling the #if 0 part to disable the use collapsible, it expands itself in a different layout which is more compressed and not overlapped.

  19. djowel commented on Jun 14, 2020

    @djowel
    Member

    I get it. Yes, my intuition was correct. The initial implementation was naive and incorrect. I should swap out the subject with an empty element when collapsed. A deck would probably be sufficient. It shouldn't be difficult, but I am swamped right now. Can you wait a little bit for a few days?

  20. jpcima commented on Jun 14, 2020

    @jpcima
    Contributor

    Sure it can wait no problem. There's no fire to the lake :)

  21. locked and limited conversation to collaborators on Oct 20, 2023
  22. converted this issue into a discussion #328 on Oct 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions