/* Calculate new positions for all images. */ static void set_new_positions(photopile_state *ss) { ModeInfo *mi = ss->mi; int i; for (i = 0; i < MI_COUNT(mi)+1; ++i) { image *frame = ss->frames + i; GLfloat w = frame->w; GLfloat h = frame->h; GLfloat d = sqrt(w*w + h*h); GLfloat leave = frand(M_PI * 2.0); GLfloat enter = frand(M_PI * 2.0); /* start position */ frame->pos[0] = frame->pos[3]; /* end position */ frame->pos[3].x = BELLRAND(MI_WIDTH(mi)); frame->pos[3].y = BELLRAND(MI_HEIGHT(mi)); frame->pos[3].angle = (frand(2.0) - 1.0) * max_tilt; /* Try to keep the images mostly inside the screen bounds */ frame->pos[3].x = MAX(0.5*w, MIN(MI_WIDTH(mi)-0.5*w, frame->pos[3].x)); frame->pos[3].y = MAX(0.5*h, MIN(MI_HEIGHT(mi)-0.5*h, frame->pos[3].y)); /* intermediate points */ frame->pos[1] = offset_pos(frame->pos[0], leave, d * (0.5 + frand(1.0))); frame->pos[2] = offset_pos(frame->pos[3], enter, d * (0.5 + frand(1.0))); } }
void wxRibbonGallery::OnPaint(wxPaintEvent& WXUNUSED(evt)) { wxAutoBufferedPaintDC dc(this); if(m_art == NULL) return; m_art->DrawGalleryBackground(dc, this, GetSize()); int padding_top = m_art->GetMetric(wxRIBBON_ART_GALLERY_BITMAP_PADDING_TOP_SIZE); int padding_left = m_art->GetMetric(wxRIBBON_ART_GALLERY_BITMAP_PADDING_LEFT_SIZE); dc.SetClippingRegion(m_client_rect); bool offset_vertical = true; if(m_art->GetFlags() & wxRIBBON_BAR_FLOW_VERTICAL) offset_vertical = false; size_t item_count = m_items.Count(); size_t item_i; for(item_i = 0; item_i < item_count; ++item_i) { wxRibbonGalleryItem *item = m_items.Item(item_i); if(!item->IsVisible()) continue; const wxRect& pos = item->GetPosition(); wxRect offset_pos(pos); if(offset_vertical) offset_pos.SetTop(offset_pos.GetTop() - m_scroll_amount); else offset_pos.SetLeft(offset_pos.GetLeft() - m_scroll_amount); m_art->DrawGalleryItemBackground(dc, this, offset_pos, item); dc.DrawBitmap(item->GetBitmap(), offset_pos.GetLeft() + padding_left, offset_pos.GetTop() + padding_top); } }