From 5b58d76864b482d7c89bbebc0ed3f0d8c4981f53 Mon Sep 17 00:00:00 2001 From: gambas Date: Wed, 10 Nov 2021 01:36:33 +0100 Subject: [PATCH] Form editor: Draw the red border of containers in a more logical way. [DEVELOPMENT ENVIRONMENT] * NEW: Form editor: Draw the red border of containers in a more logical way. --- .../gambas3/.src/Editor/Code/FCompletion.form | 2 +- .../gambas3/.src/Editor/Form/CControl.class | 9 ++-- app/src/gambas3/.src/Editor/Form/FForm.class | 2 +- app/src/gambas3/.src/Editor/Form/FForm.form | 8 ++-- app/src/gambas3/.src/FMain.form | 4 +- app/src/gambas3/.src/Family/CFamily.class | 45 +++++++++++++++---- .../.src/Family/Form/CFamilyForm.class | 13 ++++-- .../.src/Family/WebForm/CFamilyWebForm.class | 2 +- .../.src/Family/WebForm/WebformWebMenu.class | 2 +- 9 files changed, 60 insertions(+), 27 deletions(-) diff --git a/app/src/gambas3/.src/Editor/Code/FCompletion.form b/app/src/gambas3/.src/Editor/Code/FCompletion.form index e2d896703..e9441d7f7 100644 --- a/app/src/gambas3/.src/Editor/Code/FCompletion.form +++ b/app/src/gambas3/.src/Editor/Code/FCompletion.form @@ -23,7 +23,7 @@ MoveScaled(9,1,0,13) } { hvwHelp HelpView - MoveScaled(16,2,25,11) + MoveScaled(16,2,27,11) Expand = True Border = False } diff --git a/app/src/gambas3/.src/Editor/Form/CControl.class b/app/src/gambas3/.src/Editor/Form/CControl.class index c434749ab..dc5593dcd 100644 --- a/app/src/gambas3/.src/Editor/Form/CControl.class +++ b/app/src/gambas3/.src/Editor/Form/CControl.class @@ -478,7 +478,6 @@ Public Sub HasProperty(sProp As String) As Boolean End - Private Function GetRealValue(hProp As CPropertyInfo, vVal As Variant) As Variant Dim vRealVal As Variant @@ -620,10 +619,10 @@ Public Function SetProperty(sProp As String, vVal As Variant, Optional bDoNotApp If bDoNotApply Then Goto _DO_NOT_APPLY - If Control Is DrawingArea Or If IsContainer() Then - If sProp = "Enabled" Then - Goto _DO_NOT_APPLY - Endif + If Control Is DrawingArea Then + If sProp = "Enabled" Or If sProp = "Border" Then Goto _DO_NOT_APPLY + Else If IsContainer() Then + If sProp = "Enabled" Then Goto _DO_NOT_APPLY Endif If Unknown Then diff --git a/app/src/gambas3/.src/Editor/Form/FForm.class b/app/src/gambas3/.src/Editor/Form/FForm.class index eb7644411..0d5bbc996 100644 --- a/app/src/gambas3/.src/Editor/Form/FForm.class +++ b/app/src/gambas3/.src/Editor/Form/FForm.class @@ -2696,7 +2696,7 @@ Public Sub Control_Draw(...) 'Paint.FillRect(0, 0, DS * 2, DS * 2, Color.Red) Paint.Fill Endif - + $hFamily.DrawControl(hCCtrl) Endif diff --git a/app/src/gambas3/.src/Editor/Form/FForm.form b/app/src/gambas3/.src/Editor/Form/FForm.form index b3c8e7978..6519a1292 100644 --- a/app/src/gambas3/.src/Editor/Form/FForm.form +++ b/app/src/gambas3/.src/Editor/Form/FForm.form @@ -670,25 +670,25 @@ Name = "panRight" MoveScaled(8,16,1,1) Background = Color.TextBackground - Mouse = Mouse.SizeE + Mouse = Cursor.SizeE Border = Border.Plain } { panDown Panel Handle Name = "panDown" MoveScaled(6,18,1,1) Background = Color.TextBackground - Mouse = Mouse.SizeS + Mouse = Cursor.SizeS Border = Border.Plain } { panRightDown Panel Handle Name = "panRightDown" MoveScaled(8,18,1,1) Background = Color.TextBackground - Mouse = Mouse.SizeNWSE + Mouse = Cursor.SizeNWSE Border = Border.Plain } { panBorder DrawingArea - MoveScaled(29,13,24,24) + MoveScaled(25,14,24,24) Background = Color.Background { panSelectN DrawingArea panSelect Name = "panSelectN" diff --git a/app/src/gambas3/.src/FMain.form b/app/src/gambas3/.src/FMain.form index 355d69665..9d497553e 100644 --- a/app/src/gambas3/.src/FMain.form +++ b/app/src/gambas3/.src/FMain.form @@ -1303,7 +1303,7 @@ { dwgBranchColor DrawingArea MoveScaled(0,0,5,4) Visible = False - Mouse = Mouse.Pointing + Mouse = Cursor.Pointing Expand = True } { btnVcChanges ToolButton @@ -1446,7 +1446,7 @@ Separator = True Transparent = True { panImageProperty Panel - MoveScaled(8,3,16,14) + MoveScaled(9,2,16,14) Expand = True Arrangement = Arrange.Fill } diff --git a/app/src/gambas3/.src/Family/CFamily.class b/app/src/gambas3/.src/Family/CFamily.class index bc624bd47..864d110f5 100644 --- a/app/src/gambas3/.src/Family/CFamily.class +++ b/app/src/gambas3/.src/Family/CFamily.class @@ -76,11 +76,21 @@ End '' Return TRUE if the control is not managed: then a default frame with the control icon and the control name will be drawn. Public Sub DrawControl(hCtrl As CControl) As Boolean - If TypeOf(hCtrl["Border"]) = gb.Boolean And If hCtrl["Border"] Then - Paint.DrawRect(Paint.X, Paint.Y, Paint.W, Paint.H, Color.LightForeground) - Else If hCtrl Is Container Then - PaintContainer(Paint.X, Paint.Y, Paint.W, Paint.H) + If hCtrl.IsContainer() Then + PaintContainer(hCtrl) + Else If hCtrl.HasProperty("Border") Then + If hCtrl["Border"] Then + Paint.DrawRect(Paint.X, Paint.Y, Paint.W, Paint.H, Color.LightForeground) + Else + Paint.Dash = [1] + 'Paint.DrawRect(Paint.X, Paint.Y, Paint.W, Paint.H, Color.LightForeground) + Paint.Background = Color.LightForeground + Paint.Rectangle(Paint.X, Paint.Y, Paint.W, Paint.H) + Paint.Stroke + Paint.Dash = Null + Endif Endif + PaintIcon(hCtrl) End @@ -514,9 +524,25 @@ Public Sub SelectAudio((sPropertyType) As String, sAudio As String) As String End -Static Public Sub PaintContainer(X As Float, Y As Float, W As Float, H As Float) +Static Public Sub PaintContainer(hCCtrl As CControl, Optional X As Float = Paint.X, Y As Float = Paint.Y, W As Float = Paint.W, H As Float = Paint.H) - Paint.DrawRect(X, Y, W, H, Color.SetAlpha(&HFF8080, 128)) + Dim iCol As Integer + + If W < 1 Or If H < 1 Then Return + + If hCCtrl And If hCCtrl.HasProperty("Border") And If hCCtrl.GetPropertyReal("Border") Then + Paint.DrawRect(X, Y, W, H, Color.LightForeground) + If W < 3 Or If H < 3 Then Return + Inc X + Inc Y + W -= 2 + H -= 2 + iCol = &HFF8080 + Else + iCol = Color.SetAlpha(&HFF8080, 128) + Endif + + Paint.DrawRect(X, Y, W, H, iCol) End @@ -677,12 +703,15 @@ Static Public Sub PaintIcon(hCtrl As CControl) Dim DS As Integer Dim hPict As Picture + Dim W As Float + Paint.Background = Color.TextForeground DS = Desktop.Scale hPict = Picture[".control" &/ LCase(hCtrl.Kind)] If hPict Then - Paint.DrawPicture(hPict, DS, DS, DS * 4, DS * 4) - Paint.DrawText(hCtrl.Name, DS * 6, DS, Paint.W, Paint.H, Align.TopLeft) + W = DS * 4 * hPict.Width / hPict.Height + Paint.DrawPicture(hPict, DS, DS, W, DS * 4) + Paint.DrawText(hCtrl.Name, CInt(W + DS * 2), DS, Paint.W, Paint.H, Align.TopLeft) Else Paint.DrawText(hCtrl.Name, DS, DS, Paint.W, Paint.H, Align.TopLeft) Endif diff --git a/app/src/gambas3/.src/Family/Form/CFamilyForm.class b/app/src/gambas3/.src/Family/Form/CFamilyForm.class index 3dc4a403f..951e95b0a 100644 --- a/app/src/gambas3/.src/Family/Form/CFamilyForm.class +++ b/app/src/gambas3/.src/Family/Form/CFamilyForm.class @@ -71,12 +71,13 @@ Public Sub DrawControl(hCCtrl As CControl) As Boolean Dim iBorder As Integer Dim hCtrl As Control = hCCtrl.Control + Dim FW As Integer Select LCase(hCCtrl.Kind) Case "hbox", "vbox", "hpanel", "vpanel" - CFamily.PaintContainer(Paint.X, Paint.Y, Paint.W, Paint.H) + CFamily.PaintContainer(hCCtrl) Return Case "panel" @@ -86,18 +87,23 @@ Public Sub DrawControl(hCCtrl As CControl) As Boolean Select Case hCCtrl.GetProperty("Border") Case "Raised" iBorder = Border.Raised + FW = 2 Case "Sunken" iBorder = Border.Sunken + FW = 2 Case "Etched" iBorder = Border.Etched + FW = 2 Case "Plain" iBorder = Border.Plain + FW = 1 Default - CFamily.PaintContainer(Paint.X, Paint.Y, Paint.W, Paint.H) + CFamily.PaintContainer(hCCtrl) Return End Select Style.PaintPanel(0, 0, hCtrl.W, hCtrl.H, iBorder) + CFamily.PaintContainer(Null, FW, FW, hCtrl.W - 2 * FW, hCtrl.H - 2 * FW) Return Case "spring" @@ -113,7 +119,7 @@ Public Sub DrawControl(hCCtrl As CControl) As Boolean Paint.Rectangle(Paint.X, Paint.Y, Paint.W, Paint.H) Paint.Fill - CFamily.PaintContainer(Paint.X, Paint.Y, Paint.W, Paint.H) + CFamily.PaintContainer(hCCtrl) If hCCtrl["Separator"] Then Paint.FillRect(Paint.X, Paint.H - 1, Paint.W, 1, Color.LightForeground) Return @@ -127,7 +133,6 @@ Public Sub DrawControl(hCCtrl As CControl) As Boolean End Select - End Public Sub ActionDialog(sAction As String) As Boolean diff --git a/app/src/gambas3/.src/Family/WebForm/CFamilyWebForm.class b/app/src/gambas3/.src/Family/WebForm/CFamilyWebForm.class index 8b7721971..ffb350ccd 100644 --- a/app/src/gambas3/.src/Family/WebForm/CFamilyWebForm.class +++ b/app/src/gambas3/.src/Family/WebForm/CFamilyWebForm.class @@ -152,7 +152,7 @@ Public Sub DrawControl(hCCtrl As CControl) As Boolean Case "WebContainer", "WebHBox", "WebVBox" If Not CFamily.PaintExpand(hCCtrl) Then - CFamily.PaintContainer(0, 0, hCCtrl.W, hCCtrl.H) + CFamily.PaintContainer(hCCtrl, 0, 0, hCCtrl.W, hCCtrl.H) Endif Return diff --git a/app/src/gambas3/.src/Family/WebForm/WebformWebMenu.class b/app/src/gambas3/.src/Family/WebForm/WebformWebMenu.class index 84dad1bd5..0f0fed463 100644 --- a/app/src/gambas3/.src/Family/WebForm/WebformWebMenu.class +++ b/app/src/gambas3/.src/Family/WebForm/WebformWebMenu.class @@ -45,7 +45,7 @@ End Public Sub Container_Draw() 'Paint.Background = Color.LightForeground - CFamily.PaintContainer(0, -1, Paint.W, Paint.H + 1) + CFamily.PaintContainer(Null, 0, -1, Paint.W, Paint.H + 1) 'Paint.Stroke End