Skip to content

Commit c8edbd2

Browse files
committed
Fixing issues with task overload
* Comment cleanup * Tasks are now only automatically added when nodes are initially created.
1 parent d554868 commit c8edbd2

File tree

2 files changed

+48
-36
lines changed

2 files changed

+48
-36
lines changed

src/MapModel.vala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1754,6 +1754,9 @@ public class MapModel {
17541754
node.side = sibling.side;
17551755
node.attach( sibling.parent, (sibling.index() + (below ? 1 : 0)), _theme );
17561756
set_style_after_parent_attach( node );
1757+
if( sibling.task_enabled() ) {
1758+
node.enable_task( true );
1759+
}
17571760
node.parent.set_fold( false, true );
17581761
if( sibling.is_summarized() ) {
17591762
sibling.summary_node().add_node( node );
@@ -1789,6 +1792,9 @@ public class MapModel {
17891792
}
17901793
node.attach( parent, -1, _theme );
17911794
set_style_after_parent_attach( node );
1795+
if( parent.task_enabled() ) {
1796+
node.enable_task( true );
1797+
}
17921798
parent.set_fold( false, true );
17931799
return( node );
17941800
}

src/Node.vala

Lines changed: 42 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public struct NodeTaskInfo {
214214

215215
public class Node : Object {
216216

217-
/* Member variables */
217+
// Member variables
218218
private MindMap _map;
219219
protected int _id;
220220
private CanvasText _name;
@@ -250,11 +250,11 @@ public class Node : Object {
250250
private bool _sequence = false;
251251
private Tags _tags;
252252

253-
/* Node signals */
253+
// Node signals
254254
public signal void moved( double diffx, double diffy );
255255
public signal void resized( double diffw, double diffh );
256256

257-
/* Properties */
257+
// Properties
258258
public MindMap map {
259259
get {
260260
return( _map );
@@ -1719,7 +1719,7 @@ public class Node : Object {
17191719
siblings.append_val( this );
17201720
}
17211721

1722-
/* If the posx and posy values are not set, set the layout now */
1722+
// If the posx and posy values are not set, set the layout now
17231723
if( (x == null) && (y == null) ) {
17241724
string? l = n->get_prop( "layout" );
17251725
if( l != null ) {
@@ -1728,7 +1728,7 @@ public class Node : Object {
17281728
_loaded = true;
17291729
}
17301730

1731-
/* Make sure the style has a default value */
1731+
// Make sure the style has a default value
17321732
style.copy( StyleInspector.styles.get_style_for_level( (isroot ? 0 : 1), null ) );
17331733

17341734
for( Xml.Node* it = n->children; it != null; it = it->next ) {
@@ -1753,19 +1753,19 @@ public class Node : Object {
17531753

17541754
_loaded = true;
17551755

1756-
/* Force the size to get re-calculated */
1756+
// Force the size to get re-calculated
17571757
update_total_size();
17581758
update_size();
17591759

1760-
/* Load the layout after the nodes are loaded if the posx/posy information is set */
1760+
// Load the layout after the nodes are loaded if the posx/posy information is set
17611761
if( (x != null) || (y != null) ) {
17621762
string? l = n->get_prop( "layout" );
17631763
if( l != null ) {
17641764
layout = map.layouts.get_layout( l );
17651765
}
17661766
}
17671767

1768-
/* If a color was not specified and this node is a root node, colorize the children */
1768+
// If a color was not specified and this node is a root node, colorize the children
17691769
if( isroot ) {
17701770
for( int j=0; j<_children.length; j++ ) {
17711771
var child = _children.index( j );
@@ -1775,14 +1775,14 @@ public class Node : Object {
17751775
}
17761776
}
17771777

1778-
/* Get the tree bbox */
1778+
// Get the tree bbox
17791779
tree_bbox = layout.bbox( this, -1, "node.load" );
17801780

17811781
if( ts == null ) {
17821782
tree_size = side.horizontal() ? tree_bbox.height : tree_bbox.width;
17831783
}
17841784

1785-
/* Make sure that the name is positioned properly */
1785+
// Make sure that the name is positioned properly
17861786
position_text();
17871787

17881788
}
@@ -2431,23 +2431,26 @@ public class Node : Object {
24312431
attach_common( idx, theme );
24322432
}
24332433

2434+
//-------------------------------------------------------------
2435+
// Attachment method to use when node side is known and does not
2436+
// need to be calculated.
24342437
public virtual void attach_init( Node parent, int index ) {
24352438
assert( !is_summary() );
24362439
this.parent = parent;
24372440
layout = parent.layout;
24382441
attach_common( index, null );
24392442
}
24402443

2444+
//-------------------------------------------------------------
2445+
// Common attachment code that is called by the higher-level attachment
2446+
// methods.
24412447
protected virtual void attach_common( int index, Theme? theme ) {
24422448
if( index == -1 ) {
24432449
index = (int)this.parent.children().length;
24442450
parent.children().append_val( this );
24452451
} else {
24462452
parent.children().insert_val( index, this );
24472453
}
2448-
if( (parent._task_count > 0) && (_task_count == 0) ) {
2449-
_task_count = 1;
2450-
}
24512454
propagate_task_info_up( _task_count, _task_done );
24522455
if( parent.sequence ) {
24532456
for( int i=index; i<parent.children().length; i++ ) {
@@ -2525,8 +2528,11 @@ public class Node : Object {
25252528
//-------------------------------------------------------------
25262529
// Propagates task information toward the leaf nodes.
25272530
private void propagate_task_info_down( bool? enable, bool? done ) {
2531+
stdout.printf( "In propagate_task_info_down, enable: %s\n", enable.to_string() );
25282532
if( is_leaf() ) {
2533+
stdout.printf( "Found leaf\n" );
25292534
if( enable != null ) {
2535+
stdout.printf( " HERE!\n" );
25302536
_task_count = enable ? 1 : 0;
25312537
}
25322538
if( _task_count == 1 ) {
@@ -2848,7 +2854,7 @@ public class Node : Object {
28482854
style.draw_node_fill( ctx, x, y, w, h, side );
28492855
}
28502856

2851-
/* Set the fill color */
2857+
// Set the fill color
28522858
if( mode.is_selected() && !exporting ) {
28532859
Utils.set_context_color_with_alpha( ctx, theme.get_color( "nodesel_background" ), _alpha );
28542860
style.draw_node_fill( ctx, x, y, w, h, side );
@@ -2862,16 +2868,16 @@ public class Node : Object {
28622868

28632869
if( !is_root() || style.is_fillable() ) {
28642870

2865-
/* Draw the border */
2871+
// Draw the border
28662872
Utils.set_context_color_with_alpha( ctx, border_color, _alpha );
28672873
ctx.set_line_width( style.node_borderwidth );
28682874

2869-
/* If we are in a vertical orientation and the border type is underlined, draw nothing */
2875+
// If we are in a vertical orientation and the border type is underlined, draw nothing
28702876
style.draw_node_border( ctx, x, y, w, h, side );
28712877

28722878
}
28732879

2874-
/* If we have children and we need to extend our link point, let's draw the extended link link now */
2880+
// If we have children and we need to extend our link point, let's draw the extended link link now
28752881
if( (_children.length > 0) && !is_summarized() ) {
28762882
var max_width = 0;
28772883
for( int i=0; i<_children.length; i++ ) {
@@ -2914,7 +2920,7 @@ public class Node : Object {
29142920
int hmargin = 3;
29152921
int vmargin = 3;
29162922

2917-
/* Draw the selection box around the text if the node is in the 'selected' state */
2923+
// Draw the selection box around the text if the node is in the 'selected' state
29182924
if( mode.is_selected() && !exporting ) {
29192925
var padding = style.node_padding ?? 0;
29202926
var margin = style.node_margin ?? 0;
@@ -2926,7 +2932,7 @@ public class Node : Object {
29262932
ctx.fill();
29272933
}
29282934

2929-
/* Draw the text */
2935+
// Draw the text
29302936
var color = theme.get_color( "foreground" );
29312937
if( mode.is_selected() && !exporting ) {
29322938
color = theme.get_color( "nodesel_foreground" );
@@ -2987,7 +2993,7 @@ public class Node : Object {
29872993
x += _task_radius;
29882994
y += _task_radius;
29892995

2990-
/* Draw circle outline */
2996+
// Draw circle outline
29912997
ctx.new_path();
29922998
ctx.set_line_width( 2 );
29932999
ctx.arc( x, y, _task_radius, 0, (2 * Math.PI) );
@@ -2999,7 +3005,7 @@ public class Node : Object {
29993005
ctx.stroke();
30003006
}
30013007

3002-
/* Draw completeness pie */
3008+
// Draw completeness pie
30033009
if( _task_done > 0 ) {
30043010
Utils.set_context_color_with_alpha( ctx, color, _alpha );
30053011
ctx.new_path();
@@ -3033,7 +3039,7 @@ public class Node : Object {
30333039
ctx.fill();
30343040
}
30353041

3036-
/* Draw sticker */
3042+
// Draw sticker
30373043
cairo_set_source_pixbuf( ctx, _sticker_buf, x, y );
30383044
ctx.paint_with_alpha( _alpha );
30393045

@@ -3061,11 +3067,11 @@ public class Node : Object {
30613067
ctx.fill();
30623068
}
30633069

3064-
/* Draw sequence number */
3070+
// Draw sequence number
30653071
Pango.Rectangle ink_rect, log_rect;
30663072
_sequence_num.layout.get_extents( out ink_rect, out log_rect );
30673073

3068-
/* Output the text */
3074+
// Output the text
30693075
ctx.move_to( (x - (log_rect.x / Pango.SCALE)), y );
30703076
Utils.set_context_color_with_alpha( ctx, color, _alpha );
30713077
Pango.cairo_show_layout( ctx, _sequence_num.layout );
@@ -3157,14 +3163,14 @@ public class Node : Object {
31573163

31583164
if( folded ) {
31593165

3160-
/* Draw the fold rectangle */
3166+
// Draw the fold rectangle
31613167
Utils.set_context_color_with_alpha( ctx, bg_color, _alpha );
31623168
ctx.new_path();
31633169
ctx.set_line_width( 1 );
31643170
ctx.rectangle( fx, fy, fw, fh );
31653171
ctx.fill();
31663172

3167-
/* Draw circles */
3173+
// Draw circles
31683174
Utils.set_context_color_with_alpha( ctx, fg_color, _alpha );
31693175
ctx.new_path();
31703176
ctx.arc( (fx + (fw / 3)), (fy + (fh / 2)), 2, 0, (2 * Math.PI) );
@@ -3175,7 +3181,7 @@ public class Node : Object {
31753181

31763182
} else if( show_fold ) {
31773183

3178-
/* Draw the fold rectangle */
3184+
// Draw the fold rectangle
31793185
Utils.set_context_color_with_alpha( ctx, fg_color, _alpha );
31803186
ctx.new_path();
31813187
ctx.set_line_width( 2 );
@@ -3198,7 +3204,7 @@ public class Node : Object {
31983204
double x, y, w, h;
31993205
node_bbox( out x, out y, out w, out h );
32003206

3201-
/* Draw highlight border */
3207+
// Draw highlight border
32023208
Utils.set_context_color_with_alpha( ctx, theme.get_color( "attachable" ), _alpha );
32033209
ctx.set_line_width( 4 );
32043210
ctx.rectangle( x, y, w, h );
@@ -3225,7 +3231,7 @@ public class Node : Object {
32253231
var margin = style.node_margin ?? 0;
32263232
var padding = style.node_padding ?? 0;
32273233

3228-
/* Get the parent's link point */
3234+
// Get the parent's link point
32293235
var prev = previous_sibling();
32303236
var link_sibling = parent.sequence && (prev != null);
32313237
if( link_sibling ) {
@@ -3297,7 +3303,7 @@ public class Node : Object {
32973303
}
32983304

32993305

3300-
/* Draw the arrow */
3306+
// Draw the arrow
33013307
if( style.link_arrow ) {
33023308
draw_link_arrow( ctx, theme, tailx, taily, tipx, tipy );
33033309
}
@@ -3324,7 +3330,7 @@ public class Node : Object {
33243330
var x2 = tipx - arrowLength * Math.cos( theta + phi2 );
33253331
var y2 = tipy - arrowLength * Math.sin( theta + phi2 );
33263332

3327-
/* Draw the arrow */
3333+
// Draw the arrow
33283334
Utils.set_context_color_with_alpha( ctx, _link_color, _alpha );
33293335
ctx.set_line_width( 1 );
33303336
ctx.move_to( tipx, tipy );
@@ -3343,7 +3349,7 @@ public class Node : Object {
33433349
// Draw the node resizer area.
33443350
protected virtual void draw_resizer( Context ctx, Theme theme, bool exporting ) {
33453351

3346-
/* Only draw the resizer if we are the current node */
3352+
// Only draw the resizer if we are the current node
33473353
if( ((mode != NodeMode.CURRENT) && (mode != NodeMode.HIGHLIGHTED)) || exporting ) {
33483354
return;
33493355
}
@@ -3399,23 +3405,23 @@ public class Node : Object {
33993405
var nodesel_background = theme.get_color( "nodesel_background" );
34003406
var nodesel_foreground = theme.get_color( "nodesel_foreground" );
34013407

3402-
/* Draw tree_bbox */
3408+
// Draw tree_bbox
34033409
if( is_summarized() || is_summary() ) {
34043410
Utils.set_context_color_with_alpha( ctx, nodesel_background, 0.1 );
34053411
ctx.rectangle( tree_bbox.x, tree_bbox.y, tree_bbox.width, tree_bbox.height );
34063412
ctx.fill();
34073413
}
34083414

3409-
/* Draw bbox */
34103415
/*
3416+
// Draw bbox
34113417
double x, y, w, h;
34123418
bbox( out x, out y, out w, out h );
34133419
Utils.set_context_color_with_alpha( ctx, nodesel_background, 0.1 );
34143420
ctx.rectangle( x, y, w, h );
34153421
ctx.fill();
34163422
*/
34173423

3418-
/* If this is a root node, draw specifically for a root node */
3424+
// If this is a root node, draw specifically for a root node
34193425
if( is_root() ) {
34203426

34213427
var background = theme.get_color( "root_background" );
@@ -3442,7 +3448,7 @@ public class Node : Object {
34423448
draw_resizer( ctx, theme, exporting );
34433449
draw_tags( ctx, theme, exporting );
34443450

3445-
/* Otherwise, draw the node as a non-root node */
3451+
// Otherwise, draw the node as a non-root node
34463452
} else {
34473453

34483454
var background = theme.get_color( "background" );

0 commit comments

Comments
 (0)