Partially done.
This commit is contained in:
21
dw/layout.cc
21
dw/layout.cc
@ -248,13 +248,6 @@ bool Layout::LinkEmitter::emitClick (Widget *widget, int link, int img,
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
Layout::Anchor::~Anchor ()
|
||||
{
|
||||
free(name);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
Layout::Layout (std::unique_ptr< Platform > platform, bool limit)
|
||||
{
|
||||
this->platform = std::move( platform );
|
||||
@ -731,18 +724,20 @@ void Layout::setAnchor (const std::optional< std::string_view > anchor)
|
||||
/**
|
||||
* Used, when the widget is not allocated yet.
|
||||
*/
|
||||
char *Layout::addAnchor (Widget *widget, const char* name)
|
||||
std::optional< std::string >
|
||||
Layout::addAnchor (Widget *widget, const std::string &name)
|
||||
{
|
||||
return addAnchor (widget, name, -1);
|
||||
}
|
||||
|
||||
char *Layout::addAnchor (Widget *widget, const char* name, int y)
|
||||
std::optional< std::string >
|
||||
Layout::addAnchor (Widget *widget, const std::string &name, int y)
|
||||
{
|
||||
if (anchorsTable.contains (name))
|
||||
return NULL;
|
||||
return std::nullopt;
|
||||
else {
|
||||
auto anchor = std::make_unique< Anchor >();
|
||||
char *const rv= anchor->name = dStrdup (name);
|
||||
std::string rv= anchor->name= name;
|
||||
anchor->widget = widget;
|
||||
anchor->y = y;
|
||||
|
||||
@ -753,7 +748,7 @@ char *Layout::addAnchor (Widget *widget, const char* name, int y)
|
||||
}
|
||||
}
|
||||
|
||||
void Layout::changeAnchor (Widget *widget, char* name, int y)
|
||||
void Layout::changeAnchor (Widget *widget, const std::string &name, int y)
|
||||
{
|
||||
Anchor *const anchor = anchorsTable.at( name ).get();
|
||||
assert (anchor);
|
||||
@ -762,7 +757,7 @@ void Layout::changeAnchor (Widget *widget, char* name, int y)
|
||||
updateAnchor ();
|
||||
}
|
||||
|
||||
void Layout::removeAnchor (Widget *widget, char* name)
|
||||
void Layout::removeAnchor (Widget *widget, const std::string &name)
|
||||
{
|
||||
anchorsTable.erase( name );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user