Skip to content
This repository was archived by the owner on Oct 13, 2021. It is now read-only.

Add simple border#129

Open
gladmo wants to merge 4 commits intomarcusolsson:masterfrom
ynt:master
Open

Add simple border#129
gladmo wants to merge 4 commits intomarcusolsson:masterfrom
ynt:master

Conversation

@gladmo
Copy link
Copy Markdown

@gladmo gladmo commented Mar 24, 2018

Widget Grid can use SetSimpleBorder() to set the simple border.
look like:

+----------+--------------+------+-----+---------+----------------+
|  FIELD   |     TYPE     | NULL | KEY | DEFAULT |     EXTRA      |
+----------+--------------+------+-----+---------+----------------+
| user_id  | smallint(5)  | NO   | PRI | NULL    | auto_increment |
+----------+--------------+------+-----+---------+----------------+
| username | varchar(10)  | NO   |     | NULL    |                |
+----------+--------------+------+-----+---------+----------------+
| password | varchar(100) | NO   |     | NULL    |                |
+----------+--------------+------+-----+---------+----------------+

default

┌────────────┬──────────────┬───────┬───────┬──────────┬──────────────────┐
│FIELD       │ TYPE         │ NULL  │ KEY   │ DEFAULT  │ EXTRA            │
├────────────┼──────────────┼───────┼───────┼──────────┼──────────────────┤
│ user_id    │ smallint(5)  │ NO    │ PRI   │ NULL     │auto_increment    │
├────────────┼──────────────┼───────┼───────┼──────────┼──────────────────┤
│ username   │ varchar(10)  │ NO    │       │ NULL     │ dog              │
├────────────┼──────────────┼───────┼───────┼──────────┼──────────────────┤
│ password   │ varchar(100) │ NO    │       │ NULL     │ dog              │
└────────────┴──────────────┴───────┴───────┴──────────┴──────────────────┘

@marcusolsson
Copy link
Copy Markdown
Owner

marcusolsson commented Mar 25, 2018

I think this is a nice addition! Although ideally I think this could be considered a global theme setting (I don't see people using both default and simple border in the same application, but I could be wrong. I'm thinking possibly adding a method to the Theme struct (maybe tui.SetBorderStyle(tui.BorderStyleSimple)). Then, instead of checking the border style in each widget, maybe add a new tui.DrawRectangle() to the Painter struct. Since Painter has access to the current theme, you could do the lookup there instead. What do you think?

@gladmo
Copy link
Copy Markdown
Author

gladmo commented Mar 26, 2018

Thanks for your advice.

Before submitting this pr, I thought there were many ways to implement this feature without breaking the original design. One scene that makes me want to use two borders at the same time is that I use tui-go to create a terminal app which has a login page and many forms. The login in example is very pretty, you can display different forms after login. The report uses a simple border to make it look easier.

Making changes in the Painter allows for more flexible functionality and more considerations. Now that I have some good ideas for adding functionality to Painter.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants