restored menu trailing space for text (cell_padding_)
This commit is contained in:
parent
f19b907852
commit
9d8e4bcea5
3 changed files with 12 additions and 8 deletions
|
@ -786,15 +786,22 @@ void menu::column_widths_item(const std::vector<std::string>& row, std::vector<i
|
|||
{
|
||||
for(size_t col = 0; col != row.size(); ++col) {
|
||||
const SDL_Rect res = style_->item_size(row[col]);
|
||||
size_t text_trailing_space = (item_ends_with_image(row[col])) ? 0 : style_->get_cell_padding();
|
||||
|
||||
if(col == widths.size()) {
|
||||
widths.push_back(res.w + style_->get_cell_padding());
|
||||
} else if(res.w > widths[col] - style_->get_cell_padding()) {
|
||||
widths[col] = res.w + style_->get_cell_padding();
|
||||
widths.push_back(res.w + text_trailing_space);
|
||||
} else if(res.w > widths[col] - text_trailing_space) {
|
||||
widths[col] = res.w + text_trailing_space;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool menu::item_ends_with_image(const std::string& item) const
|
||||
{
|
||||
std::string::size_type pos = item.find_last_of(IMG_TEXT_SEPARATOR);
|
||||
return(item.at((pos == std::string::npos) ? 0 : pos+1) == IMAGE_PREFIX);
|
||||
}
|
||||
|
||||
const std::vector<int>& menu::column_widths() const
|
||||
{
|
||||
if(column_widths_.empty()) {
|
||||
|
|
|
@ -173,6 +173,7 @@ public:
|
|||
void sort_by(int column);
|
||||
|
||||
protected:
|
||||
bool item_ends_with_image(const std::string& item) const;
|
||||
void handle_event(const SDL_Event& event);
|
||||
void set_inner_location(const SDL_Rect& rect);
|
||||
|
||||
|
|
|
@ -49,10 +49,7 @@ menu::style::~style()
|
|||
{}
|
||||
menu::imgsel_style::imgsel_style(const std::string &img_base) : img_base_(img_base),
|
||||
initialized_(false), load_failed_(false)
|
||||
{
|
||||
cell_padding_ = 0; //FIXME: why was it needed in the parent class?
|
||||
}
|
||||
|
||||
{}
|
||||
menu::imgsel_style::~imgsel_style()
|
||||
{}
|
||||
|
||||
|
@ -86,7 +83,6 @@ bool menu::imgsel_style::load_images()
|
|||
thickness_ = minimum(
|
||||
img_map_["border-top"]->h,
|
||||
img_map_["border-left"]->w);
|
||||
//cell_padding_ = maximum(cell_padding_, thickness_);
|
||||
|
||||
selected_rgb_ = 0x000000;
|
||||
selected_alpha_ = 0.9;
|
||||
|
|
Loading…
Add table
Reference in a new issue