Skip to content

Commit

Permalink
Rename textbox object OnCanvasTextBox
Browse files Browse the repository at this point in the history
  • Loading branch information
1j01 committed Sep 20, 2019
1 parent b9fadfd commit 5a4abc4
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
6 changes: 3 additions & 3 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ might be a pointer events spec interpretation issue, and it could easily be that
* Expand box to make room for new lines
* Minimum size of 3em x 1em
* Store position of FontBox
* Keep an old TextBox while drawing a new one
* Keep an old OnCanvasTextBox while drawing a new one
* Save text and record transformations so the image can be saved as
SVG (or HTML?) with invisible selectable transformed text elements?

Expand Down Expand Up @@ -192,15 +192,15 @@ might be a pointer events spec interpretation issue, and it could easily be that

### On-Canvas Objects

* Selection
* `OnCanvasSelection`
* Proportionally resize selection while holding Shift
(or maybe by default? I feel like it should be the default, tbh.)
* Don't cut until you drag or do something else
(In MS Paint, you can make a selection, change the background color
and drag it, leaving the new background color behind.)


* TextBox
* `OnCanvasTextBox`
* See Text tool


Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ <h1><img src="images/icons/32.png" alt=""/> JS Paint <small class="version-numbe
<script src="src/$Handles.js"></script>
<script src="src/OnCanvasObject.js"></script>
<script src="src/OnCanvasSelection.js"></script>
<script src="src/TextBox.js"></script>
<script src="src/OnCanvasTextBox.js"></script>
<script src="src/image-manipulation.js"></script>
<script src="src/tool-options.js"></script>
<script src="src/tools.js"></script>
Expand Down
24 changes: 12 additions & 12 deletions src/TextBox.js → src/OnCanvasTextBox.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

function TextBox(x, y, width, height){
function OnCanvasTextBox(x, y, width, height){
var tb = this;

OnCanvasObject.call(tb, x, y, width, height);
Expand Down Expand Up @@ -39,9 +39,9 @@ function TextBox(x, y, width, height){
$G.on("option-changed", this._on_option_changed = update);
}

TextBox.prototype = Object.create(OnCanvasObject.prototype);
OnCanvasTextBox.prototype = Object.create(OnCanvasObject.prototype);

TextBox.prototype.instantiate = function(){
OnCanvasTextBox.prototype.instantiate = function(){
var tb = this;

tb.$el.addClass("instantiated").css({
Expand All @@ -53,12 +53,12 @@ TextBox.prototype.instantiate = function(){

instantiate();

if(TextBox.$fontbox && TextBox.$fontbox.closed){
TextBox.$fontbox = null;
if(OnCanvasTextBox.$fontbox && OnCanvasTextBox.$fontbox.closed){
OnCanvasTextBox.$fontbox = null;
}
var $fb = TextBox.$fontbox = TextBox.$fontbox || new $FontBox();
var $fb = OnCanvasTextBox.$fontbox = OnCanvasTextBox.$fontbox || new $FontBox();

// move the font box out of the way if it's overlapping the TextBox
// move the font box out of the way if it's overlapping the OnCanvasTextBox
var $tb = tb.$el;
var fb_rect = $fb[0].getBoundingClientRect();
var tb_rect = $tb[0].getBoundingClientRect();
Expand Down Expand Up @@ -172,7 +172,7 @@ function draw_text_wrapped(ctx, text, x, y, maxWidth, lineHeight) {
}
}

TextBox.prototype.draw = function(){
OnCanvasTextBox.prototype.draw = function(){
var tb = this;
var text = tb.$editor.val();
if(text){
Expand All @@ -191,12 +191,12 @@ TextBox.prototype.draw = function(){
}
};

TextBox.prototype.destroy = function(){
OnCanvasTextBox.prototype.destroy = function(){
OnCanvasObject.prototype.destroy.call(this);

if(TextBox.$fontbox && !TextBox.$fontbox.closed){
TextBox.$fontbox.close();
if(OnCanvasTextBox.$fontbox && !OnCanvasTextBox.$fontbox.closed){
OnCanvasTextBox.$fontbox.close();
}
TextBox.$fontbox = null;
OnCanvasTextBox.$fontbox = null;
$G.off("option-changed", this._on_option_changed);
};
2 changes: 1 addition & 1 deletion src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var colors = {
};

var selection; //the one and only OnCanvasSelection
var textbox; //the one and only TextBox
var textbox; //the one and only OnCanvasTextBox
var font = {
family: "Arial",
size: 12,
Expand Down
2 changes: 1 addition & 1 deletion src/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ tools = [{
textbox = null;
}
});
textbox = new TextBox(pointer.x, pointer.y, 1, 1);
textbox = new OnCanvasTextBox(pointer.x, pointer.y, 1, 1);
},
paint: function(){
if(!textbox){ return; }
Expand Down

0 comments on commit 5a4abc4

Please sign in to comment.