Scroom  0.14
TransparentOverlayViewInfo Class Reference

#include <transparentoverlayviewinfo.hh>

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

Public Types

using Ptr = boost::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 >
boost::shared_ptr< R > shared_from_this ()
 
template<typename R >
boost::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
99  : parentView(vi)
101  , sizeDeterminer(std::move(sizeDeterminer_))
102 {
103 }

Referenced by create().

Here is the caller graph for this function:

Member Function Documentation

◆ addChild()

void TransparentOverlayViewInfo::addChild ( const PresentationInterface::Ptr child)
145 {
146  ChildView::Ptr const view = ChildView::create(shared_from_this<TransparentOverlayViewInfo>());
147  childViews[child] = view;
148  child->open(view);
149  sizeDeterminer->open(child, view);
150  children.push_back(child);
151  createToggleToolButton(child);
152 }

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)
137 {
138  for(PresentationInterface::Ptr const& child: children_)
139  {
140  addChild(child);
141  }
142 }
Here is the call graph for this function:

◆ close()

void TransparentOverlayViewInfo::close ( )
167 {
168  for(ChildMap::value_type const& v: childViews)
169  {
170  sizeDeterminer->close(v.first, v.second);
171  v.first->close(v.second);
172  }
173 
174  childViews.clear();
175  children.clear();
176  buttons.clear();
177 }

◆ create()

TransparentOverlayViewInfo::Ptr TransparentOverlayViewInfo::create ( const ViewInterface::WeakPtr vi,
SizeDeterminer::Ptr const &  sizeDeterminer 
)
static
132 {
134 }

Referenced by TransparentOverlayPresentation::viewAdded().

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

◆ createToggleToolButton()

void TransparentOverlayViewInfo::createToggleToolButton ( PresentationInterface::Ptr const &  p)
private
111 {
112  const int n = buttons.size() + 1;
113  std::stringstream s;
114  s << "_" << n;
115 
116  GtkToolItem* button = gtk_tool_item_new();
117  GtkWidget* toggleButton = gtk_toggle_button_new_with_mnemonic(s.str().c_str());
118  setToggleButtonColor(toggleButton, p);
119  gtk_widget_set_visible(toggleButton, true);
120  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggleButton), true);
121 
122  gtk_container_add(GTK_CONTAINER(button), toggleButton);
123  g_signal_connect(static_cast<gpointer>(toggleButton), "toggled", G_CALLBACK(on_toggled), this);
124 
125  buttons.push_back(toggleButton);
126 
127  parentView->addToToolbar(button);
128 }

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)
155 {
156  for(ChildMap::value_type const& v: childViews)
157  {
158  if(v.second == cv)
159  {
160  return v.first;
161  }
162  }
163  return {};
164 }

◆ getProgressInterface()

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

◆ invalidate()

void TransparentOverlayViewInfo::invalidate ( )
inline
90 { 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 
)
180 {
182 
183  cairo_rectangle_int_t const presentationArea = pa.toGdkRectangle();
184 
185  cairo_rectangle_int_t viewArea;
186  viewArea.x = 0;
187  viewArea.y = 0;
188 
189  if(zoom > 0)
190  {
191  const int pixelSize = 1 << zoom;
192  viewArea.width = presentationArea.width * pixelSize;
193  viewArea.height = presentationArea.height * pixelSize;
194  }
195  else
196  {
197  const int pixelSize = 1 << -zoom;
198  viewArea.width = presentationArea.width / pixelSize;
199  viewArea.height = presentationArea.height / pixelSize;
200  }
201 
202  BitmapSurface::Ptr const s = BitmapSurface::create(viewArea.width, viewArea.height, CAIRO_FORMAT_ARGB32);
203  cairo_surface_t* surface = s->get();
204  cairo_t* cr_sub = cairo_create(surface);
205 
206  int count = 0;
207 
208  for(size_t i = 0; i < children.size(); i++)
209  {
210  if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(buttons[i])))
211  {
212  PresentationInterface::Ptr const& p = children[i];
213 
214  Colormappable::Ptr const c = boost::dynamic_pointer_cast<Colormappable>(p);
215  bool hasTransparentBackground = false;
216  if(c && p->isPropertyDefined(TRANSPARENT_BACKGROUND_PROPERTY_NAME))
217  {
218  if(count == 0)
219  {
220  c->disableTransparentBackground();
221  }
222  else
223  {
224  c->setTransparentBackground();
225  hasTransparentBackground = true;
226  }
227  }
228 
229  cairo_save(cr_sub);
230  cairo_set_operator(cr_sub, CAIRO_OPERATOR_CLEAR);
231  cairo_paint(cr_sub);
232  cairo_restore(cr_sub);
233 
234  cairo_save(cr_sub);
235  p->redraw(childViews[p], cr_sub, pa, zoom);
236  cairo_restore(cr_sub);
237 
238  cairo_set_source_surface(cr, surface, 0, 0);
239 
240  if(hasTransparentBackground)
241  {
242  cairo_paint(cr);
243  }
244  else
245  {
246  cairo_paint_with_alpha(cr, 1.0 / (count + 1));
247  }
248 
249  if(!hasTransparentBackground)
250  {
251  count++;
252  }
253  }
254  }
255 
256  cairo_destroy(cr_sub);
257 }
Here is the call graph for this function:

◆ toggled()

void TransparentOverlayViewInfo::toggled ( GtkToggleButton *  button)
259 { invalidate(); }
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:
ChildView::create
static Ptr create(boost::shared_ptr< TransparentOverlayViewInfo > const &parent)
Definition: transparentoverlayviewinfo.cc:70
Scroom::MemoryBlocks::RawPageData::Ptr
boost::shared_ptr< uint8_t > Ptr
Definition: blockallocator.hh:23
TransparentOverlayViewInfo::buttons
std::vector< GtkWidget * > buttons
Definition: transparentoverlayviewinfo.hh:72
TransparentOverlayViewInfo::createToggleToolButton
void createToggleToolButton(PresentationInterface::Ptr const &p)
Definition: transparentoverlayviewinfo.cc:110
TransparentOverlayViewInfo::Ptr
boost::shared_ptr< TransparentOverlayViewInfo > Ptr
Definition: transparentoverlayviewinfo.hh:63
TransparentOverlayViewInfo::addChild
void addChild(const PresentationInterface::Ptr &child)
Definition: transparentoverlayviewinfo.cc:144
anonymous_namespace{transparentoverlayviewinfo.cc}::setToggleButtonColor
void setToggleButtonColor(GtkWidget *w, PresentationInterface::Ptr const &p)
Definition: transparentoverlayviewinfo.cc:25
PresentationInterface::Ptr
boost::shared_ptr< PresentationInterface > Ptr
Definition: presentationinterface.hh:74
TransparentOverlayViewInfo::progressInterfaceMultiplexer
Scroom::Utils::ProgressInterfaceMultiplexer::Ptr progressInterfaceMultiplexer
Definition: transparentoverlayviewinfo.hh:71
TransparentOverlayViewInfo::invalidate
void invalidate()
Definition: transparentoverlayviewinfo.hh:90
TransparentOverlayViewInfo::sizeDeterminer
SizeDeterminer::Ptr sizeDeterminer
Definition: transparentoverlayviewinfo.hh:74
on_toggled
static void on_toggled(GtkToggleButton *button, gpointer data)
Definition: transparentoverlayviewinfo.cc:105
TransparentOverlayViewInfo::TransparentOverlayViewInfo
TransparentOverlayViewInfo(const ViewInterface::WeakPtr &vi, SizeDeterminer::Ptr sizeDeterminer)
Definition: transparentoverlayviewinfo.cc:98
Colormappable::Ptr
boost::shared_ptr< Colormappable > Ptr
Definition: colormappable.hh:116
Scroom::Utils::Rectangle::toGdkRectangle
cairo_rectangle_int_t toGdkRectangle() const
Definition: rectangle.hh:62
TransparentOverlayViewInfo::parentView
ViewInterface::Ptr parentView
Definition: transparentoverlayviewinfo.hh:69
Scroom::Bitmap::BitmapSurface
Definition: bitmap-helpers.hh:22
ChildView::Ptr
boost::shared_ptr< ChildView > Ptr
Definition: transparentoverlayviewinfo.hh:34
TransparentOverlayViewInfo::children
std::vector< PresentationInterface::Ptr > children
Definition: transparentoverlayviewinfo.hh:73
TRANSPARENT_BACKGROUND_PROPERTY_NAME
const std::string TRANSPARENT_BACKGROUND_PROPERTY_NAME
Definition: colormappable.hh:23
create
void create(NewPresentationInterface *interface)
Definition: loader.cc:175
TransparentOverlayViewInfo::childViews
ChildMap childViews
Definition: transparentoverlayviewinfo.hh:70
Scroom::Utils::ProgressInterfaceMultiplexer::create
static Ptr create(ProgressInterface::Ptr parent)
Definition: progressinterfacehelpers.cc:252