# HG changeset patch # User Olaf Wintermann # Date 1439980102 -7200 # Node ID d56175dd931eb3d68fa2005e5080a1d405c7d045 # Parent c13e344fa55fe203a9acc4806f8d058925fb1859 improved motif tab look diff -r c13e344fa55f -r d56175dd931e ui/motif/container.c --- a/ui/motif/container.c Sat Apr 04 12:00:32 2015 +0200 +++ b/ui/motif/container.c Wed Aug 19 12:28:22 2015 +0200 @@ -481,6 +481,7 @@ int height = 0; XtVaGetValues(widget, XmNwidth, &width, XmNheight, &height, NULL); int button_width = width / 4; + int button_height = 0; int x = 0; UCX_FOREACH(elm, v->tabs) { UiTab *tab = elm->data; @@ -490,15 +491,44 @@ XmNy, 0, XmNwidth, button_width, + XmNheight, + v->height, NULL); x += button_width; } + + if(height <= v->height) { + XtVaSetValues(widget, XmNheight, v->height + (v->height/7), NULL); + } } static void ui_tabbar_expose(Widget widget, XtPointer udata, XtPointer cdata) { MotifTabbedPane *v = (MotifTabbedPane*)udata; XmDrawingAreaCallbackStruct *cbs = (XmDrawingAreaCallbackStruct *)cdata; XEvent *event = cbs->event; + Display *dpy = XtDisplay(widget); + + XGCValues gcvals; + GC gc; + Pixel fgpix; + + int tab_x; + int tab_width; + XtVaGetValues(v->current->tab_button, XmNx, &tab_x, XmNwidth, &tab_width, XmNhighlightColor, &fgpix, NULL); + + gcvals.foreground = v->bg1; + gc = XCreateGC( dpy, XtWindow(widget), (GCForeground), &gcvals); + + int width = 0; + int height = 0; + XtVaGetValues(widget, XmNwidth, &width, XmNheight, &height, NULL); + XFillRectangle(dpy, XtWindow(widget), gc, 0, 0, width, height); + + gcvals.foreground = fgpix; + gc = XCreateGC( dpy, XtWindow(widget), (GCForeground), &gcvals); + + XFillRectangle(dpy, XtWindow(widget), gc, tab_x, 0, tab_width, height); + } UiTabbedPane* ui_tabbed_document_view(UiObject *obj) { @@ -538,8 +568,7 @@ tabbedpane->tabbar = tabbar; tabbedpane->tabs = NULL; tabbedpane->current = NULL; - - XGCValues gcv; + tabbedpane->height = 0; XtAddCallback(tabbar, XmNresizeCallback , ui_tabbar_resize, tabbedpane); XtAddCallback(tabbar, XmNexposeCallback, ui_tabbar_expose, tabbedpane); @@ -599,6 +628,18 @@ (XtCallbackProc)ui_tab_button_callback, tab); + if(v->height == 0) { + XtVaGetValues( + button, + XmNarmColor, + &v->bg1, + XmNbackground, + &v->bg2, + XmNheight, + &v->height, + NULL); + } + ui_change_tab(v, tab); ui_tabbar_resize(v->tabbar, v, NULL); @@ -621,9 +662,22 @@ UiContext *ctx = tab->content->ctx; ctx->parent->set_document(ctx->parent, ctx->document); + if(pane->current) { + XtVaSetValues(pane->current->tab_button, XmNshadowThickness, 0, XmNbackground, pane->bg1, NULL); + } + XtVaSetValues(tab->tab_button, XmNshadowThickness, 1, XmNbackground, pane->bg2, NULL); + pane->current = tab; pane->index = ucx_list_find(pane->tabs, tab, NULL, NULL); printf("index: %d\n", pane->index); + + // redraw tabbar + Display *dpy = XtDisplay(pane->tabbar); + Window window = XtWindow(pane->tabbar); + if(dpy && window) { + XClearArea(dpy, XtWindow(pane->tabbar), 0, 0, 0, 0, TRUE); + XFlush(dpy); + } } void ui_tab_set_document(UiContext *ctx, void *document) { diff -r c13e344fa55f -r d56175dd931e ui/motif/container.h --- a/ui/motif/container.h Sat Apr 04 12:00:32 2015 +0200 +++ b/ui/motif/container.h Wed Aug 19 12:28:22 2015 +0200 @@ -105,6 +105,9 @@ UcxList *tabs; UiTab *current; int index; + Pixel bg1; + Pixel bg2; + int height; }; struct UiTab {