void tlistbox::resize_content( const int width_modification , const int height_modification) { DBG_GUI_L << LOG_HEADER << " current size " << content_grid()->get_size() << " width_modification " << width_modification << " height_modification " << height_modification << ".\n"; if(content_resize_request(width_modification, height_modification)) { // Calculate new size. tpoint size = content_grid()->get_size(); size.x += width_modification; size.y += height_modification; // Set new size. content_grid()->set_size(size); // Set status. need_layout_ = true; // If the content grows assume it "overwrites" the old content. if(width_modification < 0 || height_modification < 0) { set_dirty(); } DBG_GUI_L << LOG_HEADER << " succeeded.\n"; } else { DBG_GUI_L << LOG_HEADER << " failed.\n"; } }
void listbox::layout_children(const bool force) { assert(content_grid()); if(need_layout_ || force) { const int selected_item = generator_->get_selected_item(); content_grid()->place(content_grid()->get_origin(), content_grid()->get_size()); const SDL_Rect& visible = content_visible_area_; content_grid()->set_visible_rectangle(visible); if(selected_item != -1) { SDL_Rect rect = generator_->item(selected_item).get_rectangle(); rect.x = visible.x; rect.w = visible.w; show_content_rect(rect); } need_layout_ = false; set_is_dirty(true); } }
void tlistbox::finalize(tbuilder_grid_const_ptr header, tbuilder_grid_const_ptr footer, const std::vector<string_map>& list_data) { // "Inherited." tscrollbar_container::finalize_setup(); assert(generator_); if(header) { swap_grid(&grid(), content_grid(), header->build(), "_header_grid"); } tgrid& p = find_widget<tgrid>(this, "_header_grid", false); for(unsigned i = 0, max = std::max(p.get_cols(), p.get_rows()); i < max; ++i) { if(tselectable_* selectable = find_widget<tselectable_>(&p, "sort_" + std::to_string(i), false, false)) { selectable->set_callback_state_change(std::bind(&tlistbox::order_by_column, this, i, _1)); if(orders_.size() < max ) { orders_.resize(max); } orders_[i].first = selectable; } } if(footer) { swap_grid(&grid(), content_grid(), footer->build(), "_footer_grid"); } generator_->create_items( -1, list_builder_, list_data, callback_list_item_clicked); swap_grid(nullptr, content_grid(), generator_, "_list_grid"); }
label* scroll_label::get_internal_label() { if(content_grid()) { return dynamic_cast<label*>(content_grid()->find("_label", false)); } return nullptr; }
void tscroll_label::finalize_subclass() { assert(content_grid()); tlabel* lbl = dynamic_cast<tlabel*>(content_grid()->find("_label", false)); assert(lbl); lbl->set_label(label()); lbl->set_can_wrap(wrap_on); }
void tscroll_label::set_can_wrap(bool can_wrap) { assert(content_grid()); tlabel* lbl = dynamic_cast<tlabel*>(content_grid()->find("_label", false)); assert(lbl); wrap_on = can_wrap; lbl->set_can_wrap(wrap_on); }
void tlistbox::set_content_size(const tpoint& origin, const tpoint& size) { /** @todo This function needs more testing. */ assert(content_grid()); const int best_height = content_grid()->get_best_size().y; const tpoint s(size.x, size.y < best_height ? size.y : best_height); content_grid()->place(origin, s); }
void tscroll_label::set_use_markup(bool use_markup) { // Inherit. tcontrol::set_use_markup(use_markup); if(content_grid()) { tlabel* widget = find_widget<tlabel>(content_grid(), "_label", false, true); widget->set_use_markup(use_markup); } }
void ttree_view::layout_children(const bool force) { assert(root_node_ && content_grid()); if(need_layout_ || force) { root_node_->place(indention_step_size_ , get_origin() , content_grid()->get_size().x); root_node_->set_visible_area(content_visible_area_); need_layout_ = false; } }
void tscroll_label::set_label(const t_string& label) { // Inherit. tcontrol::set_label(label); if(content_grid()) { tlabel* widget = find_widget<tlabel>(content_grid(), "_label", false, true); widget->set_label(label); content_resize_request(); } }
void ttree_view::finalize_setup() { // Inherited. tscrollbar_container::finalize_setup(); assert(content_grid()); content_grid()->set_rows_cols(1, 1); content_grid()->set_child(root_node_, 0, 0, tgrid::VERTICAL_GROW_SEND_TO_CLIENT | tgrid::HORIZONTAL_GROW_SEND_TO_CLIENT, 0); }
void tlistbox::layout_children(const bool force) { assert(content_grid()); if(need_layout_ || force) { content_grid()->place(content_grid()->get_origin(), content_grid()->get_size()); content_grid()->set_visible_rectangle(content_visible_area_); need_layout_ = false; set_is_dirty(true); } }
void tscroll_label::finalize_subclass() { assert(content_grid()); tlabel* lbl = dynamic_cast<tlabel*>( content_grid()->find("_label", false)); assert(lbl); lbl->set_label(label()); /** * @todo wrapping should be a label setting. * This setting shoul be mutual exclusive with the horizontal scrollbar. * Also the scroll_grid needs to set the status for the scrollbars. */ lbl->set_can_wrap(true); }
void tscroll_label::set_label(const t_string& label) { // Inherit. tcontrol::set_label(label); if(content_grid()) { tlabel* widget = find_widget<tlabel>(content_grid(), "_label", false, true); widget->set_label(label); // We want the width to stay cosistent widget->request_reduce_width(widget->get_size().x); content_resize_request(); } }
void tlistbox::resize_content(const twidget& row) { if(row.get_visible() == tvisible::invisible) { return; } DBG_GUI_L << LOG_HEADER << " current size " << content_grid()->get_size() << " row size " << row.get_best_size() << ".\n"; const tpoint content = content_grid()->get_size(); tpoint size = row.get_best_size(); if(size.x < content.x) { size.x = 0; } else { size.x -= content.x; } resize_content(size.x, size.y); }
void listbox::finalize(builder_grid_const_ptr header, builder_grid_const_ptr footer, const std::vector<std::map<std::string, string_map>>& list_data) { // "Inherited." scrollbar_container::finalize_setup(); assert(generator_); if(header) { swap_grid(&get_grid(), content_grid(), header->build(), "_header_grid"); } grid& p = find_widget<grid>(this, "_header_grid", false); for(unsigned i = 0, max = std::max(p.get_cols(), p.get_rows()); i < max; ++i) { // // TODO: I had to change this to case to a toggle_button in order to use a signal handler. // Should probably look into a way to make it more general like it was before (used to be // cast to selectable_item). // // - vultraz, 2017-08-23 // if(toggle_button* selectable = find_widget<toggle_button>(&p, "sort_" + std::to_string(i), false, false)) { // Register callback to sort the list. connect_signal_notify_modified(*selectable, std::bind(&listbox::order_by_column, this, i, _1)); if(orders_.size() < max) { orders_.resize(max); } orders_[i].first = selectable; } } if(footer) { swap_grid(&get_grid(), content_grid(), footer->build(), "_footer_grid"); } generator_->create_items(-1, list_builder_, list_data, std::bind(&listbox::list_item_clicked, this, _1)); swap_grid(nullptr, content_grid(), generator_, "_list_grid"); }
void tlistbox::finalize(tbuilder_grid_const_ptr header, tbuilder_grid_const_ptr footer, const std::vector<string_map>& list_data) { // "Inherited." tscrollbar_container::finalize_setup(); assert(generator_); if(header) { swap_grid(&grid(), content_grid(), header->build(), "_header_grid"); } if(footer) { swap_grid(&grid(), content_grid(), footer->build(), "_footer_grid"); } generator_->create_items( -1, list_builder_, list_data, callback_list_item_clicked); swap_grid(NULL, content_grid(), generator_, "_list_grid"); }
void ttree_view::clear() { get_root_node().clear(); resize_content(0, -content_grid()->get_size().y); }