From a535703add6bf29878845cb270997514489cfc16 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 31 Oct 2018 18:12:49 +0100 Subject: Start with images/gif, resize chat input --- include/Cache.hpp | 16 ------------ include/ChannelDataType.hpp | 2 +- include/ChatMessage.hpp | 7 ++++-- include/ChatWindow.hpp | 5 ++-- include/GlobalCache.hpp | 8 ++++++ include/GtkGif.hpp | 24 ++++++++++++++++++ include/env.hpp | 59 --------------------------------------------- include/types.hpp | 22 ----------------- 8 files changed, 41 insertions(+), 102 deletions(-) delete mode 100644 include/Cache.hpp create mode 100644 include/GlobalCache.hpp create mode 100644 include/GtkGif.hpp delete mode 100644 include/env.hpp delete mode 100644 include/types.hpp (limited to 'include') diff --git a/include/Cache.hpp b/include/Cache.hpp deleted file mode 100644 index 97ef495..0000000 --- a/include/Cache.hpp +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -#include - -namespace dchat -{ - class Cache - { - public: - Cache(); - ~Cache(); - - // Creates directory if it doesn't exist (recursively). Throws boost exception on failure - static boost::filesystem::path getDchatDir(); - }; -} diff --git a/include/ChannelDataType.hpp b/include/ChannelDataType.hpp index 398e716..21e828d 100644 --- a/include/ChannelDataType.hpp +++ b/include/ChannelDataType.hpp @@ -1,6 +1,6 @@ #pragma once -#include "types.hpp" +#include namespace dchat { diff --git a/include/ChatMessage.hpp b/include/ChatMessage.hpp index 271aa5f..c13db9d 100644 --- a/include/ChatMessage.hpp +++ b/include/ChatMessage.hpp @@ -1,6 +1,6 @@ #pragma once -#include "types.hpp" +#include #include #include @@ -11,10 +11,13 @@ namespace dchat { public: ChatMessage(const Glib::ustring &username, const Glib::ustring &text, uint32_t timestampSeconds, const User *user); - + + Gtk::Grid avatar; Gtk::Label username; Gtk::Label text; uint32_t timestampSeconds; const User *user; + private: + bool updateContent(const Cairo::RefPtr &cairo); }; } \ No newline at end of file diff --git a/include/ChatWindow.hpp b/include/ChatWindow.hpp index b10af2b..0b58506 100644 --- a/include/ChatWindow.hpp +++ b/include/ChatWindow.hpp @@ -38,8 +38,8 @@ namespace dchat Gtk::Grid leftPanelChannels; Gtk::Grid leftPanelUsers; Gtk::Label currentChannelTitle; - Gtk::ScrolledWindow chatArea; - Gtk::Grid chatAreaLayout; + Gtk::ScrolledWindow messageArea; + Gtk::Grid messageAreaLayout; Gtk::TextView chatInput; struct ChannelData @@ -53,5 +53,6 @@ namespace dchat std::vector users; ChatMessage *lastMessage; + int chatPrevNumLines; }; } \ No newline at end of file diff --git a/include/GlobalCache.hpp b/include/GlobalCache.hpp new file mode 100644 index 0000000..0b48e1c --- /dev/null +++ b/include/GlobalCache.hpp @@ -0,0 +1,8 @@ +#pragma once + +#include + +namespace dchat +{ + Cache& getGlobalCache(); +} \ No newline at end of file diff --git a/include/GtkGif.hpp b/include/GtkGif.hpp new file mode 100644 index 0000000..91b3a12 --- /dev/null +++ b/include/GtkGif.hpp @@ -0,0 +1,24 @@ +#pragma once + +#include +#include +#include + +namespace dchat +{ + class GtkGif : public Gif, public Gtk::DrawingArea + { + public: + GtkGif(StringView fileContent); + virtual ~GtkGif(){} + 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) override; + private: + Cairo::RefPtr surface; + }; +} \ No newline at end of file diff --git a/include/env.hpp b/include/env.hpp deleted file mode 100644 index 57ae068..0000000 --- a/include/env.hpp +++ /dev/null @@ -1,59 +0,0 @@ -#pragma once - -#define OS_FAMILY_WINDOWS 0 -#define OS_FAMILY_POSIX 1 - -#define OS_TYPE_WINDOWS 0 -#define OS_TYPE_LINUX 1 - -#if defined(_WIN32) || defined(_WIN64) - #if defined(_WIN64) - #define SYS_ENV_64BIT - #else - #define SYS_ENV_32BIT - #endif - #define OS_FAMILY OS_FAMILY_WINDOWS - #define OS_TYPE OS_TYPE_WINDOWS - - #ifndef UNICODE - #define UNICODE - #endif - - #ifndef _UNICODE - #define _UNICODE - #endif - - #ifndef WIN32_LEAN_AND_MEAN - #define WIN32_LEAN_AND_MEAN - #endif - - #include -#endif - -#if defined(__linux__) || defined(__unix__) || defined(__APPLE__) || defined(_POSIX_VERSION) - #define OS_FAMILY OS_FAMILY_POSIX -#endif - -#ifdef __linux__ - #define OS_TYPE OS_TYPE_LINUX -#endif - -#if defined(__GNUC__) - #if defined(__x86_64__) || defined(__pc64__) - #define SYS_ENV_64BIT - #else - #define SYS_ENV_32BIT - #endif -#endif - -#if !defined(SYS_ENV_32BIT) && !defined(SYS_ENV_64BIT) - #error "System is not detected as either 32-bit or 64-bit" -#endif - -#if !defined(OS_FAMILY) - #error "System not supported. Only Windows and Posix systems supported right now" -#endif - -#if !defined(OS_TYPE) - #error "System not supported. Only Windows and linux systems supported right now" -#endif diff --git a/include/types.hpp b/include/types.hpp deleted file mode 100644 index 762dab1..0000000 --- a/include/types.hpp +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once - -#include - -namespace dchat -{ - typedef int8_t i8; - typedef int16_t i16; - typedef int32_t i32; - typedef int64_t i64; - - typedef uint8_t u8; - typedef uint16_t u16; - typedef uint32_t u32; - typedef uint64_t u64; - - typedef float f32; - typedef double f64; - - typedef intptr_t ssize; - typedef uintptr_t usize; -} -- cgit v1.2.3