示例#1
0
        public static GLTheme CreateResourcesForGraphics(GLGraphics g)
        {
            var theme = new GLTheme();

            theme.InitializeForGraphics(g);
            return(theme);
        }
示例#2
0
        private void InitializeFonts(GLGraphics g)
        {
            if (Fonts[0] == null)
            {
                var fontTextureMap = new Dictionary <string, int>();

                for (int i = 0; i < FontDefinitions.Length; i++)
                {
                    var def = FontDefinitions[i];

                    def.Size = (int)(def.Size * MainWindowScaling);

                    var suffix   = def.Bold ? "Bold" : "";
                    var basename = $"{def.Name}{def.Size}{suffix}";
                    var fntfile  = $"FamiStudio.Resources.{basename}.fnt";
                    var imgfile  = $"FamiStudio.Resources.{basename}_0.png";

                    var str = "";
                    using (Stream stream = typeof(GLTheme).Assembly.GetManifestResourceStream(fntfile))
                        using (StreamReader reader = new StreamReader(stream))
                        {
                            str = reader.ReadToEnd();
                        }

                    var pixbuf = Gdk.Pixbuf.LoadFromResource(imgfile);
                    var lines  = str.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);

                    fontTextureMap.TryGetValue(imgfile, out int texture);
                    var font = g.CreateFont(pixbuf, lines, def.Size, def.Alignment, def.Ellipsis, texture);

                    fontTextureMap[imgfile] = font.Texture;
                    Fonts[i] = font;
                }
            }
        }
示例#3
0
 public void InitializeGL(FamiStudioForm form)
 {
     gfx = new GLGraphics();
     foreach (var ctrl in controls)
     {
         ctrl.RenderInitialized(gfx);
     }
 }
示例#4
0
        public void InitializeGL()
        {
            gfx = new GLGraphics(DpiScaling.MainWindow, DpiScaling.Font);
            res = new ThemeRenderResources(gfx);

            foreach (var ctrl in controls)
            {
                ctrl.SetDpiScales(DpiScaling.MainWindow, DpiScaling.Font);
                ctrl.SetThemeRenderResource(res);
                ctrl.RenderInitialized(gfx);
            }
        }
示例#5
0
 public override void InitializeForGraphics(GLGraphics g)
 {
     base.InitializeForGraphics(g);
     InitializeFonts(g);
 }
示例#6
0
 protected virtual void OnRender(GLGraphics g)
 {
 }
示例#7
0
 protected virtual void OnRenderInitialized(GLGraphics g)
 {
 }
示例#8
0
 public void Render(GLGraphics g)
 {
     OnRender(g);
 }
示例#9
0
 public void RenderInitialized(GLGraphics g)
 {
     OnRenderInitialized(g);
 }
示例#10
0
 public PatternBitmapCache(GLGraphics g)
 {
     graphics = g;
 }