Add makefile rules

This commit is contained in:
twinaphex 2017-07-03 07:10:23 +02:00
parent 2a6ffd9c3b
commit aed74a008c
9 changed files with 144 additions and 81 deletions

View File

@ -333,6 +333,65 @@ OBJ += libretro-db/bintree.o \
tasks/task_database_cue.o
endif
ifneq ($(C89_BUILD), 1)
HAVE_LIBUI = 0
HAVE_GTKPLUS = 0
ifeq ($(HAVE_LIBUI), 1)
ifeq ($(HAVE_GTKPLUS), 1)
CFLAGS += -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/atk-1.0
LIBS += -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0
OBJ += deps/libui/gtk/alloc.o \
deps/libui/gtk/area.o \
deps/libui/gtk/box.o \
deps/libui/gtk/button.o \
deps/libui/gtk/cellrendererbutton.o \
deps/libui/gtk/checkbox.o \
deps/libui/gtk/child.o \
deps/libui/gtk/colorbutton.o \
deps/libui/gtk/combobox.o \
deps/libui/gtk/control.o \
deps/libui/gtk/datetimepicker.o \
deps/libui/gtk/debug.o \
deps/libui/gtk/draw.o \
deps/libui/gtk/drawmatrix.o \
deps/libui/gtk/drawpath.o \
deps/libui/gtk/drawtext.o \
deps/libui/gtk/editablecombo.o \
deps/libui/gtk/entry.o \
deps/libui/gtk/fontbutton.o \
deps/libui/gtk/form.o \
deps/libui/gtk/future.o \
deps/libui/gtk/graphemes.o \
deps/libui/gtk/grid.o \
deps/libui/gtk/group.o \
deps/libui/gtk/image.o \
deps/libui/gtk/label.o \
deps/libui/gtk/main.o \
deps/libui/gtk/menu.o \
deps/libui/gtk/multilineentry.o \
deps/libui/gtk/progressbar.o \
deps/libui/gtk/radiobuttons.o \
deps/libui/gtk/separator.o \
deps/libui/gtk/slider.o \
deps/libui/gtk/spinbox.o \
deps/libui/gtk/stddialogs.o \
deps/libui/gtk/tab.o \
deps/libui/gtk/text.o \
deps/libui/gtk/util.o \
deps/libui/gtk/window.o
endif
OBJ += deps/libui/common/areaevents.o \
deps/libui/common/control.o \
deps/libui/common/debug.o \
deps/libui/common/matrix.o \
deps/libui/common/shouldquit.o \
deps/libui/common/userbugs.o
endif
endif
# Miscellaneous
ifeq ($(HAVE_STDIN_CMD), 1)

View File

@ -1,4 +1,4 @@
// 24 april 2016
/* 24 april 2016 */
#define uiAreaSignature 0x41726561
#define uiBoxSignature 0x426F784C

View File

@ -1,4 +1,4 @@
// 11 october 2015
/* 11 october 2015 */
#include <math.h>
#include "../ui.h"
#include "uipriv.h"
@ -13,17 +13,17 @@ void uiDrawMatrixSetIdentity(uiDrawMatrix *m)
m->M32 = 0;
}
// The rest of this file provides basic utilities in case the platform doesn't provide any of its own for these tasks.
// Keep these as minimal as possible. They should generally not call other fallbacks.
/* The rest of this file provides basic utilities in case the platform doesn't provide any of its own for these tasks.
* Keep these as minimal as possible. They should generally not call other fallbacks.
// see https://msdn.microsoft.com/en-us/library/windows/desktop/ff684171%28v=vs.85%29.aspx#skew_transform
// TODO see if there's a way we can avoid the multiplication
* see https://msdn.microsoft.com/en-us/library/windows/desktop/ff684171%28v=vs.85%29.aspx#skew_transform
* TODO see if there's a way we can avoid the multiplication */
void fallbackSkew(uiDrawMatrix *m, double x, double y, double xamount, double yamount)
{
uiDrawMatrix n;
uiDrawMatrixSetIdentity(&n);
// TODO explain this
/* TODO explain this */
n.M12 = tan(yamount);
n.M21 = tan(xamount);
n.M31 = -y * tan(xamount);
@ -37,8 +37,9 @@ void scaleCenter(double xCenter, double yCenter, double *x, double *y)
*y = yCenter - (*y * yCenter);
}
// the basic algorithm is from cairo
// but it's the same algorithm as the transform point, just without M31 and M32 taken into account, so let's just do that instead
/* the basic algorithm is from cairo
* but it's the same algorithm as the transform point,
* just without M31 and M32 taken into account, so let's just do that instead */
void fallbackTransformSize(uiDrawMatrix *m, double *x, double *y)
{
uiDrawMatrix m2 = *m;

View File

@ -1,4 +1,4 @@
// 6 april 2015
/* 6 april 2015 */
#ifdef __cplusplus
extern "C" {
#endif
@ -13,7 +13,7 @@ extern void *uiAlloc(size_t, const char *);
extern void *uiRealloc(void *, size_t, const char *);
extern void uiFree(void *);
// ugh, this was only introduced in MSVC 2015...
/* ugh, this was only introduced in MSVC 2015... */
#ifdef _MSC_VER
#define __func__ __FUNCTION__
#endif
@ -25,16 +25,17 @@ extern void _implbug(const char *file, const char *line, const char *func, const
extern void _userbug(const char *file, const char *line, const char *func, const char *format, ...);
#define userbug(...) _userbug(__FILE__, _ns(__LINE__), __func__, __VA_ARGS__)
// control.c
/* control.c */
extern uiControl *newControl(size_t size, uint32_t OSsig, uint32_t typesig, const char *typenamestr);
// shouldquit.c
/* shouldquit.c */
extern int shouldQuit(void);
// areaevents.c
/* areaevents.c */
typedef struct clickCounter clickCounter;
// you should call Reset() to zero-initialize a new instance
// it doesn't matter that all the non-count fields are zero: the first click will fail the curButton test straightaway, so it'll return 1 and set the rest of the structure accordingly
/* you should call Reset() to zero-initialize a new instance
* it doesn't matter that all the non-count fields are zero: the first click will fail the curButton test straightaway, so it'll return 1 and set the rest of the structure accordingly */
struct clickCounter {
int curButton;
int rectX0;
@ -48,7 +49,7 @@ int clickCounterClick(clickCounter *c, int button, int x, int y, uintptr_t time,
extern void clickCounterReset(clickCounter *);
extern int fromScancode(uintptr_t, uiAreaKeyEvent *);
// matrix.c
/* matrix.c */
extern void fallbackSkew(uiDrawMatrix *, double, double, double, double);
extern void scaleCenter(double, double, double *, double *);
extern void fallbackTransformSize(uiDrawMatrix *, double *, double *);

View File

@ -1,4 +1,4 @@
// 7 april 2015
/* 7 april 2015 */
#include <string.h>
#include "uipriv_unix.h"

View File

@ -1,4 +1,4 @@
// 22 april 2015
/* 22 april 2015 */
#define GLIB_VERSION_MIN_REQUIRED GLIB_VERSION_2_40
#define GLIB_VERSION_MAX_ALLOWED GLIB_VERSION_2_40
#define GDK_VERSION_MIN_REQUIRED GDK_VERSION_3_10
@ -18,19 +18,19 @@
#define gtkXPadding 12
#define gtkYPadding 6
// menu.c
/* menu.c */
extern GtkWidget *makeMenubar(uiWindow *);
extern void freeMenubar(GtkWidget *);
extern void uninitMenus(void);
// alloc.c
/* alloc.c */
extern void initAlloc(void);
extern void uninitAlloc(void);
// util.c
/* util.c */
extern void setMargined(GtkContainer *, int);
// child.c
/* child.c */
extern struct child *newChild(uiControl *child, uiControl *parent, GtkContainer *parentContainer);
extern struct child *newChildWithBox(uiControl *child, uiControl *parent, GtkContainer *parentContainer, int margined);
extern void childRemove(struct child *c);
@ -41,25 +41,25 @@ extern void childSetFlag(struct child *c, int flag);
extern GtkWidget *childBox(struct child *c);
extern void childSetMargined(struct child *c, int margined);
// draw.c
/* draw.c */
extern uiDrawContext *newContext(cairo_t *);
extern void freeContext(uiDrawContext *);
// drawtext.c
/* drawtext.c */
extern uiDrawTextFont *mkTextFont(PangoFont *f, gboolean add);
extern PangoFont *pangoDescToPangoFont(PangoFontDescription *pdesc);
// graphemes.c
/* graphemes.c */
extern ptrdiff_t *graphemes(const char *text, PangoContext *context);
// image.c
/* image.c */
/*TODO remove this*/typedef struct uiImage uiImage;
extern cairo_surface_t *imageAppropriateSurface(uiImage *i, GtkWidget *w);
// cellrendererbutton.c
/* cellrendererbutton.c */
extern GtkCellRenderer *newCellRendererButton(void);
// future.c
/* future.c */
extern void loadFutures(void);
extern PangoAttribute *FUTURE_pango_attr_foreground_alpha_new(guint16 alpha);
extern gboolean FUTURE_gtk_widget_path_iter_set_object_name(GtkWidgetPath *path, gint pos, const char *name);

86
deps/libui/ui.h vendored
View File

@ -1,6 +1,6 @@
// 6 april 2015
/* 6 april 2015 */
// TODO add a uiVerifyControlType() function that can be used by control implementations to verify controls
/* TODO add a uiVerifyControlType() function that can be used by control implementations to verify controls */
#ifndef __LIBUI_UI_H__
#define __LIBUI_UI_H__
@ -12,7 +12,7 @@
extern "C" {
#endif
// this macro is generated by cmake
/* this macro is generated by cmake */
#ifdef libui_EXPORTS
#ifdef _WIN32
#define _UI_EXTERN __declspec(dllexport) extern
@ -20,19 +20,19 @@ extern "C" {
#define _UI_EXTERN __attribute__((visibility("default"))) extern
#endif
#else
// TODO add __declspec(dllimport) on windows, but only if not static
/* TODO add __declspec(dllimport) on windows, but only if not static */
#define _UI_EXTERN extern
#endif
// C++ is really really really really really really dumb about enums, so screw that and just make them anonymous
// This has the advantage of being ABI-able should we ever need an ABI...
/* C++ is really really really really really really dumb about enums, so screw that and just make them anonymous
* This has the advantage of being ABI-able should we ever need an ABI... */
#define _UI_ENUM(s) typedef unsigned int s; enum
// This constant is provided because M_PI is nonstandard.
// This comes from Go's math.Pi, which in turn comes from http://oeis.org/A000796.
/* This constant is provided because M_PI is nonstandard.
* This comes from Go's math.Pi, which in turn comes from http://oeis.org/A000796. */
#define uiPi 3.14159265358979323846264338327950288419716939937510582097494459
// TODO uiBool?
/* TODO uiBool? */
typedef struct uiInitOptions uiInitOptions;
@ -73,7 +73,7 @@ struct uiControl {
void (*Enable)(uiControl *);
void (*Disable)(uiControl *);
};
// TOOD add argument names to all arguments
/* TOOD add argument names to all arguments */
#define uiControl(this) ((uiControl *) (this))
_UI_EXTERN void uiControlDestroy(uiControl *);
_UI_EXTERN uintptr_t uiControlHandle(uiControl *);
@ -90,7 +90,7 @@ _UI_EXTERN void uiControlDisable(uiControl *);
_UI_EXTERN uiControl *uiAllocControl(size_t n, uint32_t OSsig, uint32_t typesig, const char *typenamestr);
_UI_EXTERN void uiFreeControl(uiControl *);
// TODO make sure all controls have these
/* TODO make sure all controls have these */
_UI_EXTERN void uiControlVerifySetParent(uiControl *, uiControl *);
_UI_EXTERN int uiControlEnabledToUser(uiControl *);
@ -174,10 +174,11 @@ _UI_EXTERN int uiGroupMargined(uiGroup *g);
_UI_EXTERN void uiGroupSetMargined(uiGroup *g, int margined);
_UI_EXTERN uiGroup *uiNewGroup(const char *title);
// spinbox/slider rules:
// setting value outside of range will automatically clamp
// initial value is minimum
// complaint if min >= max?
/* spinbox/slider rules:
* setting value outside of range will automatically clamp
* initial value is minimum
* complaint if min >= max?
*/
typedef struct uiSpinbox uiSpinbox;
#define uiSpinbox(this) ((uiSpinbox *) (this))
@ -217,7 +218,7 @@ typedef struct uiEditableCombobox uiEditableCombobox;
_UI_EXTERN void uiEditableComboboxAppend(uiEditableCombobox *c, const char *text);
_UI_EXTERN char *uiEditableComboboxText(uiEditableCombobox *c);
_UI_EXTERN void uiEditableComboboxSetText(uiEditableCombobox *c, const char *text);
// TODO what do we call a function that sets the currently selected item and fills the text field with it? editable comboboxes have no consistent concept of selected item
/* TODO what do we call a function that sets the currently selected item and fills the text field with it? editable comboboxes have no consistent concept of selected item */
_UI_EXTERN void uiEditableComboboxOnChanged(uiEditableCombobox *c, void (*f)(uiEditableCombobox *c, void *data), void *data);
_UI_EXTERN uiEditableCombobox *uiNewEditableCombobox(void);
@ -235,7 +236,7 @@ _UI_EXTERN uiDateTimePicker *uiNewDateTimePicker(void);
_UI_EXTERN uiDateTimePicker *uiNewDatePicker(void);
_UI_EXTERN uiDateTimePicker *uiNewTimePicker(void);
// TODO provide a facility for entering tab stops?
/* TODO provide a facility for entering tab stops? */
typedef struct uiMultilineEntry uiMultilineEntry;
#define uiMultilineEntry(this) ((uiMultilineEntry *) (this))
_UI_EXTERN char *uiMultilineEntryText(uiMultilineEntry *e);
@ -291,7 +292,8 @@ struct uiAreaHandler {
// TODO RTL layouts?
// TODO reconcile edge and corner naming
_UI_ENUM(uiWindowResizeEdge) {
_UI_ENUM(uiWindowResizeEdge)
{
uiWindowResizeEdgeLeft,
uiWindowResizeEdgeTop,
uiWindowResizeEdgeRight,
@ -299,10 +301,10 @@ _UI_ENUM(uiWindowResizeEdge) {
uiWindowResizeEdgeTopLeft,
uiWindowResizeEdgeTopRight,
uiWindowResizeEdgeBottomLeft,
uiWindowResizeEdgeBottomRight,
// TODO have one for keyboard resizes?
// TODO GDK doesn't seem to have any others, including for keyboards...
// TODO way to bring up the system menu instead?
uiWindowResizeEdgeBottomRight
/* TODO have one for keyboard resizes?
* TODO GDK doesn't seem to have any others, including for keyboards...
* TODO way to bring up the system menu instead? */
};
#define uiArea(this) ((uiArea *) (this))
@ -346,29 +348,29 @@ _UI_ENUM(uiDrawBrushType) {
uiDrawBrushTypeSolid,
uiDrawBrushTypeLinearGradient,
uiDrawBrushTypeRadialGradient,
uiDrawBrushTypeImage,
uiDrawBrushTypeImage
};
_UI_ENUM(uiDrawLineCap) {
uiDrawLineCapFlat,
uiDrawLineCapRound,
uiDrawLineCapSquare,
uiDrawLineCapSquare
};
_UI_ENUM(uiDrawLineJoin) {
uiDrawLineJoinMiter,
uiDrawLineJoinRound,
uiDrawLineJoinBevel,
uiDrawLineJoinBevel
};
// this is the default for botoh cairo and Direct2D (in the latter case, from the C++ helper functions)
// Core Graphics doesn't explicitly specify a default, but NSBezierPath allows you to choose one, and this is the initial value
// so we're good to use it too!
/* this is the default for botoh cairo and Direct2D (in the latter case, from the C++ helper functions)
* Core Graphics doesn't explicitly specify a default, but NSBezierPath allows you to choose one, and this is the initial value
* so we're good to use it too! */
#define uiDrawDefaultMiterLimit 10.0
_UI_ENUM(uiDrawFillMode) {
uiDrawFillModeWinding,
uiDrawFillModeAlternate,
uiDrawFillModeAlternate
};
struct uiDrawMatrix {
@ -383,13 +385,13 @@ struct uiDrawMatrix {
struct uiDrawBrush {
uiDrawBrushType Type;
// solid brushes
/* solid brushes */
double R;
double G;
double B;
double A;
// gradient brushes
/* gradient brushes */
double X0; // linear: start X, radial: start X
double Y0; // linear: start Y, radial: start Y
double X1; // linear: end X, radial: outer circle center X
@ -502,13 +504,13 @@ _UI_ENUM(uiDrawTextWeight) {
uiDrawTextWeightBold,
uiDrawTextWeightUltraBold,
uiDrawTextWeightHeavy,
uiDrawTextWeightUltraHeavy,
uiDrawTextWeightUltraHeavy
};
_UI_ENUM(uiDrawTextItalic) {
uiDrawTextItalicNormal,
uiDrawTextItalicOblique,
uiDrawTextItalicItalic,
uiDrawTextItalicItalic
};
_UI_ENUM(uiDrawTextStretch) {
@ -520,7 +522,7 @@ _UI_ENUM(uiDrawTextStretch) {
uiDrawTextStretchSemiExpanded,
uiDrawTextStretchExpanded,
uiDrawTextStretchExtraExpanded,
uiDrawTextStretchUltraExpanded,
uiDrawTextStretchUltraExpanded
};
struct uiDrawTextFontDescriptor {
@ -561,10 +563,10 @@ _UI_EXTERN void uiDrawTextLayoutSetColor(uiDrawTextLayout *layout, int startChar
_UI_EXTERN void uiDrawText(uiDrawContext *c, double x, double y, uiDrawTextLayout *layout);
_UI_ENUM(uiModifiers) {
uiModifierCtrl = 1 << 0,
uiModifierAlt = 1 << 1,
uiModifierCtrl = 1 << 0,
uiModifierAlt = 1 << 1,
uiModifierShift = 1 << 2,
uiModifierSuper = 1 << 3,
uiModifierSuper = 1 << 3
};
// TODO document drag captures
@ -626,7 +628,7 @@ _UI_ENUM(uiExtKey) {
uiExtKeyNAdd,
uiExtKeyNSubtract,
uiExtKeyNMultiply,
uiExtKeyNDivide,
uiExtKeyNDivide
};
struct uiAreaKeyEvent {
@ -641,9 +643,9 @@ struct uiAreaKeyEvent {
typedef struct uiFontButton uiFontButton;
#define uiFontButton(this) ((uiFontButton *) (this))
// TODO document this returns a new font
/* TODO document this returns a new font */
_UI_EXTERN uiDrawTextFont *uiFontButtonFont(uiFontButton *b);
// TOOD SetFont, mechanics
/* TOOD SetFont, mechanics */
_UI_EXTERN void uiFontButtonOnChanged(uiFontButton *b, void (*f)(uiFontButton *, void *), void *data);
_UI_EXTERN uiFontButton *uiNewFontButton(void);
@ -666,14 +668,14 @@ _UI_ENUM(uiAlign) {
uiAlignFill,
uiAlignStart,
uiAlignCenter,
uiAlignEnd,
uiAlignEnd
};
_UI_ENUM(uiAt) {
uiAtLeading,
uiAtTop,
uiAtTrailing,
uiAtBottom,
uiAtBottom
};
typedef struct uiGrid uiGrid;

12
deps/libui/ui_unix.h vendored
View File

@ -1,4 +1,4 @@
// 7 april 2015
/* 7 april 2015 */
/*
This file assumes that you have included <gtk/gtk.h> and "ui.h" beforehand. It provides API-specific functions for interfacing with foreign controls on Unix systems that use GTK+ to provide their UI (currently all except Mac OS X).
@ -19,7 +19,7 @@ struct uiUnixControl {
void (*SetContainer)(uiUnixControl *, GtkContainer *, gboolean);
};
#define uiUnixControl(this) ((uiUnixControl *) (this))
// TODO document
/* TODO document */
_UI_EXTERN void uiUnixControlSetContainer(uiUnixControl *, GtkContainer *, gboolean);
#define uiUnixControlDefaultDestroy(type) \
@ -80,7 +80,7 @@ _UI_EXTERN void uiUnixControlSetContainer(uiUnixControl *, GtkContainer *, gbool
{ \
gtk_widget_set_sensitive(type(c)->widget, FALSE); \
}
// TODO this whole addedBefore stuff is a MASSIVE HACK.
/* TODO this whole addedBefore stuff is a MASSIVE HACK. */
#define uiUnixControlDefaultSetContainer(type) \
static void type ## SetContainer(uiUnixControl *c, GtkContainer *container, gboolean remove) \
{ \
@ -112,7 +112,7 @@ _UI_EXTERN void uiUnixControlSetContainer(uiUnixControl *, GtkContainer *, gbool
uiUnixControlDefaultDestroy(type) \
uiUnixControlAllDefaultsExceptDestroy(type)
// TODO document
/* TODO document */
#define uiUnixNewControl(type, var) \
var = type(uiUnixAllocControl(sizeof (type), type ## Signature, #type)); \
uiControl(var)->Destroy = type ## Destroy; \
@ -127,10 +127,10 @@ _UI_EXTERN void uiUnixControlSetContainer(uiUnixControl *, GtkContainer *, gbool
uiControl(var)->Enable = type ## Enable; \
uiControl(var)->Disable = type ## Disable; \
uiUnixControl(var)->SetContainer = type ## SetContainer;
// TODO document
/* TODO document */
_UI_EXTERN uiUnixControl *uiUnixAllocControl(size_t n, uint32_t typesig, const char *typenamestr);
// uiUnixStrdupText() takes the given string and produces a copy of it suitable for being freed by uiFreeText().
/* uiUnixStrdupText() takes the given string and produces a copy of it suitable for being freed by uiFreeText(). */
_UI_EXTERN char *uiUnixStrdupText(const char *);
#ifdef __cplusplus

View File

@ -1,4 +1,4 @@
// 21 april 2016
/* 21 april 2016 */
#include "winapi.hpp"
#include "../ui.h"
#include "../ui_windows.h"
@ -6,15 +6,15 @@
#include "resources.hpp"
#include "compilerver.hpp"
// ui internal window messages
/* ui internal window messages */
enum {
// redirected WM_COMMAND and WM_NOTIFY
/* redirected WM_COMMAND and WM_NOTIFY */
msgCOMMAND = WM_APP + 0x40, // start offset just to be safe
msgNOTIFY,
msgHSCROLL,
msgQueued,
msgD2DScratchPaint,
msgD2DScratchLButtonDown,
msgD2DScratchLButtonDown
};
// alloc.cpp