38
38
public class QuickTaskOverviewMode : DrawingArea
40
const int indicatorPadding = 3;
41
bool flatStyle = Platform.IsWindows;
42
int barPadding = Platform.IsWindows? 1 : 3;
40
44
readonly QuickTaskStrip parentStrip;
41
45
protected readonly Adjustment vadjustment;
64
68
this.parentStrip = parent;
65
69
Events |= EventMask.ButtonPressMask | EventMask.ButtonReleaseMask | EventMask.ButtonMotionMask | EventMask.PointerMotionMask | EventMask.LeaveNotifyMask;
66
70
vadjustment = this.parentStrip.VAdjustment;
68
72
vadjustment.ValueChanged += RedrawOnUpdate;
69
73
vadjustment.Changed += RedrawOnUpdate;
70
74
parentStrip.TaskProviderUpdated += RedrawOnUpdate;
268
272
return new Cairo.Color (0, 0, 0);
269
273
switch (severity) {
270
274
case Severity.Error:
271
return style.ErrorUnderline;
275
return style.UnderlineError.Color;
272
276
case Severity.Warning:
273
return style.WarningUnderline;
277
return style.UnderlineWarning.Color;
274
278
case Severity.Suggestion:
275
return style.SuggestionUnderline;
279
return style.UnderlineSuggestion.Color;
276
280
case Severity.Hint:
277
return style.HintUnderline;
281
return style.UnderlineHint.Color;
278
282
case Severity.None:
279
return style.Default.CairoColor;
283
return style.PlainText.Background;
281
285
throw new ArgumentOutOfRangeException ();
289
293
return new Cairo.Color (0, 0, 0);
290
294
switch (severity) {
291
295
case Severity.Error:
292
return style.ErrorUnderline;
296
return style.UnderlineError.Color;
293
297
case Severity.Warning:
294
return style.WarningUnderline;
298
return style.UnderlineWarning.Color;
296
return style.SuggestionUnderline;
300
return style.UnderlineSuggestion.Color;
299
303
protected virtual double IndicatorHeight {
310
314
position = Math.Max (vadjustment.Lower, Math.Min (position, vadjustment.Upper - vadjustment.PageSize));
311
315
vadjustment.Value = position;
314
318
QuickTask hoverTask = null;
320
protected uint button;
318
322
protected override bool OnButtonPressEvent (EventButton evnt)
340
344
protected void DrawIndicator (Cairo.Context cr, Severity severity)
342
cr.Rectangle (3, Allocation.Height - IndicatorHeight + 4, Allocation.Width - 6, IndicatorHeight - 6);
347
indicatorPadding + 0.5,
348
Allocation.Height - IndicatorHeight + indicatorPadding + 0.5,
349
Allocation.Width - indicatorPadding * 2,
350
IndicatorHeight - indicatorPadding * 2
344
353
var darkColor = (HslColor)GetIndicatorColor (severity);
345
354
darkColor.L *= 0.5;
358
367
protected void DrawSearchIndicator (Cairo.Context cr)
360
var x1 = 1 + Allocation.Width / 2;
361
var y1 = Allocation.Height - IndicatorHeight / 2;
364
(IndicatorHeight - 1) / 2,
369
int diameter = Math.Min (Allocation.Width, (int)IndicatorHeight) - indicatorPadding * 2;
370
var x1 = Math.Round (Allocation.Width / 2d);
371
var y1 = Allocation.Height - Math.Floor (IndicatorHeight / 2d);
372
if (diameter % 2 == 0) {
377
cr.Arc (x1, y1, diameter / 2d, 0, 2 * Math.PI);
368
var darkColor = (HslColor)TextEditor.ColorStyle.SearchTextBg;
379
var darkColor = (HslColor)TextEditor.ColorStyle.SearchResult.Color;
369
380
darkColor.L *= 0.5;
371
using (var pattern = new Cairo.RadialGradient (x1, y1, Allocation.Width / 2, x1 - Allocation.Width, y1 - Allocation.Width, Allocation.Width)) {
372
pattern.AddColorStop (0, darkColor);
373
pattern.AddColorStop (1, TextEditor.ColorStyle.SearchTextMainBg);
374
cr.Pattern = pattern;
383
using (var pattern = new Cairo.SolidPattern (TextEditor.ColorStyle.SearchResultMain.Color)) {
384
cr.Pattern = pattern;
388
using (var pattern = new Cairo.RadialGradient (x1, y1, Allocation.Width / 2, x1 - Allocation.Width, y1 - Allocation.Width, Allocation.Width)) {
389
pattern.AddColorStop (0, darkColor);
390
pattern.AddColorStop (1, TextEditor.ColorStyle.SearchResultMain.Color);
391
cr.Pattern = pattern;
378
396
cr.Color = darkColor;
426
444
protected Severity DrawQuickTasks (Cairo.Context cr)
428
446
Severity severity = Severity.None;
430
448
foreach (var usage in AllUsages) {
431
449
double y = GetYPosition (usage.Line);
432
var usageColor = TextEditor.ColorStyle.Default.CairoColor;
450
var usageColor = TextEditor.ColorStyle.PlainText.Foreground;
433
451
usageColor.A = 0.4;
434
452
cr.Color = usageColor;
435
453
cr.MoveTo (0, y - 3);
442
460
foreach (var task in AllTasks) {
443
461
double y = GetYPosition (task.Location.Line);
445
463
cr.Color = GetBarColor (task.Severity);
446
cr.Rectangle (3 + 0.5, y - 1 + 0.5, Allocation.Width - 5, 2);
464
cr.Rectangle (barPadding, Math.Round (y) - 1, Allocation.Width - barPadding * 2, 2);
449
467
switch (task.Severity) {
462
480
protected void DrawLeftBorder (Cairo.Context cr)
464
cr.MoveTo (0.5, 1.5);
465
483
cr.LineTo (0.5, Allocation.Height);
466
484
if (TextEditor.ColorStyle != null) {
467
var col = (HslColor)TextEditor.ColorStyle.Default.CairoBackgroundColor;
485
var col = (HslColor)TextEditor.ColorStyle.PlainText.Background;
476
494
protected override void OnSizeAllocated (Rectangle allocation)
484
502
if (vadjustment == null || vadjustment.Upper <= vadjustment.PageSize)
505
int barWidth = Allocation.Width - barPadding - barPadding;
488
506
var allocH = Allocation.Height - (int) IndicatorHeight;
489
507
var adjUpper = vadjustment.Upper;
490
var barY = allocH * vadjustment.Value / adjUpper + barPadding;
491
var barH = allocH * (vadjustment.PageSize / adjUpper) - barPadding - barPadding;
492
int barWidth = Allocation.Width - barPadding - barPadding;
494
MonoDevelop.Components.CairoExtensions.RoundedRectangle (cr,
501
var color = (HslColor)((TextEditor.ColorStyle != null) ? TextEditor.ColorStyle.Default.CairoColor : new Cairo.Color (0, 0, 0));
508
var barY = Math.Round (allocH * vadjustment.Value / adjUpper) + barPadding;
509
const int minBarHeight = 16;
510
var barH = Math.Max (minBarHeight, Math.Round (allocH * (vadjustment.PageSize / adjUpper)) - barPadding - barPadding);
513
cr.Rectangle (barPadding, barY, barWidth, barH);
515
MonoDevelop.Components.CairoExtensions.RoundedRectangle (cr, barPadding, barY, barWidth, barH, barWidth / 2);
518
var color = (HslColor)((TextEditor.ColorStyle != null) ? TextEditor.ColorStyle.PlainText.Foreground : new Cairo.Color (0, 0, 0));
519
color.L = flatStyle? 0.7 : 0.5;
503
520
var c = (Cairo.Color)color;
514
531
bool isMainSelection = false;
515
532
if (!TextEditor.TextViewMargin.MainSearchResult.IsInvalid)
516
533
isMainSelection = region.Offset == TextEditor.TextViewMargin.MainSearchResult.Offset;
517
cr.Color = isMainSelection ? TextEditor.ColorStyle.SearchTextMainBg : TextEditor.ColorStyle.SearchTextBg;
518
cr.Rectangle (3 + 0.5, y - 1 + 0.5, Allocation.Width - 5, 2);
534
cr.Color = isMainSelection ? TextEditor.ColorStyle.SearchResultMain.Color : TextEditor.ColorStyle.SearchResult.Color;
535
cr.Rectangle (barPadding, Math.Round (y) - 1, Allocation.Width - barPadding * 2, 2);
529
546
cr.Rectangle (0, 0, Allocation.Width, Allocation.Height);
531
548
if (TextEditor.ColorStyle != null) {
532
var grad = new Cairo.LinearGradient (0, 0, Allocation.Width, 0);
533
var col = (HslColor)TextEditor.ColorStyle.Default.CairoBackgroundColor;
549
var col = (HslColor)TextEditor.ColorStyle.PlainText.Background;
535
grad.AddColorStop (0, col);
536
grad.AddColorStop (0.7, TextEditor.ColorStyle.Default.CairoBackgroundColor);
537
grad.AddColorStop (1, col);
552
using (var pattern = new Cairo.SolidPattern (col)) {
553
cr.Pattern = pattern;
556
using (var grad = new Cairo.LinearGradient (0, 0, Allocation.Width, 0)) {
557
grad.AddColorStop (0, col);
558
grad.AddColorStop (0.7, TextEditor.ColorStyle.PlainText.Background);
559
grad.AddColorStop (1, col);
542
567
cr.Color = (HslColor)Style.Dark (State);
543
568
cr.MoveTo (-0.5, 0.5);
544
569
cr.LineTo (Allocation.Width, 0.5);
571
cr.MoveTo (-0.5, Allocation.Height - 0.5);
572
cr.LineTo (Allocation.Width, Allocation.Height - 0.5);
547
575
if (TextEditor == null)
551
579
DrawSearchResults (cr);
552
580
DrawSearchIndicator (cr);
554
var severity = DrawQuickTasks (cr);
555
DrawIndicator (cr, severity);
582
if (!Debugger.DebuggingService.IsDebugging) {
583
var severity = DrawQuickTasks (cr);
584
DrawIndicator (cr, severity);