@@ -29,6 +29,10 @@ Source information and contacts persons can be found at
2929#include " ../puzzlehandler.hpp"
3030
3131
32+ PuzzleEditorState::PuzzleEditorState () {
33+ this ->window_resize = sago::SagoLogicalResize (BOARD_WIDTH+5 , BOARD_HEIGHT+5 );
34+ }
35+
3236bool PuzzleEditorState::IsActive () {
3337 return isActive;
3438}
@@ -48,21 +52,51 @@ void PuzzleEditorState::SelectFile(const std::string& file) {
4852 LoadPuzzleStages ();
4953}
5054
55+ static void LogicalToPhysical (const sago::SagoLogicalResize& resize, ImVec2& inout) {
56+ int inx = inout.x ;
57+ int iny = inout.y ;
58+ int outx = inout.x ;
59+ int outy = inout.y ;
60+ resize.LogicalToPhysical (inx, iny, outx, outy);
61+ inout.x = outx;
62+ inout.y = outy;
63+ }
64+
5165void PuzzleEditorState::Draw (SDL_Renderer* target) {
5266 DrawBackground (target);
5367
5468 ImGui::Begin (" Board area" );
5569 ImGui::BeginChild (" Test" );
5670 ImVec2 p = ImGui::GetCursorScreenPos ();
57- float xoffset = p.x ;
58- float yoffset = p.y ;
59- float height = BOARD_HEIGHT;
60- float width = BOARD_WIDTH;
71+ ImVec2 size = ImGui::GetContentRegionAvail ();
72+ int xoffset = p.x ;
73+ int yoffset = p.y ;
74+ int height = BOARD_HEIGHT;
75+ int width = BOARD_WIDTH;
76+ window_resize.SetPhysicalSize (size.x , size.y );
77+
78+
6179 for (int i=0 ; i <= 6 ;++i) {
62- ImGui::GetWindowDrawList ()->AddLine (ImVec2 (i*50 .0f +xoffset, yoffset), ImVec2 (i*50 .0f +xoffset, height+yoffset), IM_COL32 (255 , 0 , 0 , 100 ));
80+ ImVec2 p1 (i*50 .0f , 0 );
81+ ImVec2 p2 (i*50 .0f , height);
82+ LogicalToPhysical (window_resize, p1);
83+ LogicalToPhysical (window_resize, p2);
84+ p1.x += xoffset;
85+ p1.y += yoffset;
86+ p2.x += xoffset;
87+ p2.y += yoffset;
88+ ImGui::GetWindowDrawList ()->AddLine (p1, p2, IM_COL32 (255 , 0 , 0 , 100 ));
6389 }
6490 for (int i=0 ; i <= 12 ;++i) {
65- ImGui::GetWindowDrawList ()->AddLine (ImVec2 (xoffset,yoffset+i*50 .0f ), ImVec2 (xoffset+width, yoffset+i*50 .0f ), IM_COL32 (255 , 0 , 0 , 100 ));
91+ ImVec2 p1 (0 ,i*50 .0f );
92+ ImVec2 p2 (width, i*50 .0f );
93+ LogicalToPhysical (window_resize, p1);
94+ LogicalToPhysical (window_resize, p2);
95+ p1.x += xoffset;
96+ p1.y += yoffset;
97+ p2.x += xoffset;
98+ p2.y += yoffset;
99+ ImGui::GetWindowDrawList ()->AddLine (p1, p2, IM_COL32 (255 , 0 , 0 , 100 ));
66100 }
67101 ImGui::EndChild ();
68102 ImGui::End ();
0 commit comments