tb_image_widget.cpp 897 B

123456789101112131415161718192021222324252627
  1. // ================================================================================
  2. // == This file is a part of Turbo Badger. (C) 2011-2014, Emil Segerås ==
  3. // == See tb_core.h for more information. ==
  4. // ================================================================================
  5. #include "image/tb_image_widget.h"
  6. #include "tb_widgets_reader.h"
  7. #include "tb_node_tree.h"
  8. #ifdef TB_IMAGE
  9. namespace tb {
  10. PreferredSize TBImageWidget::OnCalculatePreferredContentSize(const SizeConstraints &constraints)
  11. {
  12. return PreferredSize(m_image.Width(), m_image.Height());
  13. }
  14. void TBImageWidget::OnPaint(const PaintProps &paint_props)
  15. {
  16. if (TBBitmapFragment *fragment = m_image.GetBitmap())
  17. g_renderer->DrawBitmap(GetPaddingRect(), TBRect(0, 0, m_image.Width(), m_image.Height()), fragment);
  18. }
  19. }; // namespace tb
  20. #endif // TB_IMAGE