Skip to content

Commit ee5f900

Browse files
committed
Merge branch 'export-editable'
2 parents 07d5a31 + 65800ec commit ee5f900

24 files changed

+1114
-253
lines changed

meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ dependencies = [
5757
dependency('libxml-2.0'),
5858
dependency('libportal-gtk4'),
5959
dependency('pangocairo'),
60+
dependency('libarchive'),
6061
dependency('libwebp'),
6162
math_dep
6263
]

src/Canvas.vala

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ public class Canvas : DrawingArea {
118118
set_cursor( cursor );
119119
}
120120

121-
/* Opens a new image and displays it in the drawing area */
121+
//-------------------------------------------------------------
122+
// Opens a new image and displays it in the drawing area.
122123
public bool open_image( string filename ) {
123124

124125
try {
@@ -376,7 +377,7 @@ public class Canvas : DrawingArea {
376377

377378
var retval = grab_focus();
378379
if( image.cropping ) {
379-
if( image.cursor_pressed( x, y, n_press ) ) {
380+
if( image.cursor_pressed( ex, ey, n_press ) ) {
380381
queue_draw();
381382
}
382383
} else if( items.cursor_pressed( x, y, n_press ) ) {
@@ -400,7 +401,7 @@ public class Canvas : DrawingArea {
400401
_last_y = y;
401402

402403
if( image.cropping || image.picking ) {
403-
if( image.cursor_moved( x, y ) ) {
404+
if( image.cursor_moved( ex, ey ) ) {
404405
queue_draw();
405406
}
406407
} else if( items.cursor_moved( x, y ) ) {
@@ -416,7 +417,7 @@ public class Canvas : DrawingArea {
416417
var y = scale_y( ey );
417418

418419
if( image.cropping || image.picking ) {
419-
if( image.cursor_released( x, y ) ) {
420+
if( image.cursor_released( ex, ey ) ) {
420421
queue_draw();
421422
}
422423
} else if( items.cursor_released( x, y ) ) {
@@ -494,6 +495,42 @@ public class Canvas : DrawingArea {
494495

495496
}
496497

498+
/****************************************************************************/
499+
// SAVE/LOAD
500+
/****************************************************************************/
501+
502+
//-------------------------------------------------------------
503+
// Saves this canvas and all canvas items in XML format.
504+
public Xml.Node* save( string image_dir, int compression ) {
505+
506+
Xml.Node* node = new Xml.Node( null, "canvas" );
507+
508+
node->add_child( image.save( image_dir, compression ) );
509+
node->add_child( items.save( image_dir ) );
510+
511+
return( node );
512+
513+
}
514+
515+
//-------------------------------------------------------------
516+
// Loads this canvas and the canvas items from XML format.
517+
public bool load( Xml.Node* node ) {
518+
519+
bool image_loaded = false;
520+
521+
for( Xml.Node* it=node->children; it!=null; it=it->next ) {
522+
if( it->type == Xml.ElementType.ELEMENT_NODE ) {
523+
switch( it->name ) {
524+
case "image" : image_loaded = image.load( it ); break;
525+
case "items" : items.load( it ); break;
526+
}
527+
}
528+
}
529+
530+
return( image_loaded );
531+
532+
}
533+
497534
/****************************************************************************/
498535
// DRAWING FUNCTIONS
499536
/****************************************************************************/

0 commit comments

Comments
 (0)