SRC += settings.c
SRC += utils.c
SRC += json.c
+SRC += Sidebar.c
OBJ = $(SRC:%.c=$(BUILD_ROOT)/build/application/%.$(OBJ_EXT))
--- /dev/null
+/*
+ * Copyright 2022 Olaf Wintermann
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include "Sidebar.h"
+#include "SidebarP.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+static void sidebar_class_init(void);
+static void sidebar_class_part_init (WidgetClass wc);
+static void sidebar_init(Widget request, Widget neww, ArgList args, Cardinal *num_args);
+static void sidebar_destroy(Widget widget);
+static void sidebar_resize(Widget widget);
+static void sidebar_realize(Widget widget, XtValueMask *mask, XSetWindowAttributes *attributes);
+static void sidebar_expose(Widget widget, XEvent *event, Region region);
+static Boolean sidebar_set_values(Widget old, Widget request, Widget neww, ArgList args, Cardinal *num_args);
+static void sidebar_insert_child(Widget child);
+Boolean sidebar_acceptfocus(Widget widget, Time *time);
+static void FocusInAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
+
+
+static XtResource resources[] = {
+
+};
+
+static XtActionsRec actionslist[] = {
+ {"focusIn", FocusInAP},
+ {"NULL", NULL}
+};
+
+static char defaultTranslations[] = "<FocusIn>: focusIn()";
+
+
+static XtResource constraints[] = {};
+
+SidebarClassRec sidebarWidgetClassRec = {
+ // Core Class
+ {
+ (WidgetClass)&xmManagerClassRec,
+ "XnSidebar", // class_name
+ sizeof(SidebarRec), // widget_size
+ sidebar_class_init, // class_initialize
+ sidebar_class_part_init, // class_part_initialize
+ FALSE, // class_inited
+ sidebar_init, // initialize
+ NULL, // initialize_hook
+ sidebar_realize, // realize
+ actionslist, // actions
+ XtNumber(actionslist), // num_actions
+ resources, // resources
+ XtNumber(resources), // num_resources
+ NULLQUARK, // xrm_class
+ True, // compress_motion
+ True, // compress_exposure
+ True, // compress_enterleave
+ False, // visible_interest
+ sidebar_destroy, // destroy
+ sidebar_resize, // resize
+ sidebar_expose, // expose
+ sidebar_set_values, // set_values
+ NULL, // set_values_hook
+ XtInheritSetValuesAlmost, // set_values_almost
+ NULL, // get_values_hook
+ sidebar_acceptfocus, // accept_focus
+ XtVersion, // version
+ NULL, // callback_offsets
+ defaultTranslations, // tm_table
+ XtInheritQueryGeometry, // query_geometry
+ XtInheritDisplayAccelerator, // display_accelerator
+ NULL, // extension
+ },
+ // Composite Class
+ {
+ XtInheritGeometryManager, // geometry_manager
+ XtInheritChangeManaged, // change_managed
+ sidebar_insert_child, // insert_child
+ XtInheritDeleteChild, // delete_child
+ NULL, // extension
+ },
+ // Constraint Class
+ {
+ constraints, // resources
+ XtNumber(constraints), // num_resources
+ sizeof(XmFormConstraintRec), // constraint_size
+ NULL, // initialize
+ NULL, // destroy
+ NULL, // set_value
+ NULL, // extension
+ },
+ // XmManager Class
+ {
+ XtInheritTranslations, // translations
+ NULL, // syn_resources
+ 0, // num_syn_resources
+ NULL, // syn_constraint_resources
+ 0, // num_syn_constraint_resources
+ XmInheritParentProcess, // parent_process
+ NULL // extension
+ },
+ // Sidebar Class
+ {
+ 0
+ }
+};
+
+WidgetClass xnSidebarWidgetClass = (WidgetClass)&sidebarWidgetClassRec;
+
+
+static void sidebar_class_init(void) {
+
+}
+
+static void sidebar_class_part_init (WidgetClass wc) {
+ SidebarClassRec *sidebarClass = (SidebarClassRec*)wc;
+ XmManagerClassRec *managerClass = (XmManagerClassRec*)xmManagerWidgetClass;
+
+ sidebarClass->constraint_class.initialize = managerClass->constraint_class.initialize;
+ sidebarClass->constraint_class.set_values = managerClass->constraint_class.set_values;
+}
+
+
+
+static void sidebar_init(Widget request, Widget neww, ArgList args, Cardinal *num_args) {
+
+}
+
+
+
+static void sidebar_destroy(Widget widget) {
+
+}
+
+static void sidebar_resize(Widget widget) {
+
+}
+
+static void sidebar_realize(Widget widget, XtValueMask *mask, XSetWindowAttributes *attributes) {
+ (xmManagerClassRec.core_class.realize)(widget, mask, attributes);
+
+
+}
+
+static void sidebar_expose(Widget widget, XEvent *event, Region region) {
+ printf("expose\n");
+ Dimension w, h;
+ XtMakeResizeRequest(widget, 200, 200, &w, &h);
+}
+
+static Boolean sidebar_set_values(Widget old, Widget request, Widget neww, ArgList args, Cardinal *num_args) {
+ Boolean r = False;
+
+ return r;
+}
+
+static void sidebar_insert_child(Widget child) {
+ (xmManagerClassRec.composite_class.insert_child)(child);
+}
+
+Boolean sidebar_acceptfocus(Widget widget, Time *time) {
+ return 0;
+}
+
+
+static void FocusInAP(Widget w, XEvent *event, String *args, Cardinal *nArgs) {
+
+}
+
+
+
+/* --------------------------- public --------------------------- */
+
+Widget CreateSidebar(
+ Widget parent,
+ String name,
+ ArgList arglist,
+ Cardinal argcount)
+{
+ return XtCreateWidget(name, xnSidebarWidgetClass, parent, arglist, argcount);
+}
--- /dev/null
+/*
+ * Copyright 2022 Olaf Wintermann
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef SIDEBAR_H
+#define SIDEBAR_H
+
+#include <Xm/PrimitiveP.h>
+#include <Xm/ManagerP.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+Widget CreateSidebar(
+ Widget parent,
+ String name,
+ ArgList arglist,
+ Cardinal argcount);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* SIDEBAR_H */
+
--- /dev/null
+/*
+ * Copyright 2022 Olaf Wintermann
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef SIDEBARP_H
+#define SIDEBARP_H
+
+
+#include <Xm/XmP.h>
+#include <Xm/PrimitiveP.h>
+#include <Xm/ManagerP.h>
+#include <Xm/FormP.h>
+#include <X11/Intrinsic.h>
+#include <Xm/PrimitiveP.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+typedef struct SidebarData SidebarData;
+struct SidebarData {
+ int a;
+};
+
+
+typedef struct SidebarClassPart {
+ int unused;
+} SidebarClassPart;
+
+typedef struct SidebarClassRec {
+ CoreClassPart core_class;
+ CompositeClassPart composite_class;
+ ConstraintClassPart constraint_class;
+ XmManagerClassPart manager_class;
+ SidebarClassPart sidebar_class;
+} SidebarClassRec;
+
+typedef struct SidebarPart {
+ int a;
+} SidebarPart;
+
+typedef struct SidebarRec {
+ CorePart core;
+ CompositePart composite;
+ ConstraintPart constraint;
+ XmManagerPart manager;
+ SidebarPart sidebar;
+} SidebarRec;
+
+typedef struct SidebarRec *Sidebar;
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* SIDEBARP_H */
+
#include "player.h"
#include "Fsb.h"
+#include "Sidebar.h"
static MainWindow *main_window;
static void PlayRepeatListCB(Widget w, void *udata, void *cdata);
static void PlayAutoPlayCB(Widget w, void *udata, void *cdata);
static void ViewFullscreenCB(Widget w, void *udata, void *cdata);
+static void ViewSidebarCB(Widget w, void *udata, void *cdata);
static void WindowRealized(MainWindow *win);
if(etype == MotionNotify) {
Time cur_motion_time = event->xmotion.time;
+ if(win->player) {
+ win->motion_playback_time = win->player->playback_time;
+ }
+
int x = event->xmotion.x_root;
int y = event->xmotion.y_root;
if(win->cursorhidden && cur_motion_time - win->player_event_time < IGNORE_MOTION_THRESHOLD_MS) {
XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
WindowCreateMenu(window, container, args, n);
+ n = 0;
+ XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
+ XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); 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);
+ //XtManageChild(window->sidebar);
+
n = 0;
XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
+ XtSetArg(args[n], XmNrightWidget, window->sidebar); n++;
XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
XtSetArg(args[n], XmNtopWidget, window->menubar); n++;
EnterWindowMask | KeyPressMask | KeyReleaseMask |
LeaveWindowMask, FALSE, playerEH, window);
-
+
// get F keycode
keycodeF = XKeysymToKeycode(XtDisplay(window->window), XStringToKeysym("F"));
// view menu
createMenuItem(viewMenu, "viewFullscreen", "Fullscreen", 'F', "<Key>F", "F", ViewFullscreenCB, NULL);
+ win->viewSidebarButton = createToggleMenuItem(viewMenu, "viewSidebar", "View Sidebar", 'S', False, NULL, NULL, ViewSidebarCB, win);
}
void go_fullscreen(Display *dsp, Window win)
WindowFullscreen(main_window, FALSE);
} else {
WindowFullscreen(main_window, TRUE);
+ }
+}
+
+static void ViewSidebarCB(Widget w, void *udata, void *cdata) {
+ MainWindow *win = udata;
+ XmToggleButtonCallbackStruct *cb = cdata;
+ if(cb->set) {
+ WindowShowSidebar(win);
+ } else {
+ WindowHideSidebar(win);
}
-
}
void WindowAdjustAspectRatio(MainWindow *win) {
}
win->cursorhidden = False;
}
+
+void WindowHideSidebar(MainWindow *win) {
+ XtUnmanageChild(win->sidebar);
+ XtVaSetValues(win->player_widget, XmNrightAttachment, XmATTACH_FORM, NULL);
+}
+
+void WindowShowSidebar(MainWindow *win) {
+ XtManageChild(win->sidebar);
+ XtVaSetValues(win->player_widget, XmNrightAttachment, XmATTACH_WIDGET, XmNrightWidget, win->sidebar, NULL);
+}
+
Widget window;
Widget menubar;
Widget player_widget;
+ Widget sidebar;
char *file;
Player *player;
bool fullscreen;
bool mbvisible;
+ bool sidebarvisible;
bool cursorhidden;
bool buttongrab;
bool pwbuttonpressed;
Widget playRepeatTrackButton;
Widget playRepeatListButton;
Widget playAutoPlayButton;
+ Widget viewSidebarButton;
Time player_event_time;
Time button_press_time;
void WindowHandlePlayerEvent(MainWindow *win, XEvent *event);
+void WindowHideSidebar(MainWindow *win);
+void WindowShowSidebar(MainWindow *win);
+
#ifdef __cplusplus
}
#endif