예제 #1
0
void scrollbar_widget::set_value(const std::string& key, const variant& v)
{
	if(key == "on_scroll") {
		ffl_handler_ = get_environment()->create_formula(v["on_scroll"]);
	} else if(key == "up_arrow") {
		up_arrow_ = widget_factory::create(v, get_environment());
	} else if(key == "down_arrow") {
		down_arrow_ = widget_factory::create(v, get_environment());
	} else if(key == "handle") {
		handle_ = widget_factory::create(v, get_environment());
	} else if(key == "handle_bottom") {
		handle_bot_ = widget_factory::create(v, get_environment());
	} else if(key == "handle_top") {
		handle_top_ = widget_factory::create(v, get_environment());
	} else if(key == "background") {
		background_ = widget_factory::create(v, get_environment());
	} else if(key == "range") {
		std::vector<int> range = v.as_list_int();
		ASSERT_EQ(range.size(), 2);
		set_range(range[0], range[1]);
	} else if(key == "position") {
		window_pos_ = v.as_int();
		clip_window_position();
	}
	
	widget::set_value(key, v);
}
예제 #2
0
VoxelPos read_voxel_pos(const variant& v) {
	std::vector<int> res = v.as_list_int();
	ASSERT_LOG(res.size() == 3, "Illegal voxel pos: " << v.write_json() << " " << v.debug_location());
	VoxelPos result;
	result[0] = res[0];
	result[1] = res[1];
	result[2] = res[2];
	return result;
}
예제 #3
0
void widget::set_value(const std::string& key, const variant& v)
{
	if(key == "width") {
		w_ = v.as_int();
	} else if(key == "height") {
		h_ = v.as_int();
	} else if(key == "rect" || key == "draw_area") {
		std::vector<int> r = v.as_list_int();
		ASSERT_LOG(r.size() == 4, "Four values must be supplied to the rect attribute");
		set_loc(r[0], r[1]);
		set_dim(r[2], r[3]);
	} else if(key == "xy" || key == "left_top") {
		std::vector<int> xy = v.as_list_int();
		ASSERT_LOG(xy.size() == 2, "Two values must be supplied to the X, Y attribute");
		set_loc(xy[0], xy[1]);
	} else if(key == "wh") {
		std::vector<int> wh = v.as_list_int();
		ASSERT_LOG(wh.size() == 2, "Two values must be supplied to the W, H attribute");
		set_dim(wh[0], wh[1]);
	} else if(key == "right_bottom") {
		std::vector<int> rb = v.as_list_int();
		ASSERT_LOG(rb.size() == 2, "Two values must be supplied to the R, B attribute");
		set_dim(rb[0] - x(), rb[1] - y());
	} else if(key == "left") {
		x_ = v.as_int();
	} else if(key == "top") {
		y_ = v.as_int();
	} else if(key == "right") {
		w_ = v.as_int() - x();
	} else if(key == "bottom") {
		h_ = v.as_int() - y();
	} else if(key == "visible") {
		visible_ = v.as_bool();
	} else if(key == "id") {
		id_ = v.as_string();
	} else if(key == "disable") {
		disabled_ = v.as_bool();
	} else if(key == "enable") {
		disabled_ = !v.as_bool();
	} else if(key == "disabled_opacity") {
		int opa = v.as_int();
		disabled_opacity_ = (opa > 255) ? 255 : (opa < 0) ? 0 : opa;
	}
}
예제 #4
0
point::point(const variant& v)
{
	*this = point(v.as_list_int());
}
예제 #5
0
rect::rect(const variant& value)
{
	std::vector<int> v = value.as_list_int();
	*this = rect(v);
}