<commit_before>
#include "builder.h"
#include "window.h"
#include "application.h"
#include "style.h"
#include <view/cocoa/button.h>
#include <react/button.h>

namespace gui
{

////////////////////////////////////////

builder::builder( const std::shared_ptr<window> &w )
	: _container( w->get_container() )
{
	auto sty = application::current()->get_style();
	auto bg = sty->bg_frame( _container->area() );
	_container->add_view( bg );
}

////////////////////////////////////////

builder::~builder( void )
{
}

////////////////////////////////////////

void builder::make_label( const std::shared_ptr<draw::area> &a, const std::string &txt )
{
	auto sty = application::current()->get_style();
	auto text = sty->label_text( a, txt );
	_container->add_view( text );
}

////////////////////////////////////////

void builder::make_button( const std::shared_ptr<draw::area> &a, const std::string &txt )
{
	auto sty = application::current()->get_style();

	auto frame = sty->button_frame( a );
	_container->add_view( frame );

	auto text = sty->button_text( a, txt );
	_container->add_view( text );

	auto react = std::make_shared<react::button>( a );
	_container->add_reactor( react );

	auto cbutton = std::dynamic_pointer_cast<cocoa::button>( frame );
	if ( !cbutton )
		throw std::runtime_error( "not a cocoa button" );

	react->when_pressed( [=]( bool p ) { cbutton->set_pressed( p ); } );
}

////////////////////////////////////////

}
<commit_msg>Switch builder to use action.<commit_after>
#include "builder.h"
#include "window.h"
#include "application.h"
#include "style.h"
#include <view/cocoa/button.h>
#include <react/button.h>

namespace gui
{

////////////////////////////////////////

builder::builder( const std::shared_ptr<window> &w )
	: _container( w->get_container() )
{
	auto sty = application::current()->get_style();
	auto bg = sty->bg_frame( _container->area() );
	_container->add_view( bg );
}

////////////////////////////////////////

builder::~builder( void )
{
}

////////////////////////////////////////

void builder::make_label( const std::shared_ptr<draw::area> &a, const std::string &txt )
{
	auto sty = application::current()->get_style();
	auto text = sty->label_text( a, txt );
	_container->add_view( text );
}

////////////////////////////////////////

void builder::make_button( const std::shared_ptr<draw::area> &a, const std::string &txt )
{
	auto react = std::make_shared<react::button>( a );
	_container->add_reactor( react );

	auto sty = application::current()->get_style();

	auto frame = sty->button_frame( a );
	_container->add_view( frame );

	auto text = sty->button_text( a, txt );
	_container->add_view( text );

	auto cbutton = std::dynamic_pointer_cast<cocoa::button>( frame );
	if ( !cbutton )
		throw std::runtime_error( "not a cocoa button" );

	react->pressed.callback( [=]( bool p ) { cbutton->set_pressed( p ); } );
}

////////////////////////////////////////

}

{'fraction_non_alphanumeric': 0.2906100068540096, 'fraction_numerical': 0.0, 'mean_word_length': 2.5554202192448234, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 49, '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': '2044685', 'n_tokens_mistral': 919, 'n_tokens_neox': 900, 'n_words': 198}