LCOV - code coverage report
Current view: top level - pencil/include - pencil_size.inl (source / functions) Coverage Total Hit
Test: crystal-facet-uml_v1.63.2_covts Lines: 78.9 % 128 101
Test Date: 2025-05-01 10:10:14 Functions: 47.8 % 23 11

            Line data    Source code
       1              : /* File: pencil_size.inl; Copyright and License: see below */
       2              : 
       3              : #include "u8/u8_log.h"
       4              : #include <assert.h>
       5              : 
       6            5 : static inline void pencil_size_init( pencil_size_t *this_, double width, double height )
       7              : {
       8            5 :     pencil_size_init_empty( this_ );
       9            5 :     pencil_size_reinit( this_, width, height);
      10            5 : }
      11              : 
      12            9 : static inline void pencil_size_destroy( pencil_size_t *this_ )
      13              : {
      14            9 :     pango_font_description_free ( (*this_).footnote_font_description );
      15            9 :     (*this_).footnote_font_description = NULL;
      16            9 :     pango_font_description_free ( (*this_).standard_font_description );
      17            9 :     (*this_).standard_font_description = NULL;
      18            9 :     pango_font_description_free ( (*this_).title_font_description );
      19            9 :     (*this_).title_font_description = NULL;
      20            9 : }
      21              : 
      22              : static const char *PENCIL_SIZE_FONT_FAMILY = "Sans";
      23              : 
      24            9 : static inline void pencil_size_init_empty( pencil_size_t *this_ )
      25              : {
      26            9 :     (*this_).standard_color.red = 0.0;
      27            9 :     (*this_).standard_color.green = 0.0;
      28            9 :     (*this_).standard_color.blue = 0.0;
      29            9 :     (*this_).standard_color.alpha = 1.0;
      30              : 
      31            9 :     (*this_).select_color.red = 1.0;
      32            9 :     (*this_).select_color.green = 0.3;
      33            9 :     (*this_).select_color.blue = 0.8;
      34            9 :     (*this_).select_color.alpha = 1.0;
      35              : 
      36            9 :     (*this_).highlight_color.red = 0.0;
      37            9 :     (*this_).highlight_color.green = 0.6;
      38            9 :     (*this_).highlight_color.blue = 0.4;
      39            9 :     (*this_).highlight_color.alpha = 1.0;
      40              : 
      41            9 :     (*this_).focus_color.red = 0.9;
      42            9 :     (*this_).focus_color.green = 0.85;
      43            9 :     (*this_).focus_color.blue = 0.0;
      44            9 :     (*this_).focus_color.alpha = 1.0;
      45              : 
      46            9 :     (*this_).emphasized_bgcolor.red = 1.0;
      47            9 :     (*this_).emphasized_bgcolor.green = 1.0;
      48            9 :     (*this_).emphasized_bgcolor.blue = 0.3;
      49            9 :     (*this_).emphasized_bgcolor.alpha = 1.0;
      50              : 
      51            9 :     (*this_).gray_out_color.red = 0.7;
      52            9 :     (*this_).gray_out_color.green = 0.7;
      53            9 :     (*this_).gray_out_color.blue = 0.7;
      54            9 :     (*this_).gray_out_color.alpha = 1.0;
      55              : 
      56              :     /* guess some default values: */
      57            9 :     (*this_).footnote_font_size = 9.0;
      58            9 :     (*this_).footnote_font_description = pango_font_description_new ();
      59            9 :     pango_font_description_set_family_static ( (*this_).footnote_font_description, PENCIL_SIZE_FONT_FAMILY );
      60            9 :     pango_font_description_set_style ( (*this_).footnote_font_description, PANGO_STYLE_NORMAL );
      61            9 :     pango_font_description_set_weight ( (*this_).footnote_font_description, PANGO_WEIGHT_MEDIUM );
      62            9 :     pango_font_description_set_stretch ( (*this_).footnote_font_description, PANGO_STRETCH_NORMAL );
      63            9 :     pango_font_description_set_size ( (*this_).footnote_font_description, 9 * PANGO_SCALE );
      64              : 
      65            9 :     (*this_).standard_font_size = 12.0;
      66            9 :     (*this_).standard_font_description = pango_font_description_new ();
      67            9 :     pango_font_description_set_family_static ( (*this_).standard_font_description, PENCIL_SIZE_FONT_FAMILY );
      68            9 :     pango_font_description_set_style ( (*this_).standard_font_description, PANGO_STYLE_NORMAL );
      69            9 :     pango_font_description_set_weight ( (*this_).standard_font_description, PANGO_WEIGHT_MEDIUM );
      70            9 :     pango_font_description_set_stretch ( (*this_).standard_font_description, PANGO_STRETCH_NORMAL );
      71            9 :     pango_font_description_set_size ( (*this_).standard_font_description, 12 * PANGO_SCALE );
      72              : 
      73            9 :     (*this_).title_font_size = 14.0;
      74            9 :     (*this_).title_font_description = pango_font_description_new ();
      75            9 :     pango_font_description_set_family_static ( (*this_).title_font_description, PENCIL_SIZE_FONT_FAMILY );
      76            9 :     pango_font_description_set_style ( (*this_).title_font_description, PANGO_STYLE_NORMAL );
      77            9 :     pango_font_description_set_weight ( (*this_).title_font_description, PANGO_WEIGHT_BOLD );
      78            9 :     pango_font_description_set_stretch ( (*this_).title_font_description, PANGO_STRETCH_NORMAL );
      79            9 :     pango_font_description_set_size ( (*this_).title_font_description, 14 * PANGO_SCALE );
      80              : 
      81            9 :     (*this_).standard_line_width = 1.0;
      82            9 :     (*this_).bold_line_width = 2.0;
      83            9 :     (*this_).line_dash_length = 5.0;
      84            9 :     (*this_).standard_object_border = 4.0;
      85            9 :     (*this_).arrow_stroke_length = 10.0;
      86            9 :     (*this_).arrow_stroke_087_length = 8.66;
      87            9 :     (*this_).preferred_object_distance = 20.0;
      88            9 :     (*this_).classifier_symbol_height = 24.0;
      89            9 : }
      90              : 
      91            5 : static inline void pencil_size_reinit( pencil_size_t *this_, double width, double height )
      92              : {
      93            5 :     double smaller_border = (width<height) ? width : height;
      94              : 
      95            5 :     (*this_).footnote_font_size = smaller_border/80.0;
      96            5 :     if ( (*this_).footnote_font_size < 1.0 )
      97              :     {
      98            0 :         (*this_).footnote_font_size = 1.0;
      99              :     }
     100            5 :     pango_font_description_set_size ( (*this_).footnote_font_description, ((int)((*this_).footnote_font_size * PANGO_SCALE) ));
     101              : 
     102            5 :     (*this_).standard_font_size = smaller_border/56.0;
     103            5 :     if ( (*this_).standard_font_size < 1.0 )
     104              :     {
     105            0 :         (*this_).standard_font_size = 1.0;
     106              :     }
     107            5 :     pango_font_description_set_size ( (*this_).standard_font_description, ((int)((*this_).standard_font_size * PANGO_SCALE) ));
     108              : 
     109            5 :     (*this_).title_font_size = smaller_border/48.0;
     110            5 :     if ( (*this_).title_font_size < 1.0 )
     111              :     {
     112            0 :         (*this_).title_font_size = 1.0;
     113              :     }
     114            5 :     pango_font_description_set_size ( (*this_).title_font_description, ((int)((*this_).title_font_size * PANGO_SCALE) ));
     115              : 
     116            5 :     (*this_).standard_line_width = smaller_border/800.0;
     117            5 :     (*this_).bold_line_width = smaller_border/400.0;
     118            5 :     (*this_).line_dash_length = smaller_border/80.0;
     119            5 :     (*this_).standard_object_border = smaller_border/200.0;
     120            5 :     (*this_).arrow_stroke_length = smaller_border/67;
     121            5 :     (*this_).arrow_stroke_087_length = (*this_).arrow_stroke_length*0.866025403784; /* =sqrt(0.75) */
     122            5 :     (*this_).preferred_object_distance = smaller_border/33.0;
     123            5 :     (*this_).classifier_symbol_height = smaller_border/20.0;
     124            5 : }
     125              : 
     126              : static inline double pencil_size_get_footnote_font_size( const pencil_size_t *this_ )
     127              : {
     128              :     return (*this_).footnote_font_size;
     129              : }
     130              : 
     131            0 : static inline const PangoFontDescription *pencil_size_get_footnote_font_description( const pencil_size_t *this_ )
     132              : {
     133            0 :     return (*this_).footnote_font_description;
     134              : }
     135              : 
     136           52 : static inline double pencil_size_get_standard_font_size( const pencil_size_t *this_ )
     137              : {
     138           52 :     return (*this_).standard_font_size;
     139              : }
     140              : 
     141          268 : static inline const PangoFontDescription *pencil_size_get_standard_font_description( const pencil_size_t *this_ )
     142              : {
     143          268 :     return (*this_).standard_font_description;
     144              : }
     145              : 
     146           16 : static inline double pencil_size_get_title_font_size( const pencil_size_t *this_ )
     147              : {
     148           16 :     return (*this_).title_font_size;
     149              : }
     150              : 
     151          256 : static inline const PangoFontDescription *pencil_size_get_title_font_description( const pencil_size_t *this_ )
     152              : {
     153          256 :     return (*this_).title_font_description;
     154              : }
     155              : 
     156            0 : static inline double pencil_size_get_font_tab_size( const pencil_size_t *this_ )
     157              : {
     158            0 :     return 3.0 * (*this_).standard_font_size;
     159              : }
     160              : 
     161          256 : static inline double pencil_size_get_font_line_gap( const pencil_size_t *this_ )
     162              : {
     163          256 :     return (*this_).standard_line_width;  /* equals the standard line width */
     164              : }
     165              : 
     166            0 : static inline double pencil_size_get_standard_line_width( const pencil_size_t *this_ )
     167              : {
     168            0 :     return (*this_).standard_line_width;
     169              : }
     170              : 
     171            0 : static inline double pencil_size_get_bold_line_width( const pencil_size_t *this_ )
     172              : {
     173            0 :     return (*this_).bold_line_width;
     174              : }
     175              : 
     176            0 : static inline double pencil_size_get_line_dash_length( const pencil_size_t *this_ )
     177              : {
     178            0 :     return (*this_).line_dash_length;
     179              : }
     180              : 
     181          802 : static inline double pencil_size_get_standard_object_border( const pencil_size_t *this_ )
     182              : {
     183          802 :     return (*this_).standard_object_border;
     184              : }
     185              : 
     186            0 : static inline double pencil_size_get_arrow_stroke_length( const pencil_size_t *this_ )
     187              : {
     188            0 :     return (*this_).arrow_stroke_length;
     189              : }
     190              : 
     191            0 : static inline double pencil_size_get_arrow_stroke_087_length( const pencil_size_t *this_ )
     192              : {
     193            0 :     return (*this_).arrow_stroke_087_length;
     194              : }
     195              : 
     196            0 : static inline double pencil_size_get_preferred_object_distance( const pencil_size_t *this_ )
     197              : {
     198            0 :     return (*this_).preferred_object_distance;
     199              : }
     200              : 
     201          108 : static inline double pencil_size_get_classifier_symbol_height( const pencil_size_t *this_ )
     202              : {
     203          108 :     return (*this_).classifier_symbol_height;
     204              : }
     205              : 
     206            0 : static inline GdkRGBA pencil_size_get_standard_color( const pencil_size_t *this_ )
     207              : {
     208            0 :     return (*this_).standard_color;
     209              : }
     210              : 
     211              : static inline GdkRGBA pencil_size_get_select_color( const pencil_size_t *this_ )
     212              : {
     213              :     return (*this_).select_color;
     214              : }
     215              : 
     216            0 : static inline GdkRGBA pencil_size_get_highlight_color( const pencil_size_t *this_ )
     217              : {
     218            0 :     return (*this_).highlight_color;
     219              : }
     220              : 
     221              : static inline GdkRGBA pencil_size_get_focus_color( const pencil_size_t *this_ )
     222              : {
     223              :     return (*this_).focus_color;
     224              : }
     225              : 
     226            0 : static inline GdkRGBA pencil_size_get_emphasized_bgcolor( const pencil_size_t *this_ )
     227              : {
     228            0 :     return (*this_).emphasized_bgcolor;
     229              : }
     230              : 
     231            0 : static inline GdkRGBA pencil_size_get_gray_out_color( const pencil_size_t *this_ )
     232              : {
     233            0 :     return (*this_).gray_out_color;
     234              : }
     235              : 
     236              : 
     237              : /*
     238              : Copyright 2016-2025 Andreas Warnke
     239              : 
     240              : Licensed under the Apache License, Version 2.0 (the "License");
     241              : you may not use this file except in compliance with the License.
     242              : You may obtain a copy of the License at
     243              : 
     244              :     http://www.apache.org/licenses/LICENSE-2.0
     245              : 
     246              : Unless required by applicable law or agreed to in writing, software
     247              : distributed under the License is distributed on an "AS IS" BASIS,
     248              : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     249              : See the License for the specific language governing permissions and
     250              : limitations under the License.
     251              : */
        

Generated by: LCOV version 2.0-1