summaryrefslogtreecommitdiff
path: root/src/components/channels.hpp
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2021-12-04 02:21:08 -0500
committerouwou <26526779+ouwou@users.noreply.github.com>2021-12-04 02:21:08 -0500
commit246140688714936820b5c977665ad2a904fa7222 (patch)
tree6e7e9e988169bf85f02beaa4c19ffa17a31d10ac /src/components/channels.hpp
parent8e11dd97e9effa0b4abf9945ad3ec3fee9d9ec5d (diff)
downloadabaddon-portaudio-246140688714936820b5c977665ad2a904fa7222.tar.gz
abaddon-portaudio-246140688714936820b5c977665ad2a904fa7222.zip
split channel CellRenderer into its own sources
Diffstat (limited to 'src/components/channels.hpp')
-rw-r--r--src/components/channels.hpp116
1 files changed, 1 insertions, 115 deletions
diff --git a/src/components/channels.hpp b/src/components/channels.hpp
index 1faf367..6ab8174 100644
--- a/src/components/channels.hpp
+++ b/src/components/channels.hpp
@@ -8,126 +8,12 @@
#include <sigc++/sigc++.h>
#include "discord/discord.hpp"
#include "state.hpp"
+#include "channelscellrenderer.hpp"
constexpr static int GuildIconSize = 24;
constexpr static int DMIconSize = 20;
constexpr static int OrphanChannelSortOffset = -100; // forces orphan channels to the top of the list
-enum class RenderType : uint8_t {
- Guild,
- Category,
- TextChannel,
- Thread,
-
- DMHeader,
- DM,
-};
-
-class CellRendererChannels : public Gtk::CellRenderer {
-public:
- CellRendererChannels();
- virtual ~CellRendererChannels();
-
- Glib::PropertyProxy<RenderType> property_type();
- Glib::PropertyProxy<Glib::ustring> property_name();
- Glib::PropertyProxy<Glib::RefPtr<Gdk::Pixbuf>> property_icon();
- Glib::PropertyProxy<Glib::RefPtr<Gdk::PixbufAnimation>> property_icon_animation();
- Glib::PropertyProxy<bool> property_expanded();
- Glib::PropertyProxy<bool> property_nsfw();
-
-protected:
- void get_preferred_width_vfunc(Gtk::Widget &widget, int &minimum_width, int &natural_width) const override;
- void get_preferred_width_for_height_vfunc(Gtk::Widget &widget, int height, int &minimum_width, int &natural_width) const override;
- void get_preferred_height_vfunc(Gtk::Widget &widget, int &minimum_height, int &natural_height) const override;
- void get_preferred_height_for_width_vfunc(Gtk::Widget &widget, int width, int &minimum_height, int &natural_height) const override;
- void render_vfunc(const Cairo::RefPtr<Cairo::Context> &cr,
- Gtk::Widget &widget,
- const Gdk::Rectangle &background_area,
- const Gdk::Rectangle &cell_area,
- Gtk::CellRendererState flags) override;
-
- // guild functions
- void get_preferred_width_vfunc_guild(Gtk::Widget &widget, int &minimum_width, int &natural_width) const;
- void get_preferred_width_for_height_vfunc_guild(Gtk::Widget &widget, int height, int &minimum_width, int &natural_width) const;
- void get_preferred_height_vfunc_guild(Gtk::Widget &widget, int &minimum_height, int &natural_height) const;
- void get_preferred_height_for_width_vfunc_guild(Gtk::Widget &widget, int width, int &minimum_height, int &natural_height) const;
- void render_vfunc_guild(const Cairo::RefPtr<Cairo::Context> &cr,
- Gtk::Widget &widget,
- const Gdk::Rectangle &background_area,
- const Gdk::Rectangle &cell_area,
- Gtk::CellRendererState flags);
-
- // category
- void get_preferred_width_vfunc_category(Gtk::Widget &widget, int &minimum_width, int &natural_width) const;
- void get_preferred_width_for_height_vfunc_category(Gtk::Widget &widget, int height, int &minimum_width, int &natural_width) const;
- void get_preferred_height_vfunc_category(Gtk::Widget &widget, int &minimum_height, int &natural_height) const;
- void get_preferred_height_for_width_vfunc_category(Gtk::Widget &widget, int width, int &minimum_height, int &natural_height) const;
- void render_vfunc_category(const Cairo::RefPtr<Cairo::Context> &cr,
- Gtk::Widget &widget,
- const Gdk::Rectangle &background_area,
- const Gdk::Rectangle &cell_area,
- Gtk::CellRendererState flags);
-
- // text channel
- void get_preferred_width_vfunc_channel(Gtk::Widget &widget, int &minimum_width, int &natural_width) const;
- void get_preferred_width_for_height_vfunc_channel(Gtk::Widget &widget, int height, int &minimum_width, int &natural_width) const;
- void get_preferred_height_vfunc_channel(Gtk::Widget &widget, int &minimum_height, int &natural_height) const;
- void get_preferred_height_for_width_vfunc_channel(Gtk::Widget &widget, int width, int &minimum_height, int &natural_height) const;
- void render_vfunc_channel(const Cairo::RefPtr<Cairo::Context> &cr,
- Gtk::Widget &widget,
- const Gdk::Rectangle &background_area,
- const Gdk::Rectangle &cell_area,
- Gtk::CellRendererState flags);
-
- // thread
- void get_preferred_width_vfunc_thread(Gtk::Widget &widget, int &minimum_width, int &natural_width) const;
- void get_preferred_width_for_height_vfunc_thread(Gtk::Widget &widget, int height, int &minimum_width, int &natural_width) const;
- void get_preferred_height_vfunc_thread(Gtk::Widget &widget, int &minimum_height, int &natural_height) const;
- void get_preferred_height_for_width_vfunc_thread(Gtk::Widget &widget, int width, int &minimum_height, int &natural_height) const;
- void render_vfunc_thread(const Cairo::RefPtr<Cairo::Context> &cr,
- Gtk::Widget &widget,
- const Gdk::Rectangle &background_area,
- const Gdk::Rectangle &cell_area,
- Gtk::CellRendererState flags);
-
- // dm header
- void get_preferred_width_vfunc_dmheader(Gtk::Widget &widget, int &minimum_width, int &natural_width) const;
- void get_preferred_width_for_height_vfunc_dmheader(Gtk::Widget &widget, int height, int &minimum_width, int &natural_width) const;
- void get_preferred_height_vfunc_dmheader(Gtk::Widget &widget, int &minimum_height, int &natural_height) const;
- void get_preferred_height_for_width_vfunc_dmheader(Gtk::Widget &widget, int width, int &minimum_height, int &natural_height) const;
- void render_vfunc_dmheader(const Cairo::RefPtr<Cairo::Context> &cr,
- Gtk::Widget &widget,
- const Gdk::Rectangle &background_area,
- const Gdk::Rectangle &cell_area,
- Gtk::CellRendererState flags);
-
- // dm
- void get_preferred_width_vfunc_dm(Gtk::Widget &widget, int &minimum_width, int &natural_width) const;
- void get_preferred_width_for_height_vfunc_dm(Gtk::Widget &widget, int height, int &minimum_width, int &natural_width) const;
- void get_preferred_height_vfunc_dm(Gtk::Widget &widget, int &minimum_height, int &natural_height) const;
- void get_preferred_height_for_width_vfunc_dm(Gtk::Widget &widget, int width, int &minimum_height, int &natural_height) const;
- void render_vfunc_dm(const Cairo::RefPtr<Cairo::Context> &cr,
- Gtk::Widget &widget,
- const Gdk::Rectangle &background_area,
- const Gdk::Rectangle &cell_area,
- Gtk::CellRendererState flags);
-
-private:
- Gtk::CellRendererText m_renderer_text;
-
- Glib::Property<RenderType> m_property_type; // all
- Glib::Property<Glib::ustring> m_property_name; // all
- Glib::Property<Glib::RefPtr<Gdk::Pixbuf>> m_property_pixbuf; // guild, dm
- Glib::Property<Glib::RefPtr<Gdk::PixbufAnimation>> m_property_pixbuf_animation; // guild
- Glib::Property<bool> m_property_expanded; // category
- Glib::Property<bool> m_property_nsfw; // channel
-
- // same pitfalls as in https://github.com/uowuo/abaddon/blob/60404783bd4ce9be26233fe66fc3a74475d9eaa3/components/cellrendererpixbufanimation.hpp#L32-L39
- // this will manifest though since guild icons can change
- // an animation or two wont be the end of the world though
- std::map<Glib::RefPtr<Gdk::PixbufAnimation>, Glib::RefPtr<Gdk::PixbufAnimationIter>> m_pixbuf_anim_iters;
-};
-
class ChannelList : public Gtk::ScrolledWindow {
public:
ChannelList();