NeuralAmpModelerPlugin

Plugin for Neural Amp Modeler
Log | Files | Refs | Submodules | README | LICENSE

IGraphics.code-snippets (10011B)


      1 {
      2 	"icontrol": {
      3 	"prefix": "IControl",
      4 	"body": [
      5 		"class ${1:MyNewControl} : public IControl",
      6 		"{", 
      7 		"public:", 
      8 		"\t$1(const IRECT& bounds)",
      9 		"\t: IControl(bounds)",
     10 		"\t{}",
     11 		"\t",
     12 		"\tvoid Draw(IGraphics& g) override",
     13 		"\t{",
     14 		"\t\tg.FillRect(COLOR_RED, mRECT);",
     15 		"\t}",
     16 		"\t",
     17 		"\t//void OnMouseDown(float x, float y, const IMouseMod& mod) override {}",
     18 		"\t//void OnMouseUp(float x, float y, const IMouseMod& mod) override {}",
     19 		"\t//void OnMouseDrag(float x, float y, float dX, float dY, const IMouseMod& mod) override {}",
     20 		// "\t//void OnMouseOver(float x, float y, const IMouseMod& mod) override {}",
     21 		// "\t//void OnMouseOut() override {}",
     22 		// "\t//void OnMouseWheel(float x, float y, const IMouseMod& mod, float d) override {}",
     23 		// "\t",
     24 		// "private:", 
     25 		// "\t$2", 
     26 		"};"
     27 	],
     28 	"description": "New IControl class"
     29 	},
     30 
     31 	"icontrolwithlayer": {
     32 		"prefix": "LayerIControl",
     33 		"body": [
     34 			"class ${1:MyNewControl} : public IControl",
     35 			"{", 
     36 			"public:", 
     37 			"\t$1(const IRECT& bounds)",
     38 			"\t: IControl(bounds)",
     39 			"\t{}",
     40 			"\t",
     41 			"\tvoid Draw(IGraphics& g) override",
     42 			"\t{",
     43 			"\t\tif(!g.CheckLayer(mLayer))",
     44 			"\t\t{",
     45 			"\t\t\tg.StartLayer(this, mRECT);",
     46 			"\t\t\tg.FillEllipse(COLOR_BLUE, mRECT);",
     47 			"\t\t\tmLayer = g.EndLayer();",
     48 			"\t\t}",
     49 			"\t}",
     50 			"\t",
     51 			"private:", 
     52 			"\tILayerPtr mLayer;", 
     53 			"};"
     54 		],
     55 		"description": "New IControl class with layer"
     56 		},
     57 
     58 	"skiacontrol": {
     59 		"prefix": "SkiaControl",
     60 		"body": [
     61 			"class ${1:MyNewSkiaControl} : public IControl",
     62 			"{", 
     63 			"public:", 
     64 			"\t$1(const IRECT& bounds)",
     65 			"\t: IControl(bounds)",
     66 			"\t{}",
     67 			"\t",
     68 			"\tvoid Draw(IGraphics& g) override",
     69 			"\t{",
     70 			"\t\tSkCanvas* canvas = static_cast<SkCanvas*>(g.GetDrawContext());",
     71 			"\t}",
     72 			"\t",
     73 			// "\t//void OnMouseDown(float x, float y, const IMouseMod& mod) override {}",
     74 			// "\t//void OnMouseUp(float x, float y, const IMouseMod& mod) override {}",
     75 			// "\t//void OnMouseDrag(float x, float y, float dX, float dY, const IMouseMod& mod) override {}",
     76 			// "\t//void OnMouseOver(float x, float y, const IMouseMod& mod) override {}",
     77 			// "\t//void OnMouseOut() override {}",
     78 			// "\t//void OnMouseWheel(float x, float y, const IMouseMod& mod, float d) override {}",
     79 			// "\t",
     80 			// "private:", 
     81 			// "\t$2", 
     82 			"};"
     83 		],
     84 		"description": "New IControl class"
     85 		},
     86 
     87 	"ivcontrol": {
     88 		"prefix": "IVControl",
     89 		"body": [
     90 			"class ${1:MyNewVControl} : public IControl",
     91 			"                    , public IVectorBase",
     92 			"{", 
     93 			"public:", 
     94 			"\t$1(const IRECT& bounds, const char* label = \"\", const IVStyle& style = DEFAULT_STYLE)",
     95 			"\t: IControl(bounds)",
     96 			"\t, IVectorBase(style)",
     97 			"\t{",
     98 			"\t\tAttachIControl(this, label);",
     99 			"\t}",
    100 			"\t",
    101 
    102 			"\tvoid Draw(IGraphics& g) override",
    103 			"\t{",
    104 			"\t\tDrawBackground(g, mRECT);",
    105 			"\t\tDrawWidget(g);",
    106 			"\t\tDrawLabel(g);",
    107 			"\t\tDrawValue(g, mMouseIsOver);",
    108 			"\t}",
    109 			"\t",
    110 			"\tvoid DrawWidget(IGraphics& g) override",
    111 			"\t{",
    112 			"\t\tg.FillRect(GetColor(kFG), mWidgetBounds);",
    113 			"\t}",
    114 			"\t",
    115 			"\tvoid OnResize() override",
    116 			"\t{",
    117 			"\t\tSetTargetRECT(MakeRects(mRECT));",
    118 			"\t}",
    119 			"\t",
    120 			"\t//void OnMouseDown(float x, float y, const IMouseMod& mod) override {}",
    121 			"\t//void OnMouseUp(float x, float y, const IMouseMod& mod) override {}",
    122 			"\t//void OnMouseDrag(float x, float y, float dX, float dY, const IMouseMod& mod) override {}",
    123 			// "\t//void OnMouseOver(float x, float y, const IMouseMod& mod) override {}",
    124 			// "\t//void OnMouseOut() override {}",
    125 			// "\t//void OnMouseWheel(float x, float y, const IMouseMod& mod, float d) override {}",
    126 			// "\t",
    127 			// "private:", 
    128 			// "\t$2", 
    129 			"};"
    130 		],
    131 		"description": "New IVControl class"
    132 	  },
    133 
    134 	"ibcontrol": {
    135 		"prefix": "IBControl",
    136 		"body": [
    137 			"class ${1:MyNewBControl} : public IControl",
    138 			"                    , public IBitmapBase",
    139 			"{", 
    140 			"public:", 
    141 			"\t$1(const IRECT& bounds, const IBitmap& bitmap)",
    142 			"\t: IControl(bounds)",
    143 			"\t, IBitmapBase(bitmap)",
    144 			"\t{",
    145 			"\t\tAttachIControl(this);",
    146 			"\t}",
    147 			"\t",
    148 			"\tvoid Draw(IGraphics& g) override",
    149 			"\t{",
    150 			"\t\tDrawBitmap(g);",
    151 			"\t}",
    152 			"\t",
    153 			"\tvoid OnRescale() override",
    154 			"\t{",
    155 			"\t\tmBitmap = GetUI()->GetScaledBitmap(mBitmap);",
    156 			"\t}",
    157 			"\t",
    158 			"\t//void OnMouseDown(float x, float y, const IMouseMod& mod) override {}",
    159 			"\t//void OnMouseUp(float x, float y, const IMouseMod& mod) override {}",
    160 			"\t//void OnMouseDrag(float x, float y, float dX, float dY, const IMouseMod& mod) override {}",
    161 			// "\t//void OnMouseOver(float x, float y, const IMouseMod& mod) override {}",
    162 			// "\t//void OnMouseOut() override {}",
    163 			// "\t//void OnMouseWheel(float x, float y, const IMouseMod& mod, float d) override {}",
    164 			// "\t",
    165 			// "private:", 
    166 			// "\t$2", 
    167 			"};"
    168 		],
    169 		"description": "New IBControl class"
    170 	  },
    171 
    172 	"itext": {
    173 		"prefix": "IText",
    174 		"body": [
    175 			"const IText text {",
    176 			"\tDEFAULT_TEXT_SIZE,            // size",
    177 			"\tDEFAULT_TEXT_FGCOLOR,         // color",
    178 			"\t\"Roboto-Regular\",             // font",
    179 			"\tEAlign::Center,               // horizontal align",
    180 			"\tEVAlign::Middle,              // vertical align",
    181 			"\t0,                            // angle",
    182 			"\tDEFAULT_TEXTENTRY_BGCOLOR,    // text entry BG color",
    183 			"\tDEFAULT_TEXTENTRY_FGCOLOR     // text entry text color",
    184 			"};",
    185 		],
    186 		"description": "Init IText"
    187 	},
    188 
    189 	"ivstyle": {
    190 		"prefix": "IVStyle",
    191 		"body": [
    192 			"const IVStyle style {",
    193 			"\tDEFAULT_SHOW_LABEL,           // show label",
    194 			"\tDEFAULT_SHOW_VALUE,           // show value",
    195 			"\t{                             // color spec:",
    196 			"\t\tDEFAULT_BGCOLOR,              // Background",
    197 			"\t\tDEFAULT_FGCOLOR,              // Foreground",
    198 			"\t\tDEFAULT_PRCOLOR,              // Pressed",
    199 			"\t\tCOLOR_BLACK,                  // Frame",
    200 			"\t\tDEFAULT_HLCOLOR,              // Highlight",
    201 			"\t\tDEFAULT_SHCOLOR,              // Shadow",
    202 			"\t\tCOLOR_BLACK,                  // Extra 1",
    203 			"\t\tDEFAULT_X2COLOR,              // Extra 2",
    204 			"\t\tDEFAULT_X3COLOR               // Extra 3",
    205 			"\t},",
    206 			"\t{                             // label text:",
    207 			"\t\tDEFAULT_TEXT_SIZE,            // size",
    208 			"\t\tDEFAULT_TEXT_FGCOLOR,         // color",
    209 			"\t\t\"Roboto-Regular\",             // font",
    210 			"\t\tEAlign::Center,               // horizontal align",
    211 			"\t\tEVAlign::Middle,              // vertical align",
    212 			"\t\t0                             // angle",
    213 			"\t},",
    214 			"\t{                             // value text:",
    215 			"\t\tDEFAULT_TEXT_SIZE,            // size",
    216 			"\t\tDEFAULT_TEXT_FGCOLOR,         // color",
    217 			"\t\t\"Roboto-Regular\",             // font",
    218 			"\t\tEAlign::Center,               // horizontal align",
    219 			"\t\tEVAlign::Middle,              // vertical align",
    220 			"\t\t0,                            // angle",
    221 			"\t\tDEFAULT_TEXTENTRY_BGCOLOR,    // text entry BG color",
    222 			"\t\tDEFAULT_TEXTENTRY_FGCOLOR     // text entry text color",
    223 			"\t},",
    224 			"\tDEFAULT_HIDE_CURSOR,          // hide cursor",
    225 			"\tDEFAULT_DRAW_FRAME,           // draw frame",
    226 			"\tDEFAULT_DRAW_SHADOWS,         // draw shadows",
    227 			"\tDEFAULT_EMBOSS,               // emboss",
    228 			"\tDEFAULT_ROUNDNESS,            // roundness",
    229 			"\tDEFAULT_FRAME_THICKNESS,      // frame thickness",
    230 			"\tDEFAULT_SHADOW_OFFSET,        // shadow offset",
    231 			"\tDEFAULT_WIDGET_FRAC,          // widget fraction",
    232 			"\tDEFAULT_WIDGET_ANGLE          // widget angle",
    233 			"};"
    234 		],
    235 		"description": "Init IVStyle"
    236 	},
    237 
    238 	"ivcolorspec": {
    239 		"prefix": "IVColorSpec",
    240 		"body": [
    241 			"const IVColorSpec spec {",
    242 			"\tDEFAULT_BGCOLOR,              // Background",
    243 			"\tDEFAULT_FGCOLOR,              // Foreground",
    244 			"\tDEFAULT_PRCOLOR,              // Pressed",
    245 			"\tCOLOR_BLACK,                  // Frame",
    246 			"\tDEFAULT_HLCOLOR,              // Highlight",
    247 			"\tDEFAULT_SHCOLOR,              // Shadow",
    248 			"\tCOLOR_BLACK,                  // Extra 1",
    249 			"\tDEFAULT_X2COLOR,              // Extra 2",
    250 			"\tDEFAULT_X3COLOR               // Extra 3",
    251 			"};"
    252 		],
    253 		"description": "Init IVColorSpec"
    254 	},
    255 
    256 	"lineargradient": {
    257 		"prefix": "LinearGradientPattern",
    258 		"body": [
    259 			"const IPattern pattern = IPattern::CreateLinearGradient(b, EDirection::Horizontal, { {${1:COLOR_WHITE}, 0.f}, {${2:COLOR_BLACK}, 1.f} });"
    260 		],
    261 		"description": "Init linear gradient IPattern"
    262 	},
    263 
    264 	"radialgradient": {
    265 		"prefix": "RadialGradientPattern",
    266 		"body": [
    267 			"const IPattern pattern = IPattern::CreateRadialGradient(b.MW(), b.MH(), b.W()/2.f, { {${1:COLOR_WHITE}, 0.f}, {${2:COLOR_BLACK}, 1.f} });"
    268 		],
    269 		"description": "Init radial gradient IPattern"
    270 	},
    271 
    272 	"attachlambda": {
    273 		"prefix": "AttachLambdaControl",
    274 		"body": [
    275 			"pGraphics->AttachControl(new ILambdaControl(bounds,",
    276 			"\t[](ILambdaControl* pCaller, IGraphics& g, IRECT& rect) {",
    277 			"\t",
    278 			"\t\tg.FillRect(COLOR_RED, rect);",
    279 			"\t",
    280 			"}, DEFAULT_ANIMATION_DURATION, false /*loop*/, false /*start immediately*/));",
    281 		],
    282 		"description": "Attach an ILambdaControl"
    283 	},
    284 
    285 	"attachivbutton": {
    286 		"prefix": "AttachIVButtonControl",
    287 		"body": [
    288 			"pGraphics->AttachControl(new IVButtonControl(bounds, SplashClickActionFunc,",
    289 			"\t\"${1:Press Me}\", DEFAULT_STYLE.WithColor(kFG, ${2:COLOR_WHITE}).WithLabelText({15.f, EVAlign::Middle})))->SetAnimationEndActionFunction(",
    290 			"\t[](IControl* pCaller) {",
    291 			"\t\t${3:DBGMSG(\"button clicked\")};",
    292 			"});",
    293 		],
    294 		"description": "Attach an IVButtonControl"
    295 	},
    296 
    297 	"attachprettyivslider": {
    298 		"prefix": "AttachIVSliderControl",
    299 		"body": [
    300 			"pGraphics->AttachControl(new IVSliderControl(b.GetCentredInside(30,100), [](IControl* pCaller){",
    301 			"\tdynamic_cast<IVSliderControl*>(pCaller)->SetColor(kX1, IColor::LinearInterpolateBetween(COLOR_RED, COLOR_ORANGE, pCaller->GetValue())); },",
    302 			"\t\"\", DEFAULT_STYLE, false, EDirection::Vertical, DEFAULT_GEARING, 0.f, 15.f));",
    303 		],
    304 		"description": "Attach an AttachIVSliderControl"
    305 	},
    306   }