Created
May 20, 2013 23:43
-
-
Save deltaluca/5616487 to your computer and use it in GitHub Desktop.
Funky mixin method.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package imgui; | |
#if macro | |
import haxe.macro.Context; | |
class ImColourBuild { | |
public static function run() { | |
var fields = Context.getBuildFields(); | |
fields.push({ | |
pos: Context.currentPos(), | |
name: "_colour", | |
meta: null, | |
doc: null, | |
access: [APublic], | |
kind: FVar(macro :Vec4, null) | |
}); | |
return fields; | |
} | |
} | |
#else | |
import ogl.GLM; | |
class ImColourBuild {} | |
class ImColourMixin { | |
public static function colour<T>(x:ImColour<T>, colour:Vec4) { | |
x._colour = colour; | |
return x; | |
} | |
} | |
@:build(imgui.ImColourBuild.run()) | |
@:autoBuild(imgui.ImColourBuild.run()) | |
interface ImColour<T> {} | |
#end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ogl.GLM; | |
import imgui.ImColour; | |
using imgui.ImColour.ImColourMixin; | |
class Panel implements ImColour<Panel> { | |
public function new() {} | |
} | |
class Main { | |
static function main() { | |
new Panel().colour([1,1,1,1]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment