github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

abock / moonshine

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 7
    • 0
  • Source
  • Commits
  • Network (0)
  • Issues (0)
  • Downloads (1)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (2)
    • live-web
    • master ✓
  • Tags (1)
    • live-web
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

An embedded media player plugin for Firefox that leverages Moonlight to provide native Windows Media support for Linux. — Read more

  cancel

http://go-mono.com/moonlight

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Fixes to work with Moonlight 2.0 
jstedfast (author)
Wed Sep 02 12:33:04 -0700 2009
Aaron Bockover (committer)
Wed Sep 02 12:53:06 -0700 2009
commit  1e6efed14d57c937005f8610e2a4fadfea37cfa4
tree    9f86e3093a035e515e3bef043f13574898fcc923
parent  b80f974aaa215a59c852209c767a914d171f9d42
moonshine / player / mtk / mtk-style.js player/mtk/mtk-style.js
100644 177 lines (139 sloc) 5.567 kb
edit raw blame history
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
//
// This file is licensed under the MIT X11 open source license.
// http://www.opensource.org/licenses/mit-license.php
//
// Authors: Aaron Bockover <abockover@novell.com>
//
// Copyright 2009 Novell, Inc.
//
 
var MtkStyle = {
 
    //
    // Style Loading
    //
    
    Notify: new MtkObject,
 
    Reload: function () {
        MtkStyle.ShadeColorsFromNormal (MtkStyle.DefaultColors);
        MtkStyle.system_colors = null;
        
        // Load the color scheme from the CSS named system colors
        
        try {
            var css_color_map = {
                "Window" : "window_bg",
                "WindowText" : "window_fg",
                "ButtonFace" : "button_bg",
                "ButtonText" : "button_fg",
                "ButtonShadow" : "button_shadow",
                "ButtonHighlight" : "button_highlight",
                "Highlight" : "highlight_bg",
                "HighlightText" : "highlight_fg",
                "Scrollbar" : "trough_bg"
            };
    
            var colors = {};
            var elem = document.createElement ("div");
          
            for (var css in css_color_map) {
                elem.style.color = css;
                var style = document.defaultView.getComputedStyle (elem, null);
                var color = style.getPropertyValue ("color");
                colors[css_color_map[css]] = { normal: MtkColor.FromString (color) };
            }
    
            MtkStyle.ShadeColorsFromNormal (colors);
            MtkStyle.system_colors = colors;
        } catch (e) {
            MtkConsole.Log ("Could not load system color scheme from CSS/DOM: " + e);
        }
        
        try {
            MtkStyle.LoadFont ();
        } catch (e) {
            MtkConsole.Log ("Could not load font data from CSS/DOM: " + e);
        }
        
        MtkStyle.Notify.RaiseEvent ("reload");
    },
    
    //
    // Colors
    //
    
    DefaultColors: {
        /*bg: { normal: MtkColor.FromInt (0xd8d8d8) },
fg: { normal: MtkColor.FromInt (0x444444) },
focus: { normal: MtkColor.FromInt (0x4d9f0e) }*/
    },
 
    system_colors: null,
    get Colors () { return MtkStyle.system_colors || MtkStyle.DefaultColors; },
 
    ShadeColorsFromNormal: function (colors) {
        for (var set_name in colors) {
            var set = colors[set_name];
            set.light = MtkColor.Lighter (set.normal);
            set.dark = MtkColor.Darker (set.normal);
            set.lighter = MtkColor.Lighter (set.light);
            set.darker = MtkColor.Darker (set.dark);
            set.lightest = MtkColor.Lighter (set.lighter);
            set.darkest = MtkColor.Darker (set.darker);
        }
    },
 
    //
    // Font/Text
    //
 
    DefaultFont: {
        Family: "DejaVu Sans, sans-serif",
        Size: 11
    },
    
    system_font: null,
    get Font () { return MtkStyle.system_font || MtkStyle.DefaultFont; },
    
    ScreenDpi: 96, // FIXME: try to compute this
    
    LoadFont: function () {
        var elem = document.body;
        
        MtkStyle.system_font = null;
        
        if (!elem || !document.defaultView || !document.defaultView.getComputedStyle) {
            return;
        }
 
        var style = document.defaultView.getComputedStyle (elem, null);
        if (!style || !style.getPropertyValue) {
            return;
        }
        
        var family = style.getPropertyValue ("font-family");
 
        var computed_size = 0;
        var size = /^([0-9]+)([a-z]*)$/.exec (style.getPropertyValue ("font-size"));
        if (size && size.length > 1) {
            var size_value = parseInt (size[1]);
            if (size_value > 0 && size.length > 2 && size[2] == "px") {
                computed_size = size_value * (72 / MtkStyle.ScreenDpi);
            } else if (size_value > 3) {
                // we'll just assume the unit is in pt already,
                // and it's of a reasonable size to be visible
                computed_size = size_value;
            }
        }
 
        MtkStyle.system_font = { Family: family, Size: computed_size };
    },
    
    //
    // Drawing Utilities
    //
    
    GetColor: function (style, shade)
        MtkColor.ToString (MtkStyle.Colors[style][shade || "normal"]),
    
    CreateGradient: function (widget, style, inset, c, o) {
        var offsets = o || [ 0, 0.5, 0.5, 1 ];
        var colors = c || [ "lighter", "light", "normal", "dark" ];
        
        if (inset) {
            colors.reverse ();
        }
        
        for (var i = 0; i < colors.length; i++) {
            colors[i] = MtkStyle.GetColor (style, colors[i]);
        }
        
        return MtkStyle.CreateLinearGradient (widget, offsets, colors);
    },
    
    CreateLinearGradient: function (widget, offsets, colors, start_point, end_point) {
        var brush = widget.CreateXaml ("<LinearGradientBrush/>");
        brush.StartPoint = start_point || "0,0";
        brush.EndPoint = end_point || "0,1";
        
        for (var i = 0, n = Math.min (offsets.length, colors.length); i < n; i++) {
            brush.GradientStops.Add (MtkStyle.CreateGradientStop (widget, offsets[i],
                typeof colors[i] != "string" ? MtkColor.ToString (colors[i]) : colors[i]
            ));
        }
                
        return brush;
    },
    
    CreateGradientStop: function (widget, offset, color) {
        var stop = widget.CreateXaml ("<GradientStop/>");
        stop.Offset = offset;
        stop.Color = color;
        return stop;
    }
};
 
 
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server