mirror of
https://github.com/rivo/tview.git
synced 2026-04-26 13:25:51 +03:00
[GH-ISSUE #104] Feature: popup/docked menu #82
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#82
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @stephencheng on GitHub (Apr 17, 2018).
Original GitHub issue: https://github.com/rivo/tview/issues/104
The reason I am asking for popup menu is that the list using as menu taking too much space if laid vertically, it just doesn't look proper as a habit if laid horizontally.
Two solutions:
I tried current modal, it seems the way of using it is too much mind twisted. I don't like it for a few reasons:
User need to put it into a page, then hide it, you will have to switch to that page in order to show it. This way, the whole page of modal normally hide the view of your working page. It is not a popup, at least the way using it does not feel intuitive
This modal page is taking a tab page and it is not naturally belongs to the tab pages. If I need one modal window as menu for a tab page for some operations, there would be too many pages used for the modal windows. To avoid displaying the modal window page, when I render the tab number and switch logic, I will have to put special logic for it
Not sure if this is good. But if it's doable and easy to implement, then it should be cool
Allow a triggering key(eg: m for menu) from current focused gui component, eg: page/table/textview etc to trigger the popup modal
For a tab page structured as: flex [(hidden list) | table]. The hidden list won't be showing and take any space. Only when the triggering key is pressed, then the list will be showing and take the space, the table component will take the space as normal. After user select the list item to trigger required function, the list will be hidden again.
Just a thought for your consideration. tview will get better and even cooler :)
@muesli commented on GitHub (Apr 17, 2018):
I do something similar here: https://github.com/muesli/service-tools/blob/master/service-monitor/servicescmd.go#L90 (grep for loglevel).
@stephencheng commented on GitHub (Apr 18, 2018):
@muesli Thanks. I did have a look of the code when you raise an issue previously, but it looks like it's tool running in linux, is it?
Is it possible you could grab a animation gif to show how your menu works? or a quick screen capture video?
@stephencheng commented on GitHub (Apr 18, 2018):
@muesli I managed to get it run in a debian box. It's impressive.
It works, in a way exactly as what I detailed as solution A, and as I mentioned, due to a tview's current implementation, the popup is not a popup window. It shield the foreground view of current window with the entire active page. This also brings a unacceptable bad experience of redraw the whole screen in remote ssh. Even in my local vagrant box, the refresh of the full page is terrible slow.
Also the implementation code will be too not elegant due to lack of such support with a new widget to make top most modal window with a list.
I do like the popup search input, it's a good pattern I will adopt.
Thanks
@stephencheng commented on GitHub (Apr 20, 2018):
@rivo
I was considering a way for simplest support for the docked solution (B)
In this way, take the demo-> presentation -> table code for example:
User could trigger a key, eg: m to show the list menu, after execution of the method, it hide the list menu again.
Just a thought
@rivo commented on GitHub (Apr 23, 2018):
Can we back up a little bit? I have some trouble understanding what you are trying to achieve in the first place. (And I'm sorry but I don't have the time to build and try out applications to figure it out.)
Would it be possible for you to send me a screenshot of what you need with a bit more explanation? (I can think of all kinds of "popup menus". I'm not sure what exactly you're referring to.)
Thanks!
@stephencheng commented on GitHub (Apr 24, 2018):
@rivo
This is what I mean for the solution B:
The request is not really to need you to dev the app, but the capability for user to be able to do it
Let me know if you need more info
@stephencheng commented on GitHub (Apr 24, 2018):
@rivo
This is the idea for the solution A:
@rivo commented on GitHub (Apr 27, 2018):
Thanks for the screenshots. Let's talk about (B) first:
Here, the menu is part of a
Flexlayout. But it should not be visible all the time. So is what you are missing avisibleflag for aFlexitem which you can switch on and off?Regarding (A), I understand that there are some limitations to achieving this:
Modalclass does not allow you to add a menu list.I am planning to let you add
nilelements toFlexandGridlayouts. These would not be drawn but instead keep the background as it is. It would help you for (2), to add your list and make it centered. Let me know if this would help you achieve your goal.In any case, however, I don't see a way around using the
Pageslayout. Every time there are overlapping primitives, you will have to use thePageslayout to make it work consistently.@stephencheng commented on GitHub (Apr 27, 2018):
@rivo Thanks for the idea. Yes, I could make it work using a flex to be removed and re-added to parent flex in sequence of all other items with same parent flex.
I guess to add a SetVisible would definitely make these tedious process smoother.
Some fake code:
By doing above, sol B could be achieved.
I also got the idea of nil element could be used for a place holder to be not drawn. However I am not sure what use case could be. It could only be used as parameter in AddItem, but can not be defined as a variable, hence be referenced.
I am guessing that what you mentioned for (A) seems to indirectly route back to sol B, am I right? I don't get it what you mean I could make the list centered, or could you elaborate it a little more?
@stephencheng commented on GitHub (Apr 28, 2018):
I think I have got your idea of using nil, it works but not perfect.
for example:
If I call the popup menu, it will show:
I used two nil element above flex5 and below flex5, they are just two place holders. The problem of it is that it still hide the content area: box3. I have no idea how the nil element area could help with that. Basically flex2 is the dad of box3 and flex3, you will have to swap to show one or another. Am I missing anything from you idea? is there any way that in this demo, I could still see the content area but the popup appear to be above box3?
@stephencheng commented on GitHub (May 2, 2018):
@rivo closing this for now.
There could be a nice to have exported function but it's all right that I could manage it in my end.
Thanks
@rivo commented on GitHub (May 2, 2018):
Apologies for replying so late. I was very busy in the last few days so I couldn't reply any sooner.
The
niloption forFlexlayouts was there but it wasn't fully implemented. With the latest commit,FlexandGriddon't clear their background per default anymore. So if you havenilitems, other primitives below won't be erased. UsingGridto create a modal is actually even easier.I put an example in the Wiki: https://github.com/rivo/tview/wiki/Modal
Regarding a "visible" flag, I haven't added it yet. If it's really needed, I would probably do something different, for example
SetItemSize(p Primitive, fixedSize, proportion int)and say iffixedSizeandproportionare0, the item will disappear.But if you're ok, I'll leave it the way it is for now.
@stephencheng commented on GitHub (May 5, 2018):
@rivo
Thanks. Your new update works straight away in my demo code. However, it appears that it brought a bug in: the flex I used won't come with border and title. Is this a cost comes with the change, if so I am fine and accept that.
I only use a debug toggle to explicitly show the border and title in development env to understand the layout structure.
If this is a bug, then you might need to fix it in grid too.
Adding a SetItemSize would be definitely very useful and make tview visually more dynamic, fun to use and easy to add more client features. I (as a user) could implement my way for it, it's just a little repetitive to do same thing for multiple tview components. Again, it is a very useful thing to nice to have as builtin. I will leave the decision to you if you think it could benefit many others and also you have some time for it.
Thank you again. It's really nice work.
@stephencheng commented on GitHub (May 8, 2018):
Something to add on as I just spent sometime to verified, the two modal examples using pages are not entirely 'correct' as the page will overwrite each other eventually if you switch one of them on.
My way of doing it is to use flex(or grid[easier]) as layout parent and manage removing all of them and add only required. This is where the visible function needed.
@rivo commented on GitHub (May 12, 2018):
I'm sorry but I have trouble following your explanations. It may just be a language issue so let me address what I do think I understood:
It never did. I haven't made any changes to this part. In fact, none of the primitives come with border and title. If you want it, you have to switch it on explicitly using
SetBorder(true)andSetTitle().The point of the
Pagesclass is that you can have multiple primitives that overlap. This is not possible withFlexorGrid. Modals are typically centered on screen, with the background around it (i.e. "behind it") still visible. That's what the examples show and what you can achieve withPagesandGrid/Flex. That's your solution "A" above. I'm not sure I understand what's not "correct" about it.@stephencheng commented on GitHub (May 13, 2018):
@rivo for the bug, this is what I meant:
The version I used is as below, which introduced "clearing of flex and grid back ground":
With this version, even with SetBorder(true) and SetTitle("whatever"), it will not draw the border and display the title. With previous version, it did render them correctly, that's what I mean the bug is.
The code:
The screen:
This is one version earlier before the change
github.com/rivo/tview@213c37c368@rivo commented on GitHub (May 15, 2018):
Right. Sorry for my cluelessness. ;-) I fixed this. I had wanted to reintroduce it while I fixed the other part but forgot.
It's fixed now.
@stephencheng commented on GitHub (May 16, 2018):
Thanks very much for fixing it
@lenormf commented on GitHub (Jun 15, 2019):
I'm interested in the
visibleflag that would allow to show contextual menus in aFlexlayout, is that doable already?