ObjectivelyMVC
Object oriented MVC framework for SDL3 and GNU C
Loading...
Searching...
No Matches
DebugViewController Struct Reference

The DebugViewController type. More...

#include <DebugViewController.h>

Inheritance diagram for DebugViewController:
ViewController

Public Member Functions

Class * _DebugViewController (void)
 The DebugViewController archetype.
 
void debug (DebugViewController *self, const View *view, Renderer *renderer)
 Debugs the given View.
 
DebugViewControllerinit (DebugViewController *self)
 Initializes this DebugViewController.
 
- Public Member Functions inherited from ViewController
Class * _ViewController (void)
 The ViewController archetype.
 
void addChildViewController (ViewController *self, ViewController *childViewController)
 Adds the specified child ViewController to this ViewController.
 
ViewControllerinit (ViewController *self)
 Initializes this ViewController.
 
void loadView (ViewController *self)
 Loads this ViewController's View.
 
void loadViewIfNeeded (ViewController *self)
 Loads this ViewController's View if it is not already loaded.
 
void moveToParentViewController (ViewController *self, ViewController *parentViewController)
 Moves this ViewController to the specified parent.
 
void removeChildViewController (ViewController *self, ViewController *childViewController)
 Removes the specified child ViewController from this ViewController.
 
void removeFromParentViewController (ViewController *self)
 Removes this ViewController from its parent.
 
void renderDeviceDidReset (ViewController *self)
 Informs this ViewController that the render device has reset.
 
void renderDeviceWillReset (ViewController *self)
 Informs this ViewController that the render device will reset.
 
void respondToEvent (ViewController *self, const SDL_Event *event)
 Responds to the given event.
 
void setView (ViewController *self, View *view)
 Sets this ViewController's View.
 
void viewDidAppear (ViewController *self)
 This method is invoked after this ViewController's View is added to the View hierarchy.
 
void viewDidDisappear (ViewController *self)
 This method is invoked after this ViewController's View is removed to the View hierarchy.
 
void viewWillAppear (ViewController *self)
 This method is invoked before this ViewController's View is added to the View hierarchy.
 
void viewWillDisappear (ViewController *self)
 This method is invoked before this ViewController's View is removed from the View hierarchy.
 

Data Fields

TableViewcomputedStyle
 The computed style of the View.
 
const Viewdebug
 The View to debug.
 
Textdescription
 The View description.
 
int frames
 
Textpath
 The path to the debug View.
 
Rendererrenderer
 A weak referece to the current WindowController's renderer.
 
const Viewroot
 The root ancestor of the debug View.
 
TableViewselectors
 The CSS selectors matching the View.
 
Textstatistics
 
Uint64 timestamp
 
ViewController viewController
 The superclass.
 
int visibleViews
 The count of visibile Views.
 
TableViewwarnings
 The warnings generated by the View.
 
- Data Fields inherited from ViewController
Array * childViewControllers
 The child view controllers.
 
ViewControllerInterface * interface
 The interface.
 
Object object
 The superclass.
 
ViewControllerparentViewController
 The parent view controller.
 
Viewview
 The main view.
 

Protected Attributes

DebugViewControllerInterface * interface
 The interface.
 

Detailed Description

The DebugViewController type.

Definition at line 41 of file DebugViewController.h.

Member Function Documentation

◆ _DebugViewController()

Class * _DebugViewController ( void  )

The DebugViewController archetype.

Returns
The DebugViewController Class.

Definition at line 341 of file DebugViewController.c.

341 {
342 static Class *clazz;
343 static Once once;
344
345 do_once(&once, {
346 clazz = _initialize(&(const ClassDef) {
347 .name = "DebugViewController",
348 .superclass = _ViewController(),
349 .instanceSize = sizeof(DebugViewController),
350 .interfaceOffset = offsetof(DebugViewController, interface),
351 .interfaceSize = sizeof(DebugViewControllerInterface),
353 });
354 });
355
356 return clazz;
357}
static void initialize(Class *clazz)
Definition Box.c:123
The DebugViewController type.
DebugViewControllerInterface * interface
The interface.
Class * _ViewController(void)
The ViewController archetype.

◆ debug()

void debug ( DebugViewController self,
const View view,
Renderer renderer 
)

Debugs the given View.

Parameters
selfThe DebugViewController.
viewThe View to debug.
rendererThe Renderer to draw debugging information with.

Definition at line 264 of file DebugViewController.c.

264 {
265
266 if (view != self->debug) {
267 self->debug = view;
268
269 if (self->debug) {
270 self->root = self->debug;
271 while (self->root->superview) {
272 self->root = self->root->superview;
273 }
274
275 String *path = $(self->debug, path);
276 $(self->path, setText, path->chars);
277 release(path);
278
279 String *description = $((Object *) view, description);
280 $(self->description, setText, description->chars);
281 release(description);
282 } else {
283 $(self->path, setText, NULL);
284 $(self->description, setText, NULL);
285 }
286
287 $(self->selectors, reloadData);
288 $((View *) self->selectors, sizeToFit);
289
290 $(self->computedStyle, reloadData);
291 $((View *) self->computedStyle, sizeToFit);
292
293 $(self->warnings, reloadData);
294 $((View *) self->warnings, sizeToFit);
295 }
296
297 self->renderer = renderer;
298 assert(self->renderer);
299
300 self->visibleViews = 0;
301
302 if (self->root) {
303 $((View *) self->root, enumerate, debugEnumerate, self);
304 }
305
306 self->frames++;
307 if (SDL_GetTicks() - self->timestamp >= 1000) {
308
309 $(self->statistics, setTextWithFormat, "%d views, %dfps", self->visibleViews, self->frames);
310
311 self->timestamp = SDL_GetTicks();
312 self->frames = 0;
313 }
314}
static void reloadData(CollectionView *self)
static void debugEnumerate(View *view, ident data)
static void setTextWithFormat(Text *self, const char *fmt,...)
Definition Text.c:558
static void setText(Text *self, const char *text)
Definition Text.c:532
static void enumerate(View *self, ViewEnumerator enumerator, ident data)
Definition View.c:749
static void sizeToFit(View *self)
Definition View.c:1767
TableView * selectors
The CSS selectors matching the View.
const View * debug
The View to debug.
TableView * computedStyle
The computed style of the View.
int visibleViews
The count of visibile Views.
Renderer * renderer
A weak referece to the current WindowController's renderer.
TableView * warnings
The warnings generated by the View.
Text * description
The View description.
const View * root
The root ancestor of the debug View.
Text * path
The path to the debug View.
View * view
The main view.
Views are the fundamental building blocks of ObjectivelyMVC user interfaces.
Definition View.h:134
View * superview
The super View.
Definition View.h:259

◆ init()

Initializes this DebugViewController.

Parameters
selfThe DebugViewController.
Returns
The initialized DebugViewController, or NULL on error.

Definition at line 320 of file DebugViewController.c.

320 {
321 return (DebugViewController *) super(ViewController, self, init);
322}
DebugViewController * init(DebugViewController *self)
Initializes this DebugViewController.
A ViewController manages a View and its descendants.

Field Documentation

◆ computedStyle

TableView* DebugViewController::computedStyle

The computed style of the View.

Definition at line 103 of file DebugViewController.h.

◆ debug

const View* DebugViewController::debug

The View to debug.

Definition at line 57 of file DebugViewController.h.

◆ description

Text* DebugViewController::description

The View description.

Definition at line 93 of file DebugViewController.h.

◆ frames

int DebugViewController::frames

Framerate counters.

Definition at line 82 of file DebugViewController.h.

◆ interface

DebugViewControllerInterface* DebugViewController::interface
protected

The interface.

Definition at line 52 of file DebugViewController.h.

◆ path

Text* DebugViewController::path

The path to the debug View.

Definition at line 77 of file DebugViewController.h.

◆ renderer

Renderer* DebugViewController::renderer

A weak referece to the current WindowController's renderer.

Definition at line 67 of file DebugViewController.h.

◆ root

const View* DebugViewController::root

The root ancestor of the debug View.

Definition at line 62 of file DebugViewController.h.

◆ selectors

TableView* DebugViewController::selectors

The CSS selectors matching the View.

Definition at line 98 of file DebugViewController.h.

◆ statistics

Text* DebugViewController::statistics

The debug statistics.

Definition at line 72 of file DebugViewController.h.

◆ timestamp

Uint64 DebugViewController::timestamp

Definition at line 83 of file DebugViewController.h.

◆ viewController

ViewController DebugViewController::viewController

The superclass.

Definition at line 46 of file DebugViewController.h.

◆ visibleViews

int DebugViewController::visibleViews

The count of visibile Views.

Definition at line 88 of file DebugViewController.h.

◆ warnings

TableView* DebugViewController::warnings

The warnings generated by the View.

Definition at line 108 of file DebugViewController.h.


The documentation for this struct was generated from the following files: