summaryrefslogtreecommitdiff
path: root/src/ui/util.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-10-22 07:22:15 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-10-22 07:22:15 +0300
commitd14f9aebe27cd48a8d21c0eb691c8e7bf94722a8 (patch)
treeda58c38b49dba1c45483eec89ea9408432655aea /src/ui/util.c
parent525c0e24dca01a08ae389b271aee7400ebd8c16b (diff)
Working on tab close buttons
An [x] button appears on tab buttons when hovering on them. Still needs a bit of layout tweaks and the first tab doesn't have a button yet.
Diffstat (limited to 'src/ui/util.c')
-rw-r--r--src/ui/util.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/ui/util.c b/src/ui/util.c
index b18a3292..66704370 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -1436,7 +1436,7 @@ void resizeToLargestPage_Widget(iWidget *tabs) {
1436// puts("... DONE WITH RESIZE TO LARGEST PAGE"); 1436// puts("... DONE WITH RESIZE TO LARGEST PAGE");
1437} 1437}
1438 1438
1439iLabelWidget *tabButtonForPage_Widget_(iWidget *tabs, const iWidget *page) { 1439static iLabelWidget *tabButtonForPage_Widget_(iWidget *tabs, const iWidget *page) {
1440 iWidget *buttons = findChild_Widget(tabs, "tabs.buttons"); 1440 iWidget *buttons = findChild_Widget(tabs, "tabs.buttons");
1441 iForEach(ObjectList, i, buttons->children) { 1441 iForEach(ObjectList, i, buttons->children) {
1442 iAssert(isInstance_Object(i.object, &Class_LabelWidget)); 1442 iAssert(isInstance_Object(i.object, &Class_LabelWidget));
@@ -1448,6 +1448,19 @@ iLabelWidget *tabButtonForPage_Widget_(iWidget *tabs, const iWidget *page) {
1448 return NULL; 1448 return NULL;
1449} 1449}
1450 1450
1451void addTabCloseButton_Widget(iWidget *tabs, const iWidget *page, const char *command) {
1452 iLabelWidget *tabButton = tabButtonForPage_Widget_(tabs, page);
1453// setPadding1_Widget(as_Widget(tabButton), gap_UI / 8);
1454 iLabelWidget *close = addChildFlags_Widget(
1455 as_Widget(tabButton),
1456 iClob(new_LabelWidget(close_Icon,
1457 format_CStr("%s id:%s", command, cstr_String(id_Widget(page))))),
1458 moveToParentRightEdge_WidgetFlag | tight_WidgetFlag | frameless_WidgetFlag |
1459 hidden_WidgetFlag | visibleOnParentHover_WidgetFlag);
1460 updateSize_LabelWidget(close);
1461 printTree_Widget(tabs);
1462}
1463
1451void showTabPage_Widget(iWidget *tabs, const iWidget *page) { 1464void showTabPage_Widget(iWidget *tabs, const iWidget *page) {
1452 if (!page) { 1465 if (!page) {
1453 return; 1466 return;