예제 #1
0
void UIWidget::Draw(DrawContext& c){
  if(display_mode == DisplayMode::Invisible) return;

  const Size2D drawsize = c.Size();
  if(drawsize.IsEmpty()){
    needs_redrawing = false;
    return;
  }
  if(drawsize != current_size){
    std::cout << "WARNING: Implicitly calling Resize, because the draw "
    "context size " << drawsize.ToString() << " is incoherent with widget "
    "stored size " << current_size.ToString() << "!" << std::endl;
    //throw Exception("");
    Resize(drawsize);
  }
  if(needs_redrawing){
    //std::cout << "Needs redrawing. " << cache_texture->GetSize().ToString() << std::endl;
    c.Push(cache_texture, drawsize.width, drawsize.height);
    if(IsDrawn()){
      c.Clear(clear_color);
      CustomDraw(c);
      c.SetColor(overlay_color);
      c.Fill();
    }else{
      c.Clear();
    }
    c.Pop();
  }else{
    //std::cout << "No need to redraw. " << cache_texture->GetSize().ToString() << std::endl;
  }
  c.DrawTexture(cache_texture);
  current_size = drawsize;
  needs_redrawing = false;
  
}
예제 #2
0
void Container::Draw( bool draw ) {
	Widget::Draw( draw );

	std::size_t children_size = m_children.size();

	for( std::size_t index = 0; index < children_size; ++index ) {
		m_children[index]->Draw( IsDrawn() && IsVisible() );
	}
}
예제 #3
0
void Container::HandleVisibilityChange() {
	Widget::HandleVisibilityChange();

	std::size_t children_size = m_children.size();

	for( std::size_t index = 0; index < children_size; ++index ) {
		m_children[index]->Draw( IsDrawn() );
		m_children[index]->HandleParentVisibilityChange();
	}
}