| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- #pragma once
- #include "Book.hpp"
- #include <gtkmm/box.h>
- #include <gtkmm/picture.h>
- #include <gtkmm/label.h>
- #include <gtkmm/overlay.h>
- #include <gtkmm/gestureclick.h>
- #include <gtkmm/eventcontrollermotion.h>
- /**
- * @brief Compact widget that renders a single Book cover and title.
- *
- * BookTile is used by @ref BookShelf's GridView factory; it presents the
- * cover art (texture if already loaded, otherwise lazy load from disk) and
- * a caption, and forwards click gestures via @ref signalActivated().
- */
- class BookTile : public Gtk::Box {
- public:
- BookTile(const Book& book, int coverSize = 128);
- void setBook(const Book& book); // for updates
- const Book& getBook() const noexcept { return m_book; }
- void setSelected(bool selected);
- /// Emitted when the tile is clicked (single click).
- sigc::signal<void(const Book&)>& signalActivated() { return m_signalActivated; }
- private:
- void rebuild();
- void onActivated();
- Book m_book;
- int m_coverSize = 128;
- Gtk::Overlay m_overlay;
- Gtk::Picture m_cover;
- Gtk::Label m_title;
- Glib::RefPtr<Gtk::GestureClick> m_click;
- Glib::RefPtr<Gtk::EventControllerMotion> m_hover;
- bool m_selected = false;
- sigc::signal<void(const Book&)> m_signalActivated;
- };
|