Sun, 06 Oct 2024 20:49:43 +0200
revert introduction of high level ucx trees and stick to the low level API
/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * Copyright 2023 Mike Becker. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #ifndef ASCENSION_CONTEXT_H #define ASCENSION_CONTEXT_H #include "datatypes.h" #include "window.h" #include "input.h" #include "ui/font.h" #include <cx/buffer.h> /** The flag for the overall initialized state. */ #define ASC_FLAG_INITILIZED 0x01u /** Flag is set, when error buffer contains new error information. */ #define ASC_FLAG_HAS_ERROR 0x02u /** Flag is set, when SDL wants to quit the application. */ #define ASC_FLAG_QUIT 0x80000000u /** * The global ascension context. */ typedef struct AscContext { unsigned int flags; CxBuffer error_buffer; AscInput input; AscWindow windows[ASC_MAX_WINDOWS]; AscFont active_font; unsigned char fonts_loaded; unsigned char active_window; asc_col4i ink; uint64_t frame_nanos; uint64_t total_nanos; } AscContext; /** Global ascension context. */ extern AscContext asc_context; /** * The currently active font. * @see asc_font() */ #define asc_active_font asc_context.active_font #ifdef NDEBUG /** * The currently active window in the context. * @see asc_window_activate() */ #define asc_active_window \ (&asc_context.windows[asc_context.active_window]) #else /** * The currently active window in the context. * @see asc_window_activate() */ #define asc_active_window asc_active_window_assert() AscWindow *asc_active_window_assert(void); #endif // NDEBUG void asc_context_initialize(void); void asc_context_destroy(void); /** * Signals the context that we want to quit the application. */ void asc_context_quit(void); /** * Dispatches events and synchronizes all initialized windows. * * @return false, if the application wants to quit, true otherwise */ bool asc_loop_next(void); /** * Sets the active drawing color. */ #define asc_ink(color) asc_context.ink = (color) #define asc_ink_rgba(r,g,b,a) asc_context.ink = (asc_col4i){(r),(g),(b),(a)} #define asc_ink_rgb(r,g,b) asc_context.ink = (asc_col4i){(r),(g),(b),255u} #endif /* ASCENSION_CONTEXT_H */