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

            theme.InitializeForGraphics(g);
            return(theme);
        }
Example #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;
                }
            }
        }
 public void InitializeGL(FamiStudioForm form)
 {
     gfx = new GLGraphics();
     foreach (var ctrl in controls)
     {
         ctrl.RenderInitialized(gfx);
     }
 }
Example #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);
            }
        }
Example #5
0
 public override void InitializeForGraphics(GLGraphics g)
 {
     base.InitializeForGraphics(g);
     InitializeFonts(g);
 }
Example #6
0
 protected virtual void OnRender(GLGraphics g)
 {
 }
Example #7
0
 protected virtual void OnRenderInitialized(GLGraphics g)
 {
 }
Example #8
0
 public void Render(GLGraphics g)
 {
     OnRender(g);
 }
Example #9
0
 public void RenderInitialized(GLGraphics g)
 {
     OnRenderInitialized(g);
 }
Example #10
0
 public PatternBitmapCache(GLGraphics g)
 {
     graphics = g;
 }