Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark square #171

Open
wants to merge 5 commits into
base: github
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions tcl/board.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,7 @@ proc ::board::setmarks {w cmds} {

# Normalize the mark type
switch -glob $type {
"" {set type [expr {[string length $arg2] ? "arrow" : "full"}]}
"" {set type [expr {[string length $arg2] ? "arrow" : "square"}]}
"mark" {set type "full"}
? {set arg2 $type ; set type "text" }
}
Expand Down Expand Up @@ -1220,23 +1220,30 @@ proc ::board::mark::add {win args} {
#
proc ::board::mark::DrawCircle {pathName square color} {
# Some "constants":
set size 0.6 ;# inner (enclosing) box size, 0.0 < $size < 1.0
set width 0.1 ;# outline around circle, 0.0 < $width < 1.0
set size 0.934 ;# inner (enclosing) box size, 0.0 < $size < 1.0
set width 0.066 ;# outline around circle, 0.0 < $width < 1.0

set box [GetBox $pathName $square $size]
lappend pathName create oval [lrange $box 0 3] \
-tag [list mark circle mark$square p$square]
if {$width > 0.5} {
;# too thick, draw a disk instead
lappend pathName -fill $color
} else {
set width [expr {[lindex $box 4] * $width}]
if {$width <= 0.0} {set width 1.0}
lappend pathName -fill "" -outline $color -width $width
}
set width [expr {[lindex $box 4] * $width}]
if {$width <= 0.0} {set width 1.0}
lappend pathName -fill "" -outline $color -width $width
eval $pathName
}

# ::board::mark::DrawSquare --
# draw a rectangle on the square to mark
proc ::board::mark::DrawSquare { pathName square color } {
if {$square < 0 || $square > 63} { return }
set box [GetBox $pathName $square]
set width [expr {[lindex $box 4] * 0.033}]
if {$width <= 0.0} {set width 1.0}
$pathName create rectangle [expr [lindex $box 0] + $width] [expr [lindex $box 1] + $width] \
[expr [lindex $box 2] - $width - 1] [expr [lindex $box 3] - $width - 1] \
-outline $color -width [expr $width + 2] -tag [list mark square mark$square p$square]
}

# ::board::mark::DrawDisk --
#
proc ::board::mark::DrawDisk {pathName square color} {
Expand Down
2 changes: 1 addition & 1 deletion tcl/options.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ set borderwidth 0

# Square markers color and type
set ::markColor green
set ::markType full
set ::markType square

# boardCoords: 1-4 to show board Coordinates, 0 to hide them.
set boardCoords 0
Expand Down
2 changes: 1 addition & 1 deletion tcl/windows/comment.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ proc ::windows::commenteditor::createWin { {focus_if_exists 1} } {
ttk::frame $w_.mf.markers
set i 0
foreach {marker lbl} {
square ☐
full █
circle ◯
disk ⬤
Expand All @@ -200,7 +201,6 @@ proc ::windows::commenteditor::createWin { {focus_if_exists 1} } {
C C
D D
E E
F F
0 0
1 1
2 2
Expand Down