0
我想在gtk容器中添加紋理作爲背景,有可能嗎?如何在gtk中繪製紋理作爲背景?
我想要的與CSS中的repeat-x repeat-y屬性類似,但它在gtk中不受支持,那麼,如何在沒有任何醜陋的黑客的情況下執行此操作?另一個例子是鸚鵡螺有什麼,你可以在那裏改變背景。
謝謝:)
PD:對不起4毫安英語
我想在gtk容器中添加紋理作爲背景,有可能嗎?如何在gtk中繪製紋理作爲背景?
我想要的與CSS中的repeat-x repeat-y屬性類似,但它在gtk中不受支持,那麼,如何在沒有任何醜陋的黑客的情況下執行此操作?另一個例子是鸚鵡螺有什麼,你可以在那裏改變背景。
謝謝:)
PD:對不起4毫安英語
我就是這麼做的:
private bool draw_background (Cairo.Context cr) {
int width = this.get_allocated_width();
int height = this.get_allocated_height();
cr.set_operator (Cairo.Operator.CLEAR);
cr.paint();
cr.set_operator (Cairo.Operator.OVER);
var background_style = this.get_style_context();
background_style.render_background (cr, 0, 0, width, height);
background_style.render_frame (cr, 0, 0, width, height);
var pat = new Cairo.Pattern.for_surface (new Cairo.ImageSurface.from_png (Build.PKGDATADIR + "/files/texture.png"));
pat.set_extend (Cairo.Extend.REPEAT);
cr.set_source (pat);
cr.paint_with_alpha (0.6);
return false;
}