Line data Source code
1 : /* File: geometry_h_align.inl; Copyright and License: see below */ 2 : 3 : #include "u8/u8_trace.h" 4 : #include "u8/u8_log.h" 5 : #include <assert.h> 6 : 7 562 : static inline double geometry_h_align_get_left ( const geometry_h_align_t *this_, double width, double reference_left, double reference_width ) 8 : { 9 : double left; 10 : 11 562 : switch ( *this_ ) 12 : { 13 0 : case GEOMETRY_H_ALIGN_LEFT: 14 : { 15 0 : left = reference_left; 16 : } 17 0 : break; 18 : 19 562 : case GEOMETRY_H_ALIGN_CENTER: 20 : { 21 562 : left = reference_left + 0.5 * ( reference_width - width ); 22 : } 23 562 : break; 24 : 25 0 : case GEOMETRY_H_ALIGN_RIGHT: 26 : { 27 0 : left = reference_left + reference_width - width; 28 : } 29 0 : break; 30 : 31 0 : default: 32 : { 33 0 : U8_LOG_ERROR("unknown geometry_h_align_t in geometry_h_align_get_left()"); 34 0 : assert(0); 35 : left = 0.0; 36 : } 37 : break; 38 : } 39 : 40 562 : return left; 41 : } 42 : 43 : 44 : /* 45 : Copyright 2017-2024 Andreas Warnke 46 : 47 : Licensed under the Apache License, Version 2.0 (the "License"); 48 : you may not use this file except in compliance with the License. 49 : You may obtain a copy of the License at 50 : 51 : http://www.apache.org/licenses/LICENSE-2.0 52 : 53 : Unless required by applicable law or agreed to in writing, software 54 : distributed under the License is distributed on an "AS IS" BASIS, 55 : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 56 : See the License for the specific language governing permissions and 57 : limitations under the License. 58 : */