Tk Source Code

Ticket Change Details
Login
Overview

Artifact ID: 7de3d964b3b588d747af9451a5a99eca29ee4d5a
Ticket: e9a842a3c584d6e709398529863fb8f798c83e3c
TkCanvas events search for all objects , even they are not displayed
User & Date: arjenmarkus 2013-12-28 14:45:22
Changes

  1. icomment:
    I have attached a first patch that implements the ideas from Nataraja's original patch, but without using an aditional list or additional fields (merely using two bits in the existing structures).
    
    The patch is not complete yet:
    - No documentation
    - Only rectangles and ovals affected
    
    Here is the program I used to test it:
    
    # chkoptim.tcl --
    #     Incrementally check the adaptation of the canvas widget to the patch
    #
    
    #
    # Step 1: option -suppresssmallitems is properly recognised
    #
    package require Tk
    #console show
    pack [canvas .c -suppresssmallitems 1 -width 400 -height 400]
    puts [.c cget -suppresssmallitems]
    
    #
    # Step 2: create large and small rectangles
    #
    .c create rectangle  10  10  20  20 -tag {RECT LARGE}
    .c create rectangle 101 101 102 102 -tag {RECT SMALL}
    
    .c scale SMALL 100 100 0.1 0.1
    
    catch {
        console show
    }
    #puts "Suppress on:  [.c find withtag SMALL]"
    #after 2000 {
    #   .c configure -suppresssmallitems 0
    #   puts "Suppress off: [.c find withtag SMALL]"
    #}
    
    #
    # Step 3: create a large number of (small) rectangles and measure the
    #         time it takes to draw them
    #
    for {set i 0} {$i < 1000000} {incr i} {
        set x [expr {rand()*400}]
        set y [expr {rand()*400}]
    
        set id [.c create rectangle $x $y [expr {$x+0.1}] [expr {$y+0.1}]]
        #.c scale $id 0 0 1 1
    }
    
    after 1000 {
        .c configure -suppresssmallitems 1
        set id [.c create rectangle 0 0 400 400 -fill white]
        .c create rectangle 10 200 20 210 -fill yellow -width 3
        after 100 {
            .c delete $id
        }
    }
    
  2. login: "arjenmarkus"
  3. mimetype: "text/plain"