35
35
public class GlassWindow : Gtk.Window, IDoWindow
37
protected GlassFrame frame;
38
protected SymbolDisplayLabel label;
39
protected ResultsWindow resultsWindow;
40
protected HBox resultsHBox;
41
protected IDoController controller;
42
protected GlassIconBox[] iconbox;
38
SymbolDisplayLabel label;
39
ResultsWindow resultsWindow;
40
PositionWindow positionWindow;
42
IDoController controller;
43
GlassIconBox[] iconbox;
44
45
const int IconBoxIconSize = 64;
45
46
const uint IconBoxPadding = 2;
46
47
const int IconBoxRadius = 5;
48
protected int frameoffset;
49
protected const int MainRadius = 13;
51
protected Pane currentPane;
52
protected bool summonable;
48
const int NumberResultsDisplayed = 6;
51
const int MainRadius = 13;
54
56
//-------------------Events-----------------------
55
57
public new event DoEventKeyDelegate KeyPressEvent;
86
public PositionWindow PositionWindow {
88
return positionWindow ??
89
positionWindow = new PositionWindow(this, resultsWindow);
92
//---------------------ctor-----------------------
86
97
/// <param name="controller">
87
98
/// A <see cref="IDoController"/>
89
public GlassWindow (IDoController controller) : base (Gtk.WindowType.Toplevel)
100
public GlassWindow (IDoController controller)
101
: base (Gtk.WindowType.Toplevel)
91
103
this.controller = controller;
97
/// Provides primary building and packing of the IDoWindow. Custom widgets are packed in
109
/// Provides primary building and packing of the IDoWindow.
110
/// Custom widgets are packed in
98
111
/// here and most settings are selected.
100
113
protected void Build ()
116
resultsWindow = new ResultsWindow (new Color(15, 15, 15));
129
resultsWindow = new ResultsWindow (new Color(15, 15, 15),
130
NumberResultsDisplayed);
117
131
resultsWindow.SelectionChanged += OnResultsWindowSelectionChanged;
119
133
currentPane = Pane.First;
125
139
frame.FillColor = new Color(45, 45, 45);
126
140
frame.FrameColor = new Color(255, 255, 255);
127
141
frame.FrameAlpha = 1;
128
frame.DrawArrow = true;
129
142
frame.Radius = Screen.IsComposited ? MainRadius : 0;
224
237
controller.NewContextSelection (CurrentPane, args.SelectedIndex);
228
// /// Detect motion events in the area of the menu and show the menu button when hovered
230
// /// <param name="evnt">
231
// /// A <see cref="EventMotion"/>
234
// /// A <see cref="System.Boolean"/>
236
// protected override bool OnMotionNotifyEvent (EventMotion evnt)
238
// int end_x, end_y, start_x, start_y;
239
// int point_x, point_y;
241
// GetPosition (out start_x, out start_y);
242
// GetSize (out end_x, out end_y);
247
// point_x = (int) evnt.XRoot;
248
// point_y = (int) evnt.YRoot;
250
// if ((end_x - 30 <= point_x) && (point_x < end_x - 10) &&
251
// (start_y <= point_y) && (point_y < start_y + 15)) {
252
// if (!frame.DrawArrow)
253
// frame.DrawArrow = true;
255
// if (frame.DrawArrow)
256
// frame.DrawArrow = false;
259
// return base.OnMotionNotifyEvent (evnt);
241
/// Detect motion events in the area of the menu and show the menu button when hovered
243
/// <param name="evnt">
244
/// A <see cref="EventMotion"/>
247
/// A <see cref="System.Boolean"/>
249
protected override bool OnMotionNotifyEvent (EventMotion evnt)
251
int end_x, end_y, start_x, start_y;
252
int point_x, point_y;
254
GetPosition (out start_x, out start_y);
255
GetSize (out end_x, out end_y);
260
point_x = (int) evnt.XRoot;
261
point_y = (int) evnt.YRoot;
263
if ((end_x - 35 <= point_x) &&
264
(point_x < end_x - 15) &&
265
(start_y+frameoffset <= point_y) &&
266
(point_y < start_y + frameoffset + 15)) {
267
if (!frame.HoverArrow)
268
frame.HoverArrow = true;
270
if (frame.HoverArrow)
271
frame.HoverArrow = false;
274
return base.OnMotionNotifyEvent (evnt);
263
278
/// Detect if we have clicked on or off the window and and alert the controller.
288
303
Addins.Util.Appearance.PopupMainMenuAtPosition (end_x - 35, start_y + 25);
289
304
// Have to re-grab the pane from the menu.
290
305
Addins.Util.Appearance.PresentWindow (this);
291
//frame.DrawArrow = false;
306
frame.HoverArrow = false;
292
307
} else if (!click_on_window) {
293
308
controller.ButtonPressOffWindow ();
318
343
public void Reposition ()
321
Gdk.Rectangle geo, main, results;
345
Gdk.Rectangle offset;
348
offset = new Rectangle (frameoffset + ((int) IconBoxPadding * 2), 0, 0 ,0);
349
iconboxWidth = (iconbox[0].Width + ((int) IconBoxPadding * 4));
323
GetPosition (out main.X, out main.Y);
324
GetSize (out main.Width, out main.Height);
325
monitor = Screen.GetMonitorAtPoint (main.X, main.Y);
326
geo = Screen.GetMonitorGeometry (monitor);
327
main.X = (geo.Width - main.Width) / 2;
328
main.Y = (int)((geo.Height - main.Height) / 2.5);
329
Move (main.X, main.Y);
331
//use frameoffset to get proper positioning and account for additional glass framing
332
resultsWindow.GetSize (out results.Width, out results.Height);
333
results.Y = main.Y + main.Height;// - frameoffset;
334
results.X = main.X + (((iconbox[0].Width) + ((int) IconBoxPadding * 2)) *
335
(int) currentPane + MainRadius) + frameoffset;
336
resultsWindow.Move (results.X, results.Y);
351
PositionWindow.UpdatePosition (iconboxWidth, currentPane, offset);
339
354
///////////////////////
432
451
public void SetPaneContext (Pane pane, SearchContext context)
434
453
if (context.Results.Length == 0) {
454
NoResultsFoundObject noRes = new NoResultsFoundObject (context.Query);
435
455
for (int i = (int) pane; i < 3; i++) {
436
456
iconbox[i].Clear ();
437
NoResultsFoundObject noRes = new NoResultsFoundObject (context.Query);
438
457
iconbox[i].DisplayObject = noRes;
439
if (i == (int) CurrentPane)
458
if (i == (int) CurrentPane) {
440
459
label.SetDisplayLabel (noRes.Name, noRes.Description);
460
resultsWindow.Context = context;