Ignore:
Timestamp:
08/08/16 18:25:48 (9 years ago)
Author:
epyon
Message:
  • term_color implementation
  • support for background color
  • support for RGBA encoding
  • initial gfx_terminal implementation
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gui/gui_ascii_renderer.cc

    r487 r514  
    1515struct ascii_render_data : public render_data
    1616{
    17         ascii_render_data() {}
    18         bool   clear;
    19         bool   border;
    20         char   border_chars[8];
    21         uint32 border_color;
    22         uint32 text_color;
     17        bool       clear;
     18        bool       border;
     19        char       border_chars[8];
     20        ivec2      padding;
     21        term_color border_color;
     22        term_color text_color;
    2323};
    2424
     
    3838                er->border     = false;
    3939                er->clear      = false;
    40                 er->text_color = 0;
    4140                e->m_render_data = er;
    4241        }
     
    5756               
    5857                m_style.get( e, "ascii_color", selector, color );
    59                 er->text_color = uint32( color );
     58                er->text_color = term_color::color( color );
    6059                er->border     = false;
     60                vec4 padding;
     61                m_style.get( e, "ascii_padding", selector, padding );
     62                er->padding    = ivec2( int( padding.x ), int( padding.y ) );
     63
    6164                if ( m_style.get( e, "ascii_border", selector, path ) )
    6265                {
     
    6568                        int border_color = 0;
    6669                        if ( m_style.get( e, "ascii_border_color", selector, border_color ) )
    67                                 er->border_color = uint32( border_color );
     70                                er->border_color = term_color::color( border_color );
    6871                        for ( uint32 i = 0; i < 8 && i < path.length(); i++ )
    6972                                er->border_chars[i] = path[i];
     
    7679        ascii_render_data* er = static_cast< ascii_render_data* >( e->m_render_data );
    7780        rectangle abs = e->m_absolute;
    78         if ( er->clear ) m_terminal->clear( abs );
     81        if ( er->clear ) m_terminal->clear( abs, term_color::LIGHTGRAY, term_color() );
    7982        if ( er->border )
    8083        {
    8184                for ( int x = 0; x < abs.get_width(); ++x )
    8285                {
    83                         m_terminal->print( position( abs.ul.x + x, abs.ul.y ), er->border_color, er->border_chars[0] );
    84                         m_terminal->print( position( abs.ul.x + x, abs.lr.y ), er->border_color, er->border_chars[1] );
     86                        m_terminal->print( position( abs.ul.x + x, abs.ul.y ), er->border_color, term_color(), er->border_chars[0] );
     87                        m_terminal->print( position( abs.ul.x + x, abs.lr.y ), er->border_color, term_color(), er->border_chars[1] );
    8588                }
    8689
    8790                for ( int y = 0; y < abs.get_height(); ++y )
    8891                {
    89                         m_terminal->print( position( abs.ul.x, abs.ul.y + y ), er->border_color, er->border_chars[2] );
    90                         m_terminal->print( position( abs.lr.x, abs.ul.y + y ), er->border_color, er->border_chars[3] );
     92                        m_terminal->print( position( abs.ul.x, abs.ul.y + y ), er->border_color, term_color(), er->border_chars[2] );
     93                        m_terminal->print( position( abs.lr.x, abs.ul.y + y ), er->border_color, term_color(), er->border_chars[3] );
    9194                }
    9295
    93                 m_terminal->print( abs.ul,   er->border_color, er->border_chars[4] );
    94                 m_terminal->print( abs.ur(), er->border_color, er->border_chars[5] );
    95                 m_terminal->print( abs.ll(), er->border_color, er->border_chars[6] );
    96                 m_terminal->print( abs.lr,   er->border_color, er->border_chars[7] );
     96                m_terminal->print( abs.ul,   er->border_color, term_color(), er->border_chars[4] );
     97                m_terminal->print( abs.ur(), er->border_color, term_color(), er->border_chars[5] );
     98                m_terminal->print( abs.ll(), er->border_color, term_color(), er->border_chars[6] );
     99                m_terminal->print( abs.lr,   er->border_color, term_color(), er->border_chars[7] );
    97100                m_terminal->update();
    98101        }
    99102        if ( !e->m_text.empty() )
    100103        {
    101                 position p = abs.ul;
     104                position p = abs.ul + er->padding;
    102105                for ( char c : e->m_text )
    103106                {
    104                         m_terminal->print( p, er->text_color, c );
     107                        m_terminal->print( p, er->text_color, term_color(), c );
    105108                        ++p.x;
    106109                }
Note: See TracChangeset for help on using the changeset viewer.