ObjectivelyMVC
Object oriented MVC framework for SDL3 and GNU C
Loading...
Searching...
No Matches
View+JSON.h
Go to the documentation of this file.
1/*
2 * ObjectivelyMVC: Object oriented MVC framework for SDL3 and C.
3 * Copyright (C) 2014 Jay Dolan <jay@jaydolan.com>
4 *
5 * This software is provided 'as-is', without any express or implied
6 * warranty. In no event will the authors be held liable for any damages
7 * arising from the use of this software.
8 *
9 * Permission is granted to anyone to use this software for any purpose,
10 * including commercial applications, and to alter it and redistribute it
11 * freely, subject to the following restrictions:
12 *
13 * 1. The origin of this software must not be misrepresented; you must not
14 * claim that you wrote the original software. If you use this software
15 * in a product, an acknowledgment in the product documentation would be
16 * appreciated but is not required.
17 *
18 * 2. Altered source versions must be plainly marked as such, and must not be
19 * misrepresented as being the original software.
20 *
21 * 3. This notice may not be removed or altered from any source distribution.
22 */
23
24#pragma once
25
27
142
143typedef struct Inlet Inlet;
144
149struct Inlet {
150
154 const char *name;
155
160
164 ident dest;
165
169 ident data;
170};
171
180typedef void (*InletBinding)(const Inlet *inlet, ident obj);
181
186
187typedef struct Outlet Outlet;
188
194struct Outlet {
195
199 const char *identifier;
200
205};
206
210#define MakeInlet(name, type, dest, data) (Inlet) { (name), (type), (dest), (ident) (data) }
211
215#define MakeInlets(...) \
216 { \
217 __VA_ARGS__, \
218 MakeInlet(NULL, InitTypeEnd, NULL, NULL) \
219 }
220
224#define MakeOutlet(identifier, view) (Outlet) { (identifier), (View **) (view) }
225
229#define MakeOutlets(...) \
230 { \
231 __VA_ARGS__, \
232 MakeOutlet(NULL, NULL) \
233 }
234
238#define BindInlet(inlet, obj) (inletBindings[(inlet)->type])(inlet, (ident) obj)
239
246OBJECTIVELYMVC_EXPORT bool bindInlets(const Inlet *inlets, const Dictionary *dictionary);
ObjectivelyMVC base types.
#define OBJECTIVELYMVC_EXPORT
Definition Types.h:40
InletType
Inlet type constants.
Definition View+JSON.h:36
@ InletTypeSubviews
Definition View+JSON.h:116
@ InletTypeStyle
Definition View+JSON.h:110
@ InletTypeDouble
Definition View+JSON.h:67
@ InletTypeEnum
Definition View+JSON.h:75
@ InletTypePoint
Definition View+JSON.h:94
@ InletTypeCharacters
Definition View+JSON.h:52
@ InletTypeBool
Definition View+JSON.h:46
@ InletTypeClassNames
Definition View+JSON.h:57
@ InletTypeInteger
Definition View+JSON.h:89
@ InletTypeApplicationDefined
Definition View+JSON.h:139
@ InletTypeColor
Definition View+JSON.h:62
@ InletTypeView
Definition View+JSON.h:133
@ InletTypeSize
Definition View+JSON.h:104
@ InletTypeFloat
Definition View+JSON.h:80
@ InletTypeRectangle
Definition View+JSON.h:99
@ InitTypeEnd
Definition View+JSON.h:41
void(* InletBinding)(const Inlet *inlet, ident obj)
A function pointer for Inlet binding.
Definition View+JSON.h:180
OBJECTIVELYMVC_EXPORT const InletBinding inletBindings[]
The Array of InletBindings, indexed by InletType.
Definition View+JSON.h:185
OBJECTIVELYMVC_EXPORT bool bindInlets(const Inlet *inlets, const Dictionary *dictionary)
Binds each Inlet specified in inlets to the data provided in dictionary.
Definition View+JSON.c:303
Inlets enable inbound data binding of View attributes through JSON.
Definition View+JSON.h:149
const char * name
The Inlet name, e.g. "alignment".
Definition View+JSON.h:154
InletType type
The InletType, e.g. InletTypeEnum.
Definition View+JSON.h:159
ident data
Type-specific data, e.g. an array of EnumNames.
Definition View+JSON.h:169
ident dest
The Inlet destination.
Definition View+JSON.h:164
Outlets enable outbound data binding of Views through JSON.
Definition View+JSON.h:194
const char * identifier
The View identifier.
Definition View+JSON.h:199
View ** view
The output storage for the resolved View.
Definition View+JSON.h:204
Views are the fundamental building blocks of ObjectivelyMVC user interfaces.
Definition View.h:225