Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[[ Bug 22843 ]] Implement subwindow without waiting
This patch adds the `without waiting` clause to the modal and sheet subwindow
commands.
  • Loading branch information
montegoulding committed Sep 16, 2020
commit 672eff87592df0e9c110ae14752524a78eb75fc4
10 changes: 10 additions & 0 deletions engine/src/cmds.h
Original file line number Diff line number Diff line change
Expand Up @@ -1898,6 +1898,7 @@ class MCSubwindow : public MCStatement
MCExpression *properties;
protected:
Window_mode mode;
bool m_wait_while_open;
public:
MCSubwindow()
{
Expand All @@ -1921,6 +1922,7 @@ class MCTopLevel : public MCSubwindow
MCTopLevel()
{
mode = WM_TOP_LEVEL;
m_wait_while_open = false;
}
};

Expand All @@ -1930,6 +1932,7 @@ class MCModal : public MCSubwindow
MCModal()
{
mode = WM_MODAL;
m_wait_while_open = true;
}
};

Expand All @@ -1939,6 +1942,7 @@ class MCModeless : public MCSubwindow
MCModeless()
{
mode = WM_MODELESS;
m_wait_while_open = false;
}
};

Expand All @@ -1948,6 +1952,7 @@ class MCOption : public MCSubwindow
MCOption()
{
mode = WM_OPTION;
m_wait_while_open = false;
}
};

Expand All @@ -1957,6 +1962,7 @@ class MCPalette : public MCSubwindow
MCPalette()
{
mode = WM_PALETTE;
m_wait_while_open = false;
}
};

Expand All @@ -1966,6 +1972,7 @@ class MCPopup : public MCSubwindow
MCPopup()
{
mode = WM_POPUP;
m_wait_while_open = false;
}
};

Expand All @@ -1975,6 +1982,7 @@ class MCPulldown : public MCSubwindow
MCPulldown()
{
mode = WM_PULLDOWN;
m_wait_while_open = false;
}
};

Expand All @@ -1984,6 +1992,7 @@ class MCSheet : public MCSubwindow
MCSheet()
{
mode = WM_SHEET;
m_wait_while_open = true;
}
};

Expand All @@ -1994,6 +2003,7 @@ class MCDrawer : public MCSubwindow
MCDrawer()
{
mode = WM_DRAWER;
m_wait_while_open = false;
}
};

Expand Down
19 changes: 13 additions & 6 deletions engine/src/cmdss.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1490,6 +1490,13 @@ Parse_stat MCSubwindow::parse(MCScriptPoint &sp)
return PS_ERROR;
}
}
else if ((mode == WM_MODAL || mode == WM_SHEET) &&
(sp.skip_token(SP_SUGAR, TT_PREP, PT_WITHOUT) == PS_NORMAL) &&
(sp.skip_token(SP_MOVE, TT_UNDEFINED, MM_WAITING) == PS_NORMAL))
{
m_wait_while_open = false;
}

return PS_NORMAL;
}

Expand Down Expand Up @@ -1558,9 +1565,9 @@ void MCSubwindow::exec_ctxt(MCExecContext &ctxt)
case WM_PALETTE:
case WM_MODAL:
if (*optr_name != nil)
MCInterfaceExecOpenStackByName(ctxt, *optr_name, mode);
MCInterfaceExecOpenStackByName(ctxt, *optr_name, mode, m_wait_while_open);
else
MCInterfaceExecOpenStack(ctxt, (MCStack *)optr, mode);
MCInterfaceExecOpenStack(ctxt, (MCStack *)optr, mode, m_wait_while_open);
break;
case WM_SHEET:
case WM_DRAWER:
Expand All @@ -1572,9 +1579,9 @@ void MCSubwindow::exec_ctxt(MCExecContext &ctxt)
if (mode == WM_SHEET)
{
if (*optr_name != nil)
MCInterfaceExecSheetStackByName(ctxt, *optr_name, *t_parent_name, thisstack == True);
MCInterfaceExecSheetStackByName(ctxt, *optr_name, *t_parent_name, thisstack == True, m_wait_while_open);
else
MCInterfaceExecSheetStack(ctxt, (MCStack *)optr, *t_parent_name, thisstack == True);
MCInterfaceExecSheetStack(ctxt, (MCStack *)optr, *t_parent_name, thisstack == True, m_wait_while_open);
}
else
{
Expand Down Expand Up @@ -1630,9 +1637,9 @@ void MCSubwindow::exec_ctxt(MCExecContext &ctxt)
}
}
if (optr == nil)
MCInterfaceExecDrawerStackByName(ctxt, *optr_name, *t_parent_name, thisstack == True, t_pos, t_align);
MCInterfaceExecDrawerStackByName(ctxt, *optr_name, *t_parent_name, thisstack == True, t_pos, t_align, m_wait_while_open);
else
MCInterfaceExecDrawerStack(ctxt, (MCStack *)optr, *t_parent_name, thisstack == True, t_pos, t_align);
MCInterfaceExecDrawerStack(ctxt, (MCStack *)optr, *t_parent_name, thisstack == True, t_pos, t_align, m_wait_while_open);
}
break;
}
Expand Down
50 changes: 20 additions & 30 deletions engine/src/exec-interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2794,7 +2794,7 @@ void MCInterfaceExecPopupButton(MCExecContext& ctxt, MCButton *p_target, MCPoint
}
}

void MCInterfaceExecSubwindow(MCExecContext& ctxt, MCStack *p_target, MCStack *p_parent, MCRectangle p_rect, int p_at, int p_aligned, int p_mode)
void MCInterfaceExecSubwindow(MCExecContext& ctxt, MCStack *p_target, MCStack *p_parent, MCRectangle p_rect, int p_at, int p_aligned, int p_mode, bool p_wait_while_open)
{
if (p_mode != WM_PULLDOWN && p_mode != WM_POPUP && p_mode != WM_OPTION)
MCU_watchcursor(ctxt . GetObject()->getstack(), False);
Expand Down Expand Up @@ -2836,7 +2836,7 @@ void MCInterfaceExecSubwindow(MCExecContext& ctxt, MCStack *p_target, MCStack *p
MCdefaultstackptr = t_old_defaultstack;
}

void MCInterfaceExecDrawerOrSheetStack(MCExecContext& ctxt, MCStack *p_target, MCNameRef p_parent_name, bool p_parent_is_thisstack, int p_at, int p_aligned, int p_mode)
void MCInterfaceExecDrawerOrSheetStack(MCExecContext& ctxt, MCStack *p_target, MCNameRef p_parent_name, bool p_parent_is_thisstack, int p_at, int p_aligned, int p_mode, bool p_wait_while_open)
{
MCStack *parentptr;
parentptr = nil;
Expand Down Expand Up @@ -2864,15 +2864,15 @@ void MCInterfaceExecDrawerOrSheetStack(MCExecContext& ctxt, MCStack *p_target, M
}
else
// AL-2014-11-24: [[ Bug 14076 ]] Don't override window mode with WM_DRAWER
MCInterfaceExecSubwindow(ctxt, p_target, parentptr, parentptr->getrect(), p_at, p_aligned, p_mode);
MCInterfaceExecSubwindow(ctxt, p_target, parentptr, parentptr->getrect(), p_at, p_aligned, p_mode, p_wait_while_open);
}
else if (MCdefaultstackptr->getopened() || !MCtopstackptr)
MCInterfaceExecSubwindow(ctxt, p_target, MCdefaultstackptr, MCdefaultstackptr->getrect(), p_at, p_aligned, p_mode);
MCInterfaceExecSubwindow(ctxt, p_target, MCdefaultstackptr, MCdefaultstackptr->getrect(), p_at, p_aligned, p_mode, p_wait_while_open);
else
MCInterfaceExecSubwindow(ctxt, p_target, MCtopstackptr, MCtopstackptr->getrect(), p_at, p_aligned, p_mode);
MCInterfaceExecSubwindow(ctxt, p_target, MCtopstackptr, MCtopstackptr->getrect(), p_at, p_aligned, p_mode, p_wait_while_open);
}

void MCInterfaceExecDrawerOrSheetStackByName(MCExecContext& ctxt, MCNameRef p_name, MCNameRef p_parent_name, bool p_parent_is_thisstack, int p_at, int p_aligned, int p_mode)
void MCInterfaceExecDrawerOrSheetStackByName(MCExecContext& ctxt, MCNameRef p_name, MCNameRef p_parent_name, bool p_parent_is_thisstack, int p_at, int p_aligned, int p_mode, bool p_wait_while_open)
{
MCStack *sptr;
sptr = ctxt . GetObject()->getstack()->findstackname(p_name);
Expand All @@ -2884,37 +2884,27 @@ void MCInterfaceExecDrawerOrSheetStackByName(MCExecContext& ctxt, MCNameRef p_na
return;
}

MCInterfaceExecDrawerOrSheetStack(ctxt, sptr, p_parent_name, p_parent_is_thisstack, p_at, p_aligned, p_mode);
MCInterfaceExecDrawerOrSheetStack(ctxt, sptr, p_parent_name, p_parent_is_thisstack, p_at, p_aligned, p_mode, p_wait_while_open);
}

void MCInterfaceExecDrawerStack(MCExecContext& ctxt, MCStack *p_target, MCNameRef p_parent_name, bool p_parent_is_thisstack, int p_at, int p_aligned)
void MCInterfaceExecDrawerStack(MCExecContext& ctxt, MCStack *p_target, MCNameRef p_parent_name, bool p_parent_is_thisstack, int p_at, int p_aligned, bool p_wait_while_open)
{
MCInterfaceExecDrawerOrSheetStack(ctxt, p_target, p_parent_name, p_parent_is_thisstack, p_at, p_aligned, WM_DRAWER);
MCInterfaceExecDrawerOrSheetStack(ctxt, p_target, p_parent_name, p_parent_is_thisstack, p_at, p_aligned, WM_DRAWER, p_wait_while_open);
}

void MCInterfaceExecDrawerStackByName(MCExecContext& ctxt, MCNameRef p_name, MCNameRef p_parent_name, bool p_parent_is_thisstack, int p_at, int p_aligned)
void MCInterfaceExecDrawerStackByName(MCExecContext& ctxt, MCNameRef p_name, MCNameRef p_parent_name, bool p_parent_is_thisstack, int p_at, int p_aligned, bool p_wait_while_open)
{
MCInterfaceExecDrawerOrSheetStackByName(ctxt, p_name, p_parent_name, p_parent_is_thisstack, p_at, p_aligned, WM_DRAWER);
MCInterfaceExecDrawerOrSheetStackByName(ctxt, p_name, p_parent_name, p_parent_is_thisstack, p_at, p_aligned, WM_DRAWER, p_wait_while_open);
}

void MCInterfaceExecDrawerStackLegacy(MCExecContext& ctxt, MCStack *p_target, MCNameRef parent, bool p_parent_is_thisstack, intenum_t p_at, intenum_t p_aligned)
void MCInterfaceExecSheetStack(MCExecContext& ctxt, MCStack *p_target, MCNameRef p_parent_name, bool p_parent_is_thisstack, bool p_wait_while_open)
{
MCInterfaceExecDrawerStack(ctxt, p_target, parent, p_parent_is_thisstack, (int)p_at, (int)p_aligned);
MCInterfaceExecDrawerOrSheetStack(ctxt, p_target, p_parent_name, p_parent_is_thisstack, WP_DEFAULT, OP_CENTER, WM_SHEET, p_wait_while_open);
}

void MCInterfaceExecDrawerStackByNameLegacy(MCExecContext& ctxt, MCNameRef p_name, MCNameRef parent, bool p_parent_is_thisstack, intenum_t p_at, intenum_t p_aligned)
void MCInterfaceExecSheetStackByName(MCExecContext& ctxt, MCNameRef p_name, MCNameRef p_parent_name, bool p_parent_is_thisstack, bool p_wait_while_open)
{
MCInterfaceExecDrawerStackByName(ctxt, p_name, parent, p_parent_is_thisstack, (int)p_at, (int)p_aligned);
}

void MCInterfaceExecSheetStack(MCExecContext& ctxt, MCStack *p_target, MCNameRef p_parent_name, bool p_parent_is_thisstack)
{
MCInterfaceExecDrawerOrSheetStack(ctxt, p_target, p_parent_name, p_parent_is_thisstack, WP_DEFAULT, OP_CENTER, WM_SHEET);
}

void MCInterfaceExecSheetStackByName(MCExecContext& ctxt, MCNameRef p_name, MCNameRef p_parent_name, bool p_parent_is_thisstack)
{
MCInterfaceExecDrawerOrSheetStackByName(ctxt, p_name, p_parent_name, p_parent_is_thisstack, WP_DEFAULT, OP_CENTER, WM_SHEET);
MCInterfaceExecDrawerOrSheetStackByName(ctxt, p_name, p_parent_name, p_parent_is_thisstack, WP_DEFAULT, OP_CENTER, WM_SHEET, p_wait_while_open);
}

static MCStack* open_stack_relative_to(MCStack *p_target)
Expand All @@ -2927,13 +2917,13 @@ static MCStack* open_stack_relative_to(MCStack *p_target)
return p_target;
}

void MCInterfaceExecOpenStack(MCExecContext& ctxt, MCStack *p_target, int p_mode)
void MCInterfaceExecOpenStack(MCExecContext& ctxt, MCStack *p_target, int p_mode, bool p_wait_while_open)
{
MCStack* t_stack = open_stack_relative_to(p_target);
MCInterfaceExecSubwindow(ctxt, p_target, nil, t_stack->getrect(), WP_DEFAULT, OP_NONE, p_mode);
MCInterfaceExecSubwindow(ctxt, p_target, nil, t_stack->getrect(), WP_DEFAULT, OP_NONE, p_mode, p_wait_while_open);
}

void MCInterfaceExecOpenStackByName(MCExecContext& ctxt, MCNameRef p_name, int p_mode)
void MCInterfaceExecOpenStackByName(MCExecContext& ctxt, MCNameRef p_name, int p_mode, bool p_wait_while_open)
{
MCStack *sptr;
sptr = ctxt . GetObject()->getstack()->findstackname(p_name);
Expand All @@ -2945,7 +2935,7 @@ void MCInterfaceExecOpenStackByName(MCExecContext& ctxt, MCNameRef p_name, int p
return;
}

MCInterfaceExecOpenStack(ctxt, sptr, p_mode);
MCInterfaceExecOpenStack(ctxt, sptr, p_mode, p_wait_while_open);
}

void MCInterfaceExecPopupStack(MCExecContext& ctxt, MCStack *p_target, MCPoint *p_at, int p_mode)
Expand All @@ -2972,7 +2962,7 @@ void MCInterfaceExecPopupStack(MCExecContext& ctxt, MCStack *p_target, MCPoint *
}
MCRectangle t_rect;
t_rect = MCU_recttoroot(MCtargetptr -> getstack(), MCtargetptr -> getrect());
MCInterfaceExecSubwindow(ctxt, p_target, nil, t_rect, WP_DEFAULT, OP_NONE, p_mode);
MCInterfaceExecSubwindow(ctxt, p_target, nil, t_rect, WP_DEFAULT, OP_NONE, p_mode, false);
if (!MCabortscript)
return;

Expand Down
14 changes: 6 additions & 8 deletions engine/src/exec.h
Original file line number Diff line number Diff line change
Expand Up @@ -2383,14 +2383,12 @@ void MCInterfaceExecShowTaskBar(MCExecContext& ctxt);

void MCInterfaceExecPopupWidget(MCExecContext &ctxt, MCNameRef p_kind, MCPoint *p_at, MCArrayRef p_properties);
void MCInterfaceExecPopupButton(MCExecContext& ctxt, MCButton *p_target, MCPoint *p_at);
void MCInterfaceExecDrawerStack(MCExecContext& ctxt, MCStack *p_target, MCNameRef parent, bool p_parent_is_thisstack, int p_at, int p_aligned);
void MCInterfaceExecDrawerStackByName(MCExecContext& ctxt, MCNameRef p_target, MCNameRef parent, bool p_parent_is_thisstack, int p_at, int p_aligned);
void MCInterfaceExecDrawerStackLegacy(MCExecContext& ctxt, MCStack *p_target, MCNameRef parent, bool p_parent_is_thisstack, intenum_t p_at, intenum_t p_aligned);
void MCInterfaceExecDrawerStackByNameLegacy(MCExecContext& ctxt, MCNameRef p_target, MCNameRef parent, bool p_parent_is_thisstack, intenum_t p_at, intenum_t p_aligned);
void MCInterfaceExecSheetStack(MCExecContext& ctxt, MCStack *p_target, MCNameRef parent, bool p_parent_is_thisstack);
void MCInterfaceExecSheetStackByName(MCExecContext& ctxt, MCNameRef p_target, MCNameRef parent, bool p_parent_is_thisstack);
void MCInterfaceExecOpenStack(MCExecContext& ctxt, MCStack *p_target, int p_mode);
void MCInterfaceExecOpenStackByName(MCExecContext& ctxt, MCNameRef p_target, int p_mode);
void MCInterfaceExecDrawerStack(MCExecContext& ctxt, MCStack *p_target, MCNameRef parent, bool p_parent_is_thisstack, int p_at, int p_aligned, bool p_wait_while_open);
void MCInterfaceExecDrawerStackByName(MCExecContext& ctxt, MCNameRef p_target, MCNameRef parent, bool p_parent_is_thisstack, int p_at, int p_aligned, bool p_wait_while_open);
void MCInterfaceExecSheetStack(MCExecContext& ctxt, MCStack *p_target, MCNameRef parent, bool p_parent_is_thisstack, bool p_wait_while_open);
void MCInterfaceExecSheetStackByName(MCExecContext& ctxt, MCNameRef p_target, MCNameRef parent, bool p_parent_is_thisstack, bool p_wait_while_open);
void MCInterfaceExecOpenStack(MCExecContext& ctxt, MCStack *p_target, int p_mode, bool p_wait_while_open);
void MCInterfaceExecOpenStackByName(MCExecContext& ctxt, MCNameRef p_target, int p_mode, bool p_wait_while_open);
void MCInterfaceExecPopupStack(MCExecContext& ctxt, MCStack *p_target, MCPoint *p_at, int p_mode);
void MCInterfaceExecPopupStackByName(MCExecContext& ctxt, MCNameRef p_target, MCPoint *p_at, int p_mode);

Expand Down