/** * \brief Align the other item of the collision on the right of \a this. * \param info Some informations about the collision. * \param pos The bottom left position to put the other item at. * \param policy The description of how to align the items. */ bool bear::universe::physical_item::collision_align_right ( const collision_info& info, const position_type& pos, const collision_align_policy& policy ) { bool result(false); if ( collision_align_at(info.other_item(), pos) ) { result = true; physical_item& that = info.other_item(); switch ( policy.get_contact_mode() ) { case contact_mode::full_contact: that.set_left_contact(); set_right_contact(); break; case contact_mode::range_contact: that.set_left_contact( get_bottom(), get_top() ); set_right_contact( that.get_bottom(), that.get_top() ); break; case contact_mode::no_contact: // nothing to do break; } info.get_collision_repair().set_contact_normal (info.other_item(), vector_type(1, 0)); } return result; } // physical_item::collision_align_right()
TITANIUM_PROPERTY_GETTER(Animation, bottom) { auto bottom = get_bottom(); if (bottom) { return get_context().CreateNumber(*bottom); } return get_context().CreateUndefined(); }
int Rectangle::hit_test (float x, float y) { if ((x > left) && (x<get_right())) { if ((y > get_bottom()) && (y<get_top())) return 1; } return 0; }
bool contains(const Rectf& other) const { // FIXME: This is overlaps(), not contains()! if (m_p1.x >= other.get_right() || other.get_left() >= get_right()) return false; if (m_p1.y >= other.get_bottom() || other.get_top() >= get_bottom()) return false; return true; }
void cspec_list_add(cspec_list_t * list, void * data){ cspec_list_item_t * item = cspec_list_item_initialize(); item->data = data; if(list->head == NULL){ list->head = item; }else{ cspec_list_item_t * bottom = get_bottom(list->head); bottom->next = item; } }
/** * \brief Create all splinter items. */ void bear::explosion_effect_item::create_splinter_items( ) { unsigned int splinter_index(0); for ( unsigned int i = 0; i != m_splinter_count; i++) { bear::universe::position_type pos; pos.x = get_left() + (get_width() * rand() / RAND_MAX); pos.y = get_bottom() + (get_height() * rand() / RAND_MAX); create_splinter_item(splinter_index, pos); splinter_index = (splinter_index + 1) % m_splinter_animations.size(); } } // explosion_effect_item::create_splinter_items()
/** * \brief Align the other item of the collision on the bottom of \a this. * \param info Some informations about the collision. * \param policy The description of how to align the items. */ bool bear::universe::physical_item::collision_align_bottom ( const collision_info& info, const collision_align_policy& policy ) { position_type pos; if ( info.get_collision_side() == zone::bottom_zone ) pos = info.get_bottom_left_on_contact(); else pos.set( info.other_item().get_left(), get_bottom() - info.other_item().get_height() ); pos.y -= get_align_epsilon(); return collision_align_bottom( info, pos, policy ); } // physical_item::collision_align_bottom()
void WndForm::ReinitialiseLayout() { if (main_window.get_width() < get_width() || main_window.get_height() < get_height()) { // close dialog, it's creator may want to create a new layout mModalResult = mrChangeLayout; } else { // reposition dialog to fit into TopWindow int left = get_left(); int top = get_top(); if (get_right() > (int) main_window.get_width()) left = main_window.get_width() - get_width(); if (get_bottom() > (int) main_window.get_height()) top = main_window.get_height() - get_height(); if (left != get_left() || top != get_top()) move(left, top); } }
static void stacking_do_weave(WStacking **stacking, WStacking **np, bool below, Window fb_win) { WStacking *st, *ab; uint lvl; Window other; int mode; if(*np==NULL) return; /* Should do nothing.. */ enforce_level_sanity(np); ab=*stacking; while(*np!=NULL){ lvl=(*np)->level; while(ab!=NULL){ if(ab->level>lvl || (below && ab->level==lvl)) break; ab=ab->next; } get_bottom(ab, fb_win, &other, &mode); st=*np; UNLINK_ITEM(*np, st, next, prev); region_restack(st->reg, other, mode); if(ab!=NULL){ LINK_ITEM_BEFORE(*stacking, ab, st, next, prev); }else{ LINK_ITEM_LAST(*stacking, st, next, prev); } } }
bool contains(const Vector& v) const { return v.x >= m_p1.x && v.y >= m_p1.y && v.x < get_right() && v.y < get_bottom(); }
int get_vmiddle() const { return (get_top() + get_bottom()) / 2; }
int sum_neighbors(int x, int y) { //std::cout << "sn " << get_top(x, y) << " " << get_right(x,y) << " " << get_left(x,y) << " " << get_bottom(x,y) << std::endl; return get_top(x, y) + get_right(x, y) + get_left(x, y) + get_bottom(x, y); }
void Rectangle::set_size ( float width, float height) { coords[TOP] = get_bottom() + height; coords[RIGHT] = get_left() + width; }
//--------------------------------------------------------------------------------------- void GmoBox::draw_border(Drawer* pDrawer, RenderOptions& opt) { ImoStyle* pStyle = get_style(); if (pStyle && (pStyle->border_width_top() > 0.0f || pStyle->border_width_bottom() > 0.0f || pStyle->border_width_left() > 0.0f || pStyle->border_width_right() > 0.0f) ) { double xLeft = double(m_origin.x + pStyle->margin_left()); double yTop = double(m_origin.y + pStyle->margin_top()); double xRight = double(get_right() - pStyle->margin_right()); double yBottom = double(get_bottom() - pStyle->margin_bottom()); pDrawer->begin_path(); pDrawer->fill( pStyle->background_color() ); pDrawer->stroke( Color(0,0,0) ); //TODO: border color pDrawer->move_to(xLeft, yTop); //top border if (pStyle->border_width_top() > 0.0f) { pDrawer->stroke_width( pStyle->border_width_top() ); pDrawer->hline_to(xRight); } else pDrawer->move_to(xRight, yTop); //right border if (pStyle->border_width_right() > 0.0f) { pDrawer->stroke_width( pStyle->border_width_right() ); pDrawer->vline_to(yBottom); } else pDrawer->move_to(xRight, yBottom); //bottom border if (pStyle->border_width_bottom() > 0.0f) { pDrawer->stroke_width( pStyle->border_width_bottom() ); pDrawer->hline_to(xLeft); } else pDrawer->move_to(xLeft, yBottom); //left border if (pStyle->border_width_left() > 0.0f) { pDrawer->stroke_width( pStyle->border_width_left() ); pDrawer->vline_to(yTop); } pDrawer->end_path(); } if (this->is_item_main_box() && opt.draw_focus_lines_on_boxes_flag == true) { double xorg = m_origin.x; double yorg = m_origin.y; Color color = opt.unfocussed_box_color; draw_box_bounds(pDrawer, xorg, yorg, color); } else if (must_draw_bounds(opt)) { double xorg = m_origin.x; double yorg = m_origin.y; Color color = get_box_color(); draw_box_bounds(pDrawer, xorg, yorg, color); } }
Rectf grown(float border) const { return Rectf(m_p1.x - border, m_p1.y - border, get_right() + border, get_bottom() + border); }
void Rectangle::print_positions() { printf("left=%6.1f; bottom=%6.1f; width=%6.1f; height=%6.1f", get_left(), get_bottom(), get_width(), get_height() ); }
void set_bottom(float v) { m_size.height += v - get_bottom(); }
bool any_neighbor(int x, int y) { return get_top(x, y) > 0 || get_right(x, y) > 0 || get_left(x, y) > 0 || get_bottom(x, y) > 0; }