Beispiel #1
0
void TLevelsSlider::TrackSliders()
{
	BPoint newPt, oldPt;
	
	// Check to see if button is down
	uint32 	buttons = 0;
	GetMouse(&newPt, &buttons, true);	
	
	while(buttons)
	{
		// Idle if in same mouse location
		if (newPt.y != oldPt.y)
		{						
			// Get old positions
			BRect oldLeftRect 	= m_LeftSliderRect;
			BRect oldRightRect 	= m_RightSliderRect;
				
			// Move both left and right slider under mouse
			const uint32 leftHeight	 = m_LeftSlider->Bounds().IntegerHeight();
			const uint32 rightHeight = m_RightSlider->Bounds().IntegerHeight();
			
			m_LeftSliderRect.top 		= newPt.y - leftHeight/2;
			m_LeftSliderRect.bottom 	= m_LeftSliderRect.top + leftHeight;
			m_RightSliderRect.top 		= newPt.y - leftHeight/2;
			m_RightSliderRect.bottom 	= m_RightSliderRect.top + rightHeight;
			
			// Now clip the location of the slider if out of bounds
			ClipSliders();
						
			// Clean up old position
			BRect updateRect = oldLeftRect;
			updateRect.right = oldRightRect.right;
			Draw(updateRect);
			
			// Draw new location
			DrawSliders();
			
			// Set new volume level
			UpdateVolumes(newPt);
		
			// Save mouse location
			oldPt = newPt;
		}
		
		// Let other events through
		snooze(20 * 1000);
			
		// Get new mouse location and button state
		GetMouse(&newPt, &buttons, true);
		
		// Clip location
		const BRect bounds = Bounds();
		if ( newPt.y < bounds.top+kTopOffset)
			newPt.y = bounds.top+kTopOffset;
	
		if ( newPt.y > bounds.bottom-kBottomOffset)
			newPt.y = bounds.bottom-kBottomOffset;
	}
}
Beispiel #2
0
 void SoundFX::SetMute(bool value)
 {
     if (mute != value)
     {
         mute = value;
         UpdateVolumes();
     }
 }
Beispiel #3
0
    void SoundFX::SetVolume(float value)
    {
        value = Math::Clamp(value, 0.0f, 1.0f);

        if (volume != value)
        {
            volume = value;
            UpdateVolumes();
        }
    }
Beispiel #4
0
void TLevelsSlider::MouseDown(BPoint where)
{
	// Check for which button is pressed
	uint32 	buttons = 0;				
	Window()->CurrentMessage()->FindInt32("buttons", (long *)&buttons);
	
	// Determine which button has been clicked
	switch(buttons)
	{
		
		case B_PRIMARY_MOUSE_BUTTON:
			{
				const BRect bounds = Bounds();
				
				// Get old positions
				BRect oldLeftRect 	= m_LeftSliderRect;
				BRect oldRightRect 	= m_RightSliderRect;
				
				// Move both left and right slider under mouse
				const uint32 leftHeight	 = m_LeftSlider->Bounds().IntegerHeight();
				const uint32 rightHeight = m_RightSlider->Bounds().IntegerHeight();
				
				m_LeftSliderRect.top 		= where.y - leftHeight/2;
				m_LeftSliderRect.bottom 	= m_LeftSliderRect.top + leftHeight;
				m_RightSliderRect.top 		= where.y - rightHeight/2;
				m_RightSliderRect.bottom 	= m_RightSliderRect.top + rightHeight;
				
				// Now clip the location of the slider if out of bounds
				ClipSliders();
				
				// Clean up old position
				BRect updateRect 	= oldLeftRect;
				updateRect.right 	= oldRightRect.right;
				Draw(Bounds());
				
				// Draw updated position				
				DrawLeftSlider();
				DrawRightSlider();	
				
				// Update the volumes
				UpdateVolumes(where);	
								
				// Wait a while for the mouse button to be realeased
				snooze(100 * 1000);
												
				// Is button down?  They are dragging or resizing the cue...	
				// Check to see if button is down				
				Window()->CurrentMessage()->FindInt32("buttons", (long *)&buttons);	
				if (buttons)
				{
					//StartMouseWatcher(this);
					TrackSliders();
				}			
			}
			break;
			
		// User is dragging one half of the slider
		case B_SECONDARY_MOUSE_BUTTON:
			{
				const BRect bounds = Bounds();
				
				// Determine area mouse is in for slider drag
				//
				
				// Left Side
				if (where.x <= bounds.Width()/2)
				{				
					// Get old positions
					BRect oldRect 	= m_LeftSliderRect;
					
					// Move both left slider under mouse
					const uint32 leftHeight	 = m_LeftSlider->Bounds().IntegerHeight();
					
					m_LeftSliderRect.top 	= where.y - leftHeight/2;
					m_LeftSliderRect.bottom = m_LeftSliderRect.top + leftHeight;
					
					// Now clip the location of the slider if out of bounds
					ClipLeftSlider();
					
					// Clean up old position
					Draw(oldRect);
					
					// Draw updated position				
					DrawLeftSlider();
					
					// Update the volume
					UpdateLeftVolume(where);	
									
					// Wait a while for the mouse button to be realeased
					snooze(100 * 1000);
		
					// Is button down?  They are dragging or resizing the cue...	
					// Check to see if button is down				
					Window()->CurrentMessage()->FindInt32("buttons", (long *)&buttons);	
					if (buttons)
					{
						TrackLeftSlider();
					}			
				
				}
				// Right Side
				else
				{
					const BRect bounds = Bounds();
					
					// Get old positions
					BRect oldRect = m_RightSliderRect;
					
					// Move both left and right slider under mouse
					const uint32 rightHeight = m_RightSlider->Bounds().IntegerHeight();
					
					m_RightSliderRect.top 		= where.y - rightHeight/2;
					m_RightSliderRect.bottom 	= m_RightSliderRect.top + rightHeight;
					
					// Now clip the location of the slider if out of bounds
					ClipRightSlider();
					
					// Clean up old position
					Draw(oldRect);
					
					// Draw updated position				
					DrawRightSlider();	
					
					// Update the volume
					UpdateRightVolume(where);	
									
					// Wait a while for the mouse button to be realeased
					snooze(100 * 1000);
		
					// Is button down?  They are dragging or resizing the cue...	
					// Check to see if button is down				
					Window()->CurrentMessage()->FindInt32("buttons", (long *)&buttons);	
					if (buttons)
					{
						TrackRightSlider();
					}							
				}
			}
			break;
	}	
}