libwtk-sdl2  0.0.1
texture_view.hpp
1 #ifndef LIBWTK_SDL2_TEXTURE_VIEW_HPP
2 #define LIBWTK_SDL2_TEXTURE_VIEW_HPP
3 
4 #include <string>
5 
6 #include <SDL2/SDL.h>
7 
8 #include "widget.hpp"
9 #include "sdl_util.hpp"
10 
19 {
20  texture_view();
21 
29  texture_view(unique_texture_ptr p, int min_width = -1, int nat_width = -1);
30 
31  ~texture_view() override;
32 
33  void on_draw(draw_context & dc, selection_context const & sc) const override;
34  void on_box_allocated() override;
35 
36  size_hint get_size_hint(int width, int height) const override;
37 
43  void set_texture(unique_texture_ptr p, int min_width = -1, int nat_width = -1);
44 
47  private:
48 
49  void refresh_target();
50  vec fit_to_width(int width) const;
51  int decode_min_width_param(int min_width) const;
52  int decode_nat_width_param(int nat_width) const;
53 
54  unique_texture_ptr _p;
55  vec _size;
56  int _min_width;
57  int _nat_width;
58  SDL_Rect _target;
59 };
60 
61 #endif
62 
void on_draw(draw_context &dc, selection_context const &sc) const override
void on_box_allocated() override
Definition: draw_context.hpp:126
Definition: geometry.hpp:12
Definition: texture_view.hpp:18
size_hint get_size_hint(int width, int height) const override
Definition: selection_context.hpp:18
Definition: widget.hpp:52
Definition: widget.hpp:35