Skip to content

Commit 41c9ef2

Browse files
committed
Fix no source image text drawing off visible area with desktop sized canvas
1 parent f06b7f7 commit 41c9ef2

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

Bender.bmx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Repeat
2828
g_SettingsManager = New SettingsManager()
2929
g_UserInterface = New UserInterface(g_DefaultMaximizeWindow)
3030
g_FileIO = New FileIO()
31-
g_GraphicsOutput = New GraphicsOutput(g_UserInterface.GetMaxWorkspaceWidth())
31+
g_GraphicsOutput = New GraphicsOutput(g_UserInterface.GetMaxWorkspaceWidth(), g_UserInterface.GetCanvasVisibleArea())
3232

3333
'Apply user settings/defaults.
3434
g_UserInterface.SetColorTextboxValues(g_GraphicsOutput.SetBackgroundColor(Int[][g_DefaultBackgroundRed, g_DefaultBackgroundGreen, g_DefaultBackgroundBlue]))
@@ -56,8 +56,9 @@ Repeat
5656
EndSelect
5757
Case EVENT_APPRESUME
5858
ActivateWindow(g_UserInterface.m_MainWindow)
59+
ActivateGadget(g_UserInterface.m_CanvasGraphics)
5960
Case EVENT_WINDOWSIZE
60-
g_UserInterface.ProcessWindowResize()
61+
g_GraphicsOutput.SetCanvasVisibleArea(g_UserInterface.ProcessWindowResize())
6162
Case EVENT_WINDOWACCEPT
6263
g_GraphicsOutput.LoadFile(g_FileIO.SetFileToLoad(EventExtra().ToString()))
6364
Case EVENT_MENUACTION

Types/GraphicsOutput.bmx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Import "LimbManager.bmx"
44
'//// GRAPHICS OUTPUT ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
55

66
Type GraphicsOutput
7+
Field m_CanvasVisibleArea:SVec2I = Null
8+
79
Field m_SourceImage:TImage = Null
810
Field m_SourceImageSize:SVec2I = Null
911

@@ -30,10 +32,11 @@ Type GraphicsOutput
3032

3133
'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
3234

33-
Method New(maxWorkspaceWidth:Int)
35+
Method New(maxWorkspaceWidth:Int, canvasVisibleArea:SVec2I)
3436
SetClsColor(m_BackgroundColor[0], m_BackgroundColor[1], m_BackgroundColor[2])
3537
SetMaskColor(m_Magenta[0], m_Magenta[1], m_Magenta[2])
3638

39+
m_CanvasVisibleArea = canvasVisibleArea
3740
m_MaxInputZoom = Int(FloorF(maxWorkspaceWidth / 192))
3841

3942
m_LimbManager = New LimbManager()
@@ -58,6 +61,12 @@ Type GraphicsOutput
5861
Return False
5962
EndMethod
6063

64+
'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
65+
66+
Method SetCanvasVisibleArea(visibleArea:SVec2I)
67+
m_CanvasVisibleArea = visibleArea
68+
EndMethod
69+
6170
'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6271

6372
Method SetBackgroundColor:Int[](rgbValue:Int[])
@@ -249,7 +258,7 @@ Type GraphicsOutput
249258
SetScale(2, 2)
250259
Local textToDraw:String = "NO IMAGE LOADED!"
251260
Local drawColor:Int[] = [255, 230, 80]
252-
Utility.DrawTextWithShadow(textToDraw, New SVec2I((GraphicsWidth() / 2) - TextWidth(textToDraw), (GraphicsHeight() / 2) - TextHeight(textToDraw)), drawColor)
261+
Utility.DrawTextWithShadow(textToDraw, New SVec2I((m_CanvasVisibleArea[0] / 2) - TextWidth(textToDraw), (m_CanvasVisibleArea[1] / 2) - TextHeight(textToDraw)), drawColor)
253262
SetScale(1, 1)
254263
Flip(1)
255264
EndMethod

Types/UserInterface.bmx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,15 @@ Type UserInterface
178178

179179
'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
180180

181-
Method ProcessWindowResize()
181+
Method ProcessWindowResize:SVec2I()
182182
ResizeGadget(m_LeftColumn, GadgetWidth(m_LeftColumn), GadgetHeight(m_MainWindow))
183183
MoveGadget(m_LogoImagePanel, 0, GadgetHeight(m_MainWindow) - m_LogoImagePanelSize[1])
184184

185185
'Have to recreate the canvas because the backbuffer doesn't resize with the window.
186186
'FreeGadget(m_CanvasGraphics)
187187
'InitializeCanvasGraphics()
188+
189+
Return GetCanvasVisibleArea()
188190
EndMethod
189191

190192
'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -193,6 +195,12 @@ Type UserInterface
193195
Return DesktopWidth() - m_LeftColumnSize[0]
194196
EndMethod
195197

198+
'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
199+
200+
Method GetCanvasVisibleArea:SVec2I()
201+
Return New SVec2I(GadgetWidth(m_MainWindow) - m_LeftColumnSize[0], GadgetHeight(m_MainWindow))
202+
EndMethod
203+
196204
'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
197205

198206
Method GetColorTextboxValues:Int[]()

0 commit comments

Comments
 (0)