Esempio n. 1
0
static int
child_pos(struct sprite *s, struct srt *srt, struct sprite_trans *ts, struct sprite *t, int pos[2]) {
	struct sprite_trans temp;
	struct matrix temp_matrix;
	struct sprite_trans *st = trans_mul(&s->t, ts, &temp, &temp_matrix);
	if (s == t) {
		struct matrix tmp;
		if (st->mat == NULL) {
			matrix_identity(&tmp);
		} else {
			tmp = *st->mat;
		}
		matrix_srt(&tmp, srt);
		switch (s->type) {
		case TYPE_PICTURE:
			picture_pos(tmp.m, s->s.pic, srt, st, pos);
			return 0;
		case TYPE_LABEL:
			label_pos(tmp.m, s->s.label, srt, st, pos);
			return 0;
		case TYPE_ANIMATION:
		case TYPE_PANNEL:
			pos[0] = tmp.m[4] / SCREEN_SCALE;
			pos[1] = tmp.m[5] / SCREEN_SCALE;
			return 0;
		default:
			return 1;
		}
	} 
	
	if (s->type != TYPE_ANIMATION){
		return 1;
	}

	struct pack_animation *ani = s->s.ani;
	int frame = real_frame(s) + s->start_frame;
	struct pack_frame * pf = &ani->frame[frame];
	int i;
	for (i=0;i<pf->n;i++) {
		struct pack_part *pp = &pf->part[i];
		int index = pp->component_id;
		struct sprite * child = s->data.children[index];
		if (child == NULL) {
			continue;
		}
		struct sprite_trans temp2;
		struct matrix temp_matrix2;
		struct sprite_trans *ct = trans_mul(&pp->t, st, &temp2, &temp_matrix2);
		if (child_pos(child, srt, ct, t, pos) == 0) {
			return 0;
		}
	}
	return 1;
}
Esempio n. 2
0
void AudioDisplay::PaintTrackCursor(wxDC &dc) {
	wxDCPenChanger penchanger(dc, wxPen(*wxWHITE));
	dc.DrawLine(track_cursor_pos-scroll_left, audio_top, track_cursor_pos-scroll_left, audio_top+audio_height);

	if (track_cursor_label.empty()) return;

	wxDCFontChanger fc(dc);
	wxFont font = dc.GetFont();
	font.SetWeight(wxFONTWEIGHT_BOLD);
	dc.SetFont(font);

	wxSize label_size(dc.GetTextExtent(track_cursor_label));
	wxPoint label_pos(track_cursor_pos - scroll_left - label_size.x/2, audio_top + 2);
	label_pos.x = mid(2, label_pos.x, GetClientSize().GetWidth() - label_size.x - 2);

	int old_bg_mode = dc.GetBackgroundMode();
	dc.SetBackgroundMode(wxTRANSPARENT);

	// Draw border
	dc.SetTextForeground(wxColour(64, 64, 64));
	dc.DrawText(track_cursor_label, label_pos.x+1, label_pos.y+1);
	dc.DrawText(track_cursor_label, label_pos.x+1, label_pos.y-1);
	dc.DrawText(track_cursor_label, label_pos.x-1, label_pos.y+1);
	dc.DrawText(track_cursor_label, label_pos.x-1, label_pos.y-1);

	// Draw fill
	dc.SetTextForeground(*wxWHITE);
	dc.DrawText(track_cursor_label, label_pos.x, label_pos.y);
	dc.SetBackgroundMode(old_bg_mode);

	label_pos.x -= 2;
	label_pos.y -= 2;
	label_size.IncBy(4, 4);
	// If the rendered text changes size we have to draw it an extra time to make sure the entire thing was drawn
	bool need_extra_redraw = track_cursor_label_rect.GetSize() != label_size;
	track_cursor_label_rect.SetPosition(label_pos);
	track_cursor_label_rect.SetSize(label_size);
	if (need_extra_redraw)
		RefreshRect(track_cursor_label_rect, false);
}
Esempio n. 3
0
int
sprite_pos(struct sprite *s, struct srt *srt, struct matrix *m, int pos[2]) {
	struct matrix temp;
	struct matrix *t = mat_mul(s->t.mat, m, &temp);
	matrix_srt(t, srt);
	switch (s->type) {
	case TYPE_PICTURE:
		picture_pos(t->m, s->s.pic, pos);
		return 0;
	case TYPE_LABEL:
		label_pos(t->m, s->s.label, pos);
		return 0;
	case TYPE_ANIMATION:
	case TYPE_PANNEL:
		pos[0] = t->m[4] / SCREEN_SCALE;
		pos[1] = t->m[5] / SCREEN_SCALE;
		return 0;
	default:
		return 1;
	}

}