Ignore:
Timestamp:
07/23/15 21:16:01 (10 years ago)
Author:
epyon
Message:
  • massive std::string removal
  • no header depends on std::string anymore (or any other STL header)
  • still some code files do (WIP)
  • massive refactoring where std::string was used
  • lua still messy (grep for string128 - used everywhere)
  • string_twine added
File:
1 edited

Legend:

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

    r433 r440  
    99#include "nv/gui/gui_renderer.hh"
    1010
    11 #include <algorithm> // std::find on std::list
    12 
    1311        /*
    1412
     
    2725        : m_renderer( r )
    2826{
     27        r->set_environment( this );
    2928        m_screen   = create_element( handle(), m_renderer->get_area() );
    3029}
     
    161160                while ( !parent->m_children.empty() )
    162161                {
    163                         destroy_element( parent->m_children.front() );
     162                        destroy_element( parent->m_children.back() );
    164163                }
    165164        }
     
    196195}
    197196
     197nv::string_view nv::gui::environment::get_string( shash64 h )
     198{
     199        return m_strings[h];
     200}
     201
    198202bool nv::gui::environment::set_selected( handle e )
    199203{
     
    235239
    236240        handle result;
    237         element::list::reverse_iterator it = el->m_children.rbegin();
     241        auto it = el->m_children.rbegin();
    238242
    239243        while ( it != el->m_children.rend() )
     
    254258        if ( e && parent )
    255259        {
    256                 auto it = std::find( parent->m_children.begin(), parent->m_children.end(), child );
     260                auto it = find( parent->m_children.begin(), parent->m_children.end(), child );
    257261                if ( it != parent->m_children.end() )
    258262                {
     
    264268}
    265269
    266 void nv::gui::environment::move_to_bottom( handle child )
    267 {
    268         element* e      = m_elements.get( child );
    269         element* parent = m_elements.get( e->m_parent );
    270         if ( e && parent )
    271         {
    272                 auto it = std::find( parent->m_children.begin(), parent->m_children.end(), child );
    273                 if ( it != parent->m_children.end() )
    274                 {
    275                         parent->m_children.erase( it );
    276                         parent->m_children.push_front( child );
    277                         parent->m_flags[DIRTY] = true;
    278                 }
    279         }
    280 }
    281 
    282270void nv::gui::environment::set_relative( handle e, const rectangle& r )
    283271{
     
    312300}
    313301
    314 void nv::gui::environment::set_class( handle e, const std::string& text )
     302void nv::gui::environment::set_class( handle e, const string_view& text )
    315303{
    316304        element* ep = m_elements.get(e);
    317305        if ( ep != nullptr )
    318306        {
    319                 ep->m_class        = text;
     307                ep->m_class        = m_strings.insert( text );
    320308                ep->m_flags[DIRTY] = true;
    321309        }
    322310}
    323311
    324 void nv::gui::environment::set_text( handle e, const std::string& text )
     312void nv::gui::environment::set_text( handle e, const string_twine& text )
    325313{
    326314        element* ep = m_elements.get(e);
    327315        if ( ep != nullptr )
    328316        {
    329                 ep->m_text         = text;
     317                ep->m_text.assign( text );
    330318                ep->m_flags[DIRTY] = true;
    331319        }
     
    337325        if ( p )
    338326        {
    339                 auto it = std::find( p->m_children.begin(), p->m_children.end(), child );
     327                auto it = find( p->m_children.begin(), p->m_children.end(), child );
    340328                if ( it != p->m_children.end() )
    341329                {
    342330                        element* e = m_elements.get( *it );
    343331                        e->m_parent = handle();
    344                         p->m_children.erase(it);
    345                 }       
    346         }
    347 }
    348 
     332                        p->m_children.erase( it );
     333                }
     334        }
     335}
     336
Note: See TracChangeset for help on using the changeset viewer.