コード例 #1
0
ファイル: elfio_segment.hpp プロジェクト: serge1/ELFIO
//------------------------------------------------------------------------------
    Elf_Half
    add_section_index( Elf_Half sec_index, Elf_Xword addr_align )
    {
        sections.push_back( sec_index );
        if ( addr_align > get_align() ) {
            set_align( addr_align );
        }

        return (Elf_Half)sections.size();
    }
コード例 #2
0
ファイル: button_array.cpp プロジェクト: jay3d/godot
bool ButtonArray::_set(const StringName& p_name, const Variant& p_value) {

    String n=String(p_name);
    if (n.begins_with("button/")) {

        String what = n.get_slicec('/',1);
        if (what=="count") {
            int new_size=p_value;
            if (new_size>0 && buttons.size()==0) {
                selected=0;
            }

            if (new_size < buttons.size()) {
                if (selected>=new_size)
                    selected=new_size-1;
            }
            buttons.resize(new_size);
            _change_notify();
            minimum_size_changed();
        } else if (what=="align") {
            set_align(Align(p_value.operator int()));
        } else if (what=="selected") {
            set_selected(p_value);
        } else if (what == "min_button_size") {
            min_button_size = p_value;
        } else {
            int idx=what.to_int();
            ERR_FAIL_INDEX_V(idx,buttons.size(),false);
            String f = n.get_slicec('/',2);
            if (f=="text")
                buttons[idx].text=p_value;
            else if (f=="tooltip")
                buttons[idx].tooltip=p_value;
            else if (f=="icon")
                buttons[idx].icon=p_value;
            else
                return false;

        }

        update();
        return true;
    }

    return false;

}
コード例 #3
0
ファイル: grid_widget.cpp プロジェクト: KitoHo/anura
grid::grid(const variant& v, game_logic::formula_callable* e)
	: scrollable_widget(v, e), row_height_(v["row_height"].as_int(0)), selected_row_(-1), 
	allow_selection_(false), must_select_(false),
    swallow_clicks_(false), hpad_(0), show_background_(false),
	max_height_(-1), allow_highlight_(true), set_h_(0), set_w_(0),
	default_selection_(v["default_select"].as_int(-1)), 
	draw_selection_highlight_(v["draw_selection_highlighted"].as_bool(false))
{
	ASSERT_LOG(get_environment() != 0, "You must specify a callable environment");
	if(v.has_key("on_select")) {
		const variant on_select_value = v["on_select"];
		if(on_select_value.is_function()) {
			ASSERT_LOG(on_select_value.min_function_arguments() <= 1 && on_select_value.max_function_arguments() >= 1, "on_select grid function should take 1 argument: " << v.debug_location());
			static const variant fml("fn(selection)");
			ffl_on_select_.reset(new game_logic::formula(fml));

			game_logic::map_formula_callable* callable = new game_logic::map_formula_callable;
			callable->add("fn", on_select_value);

			select_arg_.reset(callable);
		} else {
			ffl_on_select_ = get_environment()->create_formula(on_select_value);
		}
		on_select_ = boost::bind(&grid::select_delegate, this, _1);
	}
	if(v.has_key("on_mouseover")) {
		allow_selection_ = true;
		on_mouseover_ = boost::bind(&grid::mouseover_delegate, this, _1);
		const variant on_mouseover_value = v["on_mouseover"];
		if(on_mouseover_value.is_function()) {
			ASSERT_LOG(on_mouseover_value.min_function_arguments() <= 1 && on_mouseover_value.max_function_arguments() >= 1, "on_mouseover grid function should take 1 argument: " << v.debug_location());
			static const variant fml("fn(selection)");
			ffl_on_mouseover_.reset(new game_logic::formula(fml));

			game_logic::map_formula_callable* callable = new game_logic::map_formula_callable;
			callable->add("fn", on_mouseover_value);

			mouseover_arg_.reset(callable);
		} else {
			ffl_on_mouseover_ = get_environment()->create_formula(v["on_mouseover"]);
		}
	}

	ncols_ = v["columns"].as_int(1);
	if(v.has_key("column_widths")) {
		if(v["column_widths"].is_list()) {
			ASSERT_LOG(v["column_widths"].num_elements() == ncols_, "List of column widths must have " << ncols_ << " elements");
			std::vector<int> li = v["column_widths"].as_list_int();
			col_widths_.assign(li.begin(), li.end());
		} else if(v["column_widths"].is_int()) {
			col_widths_.assign(ncols_, v["column_widths"].as_int());
		} else {
			ASSERT_LOG(false, "grid: column_widths must be an int or list of ints");
		}
	} else {
		col_widths_.assign(ncols_, 0);
	}
	col_aligns_.resize(ncols_);
	if(v.has_key("column_alignments")) {
		if(v["column_alignments"].is_list()) {
			// XXX this could be a list of strings as well.
			int col = 0;
			foreach(const variant& c, v["column_alignments"].as_list()) {
				if(c.is_int()) {
					set_align(col, static_cast<COLUMN_ALIGN>(c.as_int()));
				} else if(c.is_string()) {
					const std::string& s = c.as_string();
					if(s == "center" || s == "centre") {
						set_align(col, ALIGN_CENTER);
					} else if(s == "right") {
						set_align(col, ALIGN_RIGHT);
					} else if(s == "left") {
						set_align(col, ALIGN_LEFT);
					} else {
						ASSERT_LOG(false, "grid: column_alignments must be \"left\", \"right\" or \"center\"");
					}
				} else {
					ASSERT_LOG(false, "grid: column alignment members must be an integer or a string.");
				}
				col++;
			}
		} else if(v["column_alignments"].is_int()) {