1 /* 2 * Copyright (C) 2015-2017, by Laszlo Szeremi under the Boost license. 3 * 4 * Pixel Perfect Engine, concrete.stylesheet module 5 */ 6 7 module PixelPerfectEngine.concrete.stylesheet; 8 9 import PixelPerfectEngine.graphics.bitmap; 10 import PixelPerfectEngine.graphics.fontsets; 11 /** 12 * Defines style data for the Concrete GUI. 13 */ 14 public class StyleSheet{ 15 public static immutable Color[] defaultpaletteforGUI = 16 [Color(0x00,0x00,0x00,0x00), //transparent 17 Color(0xFF,0xFF,0xFF,0xFF), //normaltext 18 Color(0xFF,0x77,0x77,0x77), //window 19 Color(0xFF,0xCC,0xCC,0xCC), //windowascent 20 Color(0xFF,0x33,0x33,0x33), //windowdescent 21 Color(0xff,0x22,0x22,0x22), //windowinactive 22 Color(0xff,0xff,0x00,0x00), //selection 23 Color(0xFF,0x77,0x77,0xFF), //WHAascent 24 Color(0xFF,0x00,0x00,0x77), //WHAdescent 25 Color(0xFF,0x00,0x00,0xDD), //WHAtop 26 Color(0xFF,0x00,0x00,0xFF), 27 Color(0xFF,0x00,0x00,0x7F), 28 Color(0xFF,0xFF,0xFF,0x00), 29 Color(0xFF,0xFF,0x7F,0x00), 30 Color(0xFF,0x7F,0x7F,0x7F), 31 Color(0xFF,0x00,0x00,0x00)]; ///Default 16 color palette 32 private Fontset!Bitmap8Bit[string] font; ///Fonts stored here. 33 private ubyte[string] color; ///Colors are identified by strings. 34 private Bitmap8Bit[string] images; ///For icons, pattern fills, etc... 35 public int[string] drawParameters; ///Draw parameters are used for border thickness, padding, etc... 36 public string[string] fontTypes; ///Font type descriptions for various kind of components 37 38 /** 39 * Creates a default stylesheet. 40 */ 41 public this(){ 42 color["transparent"] = 0x0000; 43 color["normaltext"] = 0x0001; 44 color["window"] = 0x0002; 45 color["windowascent"] = 0x0003; 46 color["windowdescent"] = 0x0004; 47 color["windowinactive"] = 0x0005; 48 color["selection"] = 0x0006; 49 color["red"] = 0x0006; 50 color["WHAascent"] = 0x0007; 51 color["WHAdescent"] = 0x0008; 52 color["WHTextActive"] = 0x0001; 53 color["WHTextInactive"] = 0x000F; 54 color["WHAtop"] = 0x0009; 55 color["blue"] = 0x000A; 56 color["darkblue"] = 0x000B; 57 color["yellow"] = 0x000C; 58 color["orange"] = 0x000D; 59 color["grey"] = 0x000E; 60 color["black"] = 0x000F; 61 color["white"] = 0x0001; 62 color["PopUpMenuSecondaryTextColor"] = 0x000D; 63 color["MenuBarSeparatorColor"] = 0x000D; 64 65 drawParameters["PopUpMenuHorizPadding"] = 4; 66 drawParameters["PopUpMenuVertPadding"] = 1; 67 drawParameters["PopUpMenuMinTextSpace"] = 8; 68 69 drawParameters["MenuBarHorizPadding"] = 4; 70 drawParameters["MenuBarVertPadding"] = 2; 71 72 drawParameters["ListBoxRowHeight"] = 16; 73 drawParameters["TextSpacingTop"] = 1; 74 drawParameters["TextSpacingBottom"] = 1; 75 drawParameters["WindowLeftPadding"] = 5; 76 drawParameters["WindowRightPadding"] = 5; 77 drawParameters["WindowTopPadding"] = 20; 78 drawParameters["WindowBottomPadding"] = 5; 79 drawParameters["ComponentHeight"] = 20; 80 81 fontTypes["default"] = "OpenSans"; 82 83 } 84 public void addFontset(Fontset!Bitmap8Bit f, string style){ 85 font[style] = f; 86 } 87 public Fontset!Bitmap8Bit getFontset(string style){ 88 return font.get(fontTypes.get(style, style), font[fontTypes["default"]]); 89 } 90 public void setColor(ubyte c, string colorName){ 91 color[colorName] = c; 92 } 93 public ubyte getColor(string colorName){ 94 return color[colorName]; 95 } 96 public void setImage(Bitmap8Bit bitmap, string name){ 97 images[name] = bitmap; 98 } 99 public Bitmap8Bit getImage(string name){ 100 return images.get(name, null); 101 } 102 } 103