diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/ChatMessage.hpp | 5 | ||||
-rw-r--r-- | include/DynamicImage.hpp | 18 | ||||
-rw-r--r-- | include/GtkGif.hpp | 10 |
3 files changed, 25 insertions, 8 deletions
diff --git a/include/ChatMessage.hpp b/include/ChatMessage.hpp index c1ef459..5259a9c 100644 --- a/include/ChatMessage.hpp +++ b/include/ChatMessage.hpp @@ -1,5 +1,6 @@ #pragma once +#include "DynamicImage.hpp" #include <dchat/types.hpp> #include <gtkmm/grid.h> #include <gtkmm/label.h> @@ -12,11 +13,9 @@ namespace dchat public: ChatMessage(const Glib::ustring &username, const Glib::ustring &text, uint32_t timestampSeconds); - Gtk::Grid avatar; + DynamicImage avatar; Gtk::Label username; Gtk::Label text; uint32_t timestampSeconds; - private: - bool updateContent(const Cairo::RefPtr<Cairo::Context> &cairo); }; }
\ No newline at end of file diff --git a/include/DynamicImage.hpp b/include/DynamicImage.hpp new file mode 100644 index 0000000..578b91a --- /dev/null +++ b/include/DynamicImage.hpp @@ -0,0 +1,18 @@ +#pragma once + +#include <string> +#include <gtkmm/drawingarea.h> + +namespace dchat +{ + class DynamicImage : public Gtk::DrawingArea + { + public: + DynamicImage(int downloadLimitBytes = 12582912); + + std::string url; + int downloadLimitBytes; + private: + bool updateContent(const Cairo::RefPtr<Cairo::Context> &cairo); + }; +}
\ No newline at end of file diff --git a/include/GtkGif.hpp b/include/GtkGif.hpp index 91b3a12..a4a28d7 100644 --- a/include/GtkGif.hpp +++ b/include/GtkGif.hpp @@ -1,24 +1,24 @@ #pragma once #include <dchat/Gif.hpp> -#include <gtkmm/drawingarea.h> -#include <gdkmm/pixbuf.h> +#include <cairomm/context.h> +#include <cairomm/surface.h> namespace dchat { - class GtkGif : public Gif, public Gtk::DrawingArea + class GtkGif : public Gif { public: GtkGif(StringView fileContent); virtual ~GtkGif(){} + + void draw(const Cairo::RefPtr<Cairo::Context> &cairo, int width, int height); protected: // Return false if texture creation failed bool createTexture(int width, int height) override; // Size of texture data is same as the size that the texture was created with (also same size returned by @getSize function) void updateTexture(void *textureData) override; private: - bool on_draw(const Cairo::RefPtr<Cairo::Context> &cairo) override; - private: Cairo::RefPtr<Cairo::ImageSurface> surface; }; }
\ No newline at end of file |