Requested anchor RAIIed.
This commit is contained in:
20
dw/layout.cc
20
dw/layout.cc
@ -281,7 +281,6 @@ Layout::Layout (std::unique_ptr< Platform > platform, bool limit)
|
|||||||
DBG_OBJ_SET_NUM ("hScrollbarThickness", hScrollbarThickness);
|
DBG_OBJ_SET_NUM ("hScrollbarThickness", hScrollbarThickness);
|
||||||
DBG_OBJ_SET_NUM ("vScrollbarThickness", vScrollbarThickness);
|
DBG_OBJ_SET_NUM ("vScrollbarThickness", vScrollbarThickness);
|
||||||
|
|
||||||
requestedAnchor = NULL;
|
|
||||||
scrollIdleId = -1;
|
scrollIdleId = -1;
|
||||||
scrollIdleNotInterrupted = false;
|
scrollIdleNotInterrupted = false;
|
||||||
|
|
||||||
@ -332,9 +331,6 @@ Layout::~Layout ()
|
|||||||
delete view;
|
delete view;
|
||||||
delete textZone;
|
delete textZone;
|
||||||
|
|
||||||
if (requestedAnchor)
|
|
||||||
free (requestedAnchor);
|
|
||||||
|
|
||||||
DBG_OBJ_DELETE ();
|
DBG_OBJ_DELETE ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -410,7 +406,7 @@ void Layout::removeWidget ()
|
|||||||
view->setViewportSize (viewportWidth, viewportHeight, 0, 0);
|
view->setViewportSize (viewportWidth, viewportHeight, 0, 0);
|
||||||
view->queueDrawTotal ();
|
view->queueDrawTotal ();
|
||||||
|
|
||||||
setAnchor (NULL);
|
setAnchor (std::nullopt);
|
||||||
updateAnchor ();
|
updateAnchor ();
|
||||||
|
|
||||||
emitter.emitCanvasSizeChanged (canvasWidth, canvasAscent, canvasDescent);
|
emitter.emitCanvasSizeChanged (canvasWidth, canvasAscent, canvasDescent);
|
||||||
@ -724,13 +720,11 @@ int Layout::currVScrollbarThickness()
|
|||||||
/**
|
/**
|
||||||
* Sets the anchor to scroll to.
|
* Sets the anchor to scroll to.
|
||||||
*/
|
*/
|
||||||
void Layout::setAnchor (const char *anchor)
|
void Layout::setAnchor (const std::optional< std::string_view > anchor)
|
||||||
{
|
{
|
||||||
_MSG("setAnchor (%s)\n", anchor);
|
_MSG("setAnchor (%s)\n", anchor.value_or("").string().c_str());
|
||||||
|
|
||||||
if (requestedAnchor)
|
requestedAnchor = anchor;
|
||||||
free (requestedAnchor);
|
|
||||||
requestedAnchor = anchor ? dStrdup (anchor) : NULL;
|
|
||||||
updateAnchor ();
|
updateAnchor ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -776,9 +770,9 @@ void Layout::removeAnchor (Widget *widget, char* name)
|
|||||||
void Layout::updateAnchor ()
|
void Layout::updateAnchor ()
|
||||||
{
|
{
|
||||||
Anchor *anchor= nullptr;
|
Anchor *anchor= nullptr;
|
||||||
if (requestedAnchor and anchorsTable.contains( requestedAnchor ) )
|
if (requestedAnchor and anchorsTable.contains( requestedAnchor.value() ) )
|
||||||
{
|
{
|
||||||
anchor= anchorsTable[ requestedAnchor ].get();
|
anchor= anchorsTable[ requestedAnchor.value() ].get();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (anchor == NULL) {
|
if (anchor == NULL) {
|
||||||
@ -1292,7 +1286,7 @@ void Layout::scrollPosChanged (View *view, int x, int y)
|
|||||||
scrollX = x;
|
scrollX = x;
|
||||||
scrollY = y;
|
scrollY = y;
|
||||||
|
|
||||||
setAnchor (NULL);
|
setAnchor( std::nullopt );
|
||||||
updateAnchor ();
|
updateAnchor ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -182,7 +182,7 @@ private:
|
|||||||
VPosition scrollTargetVpos;
|
VPosition scrollTargetVpos;
|
||||||
int scrollTargetX, scrollTargetY, scrollTargetWidth, scrollTargetHeight;
|
int scrollTargetX, scrollTargetY, scrollTargetWidth, scrollTargetHeight;
|
||||||
|
|
||||||
char *requestedAnchor;
|
std::optional< std::string > requestedAnchor;
|
||||||
int scrollIdleId, resizeIdleId;
|
int scrollIdleId, resizeIdleId;
|
||||||
bool scrollIdleNotInterrupted;
|
bool scrollIdleNotInterrupted;
|
||||||
|
|
||||||
@ -300,7 +300,7 @@ public:
|
|||||||
void scrollTo (HPosition hpos, VPosition vpos,
|
void scrollTo (HPosition hpos, VPosition vpos,
|
||||||
int x, int y, int width, int height);
|
int x, int y, int width, int height);
|
||||||
void scroll (ScrollCommand);
|
void scroll (ScrollCommand);
|
||||||
void setAnchor (const char *anchor);
|
void setAnchor (std::optional< std::string_view > anchor);
|
||||||
|
|
||||||
/* View */
|
/* View */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user