MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / mouseOver

Method mouseOver

src/Interface/TextList.cpp:1051–1100  ·  view source on GitHub ↗

* Selects the row the mouse is over. * @param action Pointer to an action. * @param state State that the action handlers belong to. */

Source from the content-addressed store, hash-verified

1049 * @param state State that the action handlers belong to.
1050 */
1051void TextList::mouseOver(Action *action, State *state)
1052{
1053 if (_selectable)
1054 {
1055 int h = _font->getHeight() + _font->getSpacing();
1056 _selRow = std::max(0, (int)(_scroll + (int)floor(action->getRelativeYMouse() / (h * action->getYScale()))));
1057 if (_selRow < _rows.size())
1058 {
1059 Text *selText = _texts[_rows[_selRow]].front();
1060 int y = getY() + selText->getY();
1061 int h = selText->getHeight() + _font->getSpacing();
1062 if (y < getY() || y + h > getY() + getHeight())
1063 {
1064 h /= 2;
1065 }
1066 if (y < getY())
1067 {
1068 y = getY();
1069 }
1070 if (_selector->getHeight() != h)
1071 {
1072 // resizing doesn't work, but recreating does, so let's do that!
1073 delete _selector;
1074 _selector = new Surface(getWidth(), h, getX(), y);
1075 _selector->setPalette(getPalette());
1076 }
1077 _selector->setY(y);
1078 _selector->copy(_bg);
1079 if (_contrast)
1080 {
1081 _selector->offset(-10, 1);
1082 }
1083 else if (_comboBox)
1084 {
1085 _selector->offset(+1, Palette::backPos);
1086 }
1087 else
1088 {
1089 _selector->offset(-10, Palette::backPos);
1090 }
1091 _selector->setVisible(true);
1092 }
1093 else
1094 {
1095 _selector->setVisible(false);
1096 }
1097 }
1098
1099 InteractiveSurface::mouseOver(action, state);
1100}
1101
1102/**
1103 * Deselects the row.

Callers

nothing calls this directly

Calls 10

getSpacingMethod · 0.80
getRelativeYMouseMethod · 0.80
copyMethod · 0.80
getHeightMethod · 0.45
getYScaleMethod · 0.45
getYMethod · 0.45
setPaletteMethod · 0.45
setYMethod · 0.45
offsetMethod · 0.45
setVisibleMethod · 0.45

Tested by

no test coverage detected