Exemplo n.º 1
0
void
MainWin::ToggleNoMenu()
{
	printf("ToggleNoMenu enter\n");

	fNoMenu = !fNoMenu;

	if (fIsFullscreen) {
		// fullscreen is always without menu
		printf("ToggleNoMenu leave, doing nothing, we are fullscreen\n");
		return;
	}

//	fFrameResizedTriggeredAutomatically = true;
	fIgnoreFrameResized = true;

	if (fNoMenu) {
		fMenuBar->Hide();
		fVideoView->MoveTo(0, 0);
		fVideoView->ResizeBy(0, fMenuBarHeight);
		MoveBy(0, fMenuBarHeight);
		ResizeBy(0, - fMenuBarHeight);
//		Sync();
	} else {
		fMenuBar->Show();
		fVideoView->MoveTo(0, fMenuBarHeight);
		fVideoView->ResizeBy(0, -fMenuBarHeight);
		MoveBy(0, - fMenuBarHeight);
		ResizeBy(0, fMenuBarHeight);
//		Sync();
	}

	printf("ToggleNoMenu leave\n");
}
Exemplo n.º 2
0
void Node::MoveByAngle(float angle, float dist)
{
	float dist_X = cos(D3DXToRadian(angle)) * dist;
	float dist_Y = sin(D3DXToRadian(angle)) * dist;

	MoveBy(dist_X, dist_Y);
}
void CGraphicsCamera::Dolly( double inc )
{
	CVector3D dir = GetForwardVector();
	CVector3D temp = dir*inc;
	CPoint3D delta( temp.x, temp.y, temp.z );
	MoveBy( delta );
}
Exemplo n.º 4
0
/* frame will be the frame of the parent window as*/
MessageWin::MessageWin(BRect parentFrame, const char *title,
	window_look look, window_feel feel, uint32 flags, uint32 workspace)
	: BWindow(parentFrame ,title ,look ,feel, flags, workspace)
{
	fBox = new BBox(Bounds(), "", B_FOLLOW_ALL, B_WILL_DRAW, B_PLAIN_BORDER);
	fBox->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
	fBox->SetLowColor(fBox->ViewColor());

    // Rects for the text view
    BRect outside(fBox->Bounds());
    outside.InsetBy(10, 10);
	BRect insider(outside);
	insider.OffsetTo(B_ORIGIN);

	fText = new BTextView(outside, "message", insider, B_FOLLOW_NONE, B_WILL_DRAW);
	fText->MakeEditable(false);
	fText->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
	fText->SetLowColor(fText->ViewColor());

	fBox->AddChild(fText);
 	AddChild(fBox);
   
 	/* Relocate the window to the center of what its being given */
  	ResizeTo(parentFrame.Width(), floor(parentFrame.Height() / 3));
 	MoveBy(0, floor(parentFrame.Height() / 2 - (parentFrame.Height()/3) / 2 ));

}
Exemplo n.º 5
0
void WBCompTransform::ServerTick( float DeltaTime )
{
	if( m_Velocity.LengthSquared() > EPSILON )	// Optimization, don't want to pay MoveBy costs for a ton of static entities
	{
		MoveBy( m_Velocity * DeltaTime );
	}
}
Exemplo n.º 6
0
void TStageMovieCue::DragPicture(BPoint thePoint)
{
	BPoint 	savePt;
	uint32	buttons = 0;
	
	GetMouse(&thePoint, &buttons, true);
	
	ConvertToParent(&thePoint);
	savePt = thePoint;
			
	while (buttons)
	{				
		if (thePoint != savePt)
		{
			// Convert to parents coordinate system
			ConvertToParent(&thePoint);
			
			MoveBy( ( thePoint.x - savePt.x) , (thePoint.y - savePt.y) );
			
			// Save mouse location for next compare
			savePt = thePoint;
		}
		
		GetMouse(&thePoint, &buttons, true);
	}
}
Exemplo n.º 7
0
void
PulseWindow::MoveOnScreen()
{
	// check if the window is on screen, and move it if not
	BRect frame = Frame();
	BRect screenFrame = BScreen().Frame();

	if (frame.left > screenFrame.right)
		MoveBy(screenFrame.right - frame.right - 10, 0);
	else if (frame.right < 0)
		MoveTo(10, frame.top);

	if (frame.top > screenFrame.bottom)
		MoveBy(0, screenFrame.bottom - frame.bottom - 10);
	else if (frame.bottom < 0)
		MoveTo(frame.left, 10);
}
Exemplo n.º 8
0
void SampleGLView::KeyDown(const char *bytes, int32 numBytes)
{
    static bool moved = false;
    switch (bytes[0]) {
    case B_SPACE:
        if (moved) {
            MoveBy(-30, -30);
            moved = false;
        } else {
            MoveBy(30, 30);
            moved = true;
        }
        break;
    default:
        BView::KeyDown(bytes, numBytes);
        break;
    }
}
Exemplo n.º 9
0
void
SButton::MakeDefault(bool flag)
{
	BWindow *window = Window();

	if(is_default != flag)
	{
		is_default = flag;

		if(button_style == DANO_STYLE)
		{
			if(is_default)
			{
				MoveBy(-5, 0);
				ResizeBy(8, 0);
			}
			else
			{
				MoveBy(5, 0);
				ResizeBy(-8, 0);
			}
		}
		else
		{
			if(is_default)
			{
				MoveBy(-4, -4);
				ResizeBy(8, 8);
			}
			else
			{
				MoveBy(4, 4);
				ResizeBy(-8, -8);
			}
		}
	}

	if(window)
	{
		DrawDefault(Bounds(), waitting, window->IsActive());
		window->UpdateIfNeeded();
	}
}
Exemplo n.º 10
0
void
BButton::MakeDefault(bool flag)
{
	BButton *oldDefault = NULL;
	BWindow *window = Window();

	if (window)
		oldDefault = window->DefaultButton();

	if (flag) {
		if (fDrawAsDefault && oldDefault == this)
			return;

		if (!fDrawAsDefault) {
			fDrawAsDefault = true;

			if ((Flags() & B_SUPPORTS_LAYOUT) != 0)
				InvalidateLayout();
			else {
				ResizeBy(6.0f, 6.0f);
				MoveBy(-3.0f, -3.0f);
			}
		}

		if (window && oldDefault != this)
			window->SetDefaultButton(this);
	} else {
		if (!fDrawAsDefault)
			return;

		fDrawAsDefault = false;

		if ((Flags() & B_SUPPORTS_LAYOUT) != 0)
			InvalidateLayout();
		else {
			ResizeBy(-6.0f, -6.0f);
			MoveBy(3.0f, 3.0f);
		}

		if (window && oldDefault == this)
			window->SetDefaultButton(NULL);
	}
}
Exemplo n.º 11
0
void Boid::Tick()
{
	const float rangesq = 50.0f*50.0f;

	std::vector< const Boid* > neighbours;
	neighbours.reserve(100);
	DudeList& dudes = g_Agents->Dudes();
	DudeList::const_iterator it;
	vec2 const& pos = Pos();
	for( it=dudes.begin(); it!=dudes.end(); ++it )
	{
		if( *it == this )
			continue;
		vec2 d = (*it)->Pos()-pos;
		if( d.LenSq() < rangesq )
		{
			// DANGER DANGER!!! (need to sort out better casting!)
			neighbours.push_back( (const Boid*)*it );
		}
	}

	vec2 groupingacc = CalcGroupingAcc( neighbours );
	vec2 velmatchacc = CalcVelMatchAcc( neighbours );
	// TODO: separation!

	vec2 attackacc = g_Player->Pos() - Pos();
	if( attackacc.LenSq() < 80*80 )
		attackacc.Normalise();
	else
		attackacc = vec2::ZERO;

	vec2 avoidboundaryacc = vec2::ZERO;
	float bound = g_CurrentLevel->ArenaRadius()-20.0f;
	if( Pos().LenSq() > bound*bound )
	{
		avoidboundaryacc = -Pos();
		avoidboundaryacc.Normalise();
		avoidboundaryacc *= 0.1f;
	}

	vec2 acc = 0.3f*groupingacc + 0.6f*velmatchacc + 0.1f*attackacc + 0.4*avoidboundaryacc;
	m_Vel += acc;

	const float maxvel=1.0f;
	if( m_Vel.LenSq() > maxvel )
	{
		m_Vel.Normalise();
		m_Vel *= maxvel;
	}

	MoveBy(m_Vel);

	TurnTo( atan2(m_Vel.x,m_Vel.y) );
}
Exemplo n.º 12
0
SetKeyWindow::SetKeyWindow(BPoint p, int32 i, BView *v) : BWindow(BRect(p.x,p.y,p.x,p.y),Language.get("SET_KEY_WINDOW"), B_TITLED_WINDOW, B_NOT_RESIZABLE|B_NOT_ZOOMABLE)
	, index(i), parent(v)
{
	BRect r(0,0,300,150);
	ResizeTo(r.Width(), r.Height());
	MoveBy(-r.Width()/2, -r.Height()/2);

	BView *view = new BView(r, NULL, B_FOLLOW_ALL, B_WILL_DRAW);
	view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	
	r.InsetBy(8,8);
	r.bottom = r.top+19;
	BStringView *st;
	r.right = r.left + be_bold_font->StringWidth(Language.get("KEY_SETTINGS_FOR"));
	view->AddChild(st = new BStringView(r, NULL, Language.get("KEY_SETTINGS_FOR") ));
	st->SetFont(be_bold_font);
	r.left = r.right+8;
	r.right = Bounds().right-8;
	view->AddChild(new BStringView(r, NULL, Language.get(KeyBind.GetID(index)) ));
	
	// request the installed message
	key = KeyBind.GetKey( KeyBind.GetID(index) );
	key2 = KeyBind.GetKeyAlt( KeyBind.GetID(index) );
	mod = KeyBind.GetMod( KeyBind.GetID(index) );
	mod2 = KeyBind.GetModAlt( KeyBind.GetID(index) );
	message = KeyBind.GetMessage( KeyBind.GetID(index) );
	menu = KeyBind.IsMenuItem( KeyBind.GetID(index) );

	r.OffsetBy(0,30);
	r.left = 8;
	float x = 8 + MAX( be_plain_font->StringWidth(Language.get("PRIMARY")), be_plain_font->StringWidth(Language.get("ALTERNATE")));
	
	r.right = Bounds().right -96;
	view->AddChild(control1 = new KeyControl(r, Language.get("PRIMARY"), key, mod, menu));
	control1->SetDivider(x);
	view->AddChild(new BButton(BRect(r.right+8, r.top, Bounds().right-8, r.bottom), NULL, Language.get("CLEAR"), new BMessage(CLEAR1)) );
	r.OffsetBy(0,30);
	view->AddChild(control2 = new KeyControl(r, Language.get("ALTERNATE"), key2, mod2, false));
	control2->SetDivider(x);
	view->AddChild(new BButton(BRect(r.right+8, r.top, Bounds().right-8, r.bottom), NULL, Language.get("CLEAR"), new BMessage(CLEAR2)) );

	r = Bounds();
	r.InsetBy(8,8);
	r.top = r.bottom - 23;
	r.left = r.right - 80;
	view->AddChild(new BButton(r, NULL, Language.get("APPLY"), new BMessage(SET)) );
	r.OffsetBy(-(r.Width()+8), 0);
	view->AddChild(new BButton(r, NULL, Language.get("CANCEL"), new BMessage(B_QUIT_REQUESTED)) );

	AddChild(view);
	Run();
	Show();
}
Exemplo n.º 13
0
FreqWindow::FreqWindow(BPoint p) : BWindow(BRect(p.x,p.y,p.x,p.y),Language.get("FREQ_WINDOW"),B_FLOATING_WINDOW_LOOK,B_FLOATING_APP_WINDOW_FEEL, B_NOT_RESIZABLE|B_NOT_ZOOMABLE)
{
	BRect r(0,0,180,180);
	ResizeTo(r.Width(), r.Height());
	MoveBy(-r.Width()/2, -r.Height()/2);

	view = new BView(r, NULL, B_FOLLOW_ALL, B_WILL_DRAW);
	r.InsetBy(8,8);
	r.right = 70;

	r.top += 28;		// space for the textbox
	list = new BListView(r,"Freq list");
	BScrollView *sv = new BScrollView("scroll", list, B_FOLLOW_ALL_SIDES, B_WILL_DRAW, false, true, B_PLAIN_BORDER);
	sv->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	sv->MakeFocus(false);
	view->AddChild(sv);
	
	r.Set(4,8,85,28);
	text = new SpinControl(r, NULL, NULL, new BMessage(SET_TEXT), 4000, 96000, 44100, 500);
	view->AddChild(text);

	r = Bounds();
	r.left = r.right - 85;
	r.top = r.bottom - 32;
	r.bottom -=8;
	r.right -= 8;
	view->AddChild(new BButton(r, NULL, Language.get("OK"), new BMessage(SET)) );
	r.OffsetBy(0,-30);
	view->AddChild(new BButton(r, NULL, Language.get("CANCEL"), new BMessage(QUIT)) );

	view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	AddChild(view);

	BStringItem *it;
	list->AddItem(it = new BStringItem("96000"));
	list->AddItem(it = new BStringItem("64000"));
	list->AddItem(it = new BStringItem("48000"));
	list->AddItem(it = new BStringItem("44100"));
	list->AddItem(it = new BStringItem("32000"));
	list->AddItem(it = new BStringItem("22050"));
	list->AddItem(it = new BStringItem("16000"));
	list->AddItem(it = new BStringItem("12500"));
	list->AddItem(it = new BStringItem("11025"));
	list->AddItem(it = new BStringItem("8000"));
	list->SetSelectionMessage(new BMessage(SELECT));
	list->SetInvocationMessage(new BMessage(SELECT));
	SetList();

	m_old = Pool.frequency;
	Run();
	Show();
}
Exemplo n.º 14
0
void
BButton::MakeDefault(bool flag)
{
	BButton* oldDefault = NULL;
	BWindow* window = Window();

	if (window != NULL)
		oldDefault = window->DefaultButton();

	if (flag) {
		if (_Flag(FLAG_DEFAULT) && oldDefault == this)
			return;

		if (_SetFlag(FLAG_DEFAULT, true)) {
			if ((Flags() & B_SUPPORTS_LAYOUT) != 0)
				InvalidateLayout();
			else {
				ResizeBy(6.0f, 6.0f);
				MoveBy(-3.0f, -3.0f);
			}
		}

		if (window && oldDefault != this)
			window->SetDefaultButton(this);
	} else {
		if (!_SetFlag(FLAG_DEFAULT, false))
			return;

		if ((Flags() & B_SUPPORTS_LAYOUT) != 0)
			InvalidateLayout();
		else {
			ResizeBy(-6.0f, -6.0f);
			MoveBy(3.0f, 3.0f);
		}

		if (window && oldDefault == this)
			window->SetDefaultButton(NULL);
	}
}
Exemplo n.º 15
0
void
TTimeView::ResizeToPreferred()
{
	float width, height;
	float oldWidth = Bounds().Width(), oldHeight = Bounds().Height();

	GetPreferredSize(&width, &height);
	if (height != oldHeight || width != oldWidth) {
		ResizeTo(width, height);
		MoveBy(oldWidth - width, 0);
		fNeedToUpdate = true;
	}
}
Exemplo n.º 16
0
VolumeWindow::VolumeWindow(BRect frame, bool dontBeep, int32 volumeWhich)
	: BWindow(frame, "VolumeWindow", B_BORDERED_WINDOW_LOOK,
		B_FLOATING_ALL_WINDOW_FEEL,
		B_ASYNCHRONOUS_CONTROLS | B_WILL_ACCEPT_FIRST_CLICK
		| B_AUTO_UPDATE_SIZE_LIMITS, 0),
	fUpdatedCount(0)
{
	SetLayout(new BGroupLayout(B_HORIZONTAL));

	BGroupLayout* layout = new BGroupLayout(B_HORIZONTAL);
	layout->SetInsets(5, 5, 5, 5);

	BBox* box = new BBox("sliderbox");
	box->SetLayout(layout);
	box->SetBorder(B_PLAIN_BORDER);
	AddChild(box);

	BSlider* slider = new VolumeControl(volumeWhich, !dontBeep,
		new BMessage(kMsgVolumeChanged));
	slider->SetModificationMessage(new BMessage(kMsgVolumeUpdate));
	box->AddChild(slider);

	slider->SetTarget(this);
	ResizeTo(300, 50);

	// Make sure it's not outside the screen.
	const int32 kMargin = 3;
	BRect windowRect = Frame();
	BRect screenFrame(BScreen(B_MAIN_SCREEN_ID).Frame());
	if (screenFrame.right < windowRect.right + kMargin)
		MoveBy(- kMargin - windowRect.right + screenFrame.right, 0);
	if (screenFrame.bottom < windowRect.bottom + kMargin)
		MoveBy(0, - kMargin - windowRect.bottom + screenFrame.bottom);
	if (screenFrame.left > windowRect.left - kMargin)
		MoveBy(kMargin + screenFrame.left - windowRect.left, 0);
	if (screenFrame.top > windowRect.top - kMargin)
		MoveBy(0, kMargin + screenFrame.top - windowRect.top);
}
Exemplo n.º 17
0
void
BScrollView::SetBorder(border_style border)
{
	if (fBorder == border)
		return;

	float offset = BorderSize(fBorder) - BorderSize(border);
	float resize = 2 * offset;

	float horizontalGap = 0, verticalGap = 0;
	float change = 0;
	if (border == B_NO_BORDER || fBorder == B_NO_BORDER) {
		if (fHorizontalScrollBar != NULL)
			verticalGap = border != B_NO_BORDER ? 1 : -1;
		if (fVerticalScrollBar != NULL)
			horizontalGap = border != B_NO_BORDER ? 1 : -1;

		change = border != B_NO_BORDER ? -1 : 1;
		if (fHorizontalScrollBar == NULL || fVerticalScrollBar == NULL)
			change *= 2;
	}


	fBorder = border;

	int32 savedResizingMode = 0;
	if (fTarget != NULL) {
		savedResizingMode = fTarget->ResizingMode();
		fTarget->SetResizingMode(B_FOLLOW_NONE);
	}

	MoveBy(offset, offset);
	ResizeBy(-resize - horizontalGap, -resize - verticalGap);

	if (fTarget != NULL) {
		fTarget->MoveBy(-offset, -offset);
		fTarget->SetResizingMode(savedResizingMode);
	}

	if (fHorizontalScrollBar != NULL) {
		fHorizontalScrollBar->MoveBy(-offset - verticalGap, offset + verticalGap);
		fHorizontalScrollBar->ResizeBy(resize + horizontalGap - change, 0);
	}
	if (fVerticalScrollBar != NULL) {
		fVerticalScrollBar->MoveBy(offset + horizontalGap, -offset - horizontalGap);
		fVerticalScrollBar->ResizeBy(0, resize + verticalGap - change);
	}

	SetFlags(ModifyFlags(Flags(), border));
}
Exemplo n.º 18
0
void
TeamsWindow::Zoom(BPoint, float, float)
{
	BSize preferredSize = fTeamsListView->PreferredSize();
	ResizeBy(preferredSize.Width() - Bounds().Width(),
		0.0);

	// if the new size would extend us past the screen border,
	// move sufficiently to the left to bring us back within the bounds
	// + a bit of extra margin so we're not flush against the edge.
	BScreen screen;
	float offset = screen.Frame().right - Frame().right;
	if (offset < 0)
		MoveBy(offset - 5.0, 0.0);
}
Exemplo n.º 19
0
/***********************************************************
 * RemoveRuler
 ***********************************************************/
void
HWrapTextView::RemoveRuler()
{
	if(fRulerView)
	{
		fRulerView->RemoveSelf();
		delete fRulerView;
		fRulerView=NULL;
		
		ResizeBy(0,RULER_HEIGHT+1);
		MoveBy(0,-(RULER_HEIGHT+1));
		
		ResetTextRect();
	}
}
Exemplo n.º 20
0
void placeholder::MouseMoved(BPoint move, uint32 transit, const BMessage *message)
{
	if(moving)  //are we draggin'?
	{
		if(resize)  //resizing:
		{
			ResizeTo(initialSize.Width()+(move.x-clickPoint.x), initialSize.Height()+(move.y-clickPoint.y));
		}
		else  //moving:
		{
			MoveBy(move.x-initialSize.Width(), move.y-(initialSize.Height()-5));
		}

	}

}
Exemplo n.º 21
0
/***********************************************************
 * AddRuler
 ***********************************************************/
void
HWrapTextView::AddRuler()
{
	if(!fRulerView && Parent())
	{
		ResizeBy(0,-(RULER_HEIGHT+1));
		MoveBy(0,RULER_HEIGHT+1);
		
		BRect rect = Bounds();
		rect = Parent()->Bounds();
		rect.top += 2;
		rect.OffsetBy(2,0);
		rect.bottom = rect.top + RULER_HEIGHT;
		fRulerView = new HRulerView(rect,"ruler",this);
		Parent()->AddChild(fRulerView);
		ResetTextRect();
	}
}
Exemplo n.º 22
0
void mitk::DisplayGeometry::SetSizeInDisplayUnits(unsigned int width, unsigned int height, bool keepDisplayedRegion)
{
  Vector2D oldSizeInMM( m_SizeInMM );
  Point2D oldCenterInMM;
  if(keepDisplayedRegion)
  {
    Point2D centerInDisplayUnits;
    centerInDisplayUnits[0] = m_SizeInDisplayUnits[0]*0.5;
    centerInDisplayUnits[1] = m_SizeInDisplayUnits[1]*0.5;
    DisplayToWorld(centerInDisplayUnits, oldCenterInMM);
  }

  m_SizeInDisplayUnits[0]=width;
  m_SizeInDisplayUnits[1]=height;

  if(m_SizeInDisplayUnits[0] <= 0)
    m_SizeInDisplayUnits[0] = 1;
  if(m_SizeInDisplayUnits[1] <= 0)
    m_SizeInDisplayUnits[1] = 1;

  DisplayToWorld(m_SizeInDisplayUnits, m_SizeInMM);

  if(keepDisplayedRegion)
  {
    Point2D positionOfOldCenterInCurrentDisplayUnits;
    WorldToDisplay(oldCenterInMM, positionOfOldCenterInCurrentDisplayUnits);

    Point2D currentNewCenterInDisplayUnits;
    currentNewCenterInDisplayUnits[0] = m_SizeInDisplayUnits[0]*0.5;
    currentNewCenterInDisplayUnits[1] = m_SizeInDisplayUnits[1]*0.5;

    Vector2D shift;
    shift=positionOfOldCenterInCurrentDisplayUnits.GetVectorFromOrigin()-currentNewCenterInDisplayUnits;

    MoveBy(shift);
    Zoom(m_SizeInMM.GetNorm()/oldSizeInMM.GetNorm(), currentNewCenterInDisplayUnits);
  }

  Modified();
}
Exemplo n.º 23
0
void CModifiedButtonWidget::OnMouseEvent( CMouseEvent* event )
{
	// logger << event->GetButtons() << std::endl;
	switch( event->GetType() )
	{
	case types::mouse_button_down:
		
		if( event->GetButtons() & myClickableButtons ) 
		{
			mySpriteHandler->PlayAnimation( GetSprite(), "mouse_button_down" );
			myClicked = true;
			OnMouseDown( myParam );
		}

		if( myDragable && event->GetButtons() & myDragableButtons )
		{
			// mySpriteHandler->PlayAnimation( GetSprite(), "mouse_on_drag" );
			myDragging = true;
			myDragOffset = types::point( this->GetRect().x, this->GetRect().y ) - event->GetPosition();
			IMouse::AddConstantEventListeners( this );
		}

		if( myDoubleClickable && event->GetButtons() & myDoubleClickableButtons && myDoubleClicking == true )
		{
			if( myDoubleClickTimer.GetTime() < double_click_time )
				OnDoubleClick( myParam );
			myDoubleClicking = false;
		}
		else if( myDoubleClickable && event->GetButtons() & myDoubleClickableButtons && myDoubleClicking == false )
		{
			myDoubleClickTimer.Reset();
			myDoubleClickTimer.Resume();
			myDoubleClicking = true;
		}
		else if ( myDoubleClickable && event->GetButtons() & !myDoubleClickableButtons )
		{
			myDoubleClicking = false;
		}



		break;

	case types::mouse_button_up:
		if( myClicked && event->GetButtons() & myClickableButtons ) 
		{
			mySpriteHandler->PlayAnimation( GetSprite(), "mouse_button_up" );
			OnClick( myParam );

			myClicked = false;
			OnMouseUp( myParam );
		}

		if( myDragable && event->GetButtons() & myDragableButtons )
		{
			// mySpriteHandler->PlayAnimation( GetSprite(), "mouse_on_drag" );
			myDragging = false;
			IMouse::RemoveConstantEventListeners( this );
			OnDragEnd();
		}

		myClicked = false;
		break;

	case types::mouse_move:

		if( myDragging )
		{
			types::point where_to = event->GetPosition() + myDragOffset;

			// Fixed 12-09-2007 by Pete
			//--------------------------------------------------------------------------
			// BUGBUG: This should be the commented line, but the signal-slot 
			// doesn't support three parameters at the current time
			// OnDrag( where_to.x - GetRect().x, where_to.y - GetRect().y, myParam );

			if( config::automatic_dragging )
				MoveBy( types::point( where_to.x - GetRect().x, where_to.y - GetRect().y ) );	

			OnDrag( where_to.x - GetRect().x, where_to.y - GetRect().y, myParam );
		}

		// myDoubleClicking = false;
		break;

	case types::mouse_over:
		{
			const std::string animation = mySelectionOn?"select_mouse_over":"mouse_over";
			mySpriteHandler->PlayAnimation( GetSprite(), animation );
			OnMouseOver( myParam );
		}
		break;

	case types::mouse_out:
		{
			const std::string animation = mySelectionOn?"select_mouse_out":"mouse_out";
			mySpriteHandler->PlayAnimation( GetSprite(), animation );
			myClicked = false;
			myDoubleClicking = false;
			OnMouseOut( myParam );
		}
		break;

	default:
		break;
	}

}
Exemplo n.º 24
0
/*!	\brief Moves the decorator frame and all default rectangles

	If a subclass implements this method, be sure to call Decorator::MoveBy
	to ensure that internal members are also updated. All members of the
	Decorator class are automatically moved in this method

	\param x X Offset
	\param y y Offset
*/
void
Decorator::MoveBy(float x, float y)
{
	MoveBy(BPoint(x, y));
}
Exemplo n.º 25
0
//Move top-left coordinate of rectangle to vector
void Rectangle::MoveBy(const Vector2D* const vect) {
	MoveBy(vect->x, vect->y);
}
Exemplo n.º 26
0
void ofxBaseSprite::MoveBy(const float x, const float y, const float z)
{
	MoveBy(ofVec3f(x,y,z));
}
Exemplo n.º 27
0
void Humanoid::Update()
{
	// CHANGED
	// making the humanoid call the character's update so that knockback and AI get applied
	// Rolf, 6-13-04
	Character::Update();

	// CHANGED
	// optimization: entities that are out of sight and far away do nothing
	if (!RContext->bInCameraFrustum && RContext->fDistSquared > 1000)
		return;		

	float fDebugGroundHeight=0;
	Vector vDebugGroundNorm(0, 1, 0);

	HandleInput();

	Vector vDeccel(vInternal);  //(friction)

	//find friction
	if (!vDeccel.IsZeroVector())
		vDeccel=vDeccel/GetFriction()*Timer::GetElapsedTime();
	
	vDeccel.fComp[1]=0.0f;
	vDeccel *= - 1.0f;

	//add friction
	if(vInternal.LengthSquared()<vDeccel.LengthSquared())
		vInternal.SetToZero();
	else
		vInternal += vDeccel;

	//add gravity
	vExternal += Game::pWorld->vGravity*Timer::GetElapsedTime();

	vVelocity= vInternal + vExternal;

	MoveBy(vVelocity * Timer::GetElapsedTime());	

	RTF.mGlobal=mGlobal;

	// hack: ground clamp here to avoid jittery effect
		
	// version 1: geometry-level collision response
	// good for steep surfaces, bad for flat ones and high falling rates

	
	// version 2: ground clamp
	// fast and good for smooth terrain, but goes through walls
	if (Game::pWorld->GroundClamp (this))
	{
		vExternal.fComp[1] = 0;
		bJump = 1;
	}
	else bJump = 0;

	/*
	// version 1: geometry level collision response
	Sphere middleOfObject (GetPos(), fWidth);
	if (Game::pWorld->CollisionClamp (Sphere (GetPos(), fWidth)))
	{
		MoveTo (middleOfObject.mGlobal.GetPos());
		vExternal.fComp[1] = 0;
		bJump = 1;
	}
	else bJump = 0;
	*/

	/*	
	// version 3: hybrid
	// tries to be the best of 1 and 2 combined, but is expensive
	Vector vGroundPoint(0,0,0);		//for ground clamping
	Triangle tGround;			//for ground clamping
	Vector vIntersectPoint (0,0,0);		//for geometry-level collision
	Triangle tIntersect;	//for geometry-level collision
	Line lGoingDown (GetPos() + Vector (0, 0.4f * fHeight, 0), GetPos() - Vector (0, 0.6f * fHeight, 0));
	bool bGroundColl, bGeometryColl;
	// use the ground clamping version of collision detection, since it is more robust
	if ( (bGroundColl = Game::pWorld->CollidesWithGeometry (lGoingDown, &vGroundPoint, &tGround)) || (bGeometryColl = Game::pWorld->CollidesWithGeometry (this, &vIntersectPoint, &tIntersect)))
	{
		// use geometry level collision response for steep terrain
		if (bGeometryColl && tIntersect.vNormal.fComp[1] < 0.5f)
		{
			pBoundingShape->CollisionClamp (vIntersectPoint);
			MoveTo (pBoundingShape->GetPos());
		}
		// use ground clamping collision response for flat terrain
		else
		{
			MoveTo (vGroundPoint + Vector (0, fHeight * 0.5f, 0));
			vExternal.fComp[1] = 0;
			bJump = 1;
		}
	}
	else bJump = 0;
	*/
}
Exemplo n.º 28
0
InfoWin::InfoWin(BPoint leftTop, Controller* controller)
	:
	BWindow(BRect(leftTop.x, leftTop.y, leftTop.x + MIN_WIDTH - 1,
		leftTop.y + 300), B_TRANSLATE("File info"), B_TITLED_WINDOW,
		B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS | B_NOT_ZOOMABLE),
	fController(controller),
	fControllerObserver(new ControllerObserver(this,
		OBSERVE_FILE_CHANGES | OBSERVE_TRACK_CHANGES | OBSERVE_STAT_CHANGES))
{
	fIconView = new IconView("background", B_LARGE_ICON);

	fFilenameView = _CreateInfo("filename");
	BFont bigFont(be_plain_font);
	bigFont.SetSize(bigFont.Size() * 1.5f);
	fFilenameView->SetFont(&bigFont);

	// Create info views

	BStringView* containerLabel = _CreateLabel("containerLabel",
		B_TRANSLATE("Container"));
	fContainerInfo = _CreateInfo("container");

	fVideoSeparator = _CreateSeparator();
	fVideoLabel = _CreateLabel("videoLabel", B_TRANSLATE("Video"));
	fVideoFormatInfo = _CreateInfo("videoFormat");
	fVideoConfigInfo = _CreateInfo("videoConfig");
	fDisplayModeLabel = _CreateLabel("displayModeLabel",
		B_TRANSLATE("Display mode"));
	fDisplayModeInfo = _CreateInfo("displayMode");

	fAudioSeparator = _CreateSeparator();
	fAudioLabel = _CreateLabel("audioLabel", B_TRANSLATE("Audio"));
	fAudioFormatInfo = _CreateInfo("audioFormat");
	fAudioConfigInfo = _CreateInfo("audioConfig");

	BStringView* durationLabel = _CreateLabel("durationLabel",
		B_TRANSLATE("Duration"));
	fDurationInfo = _CreateInfo("duration");

	BStringView* locationLabel = _CreateLabel("locationLabel",
		B_TRANSLATE("Location"));
	fLocationInfo = _CreateInfo("location");

	fCopyrightSeparator = _CreateSeparator();
	fCopyrightLabel = _CreateLabel("copyrightLabel", B_TRANSLATE("Copyright"));
	fCopyrightInfo = _CreateInfo("copyright");

	BLayoutBuilder::Group<>(this, B_VERTICAL)
		.SetInsets(B_USE_DEFAULT_SPACING)
		.AddGroup(B_HORIZONTAL)
			.Add(fIconView, 0)
			.Add(fFilenameView, 1)
			.End()
		.AddGrid(2, 13)
			.Add(containerLabel, 0, 0)
			.Add(fContainerInfo, 1, 0)
			.Add(fVideoSeparator, 0, 1)
			.Add(fVideoLabel, 0, 2)
			.Add(fVideoFormatInfo, 1, 2)
			.Add(fVideoConfigInfo, 1, 3)
			.Add(fDisplayModeLabel, 0, 4)
			.Add(fDisplayModeInfo, 1, 4)
			.Add(fAudioSeparator, 0, 5)
			.Add(fAudioLabel, 0, 6)
			.Add(fAudioFormatInfo, 1, 6)
			.Add(fAudioConfigInfo, 1, 7)
			.Add(_CreateSeparator(), 0, 8)
			.Add(durationLabel, 0, 9)
			.Add(fDurationInfo, 1, 9)
			.Add(_CreateSeparator(), 0, 10)
			.Add(locationLabel, 0, 11)
			.Add(fLocationInfo, 1, 11)
			.Add(fCopyrightSeparator, 0, 12)
			.Add(fCopyrightLabel, 0, 12)
			.Add(fCopyrightInfo, 1, 12)
			.SetColumnWeight(0, 0)
			.SetColumnWeight(1, 1)
			.SetSpacing(B_USE_DEFAULT_SPACING, 0)
			.SetExplicitMinSize(BSize(MIN_WIDTH, B_SIZE_UNSET));

	fController->AddListener(fControllerObserver);
	Update();

	UpdateSizeLimits();

	// Move window on screen if needed
	BScreen screen(this);
	if (screen.Frame().bottom < Frame().bottom)
		MoveBy(0, screen.Frame().bottom - Frame().bottom);
	if (screen.Frame().right < Frame().right)
		MoveBy(0, screen.Frame().right - Frame().right);

	Show();
}
Exemplo n.º 29
0
SetKeyWindow::SetKeyWindow(BPoint p, int32 i, BView *v)
	:
	BWindow(BRect(p.x,p.y,p.x,p.y),
		B_TRANSLATE("Change Key Binding"), B_TITLED_WINDOW,
		B_NOT_RESIZABLE|B_NOT_ZOOMABLE), index(i), parent(v)
{
	BRect r(0,0,300,150);
	ResizeTo(r.Width(), r.Height());
	MoveBy(-r.Width()/2, -r.Height()/2);

	BView *view = new BView(r, NULL, B_FOLLOW_ALL, B_WILL_DRAW);
	view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	
	r.InsetBy(8,8);
	r.bottom = r.top+19;
	BStringView *st;
	r.right = r.left + be_bold_font->StringWidth(B_TRANSLATE("Enter new bindings for:"));
	view->AddChild(st = new BStringView(r, NULL, B_TRANSLATE("Enter new bindings for:")));
	st->SetFont(be_bold_font);
	r.left = r.right+8;
	r.right = Bounds().right-8;

	uint32 code = gKeyBind->GetCode(index);
	view->AddChild(new BStringView(r, NULL, B_TRANSLATE(gKeyBind->GetLabel(code))));
	
	// request the installed message
	key = gKeyBind->GetKey(code);
	key2 = gKeyBind->GetKeyAlt(code);
	mod = gKeyBind->GetMod(code);
	mod2 = gKeyBind->GetModAlt(code);
	message = code;
	menu = gKeyBind->IsMenuItem(code);

	r.OffsetBy(0,30);
	r.left = 8;
	float x = 8 + MAX( be_plain_font->StringWidth(B_TRANSLATE("Primary")),
		be_plain_font->StringWidth(B_TRANSLATE("Alternate")));
	
	r.right = Bounds().right -96;

	view->AddChild(control1 = new KeyControl(r, B_TRANSLATE("Primary"),
		key, mod, menu));

	control1->SetDivider(x);
	view->AddChild(new BButton(BRect(r.right+8, r.top, Bounds().right-8, r.bottom),
		NULL, B_TRANSLATE("CLEAR"), new BMessage(CLEAR1)) );

	r.OffsetBy(0,30);

	view->AddChild(control2 = new KeyControl(r, B_TRANSLATE("Alternate"), key2, mod2, false));

	control2->SetDivider(x);

	view->AddChild(new BButton(BRect(r.right+8, r.top, Bounds().right-8, r.bottom),
		NULL, B_TRANSLATE("CLEAR"), new BMessage(CLEAR2)) );

	r = Bounds();
	r.InsetBy(8,8);

	r.top = r.bottom - 23;
	r.left = r.right - 80;

	view->AddChild(new BButton(r, NULL, B_TRANSLATE("Apply"), new BMessage(SET)) );
	r.OffsetBy(-(r.Width()+8), 0);
	view->AddChild(new BButton(r, NULL, B_TRANSLATE("Cancel"), new BMessage(B_QUIT_REQUESTED)) );

	AddChild(view);
	Run();
	Show();
}
Exemplo n.º 30
0
void
DialogPane::SetMode(int32 mode, bool initialSetup)
{
	ASSERT(mode < 3 && mode >= 0);

	if (!initialSetup && mode == fMode)
		return;

	int32 oldMode = fMode;
	fMode = mode;

	bool followBottom = (ResizingMode() & B_FOLLOW_BOTTOM) != 0;
	// if we are follow bottom, we will move ourselves, need to place us back
	float bottomOffset = 0;
	if (followBottom && Window() != NULL)
		bottomOffset = Window()->Bounds().bottom - Frame().bottom;

	BRect newBounds(BoundsForMode(fMode));
	if (!initialSetup)
		ResizeParentWindow(fMode, oldMode);

	ResizeTo(newBounds.Width(), newBounds.Height());

	float delta = 0;
	if (followBottom && Window() != NULL)
		delta = (Window()->Bounds().bottom - Frame().bottom) - bottomOffset;

	if (delta != 0) {
		MoveBy(0, delta);
		if (fLatch && (fLatch->ResizingMode() & B_FOLLOW_BOTTOM))
			fLatch->MoveBy(0, delta);			
	}

	switch (fMode) {
		case 0:
		{
			if (oldMode > 1)
				fMode3Items.RemoveAll(this);
			if (oldMode > 0)
				fMode2Items.RemoveAll(this);

			BView *separator = FindView("separatorLine");
			if (separator) {
				BRect frame(separator->Frame());
				frame.InsetBy(-1, -1);
				RemoveChild(separator);
				Invalidate();
			}

			AddChild(new SeparatorLine(BPoint(newBounds.left, newBounds.top
				+ newBounds.Height() / 2), newBounds.Width(), false,
				"separatorLine"));
			break;
		}
		case 1:
		{
			if (oldMode > 1) 
				fMode3Items.RemoveAll(this);
			else 
				fMode2Items.AddAll(this);

			BView *separator = FindView("separatorLine");
			if (separator) {
				BRect frame(separator->Frame());
				frame.InsetBy(-1, -1);
				RemoveChild(separator);
				Invalidate();
			}
			break;						
		}
		case 2:
		{
			fMode3Items.AddAll(this);
			if (oldMode < 1) 
				fMode2Items.AddAll(this);

			BView *separator = FindView("separatorLine");
			if (separator) {
				BRect frame(separator->Frame());
				frame.InsetBy(-1, -1);
				RemoveChild(separator);
				Invalidate();
			}
			break;						
		}
	}
}