Skip to content

Commit

Permalink
ButtonStrip UC: add title caption support
Browse files Browse the repository at this point in the history
This allows me to strip many more label instances out of the project,
reducing overhead and greatly simplifying theme-aware caption rendering.

I've also made some modifications to the appearance of button strips.  A
chunkier border is now applied when hovering, which should greatly
improve visibility for users with poor eyesight (or cheap monitors).
This also brings it more into line with other PD controls.
  • Loading branch information
tannerhelland committed Jan 23, 2016
1 parent b0d4f41 commit df93cee
Show file tree
Hide file tree
Showing 81 changed files with 5,814 additions and 6,310 deletions.
804 changes: 401 additions & 403 deletions App/PhotoDemon/Languages/Deutsch_1.xml

Large diffs are not rendered by default.

804 changes: 401 additions & 403 deletions App/PhotoDemon/Languages/Deutsch_2.xml

Large diffs are not rendered by default.

804 changes: 401 additions & 403 deletions App/PhotoDemon/Languages/Espanol.xml

Large diffs are not rendered by default.

804 changes: 401 additions & 403 deletions App/PhotoDemon/Languages/Francais.xml

Large diffs are not rendered by default.

804 changes: 401 additions & 403 deletions App/PhotoDemon/Languages/Indonesian.xml

Large diffs are not rendered by default.

804 changes: 401 additions & 403 deletions App/PhotoDemon/Languages/Italiano.xml

Large diffs are not rendered by default.

804 changes: 401 additions & 403 deletions App/PhotoDemon/Languages/Malay.xml

Large diffs are not rendered by default.

726 changes: 363 additions & 363 deletions App/PhotoDemon/Languages/Master/MASTER.xml

Large diffs are not rendered by default.

804 changes: 401 additions & 403 deletions App/PhotoDemon/Languages/Portuguese.xml

Large diffs are not rendered by default.

823 changes: 410 additions & 413 deletions App/PhotoDemon/Languages/Simplified Chinese.xml

Large diffs are not rendered by default.

804 changes: 401 additions & 403 deletions App/PhotoDemon/Languages/Swedish.xml

Large diffs are not rendered by default.

804 changes: 401 additions & 403 deletions App/PhotoDemon/Languages/Vlaams.xml

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions Classes/pdVisualThemes.cls
Expand Up @@ -15,8 +15,8 @@ Attribute VB_Exposed = False
'PhotoDemon Visual Theming class
'Copyright 2013-2016 by Tanner Helland
'Created: 23/October/13
'Last updated: 26/July/14
'Last update: start centralizing color definitions
'Last updated: 22/January/16
'Last update: implement all the little XML bits that make custom theming files possible
'
'There isn't much here yet, but stay tuned - more is coming!
'
Expand Down Expand Up @@ -185,24 +185,24 @@ Public Function LoadThemeFile(ByVal themeFilename As String) As Boolean
' (TODO 6.8: make a decision on how much control we expose over theme editing; maybe the /Data folder is unnecessary)
If g_IsProgramRunning And Not g_ProgramShuttingDown Then

Dim themePath As String
themePath = g_UserPreferences.getThemePath & themeFilename
Dim ThemePath As String
ThemePath = g_UserPreferences.getThemePath & themeFilename

If m_XML.loadXMLFile(themePath) Then
If m_XML.loadXMLFile(ThemePath) Then

'Perform minor validation on the file
LoadThemeFile = m_XML.isPDDataType("Visual theme") And m_XML.validateLoadedXMLData("Colors")

Else
#If DEBUGMODE = 1 Then
If g_IsProgramRunning Then
pdDebug.LogAction "WARNING! Failed to load requested theme: " & themePath
pdDebug.LogAction "WARNING! Failed to load requested theme: " & ThemePath
pdDebug.LogAction "WARNING! Falling back to default PD theme..."
End If
#End If

themePath = g_UserPreferences.getThemePath & "Default_Light.xml"
LoadThemeFile = m_XML.loadXMLFile(themePath)
ThemePath = g_UserPreferences.getThemePath & "Default_Light.xml"
LoadThemeFile = m_XML.loadXMLFile(ThemePath)
LoadThemeFile = LoadThemeFile And m_XML.isPDDataType("Visual theme") And m_XML.validateLoadedXMLData("Colors")

End If
Expand Down
2 changes: 1 addition & 1 deletion Controls/brushSelector.ctl
Expand Up @@ -139,7 +139,7 @@ Public Sub DisplayBrushSelection()
RaiseBrushDialog
End Sub

Private Sub IControlThemable_UpdateAgainstCurrentTheme()
Private Sub IControlThemable_ApplyTheme()
Call Me.UpdateAgainstCurrentTheme
End Sub

Expand Down
154 changes: 114 additions & 40 deletions Controls/buttonStrip.ctl

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Controls/buttonStripVertical.ctl
Expand Up @@ -157,7 +157,7 @@ Public Property Let FontSize(ByVal newSize As Single)
End If
End Property

Private Sub IControlThemable_UpdateAgainstCurrentTheme()
Private Sub IControlThemable_ApplyTheme()
Call Me.UpdateAgainstCurrentTheme
End Sub

Expand Down
6 changes: 3 additions & 3 deletions Controls/colorSelector.ctl
Expand Up @@ -67,7 +67,7 @@ Public Event GotFocusAPI()
Public Event LostFocusAPI()

'This control uses two layout rects: one for the clickable primary color region, and another for the rect where the user
' can copy over the color from the main screen. These rects are calculated by the updateControlLayout function.
' can copy over the color from the main screen. These rects are calculated by the UpdateControlLayout function.
Private m_PrimaryColorRect As RECT, m_SecondaryColorRect As RECT

'The control's current color
Expand Down Expand Up @@ -174,7 +174,7 @@ Public Sub DisplayColorSelection()

End Sub

Private Sub IControlThemable_UpdateAgainstCurrentTheme()
Private Sub IControlThemable_ApplyTheme()
Call Me.UpdateAgainstCurrentTheme
End Sub

Expand Down Expand Up @@ -456,7 +456,7 @@ Private Sub MakeNewTooltip()

'Construct hex and RGB string representations of the target color
hexString = "#" & UCase(Colors.GetHexStringFromRGB(targetColor))
rgbString = Colors.ExtractR(targetColor) & ", " & Colors.ExtractG(targetColor) & ", " & Colors.ExtractB(targetColor)
rgbString = g_Language.TranslateMessage("RGB(%1, %2, %3)", Colors.ExtractR(targetColor), Colors.ExtractG(targetColor), Colors.ExtractB(targetColor))
toolString = hexString & vbCrLf & rgbString

'Append a description string to the color data
Expand Down
4 changes: 2 additions & 2 deletions Controls/commandBar.ctl
Expand Up @@ -713,12 +713,12 @@ Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
End Sub

Private Sub UserControl_Resize()
updateControlLayout
UpdateControlLayout
End Sub

'The command bar's layout is all handled programmatically. This lets it look good, regardless of the parent form's size or
' the current monitor's DPI setting.
Private Sub updateControlLayout()
Private Sub UpdateControlLayout()

On Error GoTo skipUpdateLayout

Expand Down
2 changes: 1 addition & 1 deletion Controls/gradientSelector.ctl
Expand Up @@ -137,7 +137,7 @@ Public Sub DisplayGradientSelection()
RaiseGradientDialog
End Sub

Private Sub IControlThemable_UpdateAgainstCurrentTheme()
Private Sub IControlThemable_ApplyTheme()
Call Me.UpdateAgainstCurrentTheme
End Sub

Expand Down
8 changes: 4 additions & 4 deletions Controls/pdButton.ctl
Expand Up @@ -87,7 +87,7 @@ Public Event LostFocusAPI()
' settings like caption font size.)
Private m_Caption As pdCaption

'Rect where the caption is rendered. This is calculated by updateControlLayout, and it needs to be revisited if either the caption
'Rect where the caption is rendered. This is calculated by UpdateControlLayout, and it needs to be revisited if either the caption
' or button images change.
Private m_CaptionRect As RECT

Expand Down Expand Up @@ -374,7 +374,7 @@ Private Sub cPainter_PaintWindow(ByVal winLeft As Long, ByVal winTop As Long, By

End Sub

Private Sub IControlThemable_UpdateAgainstCurrentTheme()
Private Sub IControlThemable_ApplyTheme()
Call Me.UpdateAgainstCurrentTheme
End Sub

Expand Down Expand Up @@ -619,7 +619,7 @@ Private Sub RedrawBackBuffer()
'A border is always drawn around the control; its size varies by hover state. (This is standard Win 10 behavior.)
Dim borderWidth As Single
If m_MouseInsideUC Or m_FocusRectActive Then borderWidth = 3 Else borderWidth = 1
GDI_Plus.GDIPlusDrawRectOutlineToDC m_BackBuffer.getDIBDC, 0, 0, m_BackBuffer.getDIBWidth - 1, m_BackBuffer.getDIBHeight - 1, btnColorBorder, 255, borderWidth
GDI_Plus.GDIPlusDrawRectOutlineToDC m_BackBuffer.getDIBDC, 0, 0, m_BackBuffer.getDIBWidth - 1, m_BackBuffer.getDIBHeight - 1, btnColorBorder, 255, borderWidth, False, LineJoinMiter

'Paint the image, if any
If Not (btImage Is Nothing) Then
Expand Down Expand Up @@ -656,7 +656,7 @@ Private Sub RedrawBackBuffer()
End With

DrawFocusRect m_BackBuffer.getDIBDC, tmpRect

End If

'Paint the buffer to the screen
Expand Down
2 changes: 1 addition & 1 deletion Controls/pdButtonToolbox.ctl
Expand Up @@ -294,7 +294,7 @@ Public Sub AssignImage_Pressed(Optional ByVal resName As String = "", Optional B

End Sub

Private Sub IControlThemable_UpdateAgainstCurrentTheme()
Private Sub IControlThemable_ApplyTheme()
Call Me.UpdateAgainstCurrentTheme
End Sub

Expand Down
4 changes: 2 additions & 2 deletions Controls/pdCanvas.ctl
Expand Up @@ -275,7 +275,7 @@ Option Explicit
'This implementation binding will allow us to refer to all themeable controls _
under a single type, making form control iteration much simpler _
(we won't need to maintain long lists of UserControl names)
Implements iControlThemable
Implements IControlThemable


Private Enum PD_MOUSEEVENT
Expand Down Expand Up @@ -1928,7 +1928,7 @@ Public Sub cMouseEvents_MouseWheelZoom(ByVal Button As PDMouseButtonConstants, B

End Sub

Private Sub IControlThemable_UpdateAgainstCurrentTheme()
Private Sub IControlThemable_ApplyTheme()
Call Me.UpdateAgainstCurrentTheme
End Sub

Expand Down
2 changes: 1 addition & 1 deletion Controls/pdColorVariants.ctl
Expand Up @@ -267,7 +267,7 @@ Private Sub cPainter_PaintWindow(ByVal winLeft As Long, ByVal winTop As Long, By

End Sub

Private Sub IControlThemable_UpdateAgainstCurrentTheme()
Private Sub IControlThemable_ApplyTheme()
Call Me.UpdateAgainstCurrentTheme
End Sub

Expand Down
2 changes: 1 addition & 1 deletion Controls/pdColorWheel.ctl
Expand Up @@ -373,7 +373,7 @@ Private Sub cPainter_PaintWindow(ByVal winLeft As Long, ByVal winTop As Long, By

End Sub

Private Sub IControlThemable_UpdateAgainstCurrentTheme()
Private Sub IControlThemable_ApplyTheme()
Call Me.UpdateAgainstCurrentTheme
End Sub

Expand Down
4 changes: 2 additions & 2 deletions Controls/pdComboBox.ctl
Expand Up @@ -73,7 +73,7 @@ Option Explicit
'This implementation binding will allow us to refer to all themeable controls _
under a single type, making form control iteration much simpler _
(we won't need to maintain long lists of UserControl names)
Implements iControlThemable
Implements IControlThemable


'By design, this combo box raises fewer events than a standard combo box. I would prefer the Click() event to actually be Change(),
Expand Down Expand Up @@ -841,7 +841,7 @@ Private Sub cResize_WindowResize(ByVal newWidth As Long, ByVal newHeight As Long
If Not m_InternalResizeState Then syncUserControlSizeToComboSize
End Sub

Private Sub IControlThemable_UpdateAgainstCurrentTheme()
Private Sub IControlThemable_ApplyTheme()
Call Me.UpdateAgainstCurrentTheme
End Sub

Expand Down
4 changes: 2 additions & 2 deletions Controls/pdComboBox_Font.ctl
Expand Up @@ -74,7 +74,7 @@ Option Explicit
'This implementation binding will allow us to refer to all themeable controls _
under a single type, making form control iteration much simpler _
(we won't need to maintain long lists of UserControl names)
Implements iControlThemable
Implements IControlThemable


'By design, this combo box raises fewer events than a standard combo box. I would prefer the Click() event to actually be Change(),
Expand Down Expand Up @@ -814,7 +814,7 @@ Private Sub cPainterBox_PaintWindow(ByVal winLeft As Long, ByVal winTop As Long,
drawComboBox True
End Sub

Private Sub IControlThemable_UpdateAgainstCurrentTheme()
Private Sub IControlThemable_ApplyTheme()
Call Me.UpdateAgainstCurrentTheme
End Sub

Expand Down
4 changes: 2 additions & 2 deletions Controls/pdComboBox_Hatch.ctl
Expand Up @@ -73,7 +73,7 @@ Option Explicit
'This implementation binding will allow us to refer to all themeable controls _
under a single type, making form control iteration much simpler _
(we won't need to maintain long lists of UserControl names)
Implements iControlThemable
Implements IControlThemable


'By design, this combo box raises fewer events than a standard combo box. I would prefer the Click() event to actually be Change(),
Expand Down Expand Up @@ -734,7 +734,7 @@ Private Sub cPainterBox_PaintWindow(ByVal winLeft As Long, ByVal winTop As Long,
drawComboBox True
End Sub

Private Sub IControlThemable_UpdateAgainstCurrentTheme()
Private Sub IControlThemable_ApplyTheme()
Call Me.UpdateAgainstCurrentTheme
End Sub

Expand Down
4 changes: 2 additions & 2 deletions Controls/pdHyperlink.ctl
Expand Up @@ -64,7 +64,7 @@ Option Explicit
'This implementation binding will allow us to refer to all themeable controls _
under a single type, making form control iteration much simpler _
(we won't need to maintain long lists of UserControl names)
Implements iControlThemable
Implements IControlThemable


'In its default configuration, this control raises no events. However, if default "shell URL behavior" is not desired,
Expand Down Expand Up @@ -461,7 +461,7 @@ Public Property Get ContainerHwnd() As Long
ContainerHwnd = UserControl.ContainerHwnd
End Property

Private Sub IControlThemable_UpdateAgainstCurrentTheme()
Private Sub IControlThemable_ApplyTheme()
Call Me.UpdateAgainstCurrentTheme
End Sub

Expand Down
2 changes: 1 addition & 1 deletion Controls/pdLabel.ctl
Expand Up @@ -254,7 +254,7 @@ Public Property Let UseCustomForeColor(ByVal newSetting As Boolean)
End If
End Property

Private Sub IControlThemable_UpdateAgainstCurrentTheme()
Private Sub IControlThemable_ApplyTheme()
Call Me.UpdateAgainstCurrentTheme
End Sub

Expand Down
2 changes: 1 addition & 1 deletion Controls/pdListBox.ctl
Expand Up @@ -106,7 +106,7 @@ Public Property Get hWnd() As Long
hWnd = UserControl.hWnd
End Property

Private Sub IControlThemable_UpdateAgainstCurrentTheme()
Private Sub IControlThemable_ApplyTheme()
Call Me.UpdateAgainstCurrentTheme
End Sub

Expand Down
2 changes: 1 addition & 1 deletion Controls/pdNavigator.ctl
Expand Up @@ -214,7 +214,7 @@ Private Sub cPainter_PaintWindow(ByVal winLeft As Long, ByVal winTop As Long, By

End Sub

Private Sub IControlThemable_UpdateAgainstCurrentTheme()
Private Sub IControlThemable_ApplyTheme()
Call Me.UpdateAgainstCurrentTheme
End Sub

Expand Down
2 changes: 1 addition & 1 deletion Controls/pdScrollBar.ctl
Expand Up @@ -705,7 +705,7 @@ Private Sub cPainter_PaintWindow(ByVal winLeft As Long, ByVal winTop As Long, By

End Sub

Private Sub IControlThemable_UpdateAgainstCurrentTheme()
Private Sub IControlThemable_ApplyTheme()
Call Me.UpdateAgainstCurrentTheme
End Sub

Expand Down
4 changes: 2 additions & 2 deletions Controls/pdTextBox.ctl
Expand Up @@ -70,7 +70,7 @@ Option Explicit
'This implementation binding will allow us to refer to all themeable controls _
under a single type, making form control iteration much simpler _
(we won't need to maintain long lists of UserControl names)
Implements iControlThemable
Implements IControlThemable


'By design, this textbox raises fewer events than a standard text box
Expand Down Expand Up @@ -545,7 +545,7 @@ Private Sub cPainter_PaintWindow(ByVal winLeft As Long, ByVal winTop As Long, By

End Sub

Private Sub IControlThemable_UpdateAgainstCurrentTheme()
Private Sub IControlThemable_ApplyTheme()
Call Me.UpdateAgainstCurrentTheme
End Sub

Expand Down
4 changes: 2 additions & 2 deletions Controls/pdTitle.ctl
Expand Up @@ -70,7 +70,7 @@ Public Event Click(ByVal newState As Boolean)
Public Event GotFocusAPI()
Public Event LostFocusAPI()

'Rect where the caption is rendered. This is calculated by updateControlLayout, and it needs to be revisited if the
'Rect where the caption is rendered. This is calculated by UpdateControlLayout, and it needs to be revisited if the
' caption changes, or the control size changes.
Private m_CaptionRect As RECT

Expand Down Expand Up @@ -167,7 +167,7 @@ Public Property Let Value(ByVal newState As Boolean)
End If
End Property

Private Sub IControlThemable_UpdateAgainstCurrentTheme()
Private Sub IControlThemable_ApplyTheme()
Call Me.UpdateAgainstCurrentTheme
End Sub

Expand Down
2 changes: 1 addition & 1 deletion Controls/penSelector.ctl
Expand Up @@ -141,7 +141,7 @@ Public Sub DisplayPenSelection()
RaisePenDialog
End Sub

Private Sub IControlThemable_UpdateAgainstCurrentTheme()
Private Sub IControlThemable_ApplyTheme()
Call Me.UpdateAgainstCurrentTheme
End Sub

Expand Down
4 changes: 2 additions & 2 deletions Controls/smartCheckBox.ctl
Expand Up @@ -78,7 +78,7 @@ Private m_FitFailure As Boolean
'Current control value
Private m_Value As CheckBoxConstants

'Rect where the caption is rendered. This is calculated by updateControlLayout, and it needs to be revisited if the
'Rect where the caption is rendered. This is calculated by UpdateControlLayout, and it needs to be revisited if the
' caption changes, or the control size changes.
Private m_CaptionRect As RECTF

Expand Down Expand Up @@ -149,7 +149,7 @@ Public Property Let Value(ByVal newValue As CheckBoxConstants)
End If
End Property

Private Sub IControlThemable_UpdateAgainstCurrentTheme()
Private Sub IControlThemable_ApplyTheme()
Call Me.UpdateAgainstCurrentTheme
End Sub

Expand Down
4 changes: 2 additions & 2 deletions Controls/smartOptionButton.ctl
Expand Up @@ -82,7 +82,7 @@ Private m_FitFailure As Boolean
'Current control value
Private m_Value As Boolean

'Rect where the caption is rendered. This is calculated by updateControlLayout, and it needs to be revisited if the
'Rect where the caption is rendered. This is calculated by UpdateControlLayout, and it needs to be revisited if the
' caption changes, or the control size changes.
Private m_CaptionRect As RECTF

Expand Down Expand Up @@ -188,7 +188,7 @@ Private Sub UpdateOtherButtons()

End Sub

Private Sub IControlThemable_UpdateAgainstCurrentTheme()
Private Sub IControlThemable_ApplyTheme()
Call Me.UpdateAgainstCurrentTheme
End Sub

Expand Down

0 comments on commit df93cee

Please sign in to comment.