ObjectivelyMVC
Object oriented MVC framework for SDL3 and GNU C
Loading...
Searching...
No Matches
CollectionView.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
26#include <Objectively/IndexPath.h>
27
31
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
174
178struct CollectionViewInterface {
179
183 ControlInterface controlInterface;
184
191 void (*deselectAll)(CollectionView *self);
192
200 void (*deselectItemAtIndexPath)(CollectionView *self, const IndexPath *indexPath);
201
209 void (*deselectItemsAtIndexPaths)(CollectionView *self, const Array *indexPaths);
210
219 CollectionView *(*initWithFrame)(CollectionView *self, const SDL_Rect *frame);
220
228 IndexPath *(*indexPathForItem)(const CollectionView *self, const CollectionItemView *item);
229
237 IndexPath *(*indexPathForItemAtPoint)(const CollectionView *self, const SDL_Point *point);
238
246 CollectionItemView *(*itemAtIndexPath)(const CollectionView *self, const IndexPath *indexPath);
247
254 SDL_Size (*naturalSize)(const CollectionView *self);
255
264 void (*reloadData)(CollectionView *self);
265
272 void (*selectAll)(CollectionView *self);
273
280 Array *(*selectionIndexPaths)(const CollectionView *self);
281
289 void (*selectItemAtIndexPath)(CollectionView *self, const IndexPath *indexPath);
290
298 void (*selectItemsAtIndexPaths)(CollectionView *self, const Array *indexPaths);
299};
300
308
The CollectionItemView type.
static Array * selectionIndexPaths(const CollectionView *self)
OBJECTIVELYMVC_EXPORT Class * _CollectionView(void)
OBJECTIVELYMVC_EXPORT const EnumName CollectionViewAxisNames[]
Controls are Views which capture and respond to events.
ScrollViews allow users to pan their internal contents.
#define OBJECTIVELYMVC_EXPORT
Definition Types.h:40
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[0]
The interface type.
Control control
The superclass.
Array * 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 and respond to events.
Definition Control.h:83
ScrollViews allow users to pan their internal contents.
Definition ScrollView.h:61
Views are the fundamental building blocks of ObjectivelyMVC user interfaces.
Definition View.h:225