| 1184 | } |
| 1185 | |
| 1186 | void LWSlider::OnMouseEvent(wxMouseEvent & event) |
| 1187 | { |
| 1188 | if (event.Entering()) |
| 1189 | { |
| 1190 | // Display the tooltip in the status bar |
| 1191 | auto tip = GetTip(mCurrentValue); |
| 1192 | auto pProject = FindProjectFromWindow( mParent ); |
| 1193 | if (pProject) |
| 1194 | ProjectStatus::Get( *pProject ).Set( tip ); |
| 1195 | Refresh(); |
| 1196 | } |
| 1197 | else if (event.Leaving()) |
| 1198 | { |
| 1199 | if (!mIsDragging) |
| 1200 | { |
| 1201 | ShowTip(false); |
| 1202 | } |
| 1203 | auto pProject = FindProjectFromWindow( mParent ); |
| 1204 | if (pProject) |
| 1205 | ProjectStatus::Get( *pProject ).Set({}); |
| 1206 | Refresh(); |
| 1207 | } |
| 1208 | |
| 1209 | // Events other than mouse-overs are ignored when we are disabled |
| 1210 | if (!mEnabled) |
| 1211 | return; |
| 1212 | |
| 1213 | // Windows sends a right button mouse event when you press the context menu |
| 1214 | // key, so ignore it. |
| 1215 | if ((event.RightDown() && !event.RightIsDown()) || |
| 1216 | (event.RightUp() && event.GetPosition() == wxPoint(-1, -1))) |
| 1217 | { |
| 1218 | event.Skip(false); |
| 1219 | return; |
| 1220 | } |
| 1221 | |
| 1222 | float prevValue = mCurrentValue; |
| 1223 | |
| 1224 | // Figure out the thumb position |
| 1225 | wxRect r; |
| 1226 | if (mOrientation == wxHORIZONTAL) |
| 1227 | { |
| 1228 | r.x = mLeft + ValueToPosition(mCurrentValue); |
| 1229 | r.y = mTop + (mCenterY - (mThumbHeight / 2)); |
| 1230 | } |
| 1231 | else |
| 1232 | { |
| 1233 | r.x = mLeft + (mCenterX - (mThumbWidth / 2)); |
| 1234 | r.y = mTop + ValueToPosition(mCurrentValue); |
| 1235 | } |
| 1236 | r.width = mThumbWidth; |
| 1237 | r.height = mThumbHeight; |
| 1238 | |
| 1239 | wxRect tolerantThumbRect = r; |
| 1240 | tolerantThumbRect.Inflate(3, 3); |
| 1241 | |
| 1242 | // Should probably use a right click instead/also |
| 1243 | if( event.ButtonDClick() && mPopup ) |
no test coverage detected