Exemplo n.º 1
0
void GlowTextFieldWidget::OnWidgetMouseDown(
	Glow::MouseButton button,
	int x,
	int y,
	Glow::Modifiers modifiers)
{
	GLOW_DEBUGSCOPE("GlowTextFieldWidget::OnWidgetMouseDown");
	
	if (!HasKeyboardFocus())
	{
		GrabKeyboardFocus();
	}
	_dragX = x;
	if (modifiers & Glow::shiftModifier)
	{
		_dragEnd = _data.AtPixelPos(_font, 0, x-_inset+_hpos);
		_data.SetSelection(_dragStart, _dragEnd);
	}
	else
	{
		_dragStart = _dragEnd = _data.AtPixelPos(_font, 0, x-_inset+_hpos);
		_data.SetSelection(_dragStart);
	}
	_CheckAutoScroll();
	_toggleAutoScroll = true;
	Refresh();
}
Exemplo n.º 2
0
void GlowTextFieldWidget::OnWidgetMouseDown(
	Glow::MouseButton button,
	int x,
	int y,
	Glow::Modifiers modifiers)
{
	GLOW_DEBUGSCOPE("GlowTextFieldWidget::OnWidgetMouseDown");
	
	if (!HasKeyboardFocus())
	{
		GrabKeyboardFocus();
	}
	dragX_ = x;
	if (modifiers & Glow::shiftModifier)
	{
		dragEnd_ = data_.AtPixelPos(font_, 0, x-inset_+hpos_);
		data_.SetSelection(dragStart_, dragEnd_);
	}
	else
	{
		dragStart_ = dragEnd_ = data_.AtPixelPos(font_, 0, x-inset_+hpos_);
		data_.SetSelection(dragStart_);
	}
	CheckAutoScroll();
	toggleAutoScroll_ = true;
	Refresh();
}
FReply SInlineEditableTextBlock::OnMouseButtonDown( const FGeometry& MyGeometry, const FPointerEvent& MouseEvent )
{
	if( !MouseEvent.IsMouseButtonDown(EKeys::LeftMouseButton) || MouseEvent.IsControlDown() || MouseEvent.IsShiftDown())
	{
		return FReply::Unhandled();
	}

	if(IsSelected.IsBound())
	{
		if(IsSelected.Execute() && !bIsReadOnly.Get() && !ActiveTimerHandle.IsValid())
		{
			RegisterActiveTimer(0.5f, FWidgetActiveTimerDelegate::CreateSP(this, &SInlineEditableTextBlock::TriggerEditMode));
		}
	}
	else
	{
		// The widget is not managed by another widget, so handle the mouse input and enter edit mode if ready.
		if(HasKeyboardFocus())
		{
			EnterEditingMode();
		}
		return FReply::Handled();
	}

	// Do not handle the mouse input, this will allow for drag and dropping events to trigger.
	return FReply::Unhandled();
}
Exemplo n.º 4
0
BOOL Screen::CharIn(const char * c)
	{
	// Special: Tab chars are ignored, because they are always handled as focus advance
	if (c[0] == 0x09) return FALSE;
	// mark in mouse
	Mouse.ResetActiveInput();
	// no processing if focus is not set
	if (!HasKeyboardFocus()) return FALSE;
	// always return true in exclusive mode (which means: key processed)
	BOOL fResult = IsExclusive();
	// context menu: forward to context
	if (pContext) return pContext->CharIn(c) || fResult;
	// no active dlg?
	if (!pActiveDlg || !pActiveDlg->IsVisible()) return fResult;
	// forward to dialog
	return pActiveDlg->CharIn(c) || fResult;
	}
void SObjectNameEditableTextBox::Tick( const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime )
{
	const bool bShouldAppearFocused = HasKeyboardFocus();

	if ( bUpdateHighlightSpring || bShouldAppearFocused )
	{
		// Update highlight 'target' effect
		const float HighlightLeftX = HighlightRectLeftOffset;
		const float HighlightRightX = HighlightRectRightOffset + AllottedGeometry.Size.X;

		HighlightTargetLeftSpring.SetTarget( HighlightLeftX );
		HighlightTargetRightSpring.SetTarget( HighlightRightX );

		HighlightTargetLeftSpring.Tick( InDeltaTime );
		HighlightTargetRightSpring.Tick( InDeltaTime );
	}
}
Exemplo n.º 6
0
void SGraphPanel::OnGraphChanged(const FEdGraphEditAction& EditAction)
{
	if ((EditAction.Graph == GraphObj) &&
		(EditAction.Nodes.Num() > 0) &&
		// We do not want to mark it as a UserAddedNode for graphs that do not currently have focus,
		// this causes each one to want to do the effects and rename, which causes problems.
		(HasKeyboardFocus() || HasFocusedDescendants()))
	{
		int32 ActionIndex = UserActions.Num();
		if (EditAction.Action & GRAPHACTION_AddNode)
		{
			for (const UEdGraphNode* Node : EditAction.Nodes)
			{
				UserAddedNodes.Add(Node, ActionIndex);
			}
		}
		UserActions.Add(EditAction);
	}
}
Exemplo n.º 7
0
void GlowTextFieldWidget::OnWidgetPaint()
{
	GLOW_DEBUGSCOPE("GlowTextFieldWidget::OnWidgetPaint");
	
	// Backing
	if (!IsActive())
	{
		_disableBackColor.Apply();
	}
	else if (HasKeyboardFocus())
	{
		_focusBackColor.Apply();
	}
	else
	{
		_backColor.Apply();
	}
	::glRectf(-1.0f, -1.0f, 1.0f, 1.0f);
	
	// Bevels for backing
	float bevelHeight = float(4)/float(Height());
	float bevelWidth = float(4)/float(Width());
	float etchHeight = float(2)/float(Height());
	float etchWidth = float(2)/float(Width());
	if (IsActive())
	{
		if (_style == etchedStyle)
		{
			_lightBevelColor.Apply();
			::glBegin(GL_LINE_LOOP);
			::glVertex2f(-1.0f+etchWidth, -1.0f);
			::glVertex2f(-1.0f+etchWidth, 1.0f-etchHeight-etchHeight);
			::glVertex2f(1.0f-etchWidth, 1.0f-etchHeight-etchHeight);
			::glVertex2f(1.0f-etchWidth, -1.0f);
			::glEnd();
			_darkBevelColor.Apply();
			::glBegin(GL_LINE_LOOP);
			::glVertex2f(-1.0f, -1.0f+etchHeight);
			::glVertex2f(-1.0f, 1.0f-etchHeight);
			::glVertex2f(1.0f-etchWidth-etchWidth, 1.0f-etchHeight);
			::glVertex2f(1.0f-etchWidth-etchWidth, -1.0f+etchHeight);
			::glEnd();
		}
		else if (_style == raisedStyle || _style == loweredStyle)
		{
			if (_style == raisedStyle)
			{
				_lightBevelColor.Apply();
			}
			else
			{
				_darkBevelColor.Apply();
			}
			::glBegin(GL_QUAD_STRIP);
			::glVertex2f(-1.0f, -1.0f);
			::glVertex2f(-1.0f+bevelWidth, -1.0f+bevelHeight);
			::glVertex2f(-1.0f, 1.0f);
			::glVertex2f(-1.0f+bevelWidth, 1.0f-bevelHeight);
			::glVertex2f(1.0f, 1.0f);
			::glVertex2f(1.0f-bevelWidth, 1.0f-bevelHeight);
			::glEnd();

			if (_style == raisedStyle)
			{
				_darkBevelColor.Apply();
			}
			else
			{
				_lightBevelColor.Apply();
			}
			::glBegin(GL_QUAD_STRIP);
			::glVertex2f(-1.0f, -1.0f);
			::glVertex2f(-1.0f+bevelWidth, -1.0f+bevelHeight);
			::glVertex2f(1.0f, -1.0f);
			::glVertex2f(1.0f-bevelWidth, -1.0f+bevelHeight);
			::glVertex2f(1.0f, 1.0f);
			::glVertex2f(1.0f-bevelWidth, 1.0f-bevelHeight);
			::glEnd();
		}
	}
	else
	{
		_disableOutlineColor.Apply();
		::glBegin(GL_LINE_LOOP);
		::glVertex2f(-1.0f, -1.0f);
		::glVertex2f(-1.0f, 1.0f-etchHeight);
		::glVertex2f(1.0f-etchWidth, 1.0f-etchHeight);
		::glVertex2f(1.0f-etchWidth, -1.0f);
		::glEnd();
	}
	
	// Everything else gets scissored
	GLint oldScissor[4];
	::glGetIntegerv(GL_SCISSOR_BOX, oldScissor);
	::glScissor(RootPositionX()+_inset,
		Root()->Subwindow()->Height()-Height()-RootPositionY()+_inset,
		Width()-_inset-_inset, Height()-_inset-_inset);
	
	// Highlight backing
	if (_data.SelectionLength() > 0 && HasKeyboardFocus())
	{
		_hiliteBackColor.Apply();
		float left = 0;
		float top = 0;
		float right = 0;
		float bottom = 0;
		NormalizeCoordinates(_inset-_hpos+
			_data.PixelPosOf(_font, _data.SelectionStart(), 0),
			_inset, left, top);
		NormalizeCoordinates(_inset-_hpos+
			_data.PixelPosOf(_font, _data.SelectionEnd(), 0),
			_inset+_font.Leading(), right, bottom);
		::glRectf(left, bottom, right, top);
	}
	
	// Text
	if (!IsActive())
	{
		_disableTextColor.Apply();
	}
	else if (HasKeyboardFocus())
	{
		_focusTextColor.Apply();
	}
	else
	{
		_textColor.Apply();
	}
	int startpos = 0;
	int endpos = 0;
	int pixoffset = 0;
	_data.CalcLineDrawInfo(_font, 0, _hpos, Width()-_inset-_inset,
		startpos, endpos, pixoffset);
	const char* dat = _data.data();
	while (pixoffset > _inset)
	{
		pixoffset -= ::glutBitmapWidth(_font, dat[startpos]);
		++startpos;
	}
	float x = 0;
	float y = 0;
	NormalizeCoordinates(_inset-pixoffset,
		_inset+_font.BaselinePos(), x, y);
	::glRasterPos2f(x, y);
	for (int i=startpos; i<endpos; i++)
	{
		::glutBitmapCharacter(_font, dat[i]);
	}
	
	// Insertion caret
	// Special scissoring
	if (_blink || !HasKeyboardFocus() || !IsActive())
	{
		::glScissor(RootPositionX()+_caretInset,
			Root()->Subwindow()->Height()-Height()-RootPositionY()+_caretInset,
			Width()-_caretInset-_caretInset, Height()-_caretInset-_caretInset);
		if (!IsActive())
		{
			_disableCaretColor.Apply();
		}
		else if (HasKeyboardFocus())
		{
			_focusCaretColor.Apply();
		}
		else
		{
			_caretColor.Apply();
		}
		float horiz = 0;
		float top = 0;
		float bottom = 0;
		NormalizeCoordinates(_inset-_hpos+_data.PixelPosOf(_font, _dragEnd, 0),
			_inset, horiz, top);
		NormalizeCoordinates(_inset-_hpos+_data.PixelPosOf(_font, _dragEnd, 0),
			_inset+_font.Leading(), horiz, bottom);
		float hBump = float(2)/float(Width());
		float vBump = float(2)/float(Height());
		::glBegin(GL_LINES);
		::glVertex2f(horiz, bottom);
		::glVertex2f(horiz, top-vBump);
		::glVertex2f(horiz-bevelWidth, bottom);
		::glVertex2f(horiz+bevelWidth+hBump, bottom);
		::glVertex2f(horiz-bevelWidth, top-vBump);
		::glVertex2f(horiz+bevelWidth+hBump, top-vBump);
		::glEnd();
	}
	
	// Unscissor
	::glScissor(oldScissor[0], oldScissor[1], oldScissor[2], oldScissor[3]);
	
	// Activate autoscroll timer
	if (_toggleAutoScroll)
	{
		_toggleAutoScroll = false;
		_autoScrollTimer->SetTextField(this);
		_autoScrollTimerID = Glow::RegisterTimer(_autoScrollInterval, _autoScrollTimer);
	}
}