Skip to content

Commit 6494695

Browse files
committed
Merge pull request #85 from evilC/Profile-Toolbox-Rework
Profile toolbox rework
2 parents 7cdbd76 + 74fd6c1 commit 6494695

File tree

2 files changed

+60
-25
lines changed

2 files changed

+60
-25
lines changed

Changelog.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ Key:
44
= : Change / Fix
55
+ : Added feature
66

7+
0.0.12 - 17th May 2016
8+
+ The Profile Toolbox is now integrated into the rest of the UI
9+
The UI is now resizable horizontally, so you can resize the profile toolbox.
10+
711
0.0.11 - 10th May 2016
812
= The following keyboard keys are now bindable as inputs / outputs:
913
PgUp, PgDn, End, Home, Left, Up, Right, Down, Insert, Delete

UCR.ahk

Lines changed: 56 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ return
99

1010
; ======================================================================== MAIN CLASS ===============================================================
1111
Class UCRMain {
12-
Version := "0.0.11" ; The version of the main application
13-
SettingsVersion := "0.0.2" ; The version of the settings file format
12+
Version := "0.0.12" ; The version of the main application
13+
SettingsVersion := "0.0.3" ; The version of the settings file format
1414
_StateNames := {0: "Normal", 1: "InputBind", 2: "GameBind"}
1515
_State := {Normal: 0, InputBind: 1, GameBind: 2}
1616
_GameBindDuration := 0 ; The amount of time to wait in GameBind mode (ms)
@@ -23,7 +23,8 @@ Class UCRMain {
2323
PluginList := [] ; A list of plugin Types (Lookup to PluginDetails), indexed by order of Plugin Select DDL
2424
PluginDetails := {} ; A name-indexed list of plugin Details (Classname, Description etc). Name is ".Type" property of class
2525
PLUGIN_WIDTH := 680 ; The Width of a plugin
26-
PLUGIN_FRAME_WIDTH := 720 ; The width of the app
26+
PLUGIN_FRAME_WIDTH := 720 ; The width of the plugin area
27+
SIDE_PANEL_WIDTH := 100 ; The default width of the side panel
2728
TOP_PANEL_HEIGHT := 75 ; The amount of space reserved for the top panel (profile select etc)
2829
GUI_MIN_HEIGHT := 300 ; The minimum height of the app. Required because of the way AHK_H autosize/pos works
2930
CurrentSize := {w: this.PLUGIN_FRAME_WIDTH, h: this.GUI_MIN_HEIGHT} ; The current size of the app.
@@ -121,23 +122,24 @@ Class UCRMain {
121122
_CreateGui(){
122123
Gui, % this.hwnd ":Margin", 0, 0
123124
Gui, % this.hwnd ":+Resize"
124-
Gui, % this.hwnd ":Show", % "Hide w" UCR.PLUGIN_FRAME_WIDTH " h" UCR.GUI_MIN_HEIGHT, % "UCR - Universal Control Remapper v" this.Version
125-
Gui, % this.hwnd ":+Minsize" UCR.PLUGIN_FRAME_WIDTH "x" UCR.GUI_MIN_HEIGHT
126-
Gui, % this.hwnd ":+Maxsize" UCR.PLUGIN_FRAME_WIDTH
125+
start_width := UCR.PLUGIN_FRAME_WIDTH + UCR.SIDE_PANEL_WIDTH
126+
Gui, % this.hwnd ":Show", % "Hide w" start_width " h" UCR.GUI_MIN_HEIGHT, % "UCR - Universal Control Remapper v" this.Version
127+
Gui, % this.hwnd ":+Minsize" start_width + 15 "x" UCR.GUI_MIN_HEIGHT
128+
;Gui, % this.hwnd ":+Maxsize" start_width
127129
Gui, new, HwndHwnd
128130
this.hTopPanel := hwnd
129131
Gui % this.hTopPanel ":-Border"
130132
;Gui % this.hTopPanel ":Show", % "x0 y0 w" UCR.PLUGIN_FRAME_WIDTH " h" UCR.TOP_PANEL_HEIGHT, Main UCR Window
131133

132134
; Profile Select DDL
133135
Gui, % this.hTopPanel ":Add", Text, xm y+10, Current Profile:
134-
Gui, % this.hTopPanel ":Add", Edit, % "x100 yp-5 hwndhCurrentProfile Disabled w" UCR.PLUGIN_FRAME_WIDTH - 220
136+
Gui, % this.hTopPanel ":Add", Edit, % "x100 yp-5 hwndhCurrentProfile Disabled w" UCR.PLUGIN_FRAME_WIDTH - 115
135137
this.hCurrentProfile := hCurrentProfile
136138

137-
Gui, % this.hTopPanel ":Add", Button, % "x+5 yp-1 hwndhProfileToolbox w100", Profile Toolbox
138-
this.hProfileToolbox := hProfileToolbox
139-
fn := this._ProfileToolbox.ShowButtonClicked.Bind(this._ProfileToolbox)
140-
GuiControl +g, % this.hProfileToolbox, % fn
139+
;Gui, % this.hTopPanel ":Add", Button, % "x+5 yp-1 hwndhProfileToolbox w100", Profile Toolbox
140+
;this.hProfileToolbox := hProfileToolbox
141+
;fn := this._ProfileToolbox.ShowButtonClicked.Bind(this._ProfileToolbox)
142+
;GuiControl +g, % this.hProfileToolbox, % fn
141143

142144
; Add Plugin
143145
Gui, % this.hTopPanel ":Add", Text, xm y+10, Plugin Selection:
@@ -150,13 +152,26 @@ Class UCRMain {
150152
GuiControl % this.hTopPanel ":+g", % this.hAddPlugin, % fn
151153

152154
Gui, % this.hwnd ":Add", Gui, % "w" UCR.PLUGIN_FRAME_WIDTH " h" UCR.TOP_PANEL_HEIGHT, % this.hTopPanel
155+
156+
; Add the profile toolbox
157+
;Gui, % this.hwnd ":Add", Gui, % "x" UCR.PLUGIN_FRAME_WIDTH " ym aw ah w" UCR.SIDE_PANEL_WIDTH " h" UCR.GUI_MIN_HEIGHT, % this._ProfileToolbox.hwnd
158+
159+
Gui, new, HwndHwnd
160+
this.hSidePanel := hwnd
161+
Gui % this.hSidePanel ":-Caption"
162+
Gui % this.hSidePanel ":Margin", 0, 0
163+
164+
Gui, % this.hSidePanel ":Add", Gui, % "x0 y0 aw ah", % this._ProfileToolbox.hwnd
165+
Gui % this.hSidePanel ":Show", Hide
166+
Gui, % this.hwnd ":Add", Gui, % "x" UCR.PLUGIN_FRAME_WIDTH " ym aw ah w" UCR.SIDE_PANEL_WIDTH " h" UCR.GUI_MIN_HEIGHT, % this.hSidePanel
167+
153168

154169
;Gui, % this.hwnd ":Show"
155170
}
156171

157172
_ShowGui(){
158173
xy := (this.CurrentPos.x != "" && this.CurrentPos.y != "" ? "x" this.CurrentPos.x " y" this.CurrentPos.y : "")
159-
Gui, % this.hwnd ":Show", % xy " h" this.CurrentSize.h
174+
Gui, % this.hwnd ":Show", % xy " h" this.CurrentSize.h " w" this.Currentsize.w
160175
}
161176

162177
_OnMove(wParam, lParam, msg, hwnd){
@@ -174,6 +189,7 @@ Class UCRMain {
174189

175190
_OnSize(wParam, lParam, msg, hwnd){
176191
this.CurrentSize.h := HiWord(lParam)
192+
this.CurrentSize.w := LoWord(lParam)
177193
this._SaveSettings()
178194
}
179195

@@ -571,12 +587,15 @@ Class UCRMain {
571587
obj.Profiles[id] := profile
572588
}
573589
obj.SettingsVersion := "0.0.2"
574-
return obj
590+
}
591+
592+
if (obj.SettingsVersion = "0.0.2"){
593+
obj.CurrentSize.w := this.PLUGIN_FRAME_WIDTH + this.SIDE_PANEL_WIDTH
594+
obj.SettingsVersion := "0.0.3"
575595
}
576596
; Default to making no changes
577597
return obj
578598
}
579-
580599
; A child profile changed in some way
581600
_ProfileChanged(profile){
582601
this._SaveSettings()
@@ -711,24 +730,28 @@ Class UCRMain {
711730
class _ProfileToolbox extends _ProfileSelect {
712731
__New(){
713732
base.__New()
714-
Gui, Add, Button, xm w30 hwndhAdd y210 aya aw1/4, Add
733+
Gui, Add, Button, xm w30 hwndhAdd y110 aya aw1/2, Add
715734
fn := this.AddProfile.Bind(this,0)
716735
GuiControl +g, % hAdd, % fn
717736

718-
Gui, Add, Button, x+5 w60 hwndhAdd y210 aya axa aw1/4, Add Child
737+
Gui, Add, Button, x+5 w60 hwndhAdd y110 aya axa aw1/2, Add Child
719738
fn := this.AddProfile.Bind(this,1)
720739
GuiControl +g, % hAdd, % fn
721740

722-
Gui, Add, Button, x+5 w50 hwndhRename y210 aya axa aw1/4, Rename
741+
Gui, Add, Button, xm w50 hwndhRename y+5 aya axr aw1/2, Rename
723742
fn := this.RenameProfile.Bind(this)
724743
GuiControl +g, % hRename, % fn
725744

726-
Gui, Add, Button, x+5 w40 hwndhDelete y210 aya axa aw1/4, Delete
745+
Gui, Add, Button, x+5 w40 hwndhDelete yp aya axa aw1/2, Delete
727746
fn := this.DeleteProfile.Bind(this)
728747
GuiControl +g, % hDelete, % fn
729748

730749
this.DragMidFn := this.Treeview_Dragging.Bind(this)
731750
this.DragEndFn := this.Treeview_EndDrag.Bind(this)
751+
752+
Gui, % this.hwnd ":-Caption -Resize"
753+
;Gui, % this.hwnd ":Show", % "x" x - 110 " y" y - 5, Profile Toolbox
754+
Gui, % this.hwnd ":Show"
732755
}
733756

734757
AddProfile(childmode){
@@ -762,11 +785,11 @@ class _ProfileToolbox extends _ProfileSelect {
762785
}
763786
}
764787

765-
ShowButtonClicked(){
766-
CoordMode, Mouse, Screen
767-
MouseGetPos, x, y
768-
Gui, % this.hwnd ":Show", % "x" x - 110 " y" y - 5, Profile Toolbox
769-
}
788+
;~ ShowButtonClicked(){
789+
;~ CoordMode, Mouse, Screen
790+
;~ MouseGetPos, x, y
791+
;~ Gui, % this.hwnd ":Show", % "x" x - 110 " y" y - 5, Profile Toolbox
792+
;~ }
770793

771794
;~ DeleteNode(node){
772795
;~ pid := this.LvHandleToProfileId[node]
@@ -953,6 +976,14 @@ class _ProfileToolbox extends _ProfileSelect {
953976
; =================================================================== PROFILE PICKER ==========================================================
954977
; A tool for plugins that allows users to pick a profile (eg for a profile switcher plugin). Cannot alter profile tree
955978
class _ProfilePicker extends _ProfileSelect {
979+
__New(){
980+
base.__New()
981+
; Initialize resizing system to min size of gui
982+
Gui, % this.hwnd ":Show", % "Hide"
983+
984+
Gui, % this.hwnd ":+Minsize" 120 "x" 110
985+
}
986+
956987
_CurrentCallback := 0
957988
TV_Event(){
958989
if (A_GuiEvent == "DoubleClick"){
@@ -968,7 +999,7 @@ class _ProfilePicker extends _ProfileSelect {
968999
MouseGetPos, x, y
9691000
this.BuildProfileTree()
9701001
this.SelectProfileByID(currentprofile)
971-
Gui, % this.hwnd ":Show", % "x" x - 110 " y" y - 5, Profile Picker
1002+
Gui, % this.hwnd ":Show", % "x" x - 110 " y" y - 5 " w200 h200", Profile Picker
9721003
}
9731004
}
9741005

@@ -980,7 +1011,7 @@ class _ProfileSelect {
9801011
Gui +ToolWindow
9811012
Gui +Resize
9821013
this.hwnd := hwnd
983-
Gui, Add, TreeView, w200 h200 aw ah hwndhTreeview AltSubmit
1014+
Gui, Add, TreeView, w100 h100 aw ah hwndhTreeview AltSubmit
9841015
this.hTreeview := hTreeview
9851016
;Gui, Show
9861017
this.TV_EventFn := this.TV_Event.Bind(this)

0 commit comments

Comments
 (0)