Wed, 19 Aug 2015 12:28:22 +0200
improved motif tab look
ui/motif/container.c | file | annotate | diff | comparison | revisions | |
ui/motif/container.h | file | annotate | diff | comparison | revisions |
--- 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) {