Moved a tonne of code around
This commit is contained in:
44
src/dawn/ui/breakpoint.c
Normal file
44
src/dawn/ui/breakpoint.c
Normal file
@ -0,0 +1,44 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "breakpoint.h"
|
||||
|
||||
void breakpointListInit(breakpointlist_t *list) {
|
||||
list->breakpointCount = 0;
|
||||
list->user = NULL;
|
||||
list->onBreakpoint = NULL;
|
||||
list->breakpointCurrent = 0x00;
|
||||
}
|
||||
|
||||
uint8_t breakpointGet(breakpointlist_t *list, float width) {
|
||||
uint8_t bp, i;
|
||||
bp = 0xFF;
|
||||
for(i = 0; i < list->breakpointCount; i++) {
|
||||
if(list->breakpoints[i] > width) break;
|
||||
bp = i;
|
||||
}
|
||||
if(bp == 0xFF) bp = 0;
|
||||
return bp;
|
||||
}
|
||||
|
||||
void breakpointAdd(breakpointlist_t *list, float width) {
|
||||
list->breakpoints[list->breakpointCount++] = width;
|
||||
}
|
||||
|
||||
void breakpointResize(breakpointlist_t *list, float width) {
|
||||
uint8_t bp;
|
||||
|
||||
// Determine breakpoint
|
||||
bp = breakpointGet(list, width);
|
||||
if(list->breakpointCurrent == bp) return;
|
||||
list->breakpointCurrent = bp;
|
||||
|
||||
// Fire event.
|
||||
if(list->onBreakpoint != NULL) {
|
||||
list->onBreakpoint(list->user, bp, list->breakpoints[bp]);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user