~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.QuickTasks/QuickTaskOverviewMode.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
{
38
38
        public class QuickTaskOverviewMode : DrawingArea
39
39
        {
 
40
                const int indicatorPadding = 3;
 
41
                bool flatStyle = Platform.IsWindows;
 
42
                int barPadding = Platform.IsWindows? 1 : 3;
 
43
 
40
44
                readonly QuickTaskStrip parentStrip;
41
45
                protected readonly Adjustment vadjustment;
42
46
                
64
68
                        this.parentStrip = parent;
65
69
                        Events |= EventMask.ButtonPressMask | EventMask.ButtonReleaseMask | EventMask.ButtonMotionMask | EventMask.PointerMotionMask | EventMask.LeaveNotifyMask;
66
70
                        vadjustment = this.parentStrip.VAdjustment;
67
 
                        
 
71
 
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;
280
284
                        default:
281
285
                                throw new ArgumentOutOfRangeException ();
282
286
                        }
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;
295
299
                        default:
296
 
                                return style.SuggestionUnderline;
 
300
                                return style.UnderlineSuggestion.Color;
297
301
                        }
298
302
                }
299
303
                protected virtual double IndicatorHeight  {
302
306
                        }
303
307
                }
304
308
                
305
 
                void MouseMove (double y)
 
309
                protected virtual void MouseMove (double y)
306
310
                {
307
311
                        if (button != 1)
308
312
                                return;
310
314
                        position = Math.Max (vadjustment.Lower, Math.Min (position, vadjustment.Upper - vadjustment.PageSize));
311
315
                        vadjustment.Value = position;
312
316
                }
313
 
                
 
317
 
314
318
                QuickTask hoverTask = null;
315
319
                
316
 
                uint button;
 
320
                protected uint button;
317
321
 
318
322
                protected override bool OnButtonPressEvent (EventButton evnt)
319
323
                {
339
343
 
340
344
                protected void DrawIndicator (Cairo.Context cr, Severity severity)
341
345
                {
342
 
                        cr.Rectangle (3, Allocation.Height - IndicatorHeight + 4, Allocation.Width - 6, IndicatorHeight - 6);
 
346
                        cr.Rectangle (
 
347
                                indicatorPadding + 0.5,
 
348
                                Allocation.Height - IndicatorHeight + indicatorPadding + 0.5,
 
349
                                Allocation.Width - indicatorPadding * 2,
 
350
                                IndicatorHeight - indicatorPadding * 2
 
351
                        );
343
352
                        
344
353
                        var darkColor = (HslColor)GetIndicatorColor (severity);
345
354
                        darkColor.L *= 0.5;
357
366
 
358
367
                protected void DrawSearchIndicator (Cairo.Context cr)
359
368
                {
360
 
                        var x1 = 1 + Allocation.Width / 2;
361
 
                        var y1 = Allocation.Height - IndicatorHeight / 2;
362
 
                        cr.Arc (x1, 
363
 
                                y1, 
364
 
                                (IndicatorHeight - 1) / 2, 
365
 
                                0, 
366
 
                                2 * Math.PI);
 
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) {
 
373
                                x1 += 0.5;
 
374
                                y1 += 0.5;
 
375
                        }
 
376
 
 
377
                        cr.Arc (x1, y1, diameter / 2d, 0, 2 * Math.PI);
367
378
                        
368
 
                        var darkColor = (HslColor)TextEditor.ColorStyle.SearchTextBg;
 
379
                        var darkColor = (HslColor)TextEditor.ColorStyle.SearchResult.Color;
369
380
                        darkColor.L *= 0.5;
370
 
                        
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;
375
 
                                cr.FillPreserve ();
 
381
 
 
382
                        if (flatStyle) {
 
383
                                using (var pattern = new Cairo.SolidPattern (TextEditor.ColorStyle.SearchResultMain.Color)) {
 
384
                                        cr.Pattern = pattern;
 
385
                                        cr.FillPreserve ();
 
386
                                }
 
387
                        } else {
 
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;
 
392
                                        cr.FillPreserve ();
 
393
                                }
376
394
                        }
377
395
                        
378
396
                        cr.Color = darkColor;
409
427
                        cr.LineTo (7, y);
410
428
                        cr.LineTo (0, y + 4);
411
429
                        cr.ClosePath ();
412
 
                        cr.Color = TextEditor.ColorStyle.Default.CairoColor;
 
430
                        cr.Color = TextEditor.ColorStyle.PlainText.Foreground;
413
431
                        cr.Fill ();
414
432
                }
415
433
 
426
444
                protected Severity DrawQuickTasks (Cairo.Context cr)
427
445
                {
428
446
                        Severity severity = Severity.None;
429
 
 
 
447
                        /*
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);
438
456
                                cr.ClosePath ();
439
457
                                cr.Fill ();
440
458
                        }
441
 
 
 
459
*/
442
460
                        foreach (var task in AllTasks) {
443
461
                                double y = GetYPosition (task.Location.Line);
444
462
 
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);
447
465
                                cr.Fill ();
448
466
 
449
467
                                switch (task.Severity) {
461
479
                
462
480
                protected void DrawLeftBorder (Cairo.Context cr)
463
481
                {
464
 
                        cr.MoveTo (0.5, 1.5);
 
482
                        cr.MoveTo (0.5, 0);
465
483
                        cr.LineTo (0.5, Allocation.Height);
466
484
                        if (TextEditor.ColorStyle != null) {
467
 
                                var col = (HslColor)TextEditor.ColorStyle.Default.CairoBackgroundColor;
468
 
                                col.L *= 0.90;
 
485
                                var col = (HslColor)TextEditor.ColorStyle.PlainText.Background;
 
486
                                if (!flatStyle) {
 
487
                                        col.L *= 0.88;
 
488
                                }
469
489
                                cr.Color = col;
470
 
                                
471
490
                        }
472
491
                        cr.Stroke ();
473
 
                        
474
492
                }
475
493
 
476
494
                protected override void OnSizeAllocated (Rectangle allocation)
484
502
                        if (vadjustment == null || vadjustment.Upper <= vadjustment.PageSize) 
485
503
                                return;
486
504
 
487
 
                        int barPadding = 3;
 
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;
493
 
                        
494
 
                        MonoDevelop.Components.CairoExtensions.RoundedRectangle (cr, 
495
 
                                barPadding,
496
 
                                barY,
497
 
                                barWidth,
498
 
                                barH,
499
 
                                barWidth / 2);
500
 
                        
501
 
                        var color = (HslColor)((TextEditor.ColorStyle != null) ? TextEditor.ColorStyle.Default.CairoColor : new Cairo.Color (0, 0, 0));
502
 
                        color.L = 0.5;
 
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);
 
511
 
 
512
                        if (flatStyle) {
 
513
                                cr.Rectangle (barPadding, barY, barWidth, barH);
 
514
                        } else {
 
515
                                MonoDevelop.Components.CairoExtensions.RoundedRectangle (cr, barPadding, barY, barWidth, barH, barWidth / 2);
 
516
                        }
 
517
                        
 
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;
504
521
                        c.A = 0.6;
505
522
                        cr.Color = c;
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);
519
536
                                cr.Fill ();
520
537
                        }
521
538
                }
529
546
                                cr.Rectangle (0, 0, Allocation.Width, Allocation.Height);
530
547
                                
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;
534
550
                                        col.L *= 0.95;
535
 
                                        grad.AddColorStop (0, col);
536
 
                                        grad.AddColorStop (0.7, TextEditor.ColorStyle.Default.CairoBackgroundColor);
537
 
                                        grad.AddColorStop (1, col);
538
 
                                        cr.Pattern = grad;
 
551
                                        if (flatStyle) {
 
552
                                                using (var pattern = new Cairo.SolidPattern (col)) {
 
553
                                                        cr.Pattern = pattern;
 
554
                                                }
 
555
                                        } else {
 
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);
 
560
                                                        cr.Pattern = grad;
 
561
                                                }
 
562
                                        }
539
563
                                }
540
564
                                cr.Fill ();
541
 
                                
 
565
 
 
566
                                /*
542
567
                                cr.Color = (HslColor)Style.Dark (State);
543
568
                                cr.MoveTo (-0.5, 0.5);
544
569
                                cr.LineTo (Allocation.Width, 0.5);
545
 
                                cr.Stroke ();
546
 
                                
 
570
 
 
571
                                cr.MoveTo (-0.5, Allocation.Height - 0.5);
 
572
                                cr.LineTo (Allocation.Width, Allocation.Height - 0.5);
 
573
                                cr.Stroke ();*/
 
574
 
547
575
                                if (TextEditor == null)
548
576
                                        return true;
549
577
                                
551
579
                                        DrawSearchResults (cr);
552
580
                                        DrawSearchIndicator (cr);
553
581
                                } else {
554
 
                                        var severity = DrawQuickTasks (cr);
555
 
                                        DrawIndicator (cr, severity);
 
582
                                        if (!Debugger.DebuggingService.IsDebugging) {
 
583
                                                var severity = DrawQuickTasks (cr);
 
584
                                                DrawIndicator (cr, severity);
 
585
                                        }
556
586
                                }
557
587
                                DrawCaret (cr);
558
588