ObjectivelyMVC
Object oriented MVC framework for SDL3 and GNU C
Loading...
Searching...
No Matches
ScrollHandle.c File Reference
#include "ScrollHandle.h"

Go to the source code of this file.

Macros

#define _Class   _ScrollHandle
 

Functions

Class * _ScrollHandle (void)
 
static bool captureEvent (Control *self, const SDL_Event *event)
 
static Viewinit (View *self)
 
static void initialize (Class *clazz)
 
static ScrollHandleinitWithFrame (ScrollHandle *self, const SDL_Rect *frame)
 

Macro Definition Documentation

◆ _Class

#define _Class   _ScrollHandle

Definition at line 26 of file ScrollHandle.c.

Function Documentation

◆ _ScrollHandle()

Class * _ScrollHandle ( void  )

Definition at line 102 of file ScrollHandle.c.

102 {
103 static Class *clazz;
104 static Once once;
105
106 do_once(&once, {
107 clazz = _initialize(&(const ClassDef) {
108 .name = "ScrollHandle",
109 .superclass = _Control(),
110 .instanceSize = sizeof(ScrollHandle),
111 .interfaceOffset = offsetof(ScrollHandle, interface),
112 .interfaceSize = sizeof(ScrollHandleInterface),
114 });
115 });
116
117 return clazz;
118}
Class * _Control(void)
Definition Control.c:391
static void initialize(Class *clazz)
A draggable scrollbar handle.

◆ captureEvent()

static bool captureEvent ( Control self,
const SDL_Event *  event 
)
static
See also
Control::captureEvent(Control *, const SDL_Event *)

Definition at line 42 of file ScrollHandle.c.

42 {
43
44 ScrollHandle *this = (ScrollHandle *) self;
45
46 if (event->type == SDL_EVENT_MOUSE_BUTTON_DOWN) {
47 if ($((View *) self, didReceiveEvent, event)) {
48 self->state |= ControlStateHighlighted;
49 return true;
50 }
51 } else if (event->type == SDL_EVENT_MOUSE_MOTION) {
52 if (self->state & ControlStateHighlighted) {
53 if (this->delegate.didDrag) {
54 this->delegate.didDrag(this, event->motion.yrel);
55 }
56 return true;
57 }
58 } else if (event->type == SDL_EVENT_MOUSE_BUTTON_UP) {
59 if (self->state & ControlStateHighlighted) {
60 self->state &= ~ControlStateHighlighted;
61 return true;
62 }
63 }
64
65 return super(Control, self, captureEvent, event);
66}
@ ControlStateHighlighted
Definition Control.h:67
static bool captureEvent(Control *self, const SDL_Event *event)
static bool didReceiveEvent(const View *self, const SDL_Event *event)
Definition View.c:657
Controls are Views which capture and respond to events.
Definition Control.h:83
unsigned int state
The bit mask of ControlState.
Definition Control.h:104
Views are the fundamental building blocks of ObjectivelyMVC user interfaces.
Definition View.h:134

◆ init()

static View * init ( View self)
static
See also
View::init(View *)

Definition at line 33 of file ScrollHandle.c.

33 {
34 return (View *) $((ScrollHandle *) self, initWithFrame, NULL);
35}
static ScrollHandle * initWithFrame(ScrollHandle *self, const SDL_Rect *frame)

◆ initialize()

static void initialize ( Class *  clazz)
static
See also
Class::initialize(Class *)

Definition at line 89 of file ScrollHandle.c.

89 {
90
91 ((ViewInterface *) clazz->interface)->init = init;
92
93 ((ControlInterface *) clazz->interface)->captureEvent = captureEvent;
94
95 ((ScrollHandleInterface *) clazz->interface)->initWithFrame = initWithFrame;
96}
static View * init(View *self)
View * initWithFrame(View *self, const SDL_Rect *frame)
Initializes this View with the specified frame.
Definition View.c:978

◆ initWithFrame()

static ScrollHandle * initWithFrame ( ScrollHandle self,
const SDL_Rect *  frame 
)
static

Definition at line 74 of file ScrollHandle.c.

74 {
75
76 self = (ScrollHandle *) super(Control, self, initWithFrame, frame);
77 if (self) {
78 $((View *) self, addClassName, "handle");
79 }
80
81 return self;
82}
static void addClassName(View *self, const char *className)
Definition View.c:159