Scroom 0.14-49-gb7ae7a6d
Loading...
Searching...
No Matches
TransparentOverlayViewInfo Class Reference

#include <transparentoverlayviewinfo.hh>

Inheritance diagram for TransparentOverlayViewInfo:
Inheritance graph
Collaboration diagram for TransparentOverlayViewInfo:
Collaboration graph

Public Types

using Ptr = std::shared_ptr< TransparentOverlayViewInfo >
 

Public Member Functions

void addChildren (const std::list< PresentationInterface::Ptr > &children)
 
void addChild (const PresentationInterface::Ptr &child)
 
PresentationInterface::Ptr getChild (const ChildView::Ptr &cv)
 
void close ()
 
void redraw (cairo_t *cr, Scroom::Utils::Rectangle< double > const &presentationArea, int zoom)
 
void invalidate ()
 
ProgressInterface::Ptr getProgressInterface ()
 
void toggled (GtkToggleButton *button)
 
- Public Member Functions inherited from Scroom::Utils::Base
 Base ()=default
 
 Base (const Base &)=delete
 
 Base (Base &&)=delete
 
Baseoperator= (const Base &)=delete
 
Baseoperator= (Base &&)=delete
 
virtual ~Base ()=default
 
template<typename R >
std::shared_ptr< R > shared_from_this ()
 
template<typename R >
std::shared_ptr< R const > shared_from_this () const
 

Static Public Member Functions

static Ptr create (const ViewInterface::WeakPtr &vi, SizeDeterminer::Ptr const &sizeDeterminer)
 

Private Types

using ChildMap = std::map< PresentationInterface::Ptr, ChildView::Ptr >
 

Private Member Functions

 TransparentOverlayViewInfo (const ViewInterface::WeakPtr &vi, SizeDeterminer::Ptr sizeDeterminer)
 
void createToggleToolButton (PresentationInterface::Ptr const &p)
 

Private Attributes

ViewInterface::Ptr parentView
 
ChildMap childViews
 
Scroom::Utils::ProgressInterfaceMultiplexer::Ptr progressInterfaceMultiplexer
 
std::vector< GtkWidget * > buttons
 
std::vector< PresentationInterface::Ptrchildren
 
SizeDeterminer::Ptr sizeDeterminer
 

Member Typedef Documentation

◆ ChildMap

◆ Ptr

Constructor & Destructor Documentation

◆ TransparentOverlayViewInfo()

TransparentOverlayViewInfo::TransparentOverlayViewInfo ( const ViewInterface::WeakPtr vi,
SizeDeterminer::Ptr  sizeDeterminer 
)
private
95 : parentView(vi)
97 , sizeDeterminer(std::move(sizeDeterminer_))
98{
99}
static Ptr create(ProgressInterface::Ptr parent)
Definition progressinterfacehelpers.cc:257
ViewInterface::Ptr parentView
Definition transparentoverlayviewinfo.hh:68
Scroom::Utils::ProgressInterfaceMultiplexer::Ptr progressInterfaceMultiplexer
Definition transparentoverlayviewinfo.hh:70
SizeDeterminer::Ptr sizeDeterminer
Definition transparentoverlayviewinfo.hh:73
ViewInterface::Ptr const vi
Definition pipette-tests.cc:186

Member Function Documentation

◆ addChild()

void TransparentOverlayViewInfo::addChild ( const PresentationInterface::Ptr child)
141{
142 ChildView::Ptr const view = ChildView::create(shared_from_this<TransparentOverlayViewInfo>());
143 childViews[child] = view;
144 child->open(view);
145 sizeDeterminer->open(child, view);
146 children.push_back(child);
148}
std::shared_ptr< ChildView > Ptr
Definition transparentoverlayviewinfo.hh:33
static Ptr create(std::shared_ptr< TransparentOverlayViewInfo > const &parent)
Definition transparentoverlayviewinfo.cc:66
ChildMap childViews
Definition transparentoverlayviewinfo.hh:69
std::vector< PresentationInterface::Ptr > children
Definition transparentoverlayviewinfo.hh:72
void createToggleToolButton(PresentationInterface::Ptr const &p)
Definition transparentoverlayviewinfo.cc:106
const auto view
Definition pipette-tests.cc:227

Referenced by addChildren().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addChildren()

void TransparentOverlayViewInfo::addChildren ( const std::list< PresentationInterface::Ptr > &  children)
133{
134 for(PresentationInterface::Ptr const& child: children_)
135 {
136 addChild(child);
137 }
138}
std::shared_ptr< PresentationInterface > Ptr
Definition presentationinterface.hh:73
void addChild(const PresentationInterface::Ptr &child)
Definition transparentoverlayviewinfo.cc:140
Here is the call graph for this function:

◆ close()

void TransparentOverlayViewInfo::close ( )
163{
164 for(ChildMap::value_type const& v: childViews)
165 {
166 sizeDeterminer->close(v.first, v.second);
167 v.first->close(v.second);
168 }
169
170 childViews.clear();
171 children.clear();
172 buttons.clear();
173}
std::vector< GtkWidget * > buttons
Definition transparentoverlayviewinfo.hh:71

◆ create()

TransparentOverlayViewInfo::Ptr TransparentOverlayViewInfo::create ( const ViewInterface::WeakPtr vi,
SizeDeterminer::Ptr const &  sizeDeterminer 
)
static
128{
130}
Definition transparentoverlayviewinfo.hh:60
std::shared_ptr< TransparentOverlayViewInfo > Ptr
Definition transparentoverlayviewinfo.hh:62

Referenced by TransparentOverlayPresentation::viewAdded().

Here is the caller graph for this function:

◆ createToggleToolButton()

void TransparentOverlayViewInfo::createToggleToolButton ( PresentationInterface::Ptr const &  p)
private
107{
108 const int n = buttons.size() + 1;
109 std::stringstream s;
110 s << "_" << n;
111
112 GtkToolItem* button = gtk_tool_item_new();
113 GtkWidget* toggleButton = gtk_toggle_button_new_with_mnemonic(s.str().c_str());
114 setToggleButtonColor(toggleButton, p);
115 gtk_widget_set_visible(toggleButton, true);
116 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggleButton), true);
117
118 gtk_container_add(GTK_CONTAINER(button), toggleButton);
119 g_signal_connect(static_cast<gpointer>(toggleButton), "toggled", G_CALLBACK(on_toggled), this);
120
121 buttons.push_back(toggleButton);
122
123 parentView->addToToolbar(button);
124}
PresentationInterfaceStub::Ptr const p
Definition determine-size-test.cc:172
void setToggleButtonColor(GtkWidget *w, PresentationInterface::Ptr const &p)
Definition transparentoverlayviewinfo.cc:21
BitmapSurface::Ptr const s
Definition transformpresentation_test.cc:70
static void on_toggled(GtkToggleButton *button, gpointer data)
Definition transparentoverlayviewinfo.cc:101

Referenced by addChild().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getChild()

PresentationInterface::Ptr TransparentOverlayViewInfo::getChild ( const ChildView::Ptr cv)
151{
152 for(ChildMap::value_type const& v: childViews)
153 {
154 if(v.second == cv)
155 {
156 return v.first;
157 }
158 }
159 return {};
160}

◆ getProgressInterface()

ProgressInterface::Ptr TransparentOverlayViewInfo::getProgressInterface ( )
inline
90{ return progressInterfaceMultiplexer->createProgressInterface(); }

◆ invalidate()

void TransparentOverlayViewInfo::invalidate ( )
inline
89{ parentView->invalidate(); }

Referenced by toggled().

Here is the caller graph for this function:

◆ redraw()

void TransparentOverlayViewInfo::redraw ( cairo_t *  cr,
Scroom::Utils::Rectangle< double > const &  presentationArea,
int  zoom 
)
176{
178
179 cairo_rectangle_int_t const presentationArea = pa.toGdkRectangle();
180
181 cairo_rectangle_int_t viewArea;
182 viewArea.x = 0;
183 viewArea.y = 0;
184
185 if(zoom > 0)
186 {
187 const int pixelSize = 1 << zoom;
188 viewArea.width = presentationArea.width * pixelSize;
189 viewArea.height = presentationArea.height * pixelSize;
190 }
191 else
192 {
193 const int pixelSize = 1 << -zoom;
194 viewArea.width = presentationArea.width / pixelSize;
195 viewArea.height = presentationArea.height / pixelSize;
196 }
197
198 BitmapSurface::Ptr const s = BitmapSurface::create(viewArea.width, viewArea.height, CAIRO_FORMAT_ARGB32);
199 cairo_surface_t* surface = s->get();
200 cairo_t* cr_sub = cairo_create(surface);
201
202 int count = 0;
203
204 for(size_t i = 0; i < children.size(); i++)
205 {
206 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(buttons[i])))
207 {
209
210 Colormappable::Ptr const c = std::dynamic_pointer_cast<Colormappable>(p);
211 bool hasTransparentBackground = false;
212 if(c && p->isPropertyDefined(TRANSPARENT_BACKGROUND_PROPERTY_NAME))
213 {
214 if(count == 0)
215 {
216 c->disableTransparentBackground();
217 }
218 else
219 {
220 c->setTransparentBackground();
221 hasTransparentBackground = true;
222 }
223 }
224
225 cairo_save(cr_sub);
226 cairo_set_operator(cr_sub, CAIRO_OPERATOR_CLEAR);
227 cairo_paint(cr_sub);
228 cairo_restore(cr_sub);
229
230 cairo_save(cr_sub);
231 p->redraw(childViews[p], cr_sub, pa, zoom);
232 cairo_restore(cr_sub);
233
234 cairo_set_source_surface(cr, surface, 0, 0);
235
236 if(hasTransparentBackground)
237 {
238 cairo_paint(cr);
239 }
240 else
241 {
242 cairo_paint_with_alpha(cr, 1.0 / (count + 1));
243 }
244
245 if(!hasTransparentBackground)
246 {
247 count++;
248 }
249 }
250 }
251
252 cairo_destroy(cr_sub);
253}
std::shared_ptr< Colormappable > Ptr
Definition colormappable.hh:114
Definition bitmap-helpers.hh:23
cairo_rectangle_int_t toGdkRectangle() const
Definition rectangle.hh:62
const std::string TRANSPARENT_BACKGROUND_PROPERTY_NAME
Definition colormappable.hh:21
const size_t count
Definition pageprovider-tests.cc:21
Semaphore c(0)
cairo_destroy(cr)
cairo_surface_t * surface
Definition transformpresentation_test.cc:71
cairo_t * cr
Definition transformpresentation_test.cc:72
Here is the call graph for this function:

◆ toggled()

void TransparentOverlayViewInfo::toggled ( GtkToggleButton *  button)
255{ invalidate(); }
void invalidate()
Definition transparentoverlayviewinfo.hh:89
Here is the call graph for this function:

Member Data Documentation

◆ buttons

std::vector<GtkWidget*> TransparentOverlayViewInfo::buttons
private

◆ children

std::vector<PresentationInterface::Ptr> TransparentOverlayViewInfo::children
private

Referenced by addChild(), close(), and redraw().

◆ childViews

ChildMap TransparentOverlayViewInfo::childViews
private

Referenced by addChild(), close(), getChild(), and redraw().

◆ parentView

ViewInterface::Ptr TransparentOverlayViewInfo::parentView
private

◆ progressInterfaceMultiplexer

Scroom::Utils::ProgressInterfaceMultiplexer::Ptr TransparentOverlayViewInfo::progressInterfaceMultiplexer
private

Referenced by getProgressInterface().

◆ sizeDeterminer

SizeDeterminer::Ptr TransparentOverlayViewInfo::sizeDeterminer
private

Referenced by addChild(), close(), and create().


The documentation for this class was generated from the following files: