- ColorpickerMenu.MouseEvent exported.

This commit is contained in:
Christoph Oelckers 2017-02-10 11:44:46 +01:00
commit be9b2b38fc
10 changed files with 158 additions and 76 deletions

View file

@ -124,55 +124,6 @@ public:
//
//=============================================================================
bool MouseEvent(int type, int mx, int my)
{
int olditem = mDesc->mSelectedItem;
bool res = Super::MouseEvent(type, mx, my);
if (mDesc->mSelectedItem == -1 || mDesc->mSelectedItem == mStartItem+7)
{
int y = (-mDesc->mPosition + BigFont->GetHeight() + mDesc->mItems.Size() * OptionSettings.mLinespacing) * CleanYfac_1;
int h = (screen->GetHeight() - y) / 16;
int fh = OptionSettings.mLinespacing * CleanYfac_1;
int w = fh;
int yy = y + 2 * CleanYfac_1;
int indent = (screen->GetWidth() / 2);
if (h > fh) h = fh;
else if (h < 4) return res; // no space to draw it.
int box_y = y - 2 * CleanYfac_1;
int box_x = indent - 16*w;
if (mx >= box_x && mx < box_x + 16*w && my >= box_y && my < box_y + 16*h)
{
int cell_x = (mx - box_x) / w;
int cell_y = (my - box_y) / h;
if (olditem != mStartItem+7 || cell_x != mGridPosX || cell_y != mGridPosY)
{
mGridPosX = cell_x;
mGridPosY = cell_y;
//S_Sound (CHAN_VOICE | CHAN_UI, "menu/cursor", snd_menuvolume, ATTN_NONE);
}
mDesc->mSelectedItem = mStartItem+7;
if (type == MOUSE_Release)
{
MenuEvent(MKEY_Enter, true);
if (m_use_mouse == 2) mDesc->mSelectedItem = -1;
}
res = true;
}
}
return res;
}
//=============================================================================
//
//
//
//=============================================================================
void Drawer()
{
Super::Drawer();

View file

@ -149,7 +149,7 @@ bool DMenu::Responder (event_t *ev)
res = MouseEventBack(MOUSE_Click, ev->data1, ev->data2);
// make the menu's mouse handler believe that the current coordinate is outside the valid range
if (res) ev->data2 = -1;
res |= MouseEvent(MOUSE_Click, ev->data1, ev->data2);
res |= CallMouseEvent(MOUSE_Click, ev->data1, ev->data2);
if (res)
{
SetCapture();
@ -163,7 +163,7 @@ bool DMenu::Responder (event_t *ev)
{
res = MouseEventBack(MOUSE_Move, ev->data1, ev->data2);
if (res) ev->data2 = -1;
res |= MouseEvent(MOUSE_Move, ev->data1, ev->data2);
res |= CallMouseEvent(MOUSE_Move, ev->data1, ev->data2);
}
}
else if (ev->subtype == EV_GUI_LButtonUp)
@ -173,7 +173,7 @@ bool DMenu::Responder (event_t *ev)
ReleaseCapture();
res = MouseEventBack(MOUSE_Release, ev->data1, ev->data2);
if (res) ev->data2 = -1;
res |= MouseEvent(MOUSE_Release, ev->data1, ev->data2);
res |= CallMouseEvent(MOUSE_Release, ev->data1, ev->data2);
}
}
}
@ -217,7 +217,7 @@ bool DMenu::CallMenuEvent(int mkey, bool fromcontroller)
int retval;
VMReturn ret(&retval);
GlobalVMStack.Call(func, params, 3, &ret, 1, nullptr);
return retval;
return !!retval;
}
else return MenuEvent(mkey, fromcontroller);
}
@ -253,6 +253,28 @@ bool DMenu::MouseEvent(int type, int x, int y)
return true;
}
DEFINE_ACTION_FUNCTION(DMenu, MouseEvent)
{
PARAM_SELF_PROLOGUE(DMenu);
PARAM_INT(type);
PARAM_INT(x);
PARAM_INT(y);
ACTION_RETURN_BOOL(self->MouseEvent(type, x, y));
}
bool DMenu::CallMouseEvent(int type, int x, int y)
{
IFVIRTUAL(DMenu, MouseEvent)
{
VMValue params[] = { (DObject*)this, type, x, y };
int retval;
VMReturn ret(&retval);
GlobalVMStack.Call(func, params, 4, &ret, 1, nullptr);
return !!retval;
}
else return MouseEvent (type, x, y);
}
//=============================================================================
//
//
@ -1034,7 +1056,7 @@ CCMD(reset2saved)
//native OptionMenuItem OptionMenuDescriptor.GetItem(Name iname);
//native void OptionMenuItem.drawLabel(int indent, int y, EColorRange color, bool grayed = false);
DEFINE_FIELD(DMenuDescriptor, mMenuName)
DEFINE_FIELD(DMenuDescriptor, mMenuName)
DEFINE_FIELD(DMenuDescriptor, mNetgameMessage)
DEFINE_FIELD(DMenuDescriptor, mClass)
@ -1062,3 +1084,11 @@ DEFINE_FIELD(DOptionMenu, VisBottom)
DEFINE_FIELD(DOptionMenu, mFocusControl)
DEFINE_FIELD(DOptionMenu, mDesc)
DEFINE_FIELD(FOptionMenuSettings, mTitleColor)
DEFINE_FIELD(FOptionMenuSettings, mFontColor)
DEFINE_FIELD(FOptionMenuSettings, mFontColorValue)
DEFINE_FIELD(FOptionMenuSettings, mFontColorMore)
DEFINE_FIELD(FOptionMenuSettings, mFontColorHeader)
DEFINE_FIELD(FOptionMenuSettings, mFontColorHighlight)
DEFINE_FIELD(FOptionMenuSettings, mFontColorSelection)
DEFINE_FIELD(FOptionMenuSettings, mLinespacing)

View file

@ -244,6 +244,7 @@ public:
virtual bool MouseEvent(int type, int x, int y);
bool CallMenuEvent(int mkey, bool fromcontroller);
bool CallMouseEvent(int type, int x, int y);
bool MouseEventBack(int type, int x, int y);
void SetCapture();