Added in the icons for paint's gui.
Before Width: | Height: | Size: 45 KiB |
Before Width: | Height: | Size: 562 B After Width: | Height: | Size: 562 B |
Before Width: | Height: | Size: 565 B After Width: | Height: | Size: 565 B |
Before Width: | Height: | Size: 195 B After Width: | Height: | Size: 195 B |
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 127 B After Width: | Height: | Size: 127 B |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 128 B After Width: | Height: | Size: 128 B |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 129 B After Width: | Height: | Size: 129 B |
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 148 B After Width: | Height: | Size: 148 B |
Before Width: | Height: | Size: 251 B After Width: | Height: | Size: 251 B |
Before Width: | Height: | Size: 242 B After Width: | Height: | Size: 242 B |
43
modules/paint/icons/make_header.py
Executable file
@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import glob
|
||||
import os
|
||||
|
||||
enc = "utf-8"
|
||||
|
||||
# Change to the directory where the script is located,
|
||||
# so that the script can be run from any location
|
||||
os.chdir(os.path.dirname(os.path.realpath(__file__)))
|
||||
|
||||
# Generate include files
|
||||
|
||||
f = open("paint_icons.h", "wb")
|
||||
|
||||
f.write(b"// THIS FILE HAS BEEN AUTOGENERATED, DON'T EDIT!!\n")
|
||||
|
||||
# Generate png image block
|
||||
f.write(b"\n// png image block\n")
|
||||
|
||||
pixmaps = glob.glob("*.png")
|
||||
pixmaps.sort()
|
||||
|
||||
for x in pixmaps:
|
||||
|
||||
var_str = x[:-4] + "_png"
|
||||
|
||||
s = "\nstatic const unsigned char " + var_str + "[] = {\n\t"
|
||||
f.write(s.encode(enc))
|
||||
|
||||
pngf = open(x, "rb")
|
||||
|
||||
b = pngf.read(1)
|
||||
while len(b) == 1:
|
||||
f.write(hex(ord(b)).encode(enc))
|
||||
b = pngf.read(1)
|
||||
if len(b) == 1:
|
||||
f.write(b", ")
|
||||
|
||||
f.write(b"\n};\n")
|
||||
pngf.close()
|
||||
|
||||
f.close()
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
67
modules/paint/icons/paint_icons.h
Normal file
Before Width: | Height: | Size: 240 B After Width: | Height: | Size: 240 B |
@ -32,6 +32,32 @@ SOFTWARE.
|
||||
|
||||
#include "paint_canvas_layer.h"
|
||||
|
||||
#include "icons/paint_icons.h"
|
||||
|
||||
static float scale = 1;
|
||||
|
||||
template <class T>
|
||||
static Ref<Texture> make_icon(T p_src) {
|
||||
Ref<ImageTexture> texture(memnew(ImageTexture));
|
||||
Ref<Image> img = memnew(Image(p_src));
|
||||
if (scale > 1) {
|
||||
Size2 orig_size = Size2(img->get_width(), img->get_height());
|
||||
|
||||
img->convert(Image::FORMAT_RGBA8);
|
||||
img->expand_x2_hq2x();
|
||||
if (scale != 2.0) {
|
||||
img->resize(orig_size.x * scale, orig_size.y * scale);
|
||||
}
|
||||
} else if (scale < 1) {
|
||||
Size2 orig_size = Size2(img->get_width(), img->get_height());
|
||||
img->convert(Image::FORMAT_RGBA8);
|
||||
img->resize(orig_size.x * scale, orig_size.y * scale);
|
||||
}
|
||||
texture->create_from_image(img, ImageTexture::FLAG_FILTER);
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
void PaintCanvas::_enter_tree() {
|
||||
connect("mouse_entered", this, "_on_mouse_entered");
|
||||
connect("mouse_exited", this, "_on_mouse_exited");
|
||||
@ -574,7 +600,7 @@ PaintCanvas::PaintCanvas() {
|
||||
mouse_on_top = false;
|
||||
|
||||
canvas_background_rect = memnew(TextureRect);
|
||||
//canvas_background_rect->set_texture();//res://addons/Godoxel/assets/grid.png
|
||||
canvas_background_rect->set_texture(make_icon(grid_png));
|
||||
canvas_background_rect->set_expand(true);
|
||||
canvas_background_rect->set_stretch_mode(TextureRect::STRETCH_TILE);
|
||||
add_child(canvas_background_rect);
|
||||
|
@ -24,12 +24,41 @@ SOFTWARE.
|
||||
|
||||
#include "paint_layer_button.h"
|
||||
|
||||
#include "core/image.h"
|
||||
#include "scene/resources/texture.h"
|
||||
#include "scene/resources/style_box.h"
|
||||
|
||||
#include "scene/gui/box_container.h"
|
||||
#include "scene/gui/button.h"
|
||||
#include "scene/gui/check_button.h"
|
||||
#include "scene/gui/margin_container.h"
|
||||
#include "scene/gui/texture_button.h"
|
||||
#include "scene/resources/style_box.h"
|
||||
|
||||
#include "icons/paint_icons.h"
|
||||
|
||||
static float scale = 1;
|
||||
|
||||
template <class T>
|
||||
static Ref<Texture> make_icon(T p_src) {
|
||||
Ref<ImageTexture> texture(memnew(ImageTexture));
|
||||
Ref<Image> img = memnew(Image(p_src));
|
||||
if (scale > 1) {
|
||||
Size2 orig_size = Size2(img->get_width(), img->get_height());
|
||||
|
||||
img->convert(Image::FORMAT_RGBA8);
|
||||
img->expand_x2_hq2x();
|
||||
if (scale != 2.0) {
|
||||
img->resize(orig_size.x * scale, orig_size.y * scale);
|
||||
}
|
||||
} else if (scale < 1) {
|
||||
Size2 orig_size = Size2(img->get_width(), img->get_height());
|
||||
img->convert(Image::FORMAT_RGBA8);
|
||||
img->resize(orig_size.x * scale, orig_size.y * scale);
|
||||
}
|
||||
texture->create_from_image(img, ImageTexture::FLAG_FILTER);
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
PaintLayerButton::PaintLayerButton() {
|
||||
set_custom_minimum_size(Size2(0, 32));
|
||||
@ -82,8 +111,8 @@ PaintLayerButton::PaintLayerButton() {
|
||||
// Visible Button
|
||||
visible_button = memnew(CheckButton);
|
||||
visible_button->set_pressed(true);
|
||||
//visible_button->set("custom_icons/off", ); //res://addons/Godoxel/assets/minidotta_invis.png
|
||||
//visible_button->set("custom_icons/on", ); //res://addons/Godoxel/assets/minidotta.png
|
||||
visible_button->set("custom_icons/off", make_icon(minidotta_invis_png));
|
||||
visible_button->set("custom_icons/on", make_icon(minidotta_png));
|
||||
style_box.instance();
|
||||
style_box->set("bg_color", Color(0.6, 0.6, 0.6));
|
||||
layer_button->set("custom_styles/normal", style_box);
|
||||
@ -92,8 +121,8 @@ PaintLayerButton::PaintLayerButton() {
|
||||
// Lock Button
|
||||
lock_button = memnew(CheckButton);
|
||||
lock_button->set_pressed(false);
|
||||
//lock_button->set("custom_icons/off", ); //res://addons/Godoxel/assets/unlock_layer.png
|
||||
//lock_button->set("custom_icons/on", ); //res://addons/Godoxel/assets/lock_layer_1.png
|
||||
lock_button->set("custom_icons/off", make_icon(unlock_layer_png));
|
||||
lock_button->set("custom_icons/on", make_icon(lock_layer_1_png));
|
||||
style_box.instance();
|
||||
style_box->set("bg_color", Color(0.6, 0.6, 0.6));
|
||||
layer_button->set("custom_styles/normal", style_box);
|
||||
@ -108,8 +137,8 @@ PaintLayerButton::PaintLayerButton() {
|
||||
up_button->set_stretch_mode(TextureButton::STRETCH_KEEP_CENTERED);
|
||||
up_button->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
up_button->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||
//up_button->set_normal_texture(); //res://addons/Godoxel/assets/arrow_up.png
|
||||
//up_button->set_pressed_texture(); //res://addons/Godoxel/assets/minidotta.png
|
||||
up_button->set_normal_texture(make_icon(arrow_up_png));
|
||||
up_button->set_pressed_texture(make_icon(minidotta_png));
|
||||
right_main_container->add_child(up_button);
|
||||
|
||||
down_button = memnew(TextureButton);
|
||||
@ -117,8 +146,8 @@ PaintLayerButton::PaintLayerButton() {
|
||||
down_button->set_stretch_mode(TextureButton::STRETCH_KEEP_CENTERED);
|
||||
down_button->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
down_button->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||
//down_button->set_normal_texture(); //res://addons/Godoxel/assets/arrow_up.png
|
||||
//down_button->set_pressed_texture(); //res://addons/Godoxel/assets/minidotta.png
|
||||
down_button->set_normal_texture(make_icon(arrow_down_png));
|
||||
down_button->set_pressed_texture(make_icon(minidotta_png));
|
||||
right_main_container->add_child(down_button);
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,8 @@ SOFTWARE.
|
||||
#include "paint_window.h"
|
||||
|
||||
#include "core/os/input.h"
|
||||
#include "core/image.h"
|
||||
#include "scene/resources/texture.h"
|
||||
|
||||
#include "actions/brighten_action.h"
|
||||
#include "actions/brush_action.h"
|
||||
@ -64,6 +66,32 @@ SOFTWARE.
|
||||
#include "dialogs/paint_save_file_dialog.h"
|
||||
#include "paint_settings.h"
|
||||
|
||||
#include "icons/paint_icons.h"
|
||||
|
||||
static float scale = 1;
|
||||
|
||||
template <class T>
|
||||
static Ref<Texture> make_icon(T p_src) {
|
||||
Ref<ImageTexture> texture(memnew(ImageTexture));
|
||||
Ref<Image> img = memnew(Image(p_src));
|
||||
if (scale > 1) {
|
||||
Size2 orig_size = Size2(img->get_width(), img->get_height());
|
||||
|
||||
img->convert(Image::FORMAT_RGBA8);
|
||||
img->expand_x2_hq2x();
|
||||
if (scale != 2.0) {
|
||||
img->resize(orig_size.x * scale, orig_size.y * scale);
|
||||
}
|
||||
} else if (scale < 1) {
|
||||
Size2 orig_size = Size2(img->get_width(), img->get_height());
|
||||
img->convert(Image::FORMAT_RGBA8);
|
||||
img->resize(orig_size.x * scale, orig_size.y * scale);
|
||||
}
|
||||
texture->create_from_image(img, ImageTexture::FLAG_FILTER);
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
Color PaintWindow::get_selected_color() {
|
||||
return _selected_color;
|
||||
}
|
||||
@ -1147,26 +1175,26 @@ PaintWindow::PaintWindow() {
|
||||
left_main_vbox_container->add_child(brush_container);
|
||||
|
||||
TextureButton *brush_rect_button = memnew(TextureButton);
|
||||
//brush_rect_button->set_normal_texture(); //res://addons/Godoxel/assets/BrushRect.png
|
||||
//brush_rect_button->set_hover_texture(); //res://addons/Godoxel/assets/BrushRect_Hovered.png
|
||||
brush_rect_button->set_normal_texture(make_icon(brush_rect_png));
|
||||
brush_rect_button->set_hover_texture(make_icon(brush_rect_hovered_png));
|
||||
brush_rect_button->set_custom_minimum_size(Size2(25, 25));
|
||||
brush_container->add_child(brush_rect_button);
|
||||
|
||||
TextureButton *brush_circle_button = memnew(TextureButton);
|
||||
//brush_circle_button->set_normal_texture(); //res://addons/Godoxel/assets/BrushCircle.png
|
||||
//brush_circle_button->set_hover_texture(); //res://addons/Godoxel/assets/BrushCircle_Hovered.png
|
||||
brush_circle_button->set_normal_texture(make_icon(brush_circle_png));
|
||||
brush_circle_button->set_hover_texture(make_icon(brush_circle_hovered_png));
|
||||
brush_circle_button->set_custom_minimum_size(Size2(25, 25));
|
||||
brush_container->add_child(brush_circle_button);
|
||||
|
||||
TextureButton *brush_v_line_button = memnew(TextureButton);
|
||||
//brush_v_line_button->set_normal_texture(); //res://addons/Godoxel/assets/BrushVLine.png
|
||||
//brush_v_line_button->set_hover_texture(); //res://addons/Godoxel/assets/BrushVLine_Hovered.png
|
||||
brush_v_line_button->set_normal_texture(make_icon(brush_v_line_png));
|
||||
brush_v_line_button->set_hover_texture(make_icon(brush_v_line_hovered_png));
|
||||
brush_v_line_button->set_custom_minimum_size(Size2(25, 25));
|
||||
brush_container->add_child(brush_v_line_button);
|
||||
|
||||
TextureButton *brush_h_line_button = memnew(TextureButton);
|
||||
//brush_h_line_button->set_normal_texture(); //res://addons/Godoxel/assets/BrushHLine.png
|
||||
//brush_h_line_button->set_hover_texture(); //res://addons/Godoxel/assets/BrushHLine_Hovered.png
|
||||
brush_h_line_button->set_normal_texture(make_icon(brush_h_line_png));
|
||||
brush_h_line_button->set_hover_texture(make_icon(brush_h_line_hovered_png));
|
||||
brush_h_line_button->set_custom_minimum_size(Size2(25, 25));
|
||||
brush_container->add_child(brush_h_line_button);
|
||||
|
||||
|