-
Автор темы
- #1
Код:
i saw so many guys that dont know how do equalize the spacing between each tab
Код:
sdk::c_function c_object_form::init_dep_tabs( ) {
auto form_id{ 0 };
float tab_specific_size{};
int tab_spacing = 10; /* set the spacing between tabs*/
/* calculate the total width of all tabs */
int total_tabs_width = 0;
for ( auto& form_tabs : tabs ) {
auto tab_size = sdk::drawing::get_text_size( form_tabs.title.c_str( ), sdk::drawing::c_fonts::verdana );
/* tab specific size */
if ( form_tabs.title == "rage" ) {
tab_specific_size = sdk::drawing::get_text_size( "rage", sdk::drawing::c_fonts::verdana ).x;
} else if ( form_tabs.title == "visuals" ) {
tab_specific_size = sdk::drawing::get_text_size( "visuals", sdk::drawing::c_fonts::verdana ).x;
} else if ( form_tabs.title == "misc" ) {
tab_specific_size = sdk::drawing::get_text_size( "misc", sdk::drawing::c_fonts::verdana ).x;
} else if ( form_tabs.title == "skins" ) {
tab_specific_size = sdk::drawing::get_text_size( "skins", sdk::drawing::c_fonts::verdana ).x;
} else if ( form_tabs.title == "profile" ) {
tab_specific_size = sdk::drawing::get_text_size( "profile", sdk::drawing::c_fonts::verdana ).x;
}
total_tabs_width += tab_size.x;
}
/* calculate the total width of all spaces between tabs */
int total_spacing_width = ( tabs.size( ) - 1 ) * tab_spacing;
/* calculate the initial starting position for the tabs */
int start_x = this->pos.x + ( this->size.x - total_tabs_width + total_spacing_width ) - total_spacing_width - 50;
for ( auto& form_tabs : tabs ) {
auto tab_size = sdk::drawing::get_text_size( form_tabs.title.c_str( ), sdk::drawing::c_fonts::verdana );
sdk::color::col_t col = this->selected_tab == form_id ? this->dependency( ).panel_colors[ color_palete::accent ].modify_alpha( 225 * open_menu_a ) : this->dependency( ).panel_colors[ color_palete::text ].modify_alpha( 150 * open_menu_a );
sdk::drawing::text(
start_x, this->pos.y + 4,
col, sdk::drawing::c_fonts::verdana, form_tabs.title.c_str( ), true
);
if ( sdk::c_input->is_in_box( { ( float )start_x, this->pos.y + 4 }, { tab_specific_size, ( float )15 } ) && sdk::c_input->was_key_pressed( 0x01 ) )
this->selected_tab = form_id;
/* increase the startX for the next tab */
start_x += tab_size.x + tab_spacing;
/* increase the form_id */
form_id++;
}
}