Skip to content

Commit

Permalink
added undo on add, cut and paste controls
Browse files Browse the repository at this point in the history
now cutted controls can be paste more times
  • Loading branch information
besh81 committed Jan 5, 2021
1 parent 12530f1 commit 01e1bd9
Show file tree
Hide file tree
Showing 4 changed files with 148 additions and 130 deletions.
32 changes: 31 additions & 1 deletion src/ctrls/notebook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ namespace ctrls

pages.push_back(child);

//
tbb.push_back(child->properties.property("caption").as_string());
tbb.attach(tbb.length() - 1, *child->nanawdg);

Expand All @@ -114,6 +113,37 @@ namespace ctrls
}


bool notebook::insert(ctrl* child, ctrl* pos, bool after)
{
if(!child)
return false;

int i = 0;
for(auto p = pages.begin(); p < pages.end(); ++p, ++i)
{
if(*p == pos)
{
if(after)
{
++p;
++i;
}

pages.insert(p, child);

tbb.insert(i, child->properties.property("caption").as_string());
tbb.attach(i, *child->nanawdg);

plc["pages"].fasten(*child->nanawdg);
plc.collocate();
return true;
}
}

return false;
}


bool notebook::remove(ctrl* child)
{
if(!child)
Expand Down
1 change: 1 addition & 0 deletions src/ctrls/notebook.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ namespace ctrls

// relationship management
bool append(ctrl* child) override;
bool insert(ctrl* child, ctrl* pos, bool after) override;
bool remove(ctrl* child) override;
//
bool moveup(ctrl* child) override;
Expand Down
Loading

0 comments on commit 01e1bd9

Please sign in to comment.