mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-24 14:06:23 +01:00
canvas color picker
This commit is contained in:
parent
78bf7ca154
commit
7dd31ce83e
21 changed files with 155 additions and 57 deletions
|
@ -306,6 +306,7 @@
|
|||
{"name":"s_node_rigidSim_object_spawner","order":5,"path":"sprites/s_node_rigidSim_object_spawner/s_node_rigidSim_object_spawner.yy",},
|
||||
{"name":"node_pb_draw_roundrectangle","order":4,"path":"scripts/node_pb_draw_roundrectangle/node_pb_draw_roundrectangle.yy",},
|
||||
{"name":"draw_text_function","order":11,"path":"scripts/draw_text_function/draw_text_function.yy",},
|
||||
{"name":"o_dialog_color_picker","order":6,"path":"objects/o_dialog_color_picker/o_dialog_color_picker.yy",},
|
||||
{"name":"o_dialog_file_name_collection","order":6,"path":"objects/o_dialog_file_name_collection/o_dialog_file_name_collection.yy",},
|
||||
{"name":"node_line","order":3,"path":"scripts/node_line/node_line.yy",},
|
||||
{"name":"s_node_frame","order":1,"path":"sprites/s_node_frame/s_node_frame.yy",},
|
||||
|
|
|
@ -499,6 +499,7 @@
|
|||
{"id":{"name":"s_node_rigidSim_object_spawner","path":"sprites/s_node_rigidSim_object_spawner/s_node_rigidSim_object_spawner.yy",},},
|
||||
{"id":{"name":"node_pb_draw_roundrectangle","path":"scripts/node_pb_draw_roundrectangle/node_pb_draw_roundrectangle.yy",},},
|
||||
{"id":{"name":"draw_text_function","path":"scripts/draw_text_function/draw_text_function.yy",},},
|
||||
{"id":{"name":"o_dialog_color_picker","path":"objects/o_dialog_color_picker/o_dialog_color_picker.yy",},},
|
||||
{"id":{"name":"o_dialog_file_name_collection","path":"objects/o_dialog_file_name_collection/o_dialog_file_name_collection.yy",},},
|
||||
{"id":{"name":"__node_3d_prim_cone","path":"scripts/__node_3d_prim_cone/__node_3d_prim_cone.yy",},},
|
||||
{"id":{"name":"node_line","path":"scripts/node_line/node_line.yy",},},
|
||||
|
|
Binary file not shown.
6
objects/o_dialog_color_picker/Create_0.gml
Normal file
6
objects/o_dialog_color_picker/Create_0.gml
Normal file
|
@ -0,0 +1,6 @@
|
|||
/// @description Insert description here
|
||||
onApply = noone;
|
||||
def_c = noone;
|
||||
cur_c = c_black;
|
||||
|
||||
depth = -32000;
|
7
objects/o_dialog_color_picker/Draw_64.gml
Normal file
7
objects/o_dialog_color_picker/Draw_64.gml
Normal file
|
@ -0,0 +1,7 @@
|
|||
/// @description Insert description here
|
||||
MOUSE_BLOCK = true;
|
||||
|
||||
var dx = mouse_mx + ui(36);
|
||||
var dy = mouse_my + ui(36);
|
||||
draw_sprite_stretched(THEME.color_picker_sample, 0, dx - ui(20), dy - ui(20), ui(40), ui(40));
|
||||
draw_sprite_stretched_ext(THEME.color_picker_sample, 0, dx - ui(18), dy - ui(18), ui(36), ui(36), cur_c, 1);
|
14
objects/o_dialog_color_picker/Draw_75.gml
Normal file
14
objects/o_dialog_color_picker/Draw_75.gml
Normal file
|
@ -0,0 +1,14 @@
|
|||
/// @description Insert description here
|
||||
cur_c = int64(cola(draw_getpixel(mouse_mx, mouse_my)));
|
||||
|
||||
MOUSE_BLOCK = true;
|
||||
|
||||
if(mouse_check_button_pressed(mb_right) || keyboard_check_released(ALT)) {
|
||||
if(def_c != noone) onApply(def_c);
|
||||
instance_destroy();
|
||||
}
|
||||
|
||||
if(mouse_check_button_pressed(mb_left)) {
|
||||
onApply(cur_c);
|
||||
instance_destroy();
|
||||
}
|
35
objects/o_dialog_color_picker/o_dialog_color_picker.yy
Normal file
35
objects/o_dialog_color_picker/o_dialog_color_picker.yy
Normal file
|
@ -0,0 +1,35 @@
|
|||
{
|
||||
"resourceType": "GMObject",
|
||||
"resourceVersion": "1.0",
|
||||
"name": "o_dialog_color_picker",
|
||||
"eventList": [
|
||||
{"resourceType":"GMEvent","resourceVersion":"1.0","name":"","collisionObjectId":null,"eventNum":0,"eventType":0,"isDnD":false,},
|
||||
{"resourceType":"GMEvent","resourceVersion":"1.0","name":"","collisionObjectId":null,"eventNum":64,"eventType":8,"isDnD":false,},
|
||||
{"resourceType":"GMEvent","resourceVersion":"1.0","name":"","collisionObjectId":null,"eventNum":75,"eventType":8,"isDnD":false,},
|
||||
],
|
||||
"managed": true,
|
||||
"overriddenProperties": [],
|
||||
"parent": {
|
||||
"name": "color selector",
|
||||
"path": "folders/dialog/color selector.yy",
|
||||
},
|
||||
"parentObjectId": null,
|
||||
"persistent": false,
|
||||
"physicsAngularDamping": 0.1,
|
||||
"physicsDensity": 0.5,
|
||||
"physicsFriction": 0.2,
|
||||
"physicsGroup": 1,
|
||||
"physicsKinematic": false,
|
||||
"physicsLinearDamping": 0.1,
|
||||
"physicsObject": false,
|
||||
"physicsRestitution": 0.1,
|
||||
"physicsSensor": false,
|
||||
"physicsShape": 1,
|
||||
"physicsShapePoints": [],
|
||||
"physicsStartAwake": true,
|
||||
"properties": [],
|
||||
"solid": false,
|
||||
"spriteId": null,
|
||||
"spriteMaskId": null,
|
||||
"visible": true,
|
||||
}
|
|
@ -1,6 +1,9 @@
|
|||
/// @description init
|
||||
if(winMan_isMinimized()) exit;
|
||||
|
||||
_MOUSE_BLOCK = MOUSE_BLOCK;
|
||||
MOUSE_BLOCK = false;
|
||||
|
||||
if(APP_SURF_OVERRIDE) {
|
||||
APP_SURF = surface_verify(APP_SURF, WIN_W, WIN_H);
|
||||
PRE_APP_SURF = surface_verify(PRE_APP_SURF, WIN_W, WIN_H);
|
||||
|
|
|
@ -12,6 +12,3 @@ var _dirr = point_direction(drag_cx, drag_cy, drag_sx, drag_sy);
|
|||
delta = angle_difference(_dirr, drag_sa);
|
||||
delta_acc += delta;
|
||||
drag_sa = _dirr;
|
||||
|
||||
FOCUS = noone;
|
||||
HOVER = noone;
|
|
@ -2,6 +2,3 @@
|
|||
var dx = mouse_mx - drag_mx;
|
||||
drag_mx = mouse_mx;
|
||||
drag_sx += dx;
|
||||
|
||||
FOCUS = self;
|
||||
HOVER = self;
|
|
@ -19,7 +19,9 @@ if(slide_da == -1) {
|
|||
|
||||
tb_de = 1;
|
||||
|
||||
if(mouse_press(mb_right)) {
|
||||
MOUSE_BLOCK = true;
|
||||
|
||||
if(mouse_check_button_pressed(mb_right)) {
|
||||
tb._input_text = string_real(tb.slide_sv);
|
||||
tb.apply();
|
||||
tb.sliding = false;
|
||||
|
@ -43,6 +45,7 @@ if(!MOUSE_WRAPPING) {
|
|||
var spd = (slide_da? _ady : _adx) * _s;
|
||||
val = value_snap(tb.slide_sv + spd, _s);
|
||||
if(tb.slide_int) val = round(val);
|
||||
if(tb.slide_range != noone) val = clamp(val, tb.slide_range[0], tb.slide_range[1]);
|
||||
|
||||
var _stp_sz = 50 * _s;
|
||||
var _stp_fl = round(val / _stp_sz) * _stp_sz;
|
||||
|
@ -62,10 +65,12 @@ if(!MOUSE_WRAPPING) {
|
|||
val = _snp_v;
|
||||
|
||||
if(slide_da) {
|
||||
var _val_y = slide_dy - (val - tb.slide_sv);
|
||||
|
||||
var _sdw = _tw;
|
||||
var _sdh = 256;
|
||||
var _sdx = slide_dx - _sdw / 2;
|
||||
var _sdy = mouse_my - _sdh / 2;
|
||||
var _sdy = _val_y - _sdh / 2;
|
||||
|
||||
draw_sprite_stretched_ext(THEME.textbox_number_slider, 0, _sdx, _sdy, _sdw, _sdh, COLORS.panel_inspector_group_bg, 1);
|
||||
|
||||
|
@ -79,11 +84,13 @@ if(!MOUSE_WRAPPING) {
|
|||
|
||||
draw_set_color(val == tb.slide_sv? COLORS._main_accent : COLORS._main_text);
|
||||
draw_set_alpha(1);
|
||||
draw_text(slide_dx, slide_dy - (val - tb.slide_sv) / _s, val);
|
||||
draw_text(slide_dx, _val_y, val);
|
||||
} else {
|
||||
var _val_x = slide_dx + (val - tb.slide_sv) / _s;
|
||||
|
||||
var _sdw = 240;
|
||||
var _sdh = 48;
|
||||
var _sdx = mouse_mx - _sdw / 2;
|
||||
var _sdx = _val_x - _sdw / 2;
|
||||
var _sdy = slide_dy - _sdh / 2;
|
||||
|
||||
draw_sprite_stretched_ext(THEME.textbox_number_slider, 0, _sdx, _sdy, _sdw, _sdh, COLORS.panel_inspector_group_bg, 1);
|
||||
|
@ -98,7 +105,7 @@ if(!MOUSE_WRAPPING) {
|
|||
|
||||
draw_set_color(val == tb.slide_sv? COLORS._main_accent : COLORS._main_text);
|
||||
draw_set_alpha(1);
|
||||
draw_text(slide_dx + (val - tb.slide_sv) / _s, slide_dy, val);
|
||||
draw_text(_val_x, slide_dy, val);
|
||||
}
|
||||
|
||||
tb._input_text = string_real(val);
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
/// @description Insert description here
|
||||
if(tb_de) {
|
||||
FOCUS = self;
|
||||
HOVER = self;
|
||||
tb_de--;
|
||||
}
|
|
@ -5,7 +5,6 @@
|
|||
"eventList": [
|
||||
{"resourceType":"GMEvent","resourceVersion":"1.0","name":"","collisionObjectId":null,"eventNum":64,"eventType":8,"isDnD":false,},
|
||||
{"resourceType":"GMEvent","resourceVersion":"1.0","name":"","collisionObjectId":null,"eventNum":0,"eventType":0,"isDnD":false,},
|
||||
{"resourceType":"GMEvent","resourceVersion":"1.0","name":"","collisionObjectId":null,"eventNum":0,"eventType":3,"isDnD":false,},
|
||||
],
|
||||
"managed": true,
|
||||
"overriddenProperties": [],
|
||||
|
|
|
@ -1,23 +1,10 @@
|
|||
function mouse_click(mouse, focus = true) {
|
||||
INLINE
|
||||
return focus && mouse_check_button(mouse);
|
||||
}
|
||||
|
||||
function mouse_press(mouse, focus = true) {
|
||||
INLINE
|
||||
return focus && mouse_check_button_pressed(mouse);
|
||||
}
|
||||
|
||||
function mouse_release(mouse, focus = true) {
|
||||
INLINE
|
||||
return focus && mouse_check_button_released(mouse);
|
||||
}
|
||||
|
||||
#region mouse global
|
||||
globalvar MOUSE_WRAP, MOUSE_WRAPPING;
|
||||
globalvar MOUSE_WRAP, MOUSE_WRAPPING, MOUSE_BLOCK, _MOUSE_BLOCK;
|
||||
|
||||
MOUSE_WRAP = false;
|
||||
MOUSE_WRAPPING = false;
|
||||
MOUSE_BLOCK = false;
|
||||
_MOUSE_BLOCK = false;
|
||||
|
||||
#macro SCROLL_SPEED PREFERENCES.mouse_wheel_speed
|
||||
|
||||
|
@ -26,3 +13,18 @@ function mouse_release(mouse, focus = true) {
|
|||
MOUSE_WRAP = true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
function mouse_click(mouse, focus = true) {
|
||||
INLINE
|
||||
return !_MOUSE_BLOCK && focus && mouse_check_button(mouse);
|
||||
}
|
||||
|
||||
function mouse_press(mouse, focus = true) {
|
||||
INLINE
|
||||
return !_MOUSE_BLOCK && focus && mouse_check_button_pressed(mouse);
|
||||
}
|
||||
|
||||
function mouse_release(mouse, focus = true) {
|
||||
INLINE
|
||||
return focus && mouse_check_button_released(mouse);
|
||||
}
|
|
@ -224,12 +224,12 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
tool_settings = [ [ "Channel", tool_channel_edit, "channel", tool_attribute ] ];
|
||||
|
||||
tool_attribute.size = 1;
|
||||
tool_size_edit = new textBox(TEXTBOX_INPUT.number, function(val) { tool_attribute.size = round(val); }).setSlidable(0.1, true);
|
||||
tool_size_edit = new textBox(TEXTBOX_INPUT.number, function(val) { tool_attribute.size = max(1, round(val)); }).setSlidable(0.1, true, [ 1, 999999 ]);
|
||||
tool_size_edit.font = f_p3;
|
||||
tool_size = [ "Size", tool_size_edit, "size", tool_attribute ];
|
||||
|
||||
tool_attribute.thres = 0;
|
||||
tool_thrs_edit = new textBox(TEXTBOX_INPUT.number, function(val) { tool_attribute.thres = clamp(val, 0, 1); }).setSlidable(0.01);
|
||||
tool_thrs_edit = new textBox(TEXTBOX_INPUT.number, function(val) { tool_attribute.thres = clamp(val, 0, 1); }).setSlidable(0.01, false, [ 0, 1 ]);
|
||||
tool_thrs_edit.font = f_p3;
|
||||
tool_thrs = [ "Threshold", tool_thrs_edit, "thres", tool_attribute ];
|
||||
|
||||
|
@ -292,6 +292,8 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
yy += _cw + ui(8);
|
||||
hh += _cw + ui(8);
|
||||
|
||||
var _sel = noone;
|
||||
|
||||
for( var i = 0, n = array_length(DEF_PALETTE); i < n; i++ ) {
|
||||
var _c = DEF_PALETTE[i];
|
||||
|
||||
|
@ -301,6 +303,9 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
|
||||
draw_sprite_stretched_ext(THEME.palette_mask, ii, _cx, yy, _cw, _ch, _c, 1);
|
||||
|
||||
if(_c == tool_attribute.color)
|
||||
_sel = [ _cx, yy ];
|
||||
|
||||
if(hover && point_in_rectangle(_mx, _my, _cx, yy, _cx + _cw, yy + _ch)) {
|
||||
if(mouse_click(mb_left, focus))
|
||||
tool_attribute.color = _c;
|
||||
|
@ -310,6 +315,9 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
hh += _ch;
|
||||
}
|
||||
|
||||
if(_sel != noone)
|
||||
draw_sprite_stretched_ext(THEME.palette_selecting, 0, _sel[0] - _pd, _sel[1] - _pd, _cw + _pd * 2, _ch + _pd * 2, c_white, 1);
|
||||
|
||||
return hh + ui(4);
|
||||
} #endregion
|
||||
|
||||
|
@ -701,7 +709,7 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
} #endregion
|
||||
|
||||
static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { #region
|
||||
if(instance_exists(o_dialog_color_selector)) return;
|
||||
if(instance_exists(o_dialog_color_picker)) return;
|
||||
|
||||
mouse_cur_x = round((_mx - _x) / _s - 0.5);
|
||||
mouse_cur_y = round((_my - _y) / _s - 0.5);
|
||||
|
@ -734,7 +742,14 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
}
|
||||
|
||||
brush_rand_dir = _brushRotR;
|
||||
if(key_mod_press(ALT)) return;
|
||||
|
||||
#region color selector
|
||||
if(active && key_mod_press(ALT)) {
|
||||
var dialog = instance_create(0, 0, o_dialog_color_picker);
|
||||
dialog.onApply = setToolColor;
|
||||
dialog.def_c = _col;
|
||||
}
|
||||
#endregion
|
||||
|
||||
var _canvas_surface = getCanvasSurface();
|
||||
|
||||
|
@ -1083,7 +1098,7 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
}
|
||||
surface_reset_shader();
|
||||
|
||||
if(active && isUsingTool()) {
|
||||
if((active || mouse_holding) && isUsingTool()) {
|
||||
if(isUsingTool("Selection")) {
|
||||
if(is_selected) {
|
||||
var pos_x = _x + selection_position[0] * _s;
|
||||
|
|
|
@ -76,7 +76,9 @@ function rotator(_onModify, _step = -1) : widget() constructor {
|
|||
if(onModify(val))
|
||||
UNDO_HOLDING = true;
|
||||
|
||||
if(mouse_press(mb_right)) {
|
||||
MOUSE_BLOCK = true;
|
||||
|
||||
if(mouse_check_button_pressed(mb_right)) {
|
||||
onModify(drag_sv);
|
||||
instance_destroy(dragging);
|
||||
dragging = noone;
|
||||
|
|
|
@ -154,7 +154,9 @@ function rotatorRandom(_onModify) : widget() constructor {
|
|||
}
|
||||
}
|
||||
|
||||
if(mouse_press(mb_right)) {
|
||||
MOUSE_BLOCK = true;
|
||||
|
||||
if(mouse_check_button_pressed(mb_right)) {
|
||||
for( var i = 0; i < 5; i++ ) onModify(i, drag_dat[i]);
|
||||
|
||||
instance_destroy(rotator_Rotator);
|
||||
|
@ -245,7 +247,9 @@ function rotatorRandom(_onModify) : widget() constructor {
|
|||
if(onModify(2, val)) UNDO_HOLDING = true;
|
||||
}
|
||||
|
||||
if(mouse_press(mb_right)) {
|
||||
MOUSE_BLOCK = true;
|
||||
|
||||
if(mouse_check_button_pressed(mb_right)) {
|
||||
for( var i = 0; i < 5; i++ ) onModify(i, drag_dat[i]);
|
||||
|
||||
instance_destroy(rotator_Rotator);
|
||||
|
@ -328,7 +332,9 @@ function rotatorRandom(_onModify) : widget() constructor {
|
|||
|
||||
if(onModify(ind, val)) UNDO_HOLDING = true;
|
||||
|
||||
if(mouse_press(mb_right)) {
|
||||
MOUSE_BLOCK = true;
|
||||
|
||||
if(mouse_check_button_pressed(mb_right)) {
|
||||
for( var i = 0; i < 5; i++ ) onModify(i, drag_dat[i]);
|
||||
|
||||
instance_destroy(rotator_Rotator);
|
||||
|
@ -418,7 +424,9 @@ function rotatorRandom(_onModify) : widget() constructor {
|
|||
|
||||
if(onModify(ind, val)) UNDO_HOLDING = true;
|
||||
|
||||
if(mouse_press(mb_right)) {
|
||||
MOUSE_BLOCK = true;
|
||||
|
||||
if(mouse_check_button_pressed(mb_right)) {
|
||||
for( var i = 0; i < 5; i++ ) onModify(i, drag_dat[i]);
|
||||
|
||||
instance_destroy(rotator_Rotator);
|
||||
|
|
|
@ -115,7 +115,9 @@ function rotatorRange(_onModify) : widget() constructor {
|
|||
}
|
||||
}
|
||||
|
||||
if(mouse_press(mb_right)) {
|
||||
MOUSE_BLOCK = true;
|
||||
|
||||
if(mouse_check_button_pressed(mb_right)) {
|
||||
for( var i = 0; i < 2; i++ ) onModify(i, drag_dat[i]);
|
||||
|
||||
instance_destroy(rotator_Rotator);
|
||||
|
|
|
@ -125,11 +125,14 @@ function slider(_min, _max, _step, _onModify = noone, _onRelease = noone) : widg
|
|||
if(update_stat == SLIDER_UPDATE.realtime && onModify != noone && onModify(val))
|
||||
UNDO_HOLDING = true;
|
||||
|
||||
if(mouse_press(mb_right)) {
|
||||
MOUSE_BLOCK = true;
|
||||
|
||||
if(mouse_check_button_pressed(mb_right)) {
|
||||
onModify(drag_sv);
|
||||
instance_destroy(dragging);
|
||||
dragging = noone;
|
||||
UNDO_HOLDING = false;
|
||||
|
||||
} else if(mouse_release(mb_left)) {
|
||||
if(update_stat == SLIDER_UPDATE.release && onModify != noone)
|
||||
onModify(val);
|
||||
|
|
|
@ -85,11 +85,14 @@ function sliderRange(_min, _max, _step, _onModify) : widget() constructor {
|
|||
if(onModify(dragging_index, val))
|
||||
UNDO_HOLDING = true;
|
||||
|
||||
if(mouse_press(mb_right)) {
|
||||
MOUSE_BLOCK = true;
|
||||
|
||||
if(mouse_check_button_pressed(mb_right)) {
|
||||
onModify(dragging_index, drag_sv);
|
||||
instance_destroy(dragging);
|
||||
dragging = noone;
|
||||
UNDO_HOLDING = false;
|
||||
|
||||
} else if(mouse_release(mb_left)) {
|
||||
instance_destroy(dragging);
|
||||
dragging = noone;
|
||||
|
|
|
@ -19,6 +19,7 @@ function textBox(_input, _onModify) : textInput(_input, _onModify) constructor {
|
|||
slide_int = false;
|
||||
slide_sv = 0;
|
||||
slide_speed = 1 / 10;
|
||||
slide_range = noone;
|
||||
|
||||
starting_char = 1;
|
||||
|
||||
|
@ -58,10 +59,11 @@ function textBox(_input, _onModify) : textInput(_input, _onModify) constructor {
|
|||
onModify(value);
|
||||
} #endregion
|
||||
|
||||
static setSlidable = function(slideStep = slide_speed, _slide_int = false) { #region
|
||||
static setSlidable = function(slideStep = slide_speed, _slide_int = false, _slide_range = noone) { #region
|
||||
slidable = true;
|
||||
slide_speed = slideStep;
|
||||
slide_int = _slide_int;
|
||||
slide_range = _slide_range;
|
||||
|
||||
return self;
|
||||
} #endregion
|
||||
|
|
Loading…
Reference in a new issue