本文整理汇总了C#中Gdk.EventMotion类的典型用法代码示例。如果您正苦于以下问题:C# EventMotion类的具体用法?C# EventMotion怎么用?C# EventMotion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EventMotion类属于Gdk命名空间,在下文中一共展示了EventMotion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnWidgetEvent
protected override bool OnWidgetEvent (Gdk.Event evnt)
{
// This method is hooked to block the event as soon as possible if required
if(evnt.Window.Equals (this.GdkWindow))
{
switch(evnt.Type)
{
case Gdk.EventType.ButtonPress:
case Gdk.EventType.ButtonRelease:
case Gdk.EventType.ThreeButtonPress:
case Gdk.EventType.TwoButtonPress:
Gdk.EventButton eb = new Gdk.EventButton (evnt.Handle);
return PropagateEventGivenCoordinate (evnt, eb.X, eb.XRoot, eb.Y, eb.YRoot);
case Gdk.EventType.MotionNotify:
Gdk.EventMotion em = new Gdk.EventMotion (evnt.Handle);
return PropagateEventGivenCoordinate (evnt, em.X, em.XRoot, em.Y, em.YRoot);
case Gdk.EventType.LeaveNotify:
foreach(Widget w in lastHoveredWidgets)
{
w.ProcessEvent (evnt);
}
lastHoveredWidgets.Clear();
return base.OnWidgetEvent (evnt);
}
}
return base.OnWidgetEvent (evnt);
}
示例2: ShowTooltip
void ShowTooltip(EventMotion evnt)
{
HideTooltip ();
tooltipTimeout = GLib.Timeout.Add (500, delegate {
ShowTooltipWindow ((int)evnt.X, (int)evnt.Y);
return false;
});
}
示例3: OnMotionNotifyEvent
protected override bool OnMotionNotifyEvent (EventMotion e)
{
if (!buttonPressed)
return base.OnMotionNotifyEvent (e);
int winWidth, winHeight;
this.GdkWindow.GetSize (out winWidth, out winHeight);
int row = GetRowByPosition ((int) e.Y);
if ((e.State & ModifierType.ControlMask) == ModifierType.ControlMask)
SelectRow (row);
else
this.SelectedRow = row;
return true;
}
示例4: OnMotionNotifyEvent
protected override bool OnMotionNotifyEvent (EventMotion evnt)
{
TooltipText = null;
if (dragPosition >= 0) {
int x, y;
widget.GetPointer (out x, out y);
int newWidthRequest = widget.Allocation.Width - x;
newWidthRequest = Math.Min (widget.Allocation.Width - (int)widget.Editor.TextViewMargin.XOffset, Math.Max (leftSpacer, newWidthRequest));
WidthRequest = newWidthRequest;
QueueResize ();
}
int startLine = widget.Editor.YToLine (widget.Editor.VAdjustment.Value + evnt.Y);
var ann = startLine > 0 && startLine <= annotations.Count ? annotations[startLine - 1] : null;
if (ann != null)
TooltipText = GetCommitMessage (startLine);
highlightPositon = evnt.Y;
if (highlightAnnotation != ann) {
highlightAnnotation = ann;
widget.QueueDraw ();
}
return base.OnMotionNotifyEvent (evnt);
}
示例5: OnMotionNotifyEvent
protected override bool OnMotionNotifyEvent (EventMotion evnt)
{
var item = GetItemAt (evnt.X, evnt.Y);
if (item != hoverItem) {
hoverItem = item;
QueueDraw ();
}
return base.OnMotionNotifyEvent (evnt);
}
示例6: OnMotionNotifyEvent
protected override bool OnMotionNotifyEvent (EventMotion evnt)
{
SetHover (GetItemAt ((int)evnt.X, (int)evnt.Y));
return true;
}
示例7: OnMotionNotifyEvent
protected override bool OnMotionNotifyEvent(EventMotion evnt)
{
bool handled = false;
handled = handled || OnPanMotionNotifyEvent (evnt);
if (can_select)
handled = handled || OnSelectionMotionNotifyEvent (evnt);
return handled || base.OnMotionNotifyEvent (evnt);
}
示例8: OnMotionNotifyEvent
protected override bool OnMotionNotifyEvent(EventMotion evnt)
{
var position = new Point(evnt.X, evnt.Y);
GtkMouseDevice.Instance.SetClientPosition(position);
var e = new RawMouseEventArgs(
GtkMouseDevice.Instance,
evnt.Time,
_inputRoot,
RawMouseEventType.Move,
position, GetModifierKeys(evnt.State));
Input(e);
return true;
}
示例9: OnMotionNotifyEvent
protected override bool OnMotionNotifyEvent (EventMotion evnt)
{
if (button != 0)
MouseMove (evnt.Y);
return base.OnMotionNotifyEvent (evnt);
}
示例10: OnMotionNotifyEvent
/// <summary>
/// Called on mouse move events.
/// </summary>
/// <param name="e">An instance that contains the event data.</param>
/// <returns><c>true</c> if the event was handled.</returns>
protected override bool OnMotionNotifyEvent(EventMotion e)
{
return this.ActualController.HandleMouseMove(this, e.ToMouseEventArgs());
}
示例11: OnMotionNotifyEvent
protected override bool OnMotionNotifyEvent (EventMotion evnt)
{
bool hideButton = widget.MainEditor.Document.ReadOnly;
Mono.TextEditor.Utils.Hunk selectedHunk = Mono.TextEditor.Utils.Hunk.Empty;
if (!hideButton) {
int delta = widget.MainEditor.Allocation.Y - Allocation.Y;
if (Diff != null) {
foreach (var hunk in Diff) {
double z1 = delta + fromEditor.LineToY (hunk.RemoveStart) - fromEditor.VAdjustment.Value;
double z2 = delta + fromEditor.LineToY (hunk.RemoveStart + hunk.Removed) - fromEditor.VAdjustment.Value;
if (z1 == z2)
z2 = z1 + 1;
double y1 = delta + toEditor.LineToY (hunk.InsertStart) - toEditor.VAdjustment.Value;
double y2 = delta + toEditor.LineToY (hunk.InsertStart + hunk.Inserted) - toEditor.VAdjustment.Value;
if (y1 == y2)
y2 = y1 + 1;
double x, y, w, h;
GetButtonPosition (hunk, y1, y2, z1, z2, out x, out y, out w, out h);
if (evnt.X >= x && evnt.X < x + w && evnt.Y >= y && evnt.Y < y + h) {
selectedHunk = hunk;
TooltipText = GettextCatalog.GetString ("Revert this change");
QueueDrawArea ((int)x, (int)y, (int)w, (int)h);
break;
}
}
}
} else {
selectedHunk = Mono.TextEditor.Utils.Hunk.Empty;
}
if (selectedHunk.IsEmpty)
TooltipText = null;
if (this.selectedHunk != selectedHunk) {
this.selectedHunk = selectedHunk;
QueueDraw ();
}
return base.OnMotionNotifyEvent (evnt);
}
示例12: OnMotionNotifyEvent
protected override bool OnMotionNotifyEvent (EventMotion evnt)
{
if (!item.Disabled && !Selected) {
Selected = true;
if (SelectedChanged != null)
SelectedChanged (this, EventArgs.Empty);
QueueDraw ();
}
return false;
}
示例13: OnMotionNotifyEvent
protected override bool OnMotionNotifyEvent(EventMotion evnt)
{
// First check if we need to draw a box for multiple selection via dragging
if (_dragStartTime != 0 && evnt.Time - _dragStartTime > 500)
{
Console.WriteLine("Motion {0}", _dragStartTime);
TreePath endPath;
GetPathAtPos((int)evnt.X, (int)evnt.Y, out endPath);
if (!GetPathAtPos((int)evnt.X, (int)evnt.Y, out endPath))
{
GetPathAtPos(1, 1, out endPath);
}
if (_dragStartPath.Compare(endPath) < 0)
{
Selection.UnselectAll();
Selection.SelectRange(_dragStartPath, endPath);
}
else
{
Selection.UnselectAll();
Selection.SelectRange(endPath, _dragStartPath);
}
}
// Now start logic for tooltips
if (!evnt.Window.Equals(BinWindow))
goto hide;
if (DateTime.Now.Subtract(TimeSpan.FromMilliseconds(500)) < _scrollStarted)
goto hide;
TreePath path;
TreeViewColumn column;
int cellX, cellY;
if (!GetPathAtPos((int) evnt.X, (int) evnt.Y, out path, out column, out cellX, out cellY))
goto hide;
var cellRenderers = column.CellRenderers.Where(c =>
{
int startPos, width;
column.CellGetPosition(c, out startPos, out width);
return startPos < cellX && cellX < startPos + width;
});
var cellRendererText = (CellRendererText)cellRenderers.FirstOrDefault();
TreeIter iter;
Model.GetIter(out iter, path);
column.CellSetCellData(Model, iter, false, false);
if (cellRendererText != null)
{
Label label = Tooltip.Label;
label.Text = cellRendererText.Text;
label.SetPadding((int)cellRendererText.Xpad, (int)cellRendererText.Ypad);
label.SizeRequest();
label.Show();
int listOriginX, listOriginY, labelWidth, labelHeight, labelLayoutOffsetX, labelLayoutOffsetY;
BinWindow.GetOrigin(out listOriginX, out listOriginY);
Rectangle cellRectangle = GetCellArea(path, column);
var x = listOriginX + cellRectangle.X;
var y = listOriginY + cellRectangle.Y;
label.Layout.GetPixelSize(out labelWidth, out labelHeight);
label.GetLayoutOffsets(out labelLayoutOffsetX, out labelLayoutOffsetY);
labelWidth += labelLayoutOffsetX;
labelWidth += (int)cellRendererText.Xpad;
var height = cellRectangle.Height;
Tooltip.Move(x, y);
Tooltip.SetSizeRequest(labelWidth, height);
Tooltip.Resize(labelWidth, height);
if (labelWidth < cellRectangle.Width)
goto hide;
Tooltip.Show();
goto returnBase;
}
hide:
Tooltip.Hide();
returnBase:
return base.OnMotionNotifyEvent(evnt);
}
示例14: OnMotionNotifyEvent
protected override bool OnMotionNotifyEvent(EventMotion ev)
{
Gdk.ModifierType state = (Gdk.ModifierType)ev.State;
if ((state & Gdk.ModifierType.Button1Mask) != 0) {
if ((state & Gdk.ModifierType.ShiftMask) != 0) {
X = dragStartX + (int)((dragStartMouseX - ev.X) / Scale);
Y = dragStartY + (int)((dragStartMouseY - ev.Y) / Scale);
} else {
if (PixelQueried != null) {
int pixelX, pixelY;
MouseToImageCoords (ev.X, ev.Y, out pixelX, out pixelY);
PixelQueried (this, pixelX, pixelY);
}
}
return true;
}
return false;
}
示例15: OnMotionNotifyEvent
protected override bool OnMotionNotifyEvent (EventMotion evnt)
{
if (draggingTab && mouseHasLeft) {
var sr = GetScreenRect ();
sr.Height = BarHeight;
sr.Inflate (30, 30);
int x, y;
Gdk.Display.Default.GetPointer (out x, out y);
if (x < sr.Left || x > sr.Right || y < sr.Top || y > sr.Bottom) {
draggingTab = false;
mouseHasLeft = false;
CreatePlaceholderWindow ();
}
}
string newTooltip = null;
if (placeholderWindow != null) {
int x, y;
Gdk.Display.Default.GetPointer (out x, out y);
placeholderWindow.MovePosition (x, y);
return base.OnMotionNotifyEvent (evnt);
}
if (!draggingTab) {
var t = FindTab ((int)evnt.X, (int)evnt.Y);
// If the user clicks and drags on the 'x' which closes the current
// tab we can end up with a null tab here
if (t == null) {
TooltipText = null;
return base.OnMotionNotifyEvent (evnt);
}
SetHighlightedTab (t);
var newOver = IsOverCloseButton (t, (int)evnt.X, (int)evnt.Y);
if (newOver != overCloseButton) {
overCloseButton = newOver;
QueueDraw ();
}
if (!overCloseButton && !draggingTab && buttonPressedOnTab) {
draggingTab = true;
mouseHasLeft = false;
dragXProgress = 1.0f;
int x = (int)evnt.X;
dragOffset = x - t.Allocation.X;
dragX = x - dragOffset;
lastDragX = (int)evnt.X;
} else if (t != null)
newTooltip = t.Tooltip;
} else if (evnt.State.HasFlag (ModifierType.Button1Mask)) {
dragX = (int)evnt.X - dragOffset;
QueueDraw ();
var t = FindTab ((int)evnt.X, TopPadding + 3);
if (t == null) {
var last = (DockNotebookTab)notebook.Tabs.Last ();
if (dragX > last.Allocation.Right)
t = last;
if (dragX < 0)
t = (DockNotebookTab)notebook.Tabs.First ();
}
if (t != null && t != notebook.CurrentTab && (
((int)evnt.X > lastDragX && t.Index > notebook.CurrentTab.Index) ||
((int)evnt.X < lastDragX && t.Index < notebook.CurrentTab.Index))) {
t.SaveAllocation ();
t.SaveStrength = 1;
notebook.ReorderTab ((DockNotebookTab)notebook.CurrentTab, t);
t.Animate ("TabMotion",
f => t.SaveStrength = f,
1.0f,
0.0f,
easing: Easing.CubicInOut);
}
lastDragX = (int)evnt.X;
}
if (newTooltip != null && TooltipText != null && TooltipText != newTooltip)
TooltipText = null;
else
TooltipText = newTooltip;
return base.OnMotionNotifyEvent (evnt);
}