mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-16 14:16:09 -06:00
TabBar: ConfirmCloseSome
This commit is contained in:
parent
6e4ae677c6
commit
d3ef160f10
3 changed files with 10 additions and 10 deletions
|
|
@ -102,7 +102,7 @@ String>] is equivalent of [*C@5 Function<void (int, String)>].&]
|
|||
[s2; Creates alias for Function returning bool. For example, [*C@5 Gate<int,
|
||||
String>] is equivalent of [*C@5 Function<bool (int, String)>].
|
||||
Note that empty Gate returns false (because empty Function returns
|
||||
bool(), which is false).&]
|
||||
bool(0), which is false).&]
|
||||
[s3;%- &]
|
||||
[s0;%- &]
|
||||
[ {{10000@(113.42.0) [s0; [*@7;4 MemFn and THISFN]]}}&]
|
||||
|
|
|
|||
|
|
@ -331,6 +331,7 @@ TabBar::TabBar()
|
|||
|
||||
ConfirmClose = [](Value v) { return true; };
|
||||
ConfirmCloseAll = []() { return true; };
|
||||
ConfirmCloseSome = []() { return true; };
|
||||
}
|
||||
|
||||
int TabBar::GetLR( int c, int jd )
|
||||
|
|
@ -515,15 +516,13 @@ void TabBar::ContextMenu(Bar& bar)
|
|||
|
||||
void TabBar::CloseAll(int exception, int last_closed)
|
||||
{
|
||||
if(!ConfirmCloseAll())
|
||||
return;
|
||||
|
||||
ValueArray vv;
|
||||
for(int i = last_closed; i < tabs.GetCount(); i++)
|
||||
if(i != exception)
|
||||
vv.Add(tabs[i].key);
|
||||
|
||||
if(exception < 0 && last_closed == 0 ? CancelCloseAll() : CancelCloseSome(vv))
|
||||
if(exception < 0 && last_closed == 0 ? !ConfirmCloseAll() || CancelCloseAll()
|
||||
: !ConfirmCloseSome(vv) || CancelCloseSome(vv))
|
||||
return;
|
||||
|
||||
WhenCloseSome(vv);
|
||||
|
|
@ -532,7 +531,7 @@ void TabBar::CloseAll(int exception, int last_closed)
|
|||
|
||||
for(int i = tabs.GetCount() - 1; i >= last_closed; i--)
|
||||
if(i != exception) {
|
||||
if (!CancelClose(tabs[i].key)) {
|
||||
if (!CancelClose(tabs[i].key) && ConfirmClose(tabs[i].key)) {
|
||||
WhenClose(tabs[i].key);
|
||||
TabClosed(tabs[i].key);
|
||||
tabs.Remove(i);
|
||||
|
|
@ -836,7 +835,7 @@ void TabBar::DoCloseGroup(int n)
|
|||
nTabs++;
|
||||
}
|
||||
// at first, we check for CancelCloseSome()
|
||||
if(vv.GetCount() && !CancelCloseSome(vv)) {
|
||||
if(vv.GetCount() && !CancelCloseSome(vv) && ConfirmCloseSome(vv)) {
|
||||
// we didn't cancel globally, now we check CancelClose()
|
||||
// for each tab -- group gets removed ONLY if ALL of
|
||||
// group tabs are closed
|
||||
|
|
@ -861,8 +860,8 @@ void TabBar::DoCloseGroup(int n)
|
|||
{
|
||||
if (!CancelClose(vv[i]) && ConfirmClose(vv[i])) {
|
||||
WhenClose(vv[i]);
|
||||
TabClosed(vv[i]);
|
||||
tabs.Remove(vi[i]);
|
||||
TabClosed(vv[i]);
|
||||
tabs.Remove(vi[i]);
|
||||
}
|
||||
}
|
||||
// remove group if all of its tabs get closed
|
||||
|
|
@ -2212,7 +2211,7 @@ void TabBar::MiddleDown(Point p, dword keyflags)
|
|||
ValueArray vv;
|
||||
vv.Add(v);
|
||||
int highlightBack = highlight;
|
||||
if (!CancelClose(v) && ! CancelCloseSome(vv) && ConfirmClose(v)) {
|
||||
if (!CancelClose(v) && !CancelCloseSome(vv) && ConfirmCloseSome(vv) && ConfirmClose(v)) {
|
||||
// highlight can be changed by the prompt. When reading "v", it can be invalid. I use the value from before the prompt to fix it
|
||||
Value v = tabs[highlightBack].key;
|
||||
// 2014/03/06 - FIRST the callbacks, THEN remove the tab
|
||||
|
|
|
|||
|
|
@ -424,6 +424,7 @@ public:
|
|||
Gate<> ConfirmCloseAll; // Called before closing
|
||||
Event<> WhenCloseAll; // Executed before 'Close All' action
|
||||
Gate<ValueArray> CancelCloseSome; // Return true to cancel action (executed with list of closing tabs)
|
||||
Gate<ValueArray> ConfirmCloseSome; // Called before closing the group
|
||||
Event<ValueArray> WhenCloseSome; // Executed before any 'Close' action (with list of closing tabs)
|
||||
Gate<int, int> CancelDragAndDrop; // Return true to cancel drag and drop from tab to tab
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue