Edit Colors... Implementation One

This commit will be followed by a better implementation.
main
Isaiah Odhner 2014-09-22 19:17:43 -04:00
parent d2c15bef4b
commit b7a6e7af7b
4 changed files with 26 additions and 8 deletions

View File

@ -28,7 +28,7 @@ A lot of stuff isn't done yet:
* Magnification
* Free-Form Selection
* Color Replacement with the "Eraser/Color Eraser" tool
* Lots of menu items
* Some menu items
* Copying the selection to the clipboard (You can paste, though!)
There's [a lot to do.](TODO.md)

View File

@ -36,13 +36,11 @@
* Flip / Rotate
* Stretch / Skew
* Draw Opaque
* Colors
* Edit Colors...
* Help
* Help Topics ✓ um...
* About paint ✓ um......
* Enable items (Repeat, Clear Selection, Copy To...) when they are applicable
* Animation
* Sliding animation / transition effects
* Image operations should apply to the selection if there is one
@ -88,7 +86,7 @@
* Scroll Wheel draws line down and to the right (um, this is a bug, though)
* CSS: buttons shouldn't need a class `.jspaint-button`
* CSS: buttons shouldn't need a class `.jspaint-button`; color cells shouldn't be buttons
* JS: chill down on the global event handlers; they're interfering with inputs

View File

@ -1,6 +1,7 @@
function reset_colors(){
colors = ["black", "white", ""];
// note: these need to be in the same format as in the palette to be counted as the same as the colors in the palette for Colors > Edit Colors...
colors = ["#000000", "#ffffff", ""];
$colorbox && $colorbox.update_colors();
}

View File

@ -346,7 +346,26 @@ $.each({
"&Colors": [
{
item: "&Edit Colors...",
action: function(){}
action: function(){
var input;
// Note: MS Paint uses the last color cell selected as the foreground color,
// where I am instead finding color cells that match the current foreground color.
// If you select a color with the color picker that isn't in the palette it will fail.
// This implementation is therefore inferior.
$(".jspaint-color-button input").each(function(){
var button = this.parentElement;
var cs = document.querySelector(".jspaint-color-selection");
if(getComputedStyle(button).backgroundColor === getComputedStyle(cs).backgroundColor){
input = this;
return false;//break each loop
}
});
$(input).parent().trigger({type: "mousedown", ctrlKey: false, button: 0});
$(input).trigger("click", "synthetic");
}
}
],
"&Help": [
@ -359,7 +378,7 @@ $.each({
$msgbox.$content.html(
"<p style='padding:0;margin:5px'>Sorry, no help is available at this time.</p>" +
"<br>You can however try <a href='https://www.google.com/search?q=ms+paint+tutorials' target='_blank'>searching for tutorials</a> for MS Paint." +
"<br>There will be differences, but it could help."
"<br>There will be differences, but the basics are there."
).css({padding: "15px"});
$msgbox.center();
}