ObjectivelyMVC 0.1.0
Object oriented MVC framework for OpenGL, SDL2 and GNU C
CollectionView.h
Go to the documentation of this file.
1/*
2 * ObjectivelyMVC: Object oriented MVC framework for OpenGL, SDL2 and GNU 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
26#include <Objectively/IndexPath.h>
27
31
46typedef enum {
50
52
55
56typedef struct CollectionView CollectionView;
57typedef struct CollectionViewInterface CollectionViewInterface;
58
64
68 ident self;
69
74 size_t (*numberOfItems)(const CollectionView *collectionView);
75
82 ident (*objectForItemAtIndexPath)(const CollectionView *collectionView, const IndexPath *indexPath);
83};
84
90
94 ident self;
95
102 void (*didModifySelection)(CollectionView *collectionView, const Array *selectionIndexPaths);
103
110 CollectionItemView *(*itemForObjectAtIndexPath)(const CollectionView *collectionView, const IndexPath *indexPath);
111};
112
119
124
129 CollectionViewInterface *interface;
130
135
140
145
150
154 MutableArray *items;
155
160
165
170};
171
175struct CollectionViewInterface {
176
180 ControlInterface controlInterface;
181
188 void (*deselectAll)(CollectionView *self);
189
197 void (*deselectItemAtIndexPath)(CollectionView *self, const IndexPath *indexPath);
198
206 void (*deselectItemsAtIndexPaths)(CollectionView *self, const Array *indexPaths);
207
216 CollectionView *(*initWithFrame)(CollectionView *self, const SDL_Rect *frame);
217
225 IndexPath *(*indexPathForItem)(const CollectionView *self, const CollectionItemView *item);
226
234 IndexPath *(*indexPathForItemAtPoint)(const CollectionView *self, const SDL_Point *point);
235
243 CollectionItemView *(*itemAtIndexPath)(const CollectionView *self, const IndexPath *indexPath);
244
251 SDL_Size (*naturalSize)(const CollectionView *self);
252
261 void (*reloadData)(CollectionView *self);
262
269 void (*selectAll)(CollectionView *self);
270
277 Array *(*selectionIndexPaths)(const CollectionView *self);
278
286 void (*selectItemAtIndexPath)(CollectionView *self, const IndexPath *indexPath);
287
295 void (*selectItemsAtIndexPaths)(CollectionView *self, const Array *indexPaths);
296};
297
305
The CollectionItemView type.
static void selectAll(CollectionView *self)
static void deselectItemAtIndexPath(CollectionView *self, const IndexPath *indexPath)
static void deselectItemsAtIndexPaths(CollectionView *self, const Array *indexPaths)
static Array * selectionIndexPaths(const CollectionView *self)
static void selectItemsAtIndexPaths(CollectionView *self, const Array *indexPaths)
static SDL_Size naturalSize(const CollectionView *self)
static void selectItemAtIndexPath(CollectionView *self, const IndexPath *indexPath)
static void deselectAll(CollectionView *self)
static void reloadData(CollectionView *self)
OBJECTIVELYMVC_EXPORT const EnumName CollectionViewAxisNames[]
Controls are Views which capture events and dispatch Actions.
ScrollViews allow users to pan their internal contents.
#define OBJECTIVELYMVC_EXPORT
Definition: Types.h:39
CollectionViewAxis
Axis constants for specifying a CollectionView's primary layout direction.
@ CollectionViewAxisHorizontal
@ CollectionViewAxisVertical
CollectionViewItems are a visual representation of an item within a CollectionView.
The CollectionView data source protocol.
size_t(* numberOfItems)(const CollectionView *collectionView)
ident self
The data source self-reference.
ident(* objectForItemAtIndexPath)(const CollectionView *collectionView, const IndexPath *indexPath)
Called by the CollectionView for the associated object of an item.
The CollectionView delegate protocol.
void(* didModifySelection)(CollectionView *collectionView, const Array *selectionIndexPaths)
Called by the CollectionView when items are selected or deselected.
ident self
The delegate self-reference.
CollectionViews display items in a grid.
SDL_Size itemSize
The item size.
CollectionViewAxis axis
The layout axis.
CollectionViewDelegate delegate
The delegate.
CollectionViewInterface * interface
The interface.
Class * _CollectionView(void)
The CollectionView archetype.
Control control
The superclass.
MutableArray * items
The items.
CollectionViewDataSource dataSource
The data source.
ScrollView * scrollView
The scroll view.
SDL_Size itemSpacing
The item spacing.
View * contentView
The content view.
Controls are Views which capture events and dispatch Actions.
Definition: Control.h:83
The SDL_Size type.
Definition: Types.h:62
ScrollViews allow users to pan their internal contents.
Definition: ScrollView.h:62
Views are the fundamental building blocks of ObjectivelyMVC user interfaces.
Definition: View.h:133