Fix Gradient, Color Picker BG, Fix CanvasItem::draw_texture_rect p_tile
This commit is contained in:
parent
f860ee3091
commit
051234e84e
6 changed files with 10 additions and 33 deletions
|
|
@ -49,9 +49,6 @@ GradientEdit::GradientEdit() {
|
|||
popup->add_child(picker);
|
||||
|
||||
add_child(popup);
|
||||
|
||||
checker = Ref<ImageTexture>(memnew(ImageTexture));
|
||||
Ref<Image> img = memnew(Image(checker_bg_png));
|
||||
}
|
||||
|
||||
int GradientEdit::_get_point_from_pos(int x) {
|
||||
|
|
@ -311,7 +308,7 @@ void GradientEdit::_notification(int p_what) {
|
|||
int total_w = get_size().width - get_size().height - SPACING;
|
||||
|
||||
//Draw checker pattern for ramp
|
||||
_draw_checker(0, 0, total_w, h);
|
||||
draw_texture_rect(get_theme_icon("GuiMiniCheckerboard", "EditorIcons"), Rect2(0, 0, total_w, h), true);
|
||||
|
||||
//Draw color ramp
|
||||
Gradient::Point prev;
|
||||
|
|
@ -378,7 +375,7 @@ void GradientEdit::_notification(int p_what) {
|
|||
}
|
||||
|
||||
//Draw "button" for color selector
|
||||
_draw_checker(total_w + SPACING, 0, h, h);
|
||||
draw_texture_rect(get_theme_icon("GuiMiniCheckerboard", "EditorIcons"), Rect2(total_w + SPACING, 0, h, h), true);
|
||||
if (grabbed != -1) {
|
||||
//Draw with selection color
|
||||
draw_rect(Rect2(total_w + SPACING, 0, h, h), points[grabbed].color);
|
||||
|
|
@ -405,27 +402,6 @@ void GradientEdit::_notification(int p_what) {
|
|||
}
|
||||
}
|
||||
|
||||
void GradientEdit::_draw_checker(int x, int y, int w, int h) {
|
||||
//Draw it with polygon to insert UVs for scale
|
||||
Vector<Vector2> backPoints;
|
||||
backPoints.push_back(Vector2(x, y));
|
||||
backPoints.push_back(Vector2(x, y + h));
|
||||
backPoints.push_back(Vector2(x + w, y + h));
|
||||
backPoints.push_back(Vector2(x + w, y));
|
||||
Vector<Color> colorPoints;
|
||||
colorPoints.push_back(Color(1, 1, 1, 1));
|
||||
colorPoints.push_back(Color(1, 1, 1, 1));
|
||||
colorPoints.push_back(Color(1, 1, 1, 1));
|
||||
colorPoints.push_back(Color(1, 1, 1, 1));
|
||||
Vector<Vector2> uvPoints;
|
||||
//Draw checker pattern pixel-perfect and scale it by 2.
|
||||
uvPoints.push_back(Vector2(x, y));
|
||||
uvPoints.push_back(Vector2(x, y + h * .5f / checker->get_height()));
|
||||
uvPoints.push_back(Vector2(x + w * .5f / checker->get_width(), y + h * .5f / checker->get_height()));
|
||||
uvPoints.push_back(Vector2(x + w * .5f / checker->get_width(), y));
|
||||
draw_polygon(backPoints, colorPoints, uvPoints, checker);
|
||||
}
|
||||
|
||||
Size2 GradientEdit::get_minimum_size() const {
|
||||
return Vector2(0, 16);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue