From 8f9655b44f013c356ac4ac469a4fae5b8599ea1d Mon Sep 17 00:00:00 2001 From: Uwe Date: Sun, 10 Mar 2024 09:45:13 +0100 Subject: [PATCH 01/11] Popup the position when clicking right mouse button on a score in the score graph --- tcl/tools/graphs.tcl | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tcl/tools/graphs.tcl b/tcl/tools/graphs.tcl index 0cb6f7870..cf46ec3e6 100644 --- a/tcl/tools/graphs.tcl +++ b/tcl/tools/graphs.tcl @@ -669,6 +669,8 @@ proc ::tools::graphs::score::Refresh { {docreate 1 }} { ::utils::graph::redraw score } bind $w.c <1> {::tools::graphs::score::Move %x} + bind $w.c {::tools::graphs::score::Popup %x %X %Y} + bind $w.c { if {[winfo exists .scorePopup]} {wm withdraw .scorePopup} } wm title $w "Scid: [tr ToolsScore]" ::createToplevelFinalize $w ::tools::graphs::score::ConfigMenus @@ -756,6 +758,15 @@ proc ::tools::graphs::score::Move {xc} { updateBoard } +proc ::tools::graphs::score::Popup {mc xc yc} { + set x [expr {round([::utils::graph::xunmap score $mc] * 2 + 0.5)} ] + sc_game push copyfast + sc_move start + sc_move forward $x + set bd [sc_pos board] + sc_game pop + ::board::popup .scorePopup $bd $xc $yc +} #################### # Rating graph From 473c55c20f61e4428bc821ea217902d591db6f1e Mon Sep 17 00:00:00 2001 From: Uwe Date: Sun, 10 Mar 2024 10:38:05 +0100 Subject: [PATCH 02/11] Use theme style for score graph canvas --- tcl/tools/graphs.tcl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tcl/tools/graphs.tcl b/tcl/tools/graphs.tcl index cf46ec3e6..9dbfcfc3d 100644 --- a/tcl/tools/graphs.tcl +++ b/tcl/tools/graphs.tcl @@ -642,7 +642,8 @@ proc ::tools::graphs::score::Refresh { {docreate 1 }} { -variable ::tools::graphs::score::$i -offvalue "0" -onvalue "1" \ -command "::tools::graphs::score::Refresh" } - canvas $w.c -width 500 -height 300 -selectforeground [ttk::style lookup . -foreground] -background [ttk::style lookup . -background] + canvas $w.c -width 500 -height 300 + applyThemeStyle . $w.c $w.c create text 25 5 -tag text -justify center -width 1 \ -font font_Regular -anchor n @@ -700,8 +701,8 @@ proc ::tools::graphs::score::Refresh { {docreate 1 }} { } ::utils::graph::create score -width $width -height $height -xtop 25 -ytop 25 \ - -ytick $yticks -xtick 5 -font font_Small -canvas $w.c -textcolor black \ - -hline [list [list gray80 1 each $yticks ]] \ + -ytick $yticks -xtick 5 -font font_Small -canvas $w.c -textcolor [ttk::style lookup $w.c -foreground]\ + -hline [list [list gray80 1 each $yticks ]] -background [ttk::style lookup $w.c -background]\ -vline {{gray80 1 each 1} {steelBlue 1 each 5}} # Create fake dataset with bounds so we see at least -1.0 to 1.0: From 27db83a9c35a98feeec40a290d4d40986b72a946 Mon Sep 17 00:00:00 2001 From: Uwe Date: Sun, 10 Mar 2024 10:52:10 +0100 Subject: [PATCH 03/11] Use canvas foreground for text --- tcl/tools/graphs.tcl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tcl/tools/graphs.tcl b/tcl/tools/graphs.tcl index 9dbfcfc3d..ad33ded8d 100644 --- a/tcl/tools/graphs.tcl +++ b/tcl/tools/graphs.tcl @@ -713,7 +713,8 @@ proc ::tools::graphs::score::Refresh { {docreate 1 }} { set blackelo [sc_game tag get BlackElo] if {$whiteelo == 0} {set whiteelo ""} else {set whiteelo "($whiteelo)"} if {$blackelo == 0} {set blackelo ""} else {set blackelo "($blackelo)"} - $w.c itemconfigure text -text "[sc_game info white]$whiteelo - [sc_game info black]$blackelo [sc_game info site] [sc_game info date]" + $w.c itemconfigure text -fill [ttk::style lookup $w.c -foreground] \ + -text "[sc_game info white]$whiteelo - [sc_game info black]$blackelo [sc_game info site] [sc_game info date]" busyCursor $w update From 70e2632bb8d04513da10a821ad8a979304eeb3d6 Mon Sep 17 00:00:00 2001 From: Uwe Date: Sun, 10 Mar 2024 11:14:35 +0100 Subject: [PATCH 04/11] color adjustment --- tcl/tools/graphs.tcl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tcl/tools/graphs.tcl b/tcl/tools/graphs.tcl index ad33ded8d..16eae37f6 100644 --- a/tcl/tools/graphs.tcl +++ b/tcl/tools/graphs.tcl @@ -612,8 +612,8 @@ proc ::tools::graphs::MoveScoreList { invw invb } { proc ::tools::graphs::score::Refresh { {docreate 1 }} { set linecolor red - set firstColor darkgreen - set secondColor blue + set firstColor green + set secondColor dodgerblue3 set linewidth 2 set psize 2 From 2b049ba449c7bee60d8561c5513af7ac5cb40674 Mon Sep 17 00:00:00 2001 From: Uwe Date: Sat, 13 Apr 2024 14:49:03 +0200 Subject: [PATCH 05/11] Show popup board on mouse over than on right mouse button --- tcl/tools/graphs.tcl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tcl/tools/graphs.tcl b/tcl/tools/graphs.tcl index 16eae37f6..34dad5c3a 100644 --- a/tcl/tools/graphs.tcl +++ b/tcl/tools/graphs.tcl @@ -670,8 +670,8 @@ proc ::tools::graphs::score::Refresh { {docreate 1 }} { ::utils::graph::redraw score } bind $w.c <1> {::tools::graphs::score::Move %x} - bind $w.c {::tools::graphs::score::Popup %x %X %Y} - bind $w.c { if {[winfo exists .scorePopup]} {wm withdraw .scorePopup} } + bind $w.c {::tools::graphs::score::Popup %x %X %Y} + bind $w.c { if {[winfo exists .scorePopup]} {wm withdraw .scorePopup} } wm title $w "Scid: [tr ToolsScore]" ::createToplevelFinalize $w ::tools::graphs::score::ConfigMenus From be68d04fcbfda47795251709c6fc11878586835d Mon Sep 17 00:00:00 2001 From: Uwe Date: Sat, 13 Apr 2024 16:33:54 +0200 Subject: [PATCH 06/11] replace sc_game push/sc_game pop with a move list --- tcl/tools/graphs.tcl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tcl/tools/graphs.tcl b/tcl/tools/graphs.tcl index 34dad5c3a..f4d7ae0c0 100644 --- a/tcl/tools/graphs.tcl +++ b/tcl/tools/graphs.tcl @@ -579,6 +579,7 @@ proc MoveTimeList {color add} { proc ::tools::graphs::MoveScoreList { invw invb } { set moveScores { } set mainline { } + set ::tools::graphs::score::Moves { } set base [sc_base current] set gnum [sc_game number] set game [sc_base getGame $base $gnum live] @@ -590,6 +591,7 @@ proc ::tools::graphs::MoveScoreList { invw invb } { # only search in the mainline if { $RAVd == 0 && $RAVn == 0} { lappend mainline [lindex [lindex $game $i] 4] + lappend ::tools::graphs::score::Moves [lindex [lindex $game $i] 5] } } set movenr 0.0 @@ -762,11 +764,10 @@ proc ::tools::graphs::score::Move {xc} { proc ::tools::graphs::score::Popup {mc xc yc} { set x [expr {round([::utils::graph::xunmap score $mc] * 2 + 0.5)} ] - sc_game push copyfast - sc_move start - sc_move forward $x - set bd [sc_pos board] - sc_game pop + if { $x < 1 } { return } + set bd [sc_pos board "position startpos moves" [lrange $::tools::graphs::score::Moves 0 $x]] + set label "[expr int(($x+1) / 2)]. " + if { ! [expr $x % 2] } { append label "... " } ::board::popup .scorePopup $bd $xc $yc } From 4392beb47f6c7586a5fffc3ee4bb69310f1bd10d Mon Sep 17 00:00:00 2001 From: Uwe Date: Sat, 13 Apr 2024 16:47:59 +0200 Subject: [PATCH 07/11] Add evaluation info to popup widget Popup function is copied from board::popup. Maybe this should improved. --- tcl/tools/graphs.tcl | 49 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/tcl/tools/graphs.tcl b/tcl/tools/graphs.tcl index f4d7ae0c0..a573b9c81 100644 --- a/tcl/tools/graphs.tcl +++ b/tcl/tools/graphs.tcl @@ -580,6 +580,7 @@ proc ::tools::graphs::MoveScoreList { invw invb } { set moveScores { } set mainline { } set ::tools::graphs::score::Moves { } + set ::tools::graphs::score::Evals [list {}] set base [sc_base current] set gnum [sc_game number] set game [sc_base getGame $base $gnum live] @@ -598,6 +599,7 @@ proc ::tools::graphs::MoveScoreList { invw invb } { set side 0 for {set i 1} { $i < $n} { incr i } { set comment [lindex $mainline $i] + lappend ::tools::graphs::score::Evals [getScorefromComment $comment 200] set score [getScorefromComment $comment $::tools::graphs::score::MaxY] if { $score ne "" } { @@ -672,7 +674,7 @@ proc ::tools::graphs::score::Refresh { {docreate 1 }} { ::utils::graph::redraw score } bind $w.c <1> {::tools::graphs::score::Move %x} - bind $w.c {::tools::graphs::score::Popup %x %X %Y} + bind $w.c {::tools::graphs::score::ShowEvalDetails %x %X %Y} bind $w.c { if {[winfo exists .scorePopup]} {wm withdraw .scorePopup} } wm title $w "Scid: [tr ToolsScore]" ::createToplevelFinalize $w @@ -762,13 +764,54 @@ proc ::tools::graphs::score::Move {xc} { updateBoard } -proc ::tools::graphs::score::Popup {mc xc yc} { +proc ::tools::graphs::score::Popup {w positionLongStr label xc yc {above ""}} { + if {! [winfo exists $w]} { + toplevel $w + wm overrideredirect $w 1 + ttk::label $w.l + grid $w.l -sticky we -row 0 + ::board::new $w.bd 30 + grid $w.bd -row 1 + ::update idletasks + } + $w.l configure -text $label + lassign $positionLongStr pos lastmove + ::board::update $w.bd $pos + + if {$lastmove ne ""} { + ::board::lastMoveHighlight $w.bd $lastmove + } + # Make sure the popup window can fit on the screen: + set screenwidth [winfo screenwidth $w] + set screenheight [winfo screenheight $w] + set dx [winfo width $w] + set dy [winfo height $w] + incr xc 8 + if {($xc+$dx) > $screenwidth} { + set xc [expr {$screenwidth - $dx}] + } + if {($yc+$dy) > ($screenheight -8)} { + set above 1 + } + if {$above ne ""} { + set yc [expr { $yc -$dy -8 }] + if {$yc < 0} { set yc 0 } + } else { + incr yc 8 + } + wm geometry $w "+$xc+$yc" + wm deiconify $w + raiseWin $w +} + +proc ::tools::graphs::score::ShowEvalDetails {mc xc yc} { set x [expr {round([::utils::graph::xunmap score $mc] * 2 + 0.5)} ] if { $x < 1 } { return } set bd [sc_pos board "position startpos moves" [lrange $::tools::graphs::score::Moves 0 $x]] set label "[expr int(($x+1) / 2)]. " if { ! [expr $x % 2] } { append label "... " } - ::board::popup .scorePopup $bd $xc $yc + append label "[lindex $::tools::graphs::score::Moves $x]\nEvaluation: [lindex $::tools::graphs::score::Evals $x]" + ::tools::graphs::score::Popup .scorePopup $bd $label $xc $yc } #################### From 136e6aed297bd94a0b07fdd61aa170f99a853f3f Mon Sep 17 00:00:00 2001 From: Uwe Date: Sun, 14 Apr 2024 09:32:00 +0200 Subject: [PATCH 08/11] use fen string instead of startpos for sc_pos --- tcl/tools/graphs.tcl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tcl/tools/graphs.tcl b/tcl/tools/graphs.tcl index a573b9c81..0d2d854b6 100644 --- a/tcl/tools/graphs.tcl +++ b/tcl/tools/graphs.tcl @@ -585,6 +585,7 @@ proc ::tools::graphs::MoveScoreList { invw invb } { set gnum [sc_game number] set game [sc_base getGame $base $gnum live] set n [llength $game] + set ::tools::graphs::score::startFen [lindex [lindex $game 0] 2] set movenr 0 for {set i 0} { $i < $n} { incr i } { set RAVd [lindex [lindex $game $i] 0] @@ -807,7 +808,7 @@ proc ::tools::graphs::score::Popup {w positionLongStr label xc yc {above ""}} { proc ::tools::graphs::score::ShowEvalDetails {mc xc yc} { set x [expr {round([::utils::graph::xunmap score $mc] * 2 + 0.5)} ] if { $x < 1 } { return } - set bd [sc_pos board "position startpos moves" [lrange $::tools::graphs::score::Moves 0 $x]] + set bd [sc_pos board "position fen $::tools::graphs::score::startFen moves" [lrange $::tools::graphs::score::Moves 0 $x]] set label "[expr int(($x+1) / 2)]. " if { ! [expr $x % 2] } { append label "... " } append label "[lindex $::tools::graphs::score::Moves $x]\nEvaluation: [lindex $::tools::graphs::score::Evals $x]" From e361c52d285f8a68760652837a752d15875589ff Mon Sep 17 00:00:00 2001 From: Uwe Date: Sat, 26 Oct 2024 23:52:40 +0200 Subject: [PATCH 09/11] Show move and evaluation in one line --- tcl/tools/graphs.tcl | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/tcl/tools/graphs.tcl b/tcl/tools/graphs.tcl index 0d2d854b6..faabb76ec 100644 --- a/tcl/tools/graphs.tcl +++ b/tcl/tools/graphs.tcl @@ -765,19 +765,23 @@ proc ::tools::graphs::score::Move {xc} { updateBoard } -proc ::tools::graphs::score::Popup {w positionLongStr label xc yc {above ""}} { +proc ::tools::graphs::score::Popup {w positionLongStr textleft textright xc yc {above ""}} { if {! [winfo exists $w]} { toplevel $w + ::applyThemeColor_background $w wm overrideredirect $w 1 ttk::label $w.l - grid $w.l -sticky we -row 0 + grid $w.l -sticky w -row 0 -column 0 + ttk::label $w.r + grid $w.r -sticky e -row 0 -column 1 ::board::new $w.bd 30 - grid $w.bd -row 1 + grid $w.bd -row 1 -columnspan 2 ::update idletasks } - $w.l configure -text $label + $w.l configure -text $textleft + $w.r configure -text $textright lassign $positionLongStr pos lastmove - ::board::update $w.bd $pos + catch { ::board::update $w.bd $pos } if {$lastmove ne ""} { ::board::lastMoveHighlight $w.bd $lastmove @@ -807,12 +811,12 @@ proc ::tools::graphs::score::Popup {w positionLongStr label xc yc {above ""}} { proc ::tools::graphs::score::ShowEvalDetails {mc xc yc} { set x [expr {round([::utils::graph::xunmap score $mc] * 2 + 0.5)} ] - if { $x < 1 } { return } + if { $x < 1 || [llength $::tools::graphs::score::Moves] < 2 } { return } set bd [sc_pos board "position fen $::tools::graphs::score::startFen moves" [lrange $::tools::graphs::score::Moves 0 $x]] set label "[expr int(($x+1) / 2)]. " if { ! [expr $x % 2] } { append label "... " } - append label "[lindex $::tools::graphs::score::Moves $x]\nEvaluation: [lindex $::tools::graphs::score::Evals $x]" - ::tools::graphs::score::Popup .scorePopup $bd $label $xc $yc + append label "[lindex $::tools::graphs::score::Moves $x]" + ::tools::graphs::score::Popup .scorePopup $bd $label "Eval.: [lindex $::tools::graphs::score::Evals $x]" $xc $yc } #################### From e02f3aee429dac5ce2e7872223278a358d15d210 Mon Sep 17 00:00:00 2001 From: Uwe Date: Sun, 27 Oct 2024 11:36:26 +0100 Subject: [PATCH 10/11] ::tools::graphs::score::Popup replaced by ::board:popup board::popup extend with an optional textline above the board --- tcl/board.tcl | 13 +++++++++++-- tcl/tools/graphs.tcl | 46 +------------------------------------------- 2 files changed, 12 insertions(+), 47 deletions(-) diff --git a/tcl/board.tcl b/tcl/board.tcl index 59777402d..dac7bb472 100644 --- a/tcl/board.tcl +++ b/tcl/board.tcl @@ -385,18 +385,27 @@ proc ::board::san {sqno} { # Show a pop-up board. # xc and yc are the coordinates of the top-left corner, or the bottom-left # corner if above is not "". -proc ::board::popup {w positionLongStr xc yc {above ""}} { +proc ::board::popup {w positionLongStr xc yc {above ""} {textleft "" } {textright ""}} { set psize 30 if {$psize > $::boardSize} { set psize $::boardSize } if {! [winfo exists $w]} { toplevel $w wm overrideredirect $w 1 + ::applyThemeColor_background $w + ttk::label $w.l + ttk::label $w.r + if { $textleft ne "" || $textright ne "" } { + grid $w.l -sticky w -row 0 -column 0 + grid $w.r -sticky e -row 0 -column 1 + } ::board::new $w.bd $psize - grid $w.bd + grid $w.bd -row 1 -columnspan 2 ::update idletasks } + $w.l configure -text $textleft + $w.r configure -text $textright lassign $positionLongStr pos lastmove ::board::update $w.bd $pos diff --git a/tcl/tools/graphs.tcl b/tcl/tools/graphs.tcl index faabb76ec..40810fe06 100644 --- a/tcl/tools/graphs.tcl +++ b/tcl/tools/graphs.tcl @@ -765,50 +765,6 @@ proc ::tools::graphs::score::Move {xc} { updateBoard } -proc ::tools::graphs::score::Popup {w positionLongStr textleft textright xc yc {above ""}} { - if {! [winfo exists $w]} { - toplevel $w - ::applyThemeColor_background $w - wm overrideredirect $w 1 - ttk::label $w.l - grid $w.l -sticky w -row 0 -column 0 - ttk::label $w.r - grid $w.r -sticky e -row 0 -column 1 - ::board::new $w.bd 30 - grid $w.bd -row 1 -columnspan 2 - ::update idletasks - } - $w.l configure -text $textleft - $w.r configure -text $textright - lassign $positionLongStr pos lastmove - catch { ::board::update $w.bd $pos } - - if {$lastmove ne ""} { - ::board::lastMoveHighlight $w.bd $lastmove - } - # Make sure the popup window can fit on the screen: - set screenwidth [winfo screenwidth $w] - set screenheight [winfo screenheight $w] - set dx [winfo width $w] - set dy [winfo height $w] - incr xc 8 - if {($xc+$dx) > $screenwidth} { - set xc [expr {$screenwidth - $dx}] - } - if {($yc+$dy) > ($screenheight -8)} { - set above 1 - } - if {$above ne ""} { - set yc [expr { $yc -$dy -8 }] - if {$yc < 0} { set yc 0 } - } else { - incr yc 8 - } - wm geometry $w "+$xc+$yc" - wm deiconify $w - raiseWin $w -} - proc ::tools::graphs::score::ShowEvalDetails {mc xc yc} { set x [expr {round([::utils::graph::xunmap score $mc] * 2 + 0.5)} ] if { $x < 1 || [llength $::tools::graphs::score::Moves] < 2 } { return } @@ -816,7 +772,7 @@ proc ::tools::graphs::score::ShowEvalDetails {mc xc yc} { set label "[expr int(($x+1) / 2)]. " if { ! [expr $x % 2] } { append label "... " } append label "[lindex $::tools::graphs::score::Moves $x]" - ::tools::graphs::score::Popup .scorePopup $bd $label "Eval.: [lindex $::tools::graphs::score::Evals $x]" $xc $yc + ::board::popup .scorePopup $bd $xc $yc "" "$label" "Eval.: [lindex $::tools::graphs::score::Evals $x]" } #################### From 1efdd28e37374e0f07d5f566aa23c84731d0a5b8 Mon Sep 17 00:00:00 2001 From: Uwe Date: Sun, 27 Oct 2024 11:47:33 +0100 Subject: [PATCH 11/11] Do not show empty evaluation score --- tcl/tools/graphs.tcl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tcl/tools/graphs.tcl b/tcl/tools/graphs.tcl index 40810fe06..7f002a673 100644 --- a/tcl/tools/graphs.tcl +++ b/tcl/tools/graphs.tcl @@ -769,10 +769,13 @@ proc ::tools::graphs::score::ShowEvalDetails {mc xc yc} { set x [expr {round([::utils::graph::xunmap score $mc] * 2 + 0.5)} ] if { $x < 1 || [llength $::tools::graphs::score::Moves] < 2 } { return } set bd [sc_pos board "position fen $::tools::graphs::score::startFen moves" [lrange $::tools::graphs::score::Moves 0 $x]] - set label "[expr int(($x+1) / 2)]. " + set labelL "[expr int(($x+1) / 2)]. " if { ! [expr $x % 2] } { append label "... " } - append label "[lindex $::tools::graphs::score::Moves $x]" - ::board::popup .scorePopup $bd $xc $yc "" "$label" "Eval.: [lindex $::tools::graphs::score::Evals $x]" + append labelL "[lindex $::tools::graphs::score::Moves $x]" + set labelR "" + set eval [lindex $::tools::graphs::score::Evals $x] + if { $eval ne "" } { set labelR "Eval.: $eval" } + ::board::popup .scorePopup $bd $xc $yc "" $labelL $labelR } ####################