<commit_before>package h2d;

/**
	A simple Interactive checkbox button with a label.

	Useful for fast construction of development UI, but lacks on configurability side.
**/
class CheckBox extends h2d.Flow {
	/**
		When disabled, the user would not be able to change the checkbox state by interacting with it.

		It is still possible to change the `selected` state manually through the code even if checkbox is disabled.
	**/
	public var enable(default,set) : Bool = true;
	/**
		Current toggle state of the checkbox.

		Note that changing the state from the code will cause `CheckBox.onChange` to trigger.
	**/
	public var selected(default,set) : Bool = false;
	/**
		Optional text label that will be shown to the right of the checkbox.
	**/
	public var text(default,set) : String = "";

	var tf : h2d.Text;
	var select : h2d.Bitmap;

	/**
		Create a new CheckBox instance.
		@param parent An optional parent `h2d.Object` instance to which CheckBox adds itself if set.
	**/
	public function new(?parent) {
		super(parent);
		padding = 0;
		verticalAlign = Middle;
		horizontalSpacing = 5;
		borderHeight = borderWidth = 1;

		var width = 13;
		var box = new h2d.Flow(this);

		var t = h2d.Tile.fromColor(0x404040, width, width);
		new h2d.Bitmap(t, box);

		var t = h2d.Tile.fromColor(0, width - borderWidth * 2, width - borderHeight * 2);
		var bg = new h2d.Bitmap(t, box);
		bg.x = borderWidth;
		bg.y = borderHeight;
		box.getProperties(bg).isAbsolute = true;

		var t = h2d.Tile.fromColor(0x404040, width - (borderWidth + 1) * 2, width - (borderHeight + 1) * 2);
		select = new h2d.Bitmap(t, box);
		select.x = borderWidth + 1;
		select.y = borderHeight + 1;
		box.getProperties(select).isAbsolute = true;

		tf = new h2d.Text(hxd.res.DefaultFont.get(), this);
		getProperties(tf).offsetY = -2;

		//
		enableInteractive = true;
		interactive.cursor = Button;
		interactive.onClick = function(e) {<commit_msg>fix wrt Flow borderWidth changes<commit_after>package h2d;

/**
	A simple Interactive checkbox button with a label.

	Useful for fast construction of development UI, but lacks on configurability side.
**/
class CheckBox extends h2d.Flow {
	/**
		When disabled, the user would not be able to change the checkbox state by interacting with it.

		It is still possible to change the `selected` state manually through the code even if checkbox is disabled.
	**/
	public var enable(default,set) : Bool = true;
	/**
		Current toggle state of the checkbox.

		Note that changing the state from the code will cause `CheckBox.onChange` to trigger.
	**/
	public var selected(default,set) : Bool = false;
	/**
		Optional text label that will be shown to the right of the checkbox.
	**/
	public var text(default,set) : String = "";

	var tf : h2d.Text;
	var select : h2d.Bitmap;

	/**
		Create a new CheckBox instance.
		@param parent An optional parent `h2d.Object` instance to which CheckBox adds itself if set.
	**/
	public function new(?parent) {
		super(parent);
		padding = 0;
		verticalAlign = Middle;
		horizontalSpacing = 5;
		borderHeight = borderWidth = 1;

		var width = 13;
		var box = new h2d.Flow(this);

		var t = h2d.Tile.fromColor(0x404040, width, width);
		new h2d.Bitmap(t, box);

		var borderWidth = borderLeft + borderRight;
		var borderHeight = borderTop + borderBottom;
		var t = h2d.Tile.fromColor(0, width - borderWidth * 2, width - borderHeight * 2);
		var bg = new h2d.Bitmap(t, box);
		bg.x = borderWidth;
		bg.y = borderHeight;
		box.getProperties(bg).isAbsolute = true;

		var t = h2d.Tile.fromColor(0x404040, width - (borderWidth + 1) * 2, width - (borderHeight + 1) * 2);
		select = new h2d.Bitmap(t, box);
		select.x = borderWidth + 1;
		select.y = borderHeight + 1;
		box.getProperties(select).isAbsolute = true;

		tf = new h2d.Text(hxd.res.DefaultFont.get(), this);
		getProperties(tf).offsetY = -2;

		//
		enableInteractive = true;
		interactive.cursor = Button;
		interactive.onClick = function(e) {
{'fraction_non_alphanumeric': 0.11065989847715736, 'fraction_numerical': 0.02131979695431472, 'mean_word_length': 3.5772357723577235, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7171364', 'n_tokens_mistral': 1415, 'n_tokens_neox': 1275, 'n_words': 442}