}
+static int testresize = 1;
static void sidebar_resize(Widget widget) {
-
+ if(testresize) {
+ XtWidgetGeometry geom;
+ geom.request_mode = CWWidth | CWHeight;
+ geom.width = 200;
+ geom.height = 2000;
+ XtWidgetGeometry result;
+ //XtMakeGeometryRequest(widget, &geom, &result);
+ testresize = 0;
+ }
+ printf("resize\n");
}
static int xdnd_initialized = 0;
XtWindow(widget),
visual,
widget->core.colormap);
+
+ Dimension w, h;
+
+ Widget parent = XtParent(widget);
+ XtVaSetValues(parent, XmNbackground, WhitePixelOfScreen(XtScreen(parent)), NULL);
+
+ XtMakeResizeRequest(widget, 200, 100, &w, &h);
+
+
}
static void sidebar_expose(Widget widget, XEvent *event, Region region) {
//printf("expose\n");
Dimension w, h;
- XtMakeResizeRequest(widget, 200, 200, &w, &h);
+ //XtMakeResizeRequest(widget, 200, 2000, &w, &h);
- Sidebar s = (Sidebar)widget;
- XftFont *xftFont = s->sidebar.font->fonts->font;
+ w = widget->core.width;
+ h = widget->core.height;
+ Widget parent = XtParent(widget);
- XftDrawRect(s->sidebar.d, &s->sidebar.bg, 0, 0, s->core.width, s->core.height);
+ Sidebar s = (Sidebar)widget;
+ XftFont *xftFont = s->sidebar.font->fonts->font;
+ UcxList *tracks = s->sidebar.window->playlist.tracks;
+ size_t numTracks = ucx_list_size(tracks);
int fontheight = xftFont->ascent;
int height = s->sidebar.elmHeight;
+ int list_height = numTracks * height;
+ if((list_height > s->core.height) || (w < parent->core.width)) {
+ XtMakeResizeRequest(widget, parent->core.width, list_height, &w, &h);
+ }
+
+
+ XftDrawRect(s->sidebar.d, &s->sidebar.bg, 0, 0, w, h);
+
+
//printf("current track: %d\n", s->sidebar.window->playlist.current_track);
int i = 0;
path[k] = '\0';
PlayListAddFile(s->sidebar.window, path);
+ SidebarRepaint((Widget)s);
free(path);
}
"*pbbutton.shadowThickness: 1",
"*pbbutton.highlightThickness: 1",
-
+
"*XmText.baseTranslations: #override\\n" \
"Ctrl~Alt~Meta<KeyPress>v: paste-clipboard()\\n" \
"Ctrl~Alt~Meta<KeyPress>c: copy-clipboard()\\n" \
XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
XtSetArg(args[n], XmNtopWidget, window->menubar); n++;
XtSetArg(args[n], XmNwidth, 300); n++;
- window->sidebar = CreateSidebar(container, "sidebar", args, n);
+ XtSetArg(args[n], XmNscrollingPolicy, XmAUTOMATIC); n++;
+ XtSetArg(args[n], XmNscrollBarDisplayPolicy, XmAS_NEEDED); n++;
+ XtSetArg(args[n], XmNspacing, 0); n++;
+ XtSetArg(args[n], XmNshadowThickness, 0); n++;
+ window->sidebar_scrolledwindow = XmCreateScrolledWindow(container, "sw_sidebar", args, n);
+ window->sidebar = CreateSidebar(window->sidebar_scrolledwindow, "sidebar", args, 0);
SidebarSetWindow(window->sidebar, window);
+ XtManageChild(window->sidebar);
//XtManageChild(window->sidebar);
-
+
n = 0;
XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
void WindowShowSidebar(MainWindow *win, bool visible) {
if(visible) {
- XtManageChild(win->sidebar);
- XtVaSetValues(win->player_widget, XmNrightAttachment, XmATTACH_WIDGET, XmNrightWidget, win->sidebar, NULL);
+ XtManageChild(win->sidebar_scrolledwindow);
+ XtVaSetValues(win->player_widget, XmNrightAttachment, XmATTACH_WIDGET, XmNrightWidget, win->sidebar_scrolledwindow, NULL);
} else {
- XtUnmanageChild(win->sidebar);
+ XtUnmanageChild(win->sidebar_scrolledwindow);
XtVaSetValues(win->player_widget, XmNrightAttachment, XmATTACH_FORM, NULL);
}
}
Widget window;
Widget menubar;
Widget player_widget;
+ Widget sidebar_scrolledwindow;
Widget sidebar;
char *file;
Player *player;