Question 1:
I am looking for a good way to make scrolling the dropdownlist with the mouse wheel a bit faster. My backup plan atm is to look at how long has passed since the last time the wheel is moved and if under some amount, increase the increment used for scrolling. Anyone have any other ideas about how to do it?
Relevant code:
Code: Select all
WM_MOUSEWHEEL( wparam ) {
static lastTime
;~ ToolTip, % wparam
MouseGetPos,,, win
if( win != Master.Gui2.Hwnd )
return
if( Master.DDL.Active ){
if( wparam < 0 ){
Master.Index++
if( Master.Index > ( Master.FullPath.Length() - 10 ) + 1 ){
Master.Index := ( Master.FullPath.Length() - 10 ) + 1
return
}
;~ SoundBeep, 500
Master.Gui2.ClearWindow()
Master.Gui2.DrawBitmap( DDLGraphics() , { X: 0 , Y: 0 , W: 330 , H: 280 } , dispose := 1 )
Master.Gui2.UpdateWindow()
Master.SliderButtonX := floor( ( Master.Index ) * ( ( 806 - 240 ) / ( Master.FullPath.Length() - 10 ) ) + 1 ) + 240
SetImageList( Master )
_UpdateGraphics( Master )
;~ Master.Gui3.DrawBitmap( ImageViewerDisplayPanel() , { X: 0 , Y: 0 , W: 900 , H: 310 } , dispose := 1 )
;~ Master.Gui3.UpdateWindow()
SetDisplayWindow()
}else if( wparam > 0 ){
Master.Index--
if( Master.Index < 1 ){
Master.Index := 1
return
}
;~ SoundBeep, 500
Master.Gui2.ClearWindow()
Master.Gui2.DrawBitmap( DDLGraphics() , { X: 0 , Y: 0 , W: 330 , H: 280 } , dispose := 1 )
Master.Gui2.UpdateWindow()
Master.SliderButtonX := floor( ( Master.Index ) * ( ( 806 - 240 ) / ( Master.FullPath.Length() - 10 ) ) + 1 ) + 240
SetImageList( Master )
_UpdateGraphics( Master )
;~ Master.Gui3.DrawBitmap( ImageViewerDisplayPanel() , { X: 0 , Y: 0 , W: 900 , H: 310 } , dispose := 1 )
;~ Master.Gui3.UpdateWindow()
SetDisplayWindow()
}
}
}
Question 2:
There are a number of optimizations that I will be making once I am done prototyping, one of which is to improve is the image loading and display.
It works fine with small images but once you get into ones that are 3000px x 4000px things can become a bit more sluggish. I had heard about using a thumbnail, but the closest thing I found was about taking a bitmap of a image, resizing it and saving it to a new bitmap. This might work but I'm not sure. Thoughts?
As it is now, I get a bitmap of a image, resize it and display it.
Code: Select all
SetImageList( obj ){
static ft := 1
x := 180
if( ft && !ft := !ft ){
obj.Bitmaps := [] , obj.MaxSize := 66 , obj.ImageBoxSize := 70
obj.Index := 1
}
Loop, % obj.FullPath.Length() {
if( obj.BitMaps[ A_Index ].Bitmap )
Gdip_DisposeImage( obj.BitMaps[ A_Index ].Bitmap )
else
obj.BitMaps[ A_Index ] := {}
obj.BitMaps[ A_Index ].Bitmap := Gdip_CreateBitmapFromFile( obj.FullPath[ A_Index + obj.Index - 1 ] )
ResizeIt( obj.BitMaps[ A_Index ].Bitmap , Width , Height , obj.MaxSize )
obj.BitMaps[ A_Index ].X := x + ( obj.ImageBoxSize - Width ) / 2
obj.BitMaps[ A_Index ].Y := 4 + ( obj.ImageBoxSize - Height ) / 2
obj.BitMaps[ A_Index ].Width := Width
obj.BitMaps[ A_index ].Height := Height
obj.BitMaps[ A_index ].ActualFilePosition := A_Index + obj.Index - 1
if( A_Index = 10 )
break
x += obj.ImageBoxSize
}
}
Question 3:
I don't work with files all that often, what would be a good way to get this to use any image type?
Code: Select all
_LoadImageList( obj , loadit := 0 ){
local index := 0 , Fileinput := ""
IniRead Fileinput , % A_ScriptFullPath , MyPath , Path , ""
if( !Fileinput || loadit ){
Gui, 1:+OwnDialogs
FileSelectFolder, Fileinput
if( !Fileinput )
return
IniWrite, % Fileinput , % A_ScriptFullPath , MyPath, path
}
obj.FullPath := []
obj.Index := 1
Loop, % Fileinput "\*.png"
obj.FullPath[ ++Index ] := A_LoopFileFullPath
SetImageList( obj )
}
Full Script (*Windows 8+)
Code: Select all
/*
[MyPath]
path=
*/
;***************************************************************************************************
#Include <My Altered Gdip Lib> ;Replace with your path to the Gdip.ahk lib
;***************************************************************************************************
;~ #Include <PopUpWindow Class> ;I have included this class at the bottom of the script
;***************************************************************************************************
#SingleInstance force
#NoEnv
SetBatchLines, -1
GDIP_StartUp()
global Master := _CreateControlObjects()
_LoadImageList( Master )
_CreateWindows( Master )
_AddControls( Master )
_CreateDisplayWindow( Master )
OnMessage( 0x200 , "WatchMouse" )
OnMessage( 0x201 , "WatchClick" )
OnMessage(0x020A, "WM_MOUSEWHEEL")
Gui, 1:Show
Return
GuiClose:
GuiContextMenu:
*ESC::ExitApp
Numpad3::
PopUpWindow.Helper()
Return
WM_MOUSEWHEEL( wparam ) {
static lastTime
;~ ToolTip, % wparam
MouseGetPos,,, win
if( win != Master.Gui2.Hwnd )
return
if( Master.DDL.Active ){
if( wparam < 0 ){
Master.Index++
if( Master.Index > ( Master.FullPath.Length() - 10 ) + 1 ){
Master.Index := ( Master.FullPath.Length() - 10 ) + 1
return
}
;~ SoundBeep, 500
Master.Gui2.ClearWindow()
Master.Gui2.DrawBitmap( DDLGraphics() , { X: 0 , Y: 0 , W: 330 , H: 280 } , dispose := 1 )
Master.Gui2.UpdateWindow()
Master.SliderButtonX := floor( ( Master.Index ) * ( ( 806 - 240 ) / ( Master.FullPath.Length() - 10 ) ) + 1 ) + 240
SetImageList( Master )
_UpdateGraphics( Master )
;~ Master.Gui3.DrawBitmap( ImageViewerDisplayPanel() , { X: 0 , Y: 0 , W: 900 , H: 310 } , dispose := 1 )
;~ Master.Gui3.UpdateWindow()
SetDisplayWindow()
}else if( wparam > 0 ){
Master.Index--
if( Master.Index < 1 ){
Master.Index := 1
return
}
;~ SoundBeep, 500
Master.Gui2.ClearWindow()
Master.Gui2.DrawBitmap( DDLGraphics() , { X: 0 , Y: 0 , W: 330 , H: 280 } , dispose := 1 )
Master.Gui2.UpdateWindow()
Master.SliderButtonX := floor( ( Master.Index ) * ( ( 806 - 240 ) / ( Master.FullPath.Length() - 10 ) ) + 1 ) + 240
SetImageList( Master )
_UpdateGraphics( Master )
;~ Master.Gui3.DrawBitmap( ImageViewerDisplayPanel() , { X: 0 , Y: 0 , W: 900 , H: 310 } , dispose := 1 )
;~ Master.Gui3.UpdateWindow()
SetDisplayWindow()
}
}
}
_CreateDisplayWindow( obj ){
obj.Gui3 := New PopUpWindow( { WindowName: "3" , WindowOptions: " -DPIScale +AlwaysOnTop +Owner1 " , WindowSmoothing: 2 , X: obj.Gui1.X + 120 , Y: obj.Gui1.Y - 310 , W: 900 , H: 310 } )
obj.Gui3.ShowWindow()
;~ obj.Gui3.DrawBitmap( ImageViewerDisplayPanel() , { X: 0 , Y: 0 , W: 900 , H: 310 } , dispose := 1 )
;~ obj.Gui3.UpdateWindow()
}
_CreateDDLWindow(){
if( Master.Gui2 ){
Master.Gui2.DeleteWindow()
}
Master.Gui2 := New PopUpWindow( { WindowName: "2" , WindowOptions: " -DPIScale +AlwaysOnTop +Owner1" , WindowSmoothing: 2 , X: Master.Gui1.X + 21 , Y: Master.Gui1.Y + 10 , W: 330 , H: 280 } )
Master.Gui2.ShowWindow()
Master.Gui2.ClearWindow()
;~ Master.Gui2.PaintBackground( color := "0xFF000000" )
Master.Gui2.DrawBitmap( DDLGraphics() , { X: 0 , Y: 0 , W: 330 , H: 280 } , dispose := 1 )
Master.Gui2.UpdateWindow()
;~ ToolTip, % "here`n" Master.Gui2.Hwnd "`n" ctrl
Master.DDL.Handles := []
Master.DDL.ListStartPosition := Master.Index
Master.DDL.Active := 1
Master.DDL.HoverActive := 0
Master.DDL.SliderButtonY := 7
y := 5
loop, % 13 {
Gui, 2:Add, Text, % "x" 5 " y" y " w" 290 " h" 20 " hwndhwnd gSelectDDLItem"
Master.DDL.Handles[ hwnd ] := A_Index
y += 21
}
Gui, 2:Add, Text, % "x" 300 " y" 5 " w" 25 " h" 230 " gAdjustDDLSlider"
Gui, 2:Add, Text, % "x" 300 " y" 239 " w" 25 " h" 36 " gDDLClose"
}
DDLClose(){
Master.DDL.Active := 0
Master.Gui2.DeleteWindow()
}
_AdjustSlider(){
local x, lx
CoordMode, Mouse, Client
SetBatchLines, 20ms
Master.SliderMoving := 1
While( GetKeyState( "LButton" ) ){
MouseGetPos, x
x -= 7
( x < 240 ) ? ( x := 240 ) : ( ( x > 806 ) ? ( x := 806 ) )
Master.SliderButtonX := x
if( x != lx ){
lx := x
Master.Index := floor( ( x - 240 ) / ( ( 806 - 240 ) / ( Master.FullPath.Length() - 10 ) ) ) + 1
SetImageList( Master )
_UpdateGraphics( Master )
}
sleep, 30
}
SetBatchLines, -1
Master.SliderMoving := 0
}
AdjustDDLSlider(){
local y, ly
Master.DDL.MovingSlider := 1
CoordMode, Mouse, Client
While( GetKeyState( "LButton" ) ){
MouseGetPos,, y
y -= 45 ; button / 2 offset
( y < 7 ) ? ( y := 7 ) : ( ( y > 140 ) ? ( y := 140 ) )
Master.DDL.SliderButtonY := y
if( y != ly ){
ly := y
Master.Index := floor( ( y - 7 ) / ( ( 140 - 7 ) / ( Master.FullPath.Length() - 10 ) ) ) + 1
Master.Gui2.ClearWindow()
Master.Gui2.DrawBitmap( DDLGraphics() , { X: 0 , Y: 0 , W: 330 , H: 280 } , dispose := 1 )
Master.Gui2.UpdateWindow()
;~ sleep, 30
;~ SetTimer, DrawRoutine, -10
}
sleep, 30
}
SetImageList( Master )
SetTimer, DrawRoutine, -10
Master.DDL.MovingSlider := 0
}
SelectDDLItem:
;~ soundbeep, 500
MouseGetPos,,,, ctrl, 2
;~ ToolTip, % Master.DDL.Handles[ ctrl ] + Master.SelectedImage - 1
;~ Master.SelectedImage := Master.DDL.Handles[ ctrl ] + Master.DDL.ListStartPosition - 1
Master.SelectedImage := Master.DDL.Handles[ ctrl ] + Master.Index - 1
( Master.SelectedImage > Master.FullPath.Length() ) ? ( Master.SelectedImage := Master.FullPath.Length() )
if( Master.DDL.Handles[ ctrl ] > 10 && Master.SelectedImage != Master.FullPath.Length())
Master.Index += Master.DDL.Handles[ ctrl ] - 10
Master.Gui2.ClearWindow()
Master.Gui2.DrawBitmap( DDLGraphics() , { X: 0 , Y: 0 , W: 330 , H: 280 } , dispose := 1 )
Master.Gui2.UpdateWindow()
SetImageList( Master )
SetTimer, DrawRoutine, -10
;~ ToolTip, % Master.SelectedImage "`n" Master.Index
return
WatchMouse(){
if( Master.Moving )
return
MouseGetPos,,,, ctrl, 2
if( !Master.DDL.Active ){
if( Master.Handles[ctrl] && !Master.Active && Master.Controls[ Master.Handles[ ctrl ] ].Name && !Master.SliderMoving ){
Master.Active := Master.Handles[ctrl]
SetTimer, DrawRoutine, -10
SetTimer, WatchButtonLeave, -30
}else if( Master.Controls[ Master.Handles[ ctrl ] ].Position && ! Master.Display.Hover && !Master.SliderMoving ){
;~ soundbeep, 500
Master.Display.Hover := Master.Controls[ Master.Handles[ ctrl ] ].Position
SetDisplayWindow()
sleep, 30
SetTimer, WatchLeaveDisplay, 60
}
}else if( Master.DDL.Active && !Master.DDL.MovingSlider ){
if( Master.DDL.Handles[ctrl] && !Master.DDL.HoverActive ){
Master.DDL.HoverActive := Master.DDL.Handles[ctrl]
Master.Gui2.ClearWindow()
Master.Gui2.DrawBitmap( DDLGraphics() , { X: 0 , Y: 0 , W: 330 , H: 280 } , dispose := 1 )
Master.Gui2.UpdateWindow()
Master.Display.Hover := Master.DDL.HoverActive
SetDisplayWindow()
SetTimer, WatchListLeave, 60
}
}
}
WatchLeaveDisplay:
MouseGetPos,,,, ctrl, 2
if( Master.Controls[ Master.Handles[ ctrl ] ].Position != Master.Display.Hover ){
if( Master.Controls[ Master.Handles[ ctrl ] ].Position ){
Master.Display.Hover := Master.Controls[ Master.Handles[ ctrl ] ].Position
SetDisplayWindow()
}else {
SetTimer, WatchLeaveDisplay, Off
Master.Gui3.ClearWindow()
Master.Gui3.UpdateWindow()
Sleep, 30
Master.Display.Hover := 0
}
}
return
SetDisplayWindow(){
local pBitmap
Master.Gui3.ClearWindow()
Master.Gui3.DrawBitmap( ImageViewerDisplayPanel() , { X: 0 , Y: 0 , W: 900 , H: 310 } , dispose := 1 )
;~ Master.Gui3.DrawBitmap( pBitmap := "" , { X: "" , Y: "" , W: "" , H: "" } , dispose := 1 )
;~ Master.Gui3.DrawBitmap( pBitmap := "" , { X: "" , Y: "" , W: "" , H: "" } , dispose := 1 )
;~ Master.Gui3.UpdateWindow()
;left side
pBitmap := Gdip_CreateBitmapFromFile( Master.FullPath[ Master.Display.Hover + Master.Index - 2 ] )
ResizeIt( pBitmap , Width , Height , 200 )
x := 10 + ( 200 - Width ) / 2
y := 100 + ( 200 - Height ) / 2
Master.Gui3.DrawBitmap( pBitmap , { X: x , Y: y , W: Width , H: Height } , dispose := 1 )
pBitmap := Gdip_CreateBitmapFromFile( Master.FullPath[ Master.Display.Hover + Master.Index - 1 ] )
ResizeIt( pBitmap , Width , Height , 300 )
x := 223 + ( 300 - Width ) / 2
y := 5 + ( 300 - Height ) / 2
Master.Gui3.DrawBitmap( pBitmap , { X: x , Y: y , W: Width , H: Height } , dispose := 1 )
pBitmap := Gdip_CreateBitmapFromFile( Master.FullPath[ Master.Display.Hover + Master.Index ] )
ResizeIt( pBitmap , Width , Height , 200 )
x := 540 + ( 200 - Width ) / 2
y := 100 + ( 200 - Height ) / 2
Master.Gui3.DrawBitmap( pBitmap , { X: x , Y: y , W: Width , H: Height } , dispose := 1 )
Master.Gui3.UpdateWindow()
;~ ToolTip, % "here`n" Height
}
WatchClick(){
if( Master.DDL.Active && WinActive() != Master.Gui2.Hwnd ){
Master.DDL.Active := 0
Master.Gui2.DeleteWindow()
}
}
DrawRoutine:
_UpdateGraphics( Master )
return
WatchListLeave:
MouseGetPos,,,, ctrl, 2
if( Master.DDL.HoverActive && Master.DDL.Handles[ctrl] != Master.DDL.HoverActive ){
if( Master.DDL.Handles[ctrl] ){
Master.DDL.HoverActive := Master.DDL.Handles[ctrl]
Master.Gui2.ClearWindow()
Master.Gui2.DrawBitmap( DDLGraphics() , { X: 0 , Y: 0 , W: 330 , H: 280 } , dispose := 1 )
Master.Gui2.UpdateWindow()
Master.Display.Hover := Master.DDL.HoverActive
SetDisplayWindow()
}else{
Master.Gui2.ClearWindow()
Master.Gui2.DrawBitmap( DDLGraphics() , { X: 0 , Y: 0 , W: 330 , H: 280 } , dispose := 1 )
Master.Gui2.UpdateWindow()
Master.Gui3.ClearWindow()
Master.Gui3.UpdateWindow()
Master.Display.Hover := 0
SetTimer, WatchButtonLeave, Off
sleep, 30
Master.DDL.HoverActive := 0
}
}
return
WatchButtonLeave:
MouseGetPos,,,, ctrl, 2
if( Master.Active && Master.Handles[ctrl] != Master.Active ){
Master.Active := 0
SetTimer, DrawRoutine, -0
SetTimer, WatchButtonLeave, Off
}else{
SetTimer, WatchButtonLeave, -30
}
return
_MoveWindow(){
Master.Moving := 1
PostMessage, 0xA1, 2
While(GetKeyState("LButton"))
sleep, 30
WinGetPos, x, y,,, % "ahk_id " Master.Gui1.Hwnd
Master.Gui1.SetWindowProperties( { X: x , Y: y } )
Master.Gui3.SetWindowProperties( { X: x + 120 , Y: y - 310 } )
Master.Moving := 0
}
_ExpandDropDownList(){
_CreateDDLWindow()
}
_SwitchFolders(){
_LoadImageList( Master , 1 )
SetTimer, DrawRoutine, -10
}
_UseImage(){
SoundBeep, 700
}
_CloseImageViewer(){
SoundBeep, 800
ExitApp
}
_CycleImages(){
local change
MouseGetPos,,,, ctrl, 2
if( Master.Handles[ ctrl ] = 6 )
( --Master.Index < 1 ) ? ( Master.Index := 1 ) : ( change := 1 )
else if( Master.Handles[ ctrl ] = 7 )
( ( Master.Index -= 10 ) < 1 ) ? ( Master.Index := 1 , change := 1 ) : ( change := 1 )
else if( Master.Handles[ ctrl ] = 8 )
;~ ( ++Master.Index > ( Master.FullPath.Length() - 10 ) ) ? ( Master.Index := ( Master.FullPath.Length() - 10 ) ) : ( change := 1 )
( ++Master.Index > ( Master.FullPath.Length() - 9 ) ) ? ( Master.Index := ( Master.FullPath.Length() - 9 ) ) : ( change := 1 )
else if( Master.Handles[ ctrl ] = 9 )
;~ ( ( Master.Index += 10 ) > ( Master.FullPath.Length() - 10 ) ) ? ( Master.Index := ( Master.FullPath.Length() - 10 ) , change := 1 ) : ( change := 1 )
( ( Master.Index += 10 ) > ( Master.FullPath.Length() - 9 ) ) ? ( Master.Index := ( Master.FullPath.Length() - 9 ) , change := 1 ) : ( change := 1 )
if( change ){
SetImageList( Master )
;~ Master.SliderButtonX := floor( ( Master.Index ) * ( ( 806 - 240 ) / ( Master.FullPath.Length() - 11 ) ) ) + 240
Master.SliderButtonX := floor( ( Master.Index ) * ( ( 806 - 240 ) / ( Master.FullPath.Length() - 10 ) ) + 1 ) + 240
SetTimer, DrawRoutine, -10
}
}
_SelectImage(){
local index
MouseGetPos,,,, ctrl, 2
index := Master.Handles[ ctrl ]
;~ Master.SelectedImage := Master.Controls[ index ].Position + Master.Index - 1
Master.SelectedImage := Master.Controls[ index ].Position + Master.Index - 1
Master.SelectedPosition := Master.Controls[ index ].Position
;~ tooltip, % "Here`n" Master.Controls[ index ].Position "`n" Master.SelectedImage
SetTimer, DrawRoutine, -10
}
_UpdateGraphics( obj ){
obj.Gui1.ClearWindow()
obj.Gui1.DrawBitmap( ImageViewerMain( obj ) , { X: 0 , Y: 0 , W: 900 , H: 100 } , dispose := 1 )
; Loop, % obj.BitMaps.Length()
Loop, % 10
obj.Gui1.DrawBitmap( obj.BitMaps[ A_Index ].Bitmap , { X: obj.BitMaps[ A_Index ].X , Y: obj.BitMaps[ A_Index ].Y , W: obj.BitMaps[ A_Index ].Width , H: obj.BitMaps[ A_Index ].Height } , dispose := 0 )
obj.Gui1.UpdateWindow()
}
_AddControls( obj := "" ){
local hwnd, bd, Method
Loop, % obj.Controls.Length() {
Gui, % obj.WindowName ":Add", Text, % "x" obj.Controls[ A_Index ].X " y" obj.Controls[ A_Index ].Y " w" obj.Controls[ A_Index ].W " h" obj.Controls[ A_Index ].H " hwndhwnd"
obj.Handles[ hwnd ] := A_Index
obj.Controls[ A_Index ].Hwnd := hwnd
Method := obj.Controls[ A_Index ].Method
bd := Func( obj.Controls[ A_Index ].Method ).Bind( obj )
GuiControl, % obj.WindowName ":+G", % hwnd, % bd
}
}
_CreateControlObjects(){
local Master := {} , Index := 0
Master.Controls := [] , Master.Handles := [] , Master.WindowName := 1 , Master.Index := 1
Master.Active := ""
Master.LastActive := Master.Active
Master.DropDownActive := 0
Master.SliderButtonMinX := 240
Master.SliderButtonMaxX := 240 + 584
Master.SliderButtonX := 240
Master.SliderValue := 1
Master.SliderInterval := 0
Master.SliderMoving := 0
Master.SelectedImage := 5
Master.DotX := 200
Master.DDL := {}
Master.DDL.ListStartPosition := 1
Master.Display := {}
Master.Display.Hover := 0
Master.Display.Bitmaps := {}
;1: Move Window ; 5 , 33 , 22 , 58
Master.Controls[++Index] := { X: 5
, Y: 33
, W: 22
, H: 58
, Hwnd: ""
, Name: Index
, Method: "_MoveWindow" }
;2: Drop Down List ; 21 , 10 , 150 , 20
Master.Controls[++Index] := { X: 21
, Y: 10
, W: 150
, H: 20
, Hwnd: ""
, Method: "_ExpandDropDownList" }
;3: Change Folder ; 31 , 33 , 130 , 19
Master.Controls[++Index] := { X: 31
, Y: 33
, W: 130
, H: 19
, Hwnd: ""
, Name: Index
, Method: "_SwitchFolders" }
;4: Use Selected Image ; 31 , 56 , 130 , 19
Master.Controls[++Index] := { X: 31
, Y: 56
, W: 130
, H: 19
, Hwnd: ""
, Name: Index
, Method: "_UseImage" }
;5: Close ; 885 , 11 , 10 , 57
Master.Controls[++Index] := { X: 885
, Y: 11
, W: 10
, H: 57
, Hwnd: ""
, Name: Index
, Method: "_CloseImageViewer" }
;6: Left Single ; 175 , 78 , 20 , 20
Master.Controls[++Index] := { X: 175
, Y: 78
, W: 20
, H: 20
, Hwnd: ""
, Name: Index
, Method: "_CycleImages"
, Value: -1 }
;7: Left 10 ; 198 , 78 , 30 , 20
Master.Controls[++Index] := { X: 198
, Y: 78
, W: 30
, H: 20
, Hwnd: ""
, Name: Index
, Method: "_CycleImages"
, Value: -10 }
;8: Right Single ; 869 , 78 , 20 , 20
Master.Controls[++Index] := { X: 869
, Y: 78
, W: 20
, H: 20
, Hwnd: ""
, Name: Index
, Method: "_CycleImages"
, Value: +1 }
;9: Right 10 ; 836 , 78 , 30 , 20
Master.Controls[++Index] := { X: 836
, Y: 78
, W: 30
, H: 20
, Hwnd: ""
, Name: Index
, Method: "_CycleImages"
, Value: +10 }
;10: Adjust Slider ; 230 , 76 , 600 , 20
Master.Controls[++Index] := { X: 230
, Y: 76
, W: 600
, H: 20
, Hwnd: ""
, Method: "_AdjustSlider" }
;********************************************************************
;Image Panel Triggers ; 180 , 250 , 320 , 390 ...
x := 110
Loop, % 10 {
Master.Controls[++Index] := { X: x += 70
, Y: 2
, W: 70
, H: 70
, Hwnd: ""
, Position: A_Index
, Method: "_SelectImage" }
}
return Master
}
SetImageList( obj ){
static ft := 1
x := 180
if( ft && !ft := !ft ){
obj.Bitmaps := [] , obj.MaxSize := 66 , obj.ImageBoxSize := 70
obj.Index := 1
}
Loop, % obj.FullPath.Length() {
if( obj.BitMaps[ A_Index ].Bitmap )
Gdip_DisposeImage( obj.BitMaps[ A_Index ].Bitmap )
else
obj.BitMaps[ A_Index ] := {}
obj.BitMaps[ A_Index ].Bitmap := Gdip_CreateBitmapFromFile( obj.FullPath[ A_Index + obj.Index - 1 ] )
ResizeIt( obj.BitMaps[ A_Index ].Bitmap , Width , Height , obj.MaxSize )
obj.BitMaps[ A_Index ].X := x + ( obj.ImageBoxSize - Width ) / 2
obj.BitMaps[ A_Index ].Y := 4 + ( obj.ImageBoxSize - Height ) / 2
obj.BitMaps[ A_Index ].Width := Width
obj.BitMaps[ A_index ].Height := Height
obj.BitMaps[ A_index ].ActualFilePosition := A_Index + obj.Index - 1
if( A_Index = 10 )
break
x += obj.ImageBoxSize
}
}
_LoadImageList( obj , loadit := 0 ){
local index := 0 , Fileinput := ""
IniRead Fileinput , % A_ScriptFullPath , MyPath , Path , ""
if( !Fileinput || loadit ){
Gui, 1:+OwnDialogs
FileSelectFolder, Fileinput
if( !Fileinput )
return
IniWrite, % Fileinput , % A_ScriptFullPath , MyPath, path
}
obj.FullPath := []
obj.Index := 1
Loop, % Fileinput "\*.png"
obj.FullPath[ ++Index ] := A_LoopFileFullPath
SetImageList( obj )
}
ImageViewerMain( obj ){
;Bitmap Created Using: HB Bitmap Maker
; tooltip, % "Here`n" obj.FullPath[1]
pBitmap := Gdip_CreateBitmap( 900 , 100 ) , G := Gdip_GraphicsFromImage( pBitmap ) , Gdip_SetSmoothingMode( G , 2 )
; Brush := Gdip_BrushCreateSolid( "0xFFF0F0F0" ) , Gdip_FillRectangle( G , Brush , -2 , -2 , 940 , 210 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 3 , 2 , 898 , 151 , "0x99F0F0F0" , "0x99000000" , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 1 , 1 , 898 , 98 , 15 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFF22262A" ) , Gdip_FillRectangle( G , Brush , 180 , 2 , 700 , 70 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 1 , 2 , 903 , 158 , "0xaaF0F0F0" , "0xaa000000" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( G , Pen , 1 , 1 , 898 , 98 , 15 ) , Gdip_DeletePen( Pen )
;Image Display Areas
( Master.SelectedImage >= Master.Index && Master.SelectedImage <= Master.Index + 10 ) ? ( selpos := ( Master.SelectedImage - Master.Index + 1 ) , x := 110 ) : ( selpos := "" , x := 110 )
Brush1 := Gdip_CreateLineBrushFromRect( 0 , 2 , 70 , 70 , "0xFF336699" , "0xff3399ff" , 1 , 1 ) , Brush2 := Gdip_BrushCreateSolid( "0xFF333333" )
Loop, % 10
Gdip_FillRectangle( G , ( selpos = A_Index ) ? ( Brush1 ) : ( Brush2 ) , x += 70 , 2 , 70 , 70 )
Gdip_DeleteBrush( Brush1 ) , Gdip_DeleteBrush( Brush1 )
;Selected item
;~ if( Master.SelectedImage >= Master.Index && Master.SelectedImage <= Master.Index + 9 ){
if( Master.SelectedImage >= Master.Index && Master.SelectedImage <= Master.Index + 10 ){
posx := ( Master.SelectedImage - Master.Index ) * 70 + 180
;~ Pen := Gdip_CreatePen( "0xFF3399FF" , 1 ) , Gdip_DrawRectangle( G , Pen , posx , 2 , 70 , 70 ) , Gdip_DeletePen( Pen )
Pen := Gdip_CreatePen( "0xFF000000" , 1 ) , Gdip_DrawRectangle( G , Pen , posx , 2 , 70 , 70 ) , Gdip_DeletePen( Pen )
}
;Slider Background
Brush := Gdip_BrushCreateSolid( "0xFF333333" ) , Gdip_FillRoundedRectangle( G , Brush , 230 , 76 , 600 , 20 , 5 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 232 , 76 , 596 , 18 , "0x66F0F0F0" , "0x66000000" , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 231 , 77 , 598 , 18 , 5 ) , Gdip_DeleteBrush( Brush )
;Slider Image Position ( DOT )
;~ Master.DotX := floor( ( x - 240 ) / ( ( 806 - 240 ) / ( Master.FullPath.Length() - 11 ) ) ) + 1
Master.DotX := ( ( 806 - 240 ) / ( Master.FullPath.Length() ) ) * Master.SelectedImage + 240
;~ ToolTip, % "here`n" Master.DotX
;~ Brush := Gdip_BrushCreateSolid( "0xFF3399FF" ) , Gdip_FillEllipse( G , Brush , 320 , 78 , 5 , 5 ) , Gdip_DeleteBrush( Brush )
;~ Brush := Gdip_BrushCreateSolid( "0xFF3399FF" ) , Gdip_FillEllipse( G , Brush , Master.DotX , 78 , 5 , 5 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( Master.DotX , 80 , 4 , 12 , "0xFF336699" , "0xFF3399ff" , 1 , 1 ) , Gdip_FillEllipse( G , Brush , Master.DotX , 80 , 4 , 12 ) , Gdip_DeleteBrush( Brush )
;Slider Track
Brush := Gdip_BrushCreateSolid( "0xFF22262A" ) , Gdip_FillRectangle( G , Brush , 238 , 84 , 584 , 4 ) , Gdip_DeleteBrush( Brush )
;Slider Button
;****************************************************
; Brush := Gdip_CreateLineBrushFromRect( 239 , 78 , 16 , 15 , "0xFF000000" , "0xFF000000" , 1 , 1 ) , Gdip_FillEllipse( G , Brush , 240 , 79 , 14 , 14 ) , Gdip_DeleteBrush( Brush )
; Brush := Gdip_CreateLineBrushFromRect( 239 , 78 , 16 , 15 , "0x33000000" , "0x33000000" , 1 , 1 ) , Gdip_FillEllipse( G , Brush , 241 , 80 , 14 , 14 ) , Gdip_DeleteBrush( Brush )
; Brush := Gdip_CreateLineBrushFromRect( 239 , 78 , 16 , 15 , "0xFFF0F0F0" , "0xFF000000" , 1 , 1 ) , Gdip_FillEllipse( G , Brush , 240 , 79 , 14 , 14 ) , Gdip_DeleteBrush( Brush )
; Brush := Gdip_CreateLineBrushFromRect( 244 , 81 , 10 , 10 , "0xFFF0F0F0" , "0xFF000000" , 1 , 1 ) , Gdip_FillEllipse( G , Brush , 241 , 80 , 12 , 12 ) , Gdip_DeleteBrush( Brush )
;****************************************************
Brush := Gdip_CreateLineBrushFromRect( obj.SliderButtonX , 78 , 16 , 15 , "0xFF000000" , "0xFF000000" , 1 , 1 ) , Gdip_FillEllipse( G , Brush , obj.SliderButtonX , 79 , 14 , 14 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( obj.SliderButtonX , 78 , 16 , 15 , "0x33000000" , "0x33000000" , 1 , 1 ) , Gdip_FillEllipse( G , Brush , obj.SliderButtonX + 1 , 80 , 14 , 14 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( obj.SliderButtonX , 78 , 16 , 15 , "0xFFF0F0F0" , "0xFF000000" , 1 , 1 ) , Gdip_FillEllipse( G , Brush , obj.SliderButtonX , 79 , 14 , 14 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( obj.SliderButtonX + 5 , 81 , 10 , 10 , "0xFFF0F0F0" , "0xFF000000" , 1 , 1 ) , Gdip_FillEllipse( G , Brush , obj.SliderButtonX + 1 , 80 , 12 , 12 ) , Gdip_DeleteBrush( Brush )
;Left side slider Button 1
Brush := Gdip_BrushCreateSolid( "0x66000000" ) , Gdip_FillEllipse( G , Brush , 175 , 78 , 20 , 20 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 169 , 75 , 22 , 20 , "0xffF0F0F0" , "0xff000000" , 1 , 1 ) , Gdip_FillEllipse( G , Brush , 173 , 76 , 20 , 20 ) , Gdip_DeleteBrush( Brush )
; Brush := Gdip_CreateLineBrushFromRect( 169 , 75 , 22 , 20 , "0xffF0F0F0" , ( Master.Active = 6 ) ? ( "0xFF3399FF" ) : ( "0xff000000" ) , 1 , 1 ) , Gdip_FillEllipse( G , Brush , 173 , 76 , 20 , 20 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( ( Master.Active = 6 ) ? ( "0xFF3399FF" ) : ( "0xFF222222" ) ) , Gdip_FillEllipse( G , Brush , 175 , 78 , 16 , 16 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 178 , 81 , 12 , 12 , "0xff777777" , "0xff222222" , 1 , 1 ) , Gdip_FillEllipse( G , Brush , 176 , 79 , 14 , 14 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( ( Master.Active = 6 ) ? ( "0xFF3399FF" ) : ( "0xFF000000" ) ) , Gdip_TextToGraphics( G , "3" , "s12 Center vCenter Bold c" Brush " x174 y78" , "webdings" , 20 , 20 ) , Gdip_DeleteBrush( Brush )
;left side slider button 2
Brush := Gdip_BrushCreateSolid( "0x66000000" ) , Gdip_FillRoundedRectangle( G , Brush , 198 , 78 , 30 , 20 , 5 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 200 , 77 , 26 , 19 , "0xffF0F0F0" , "0xFF000000" , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 196 , 76 , 30 , 20 , 5 ) , Gdip_DeleteBrush( Brush )
; Brush := Gdip_CreateLineBrushFromRect( 200 , 77 , 26 , 19 , "0xffF0F0F0" , ( Master.Active = 7 ) ? ( "0xFF3399FF" ) : ( "0xff000000" ) , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 196 , 76 , 30 , 20 , 5 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( ( Master.Active = 7 ) ? ( "0xFF3399FF" ) : ( "0xFF222222" ) ) , Gdip_FillRoundedRectangle( G , Brush , 198 , 78 , 26 , 16 , 5 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 198 , 80 , 25 , 15 , "0xff777777" , "0xFF222222" , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 199 , 79 , 24 , 14 , 5 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( ( Master.Active = 7 ) ? ( "0xFF3399FF" ) : ( "0xFF000000" ) ) , Gdip_TextToGraphics( G , "7" , "s12 Center vCenter Bold c" Brush " x201 y78" , "webdings" , 20 , 20 ) , Gdip_DeleteBrush( Brush )
;Right Side Slider button 1
Brush := Gdip_BrushCreateSolid( "0x66000000" ) , Gdip_FillEllipse( G , Brush , 869 , 78 , 20 , 20 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 868 , 76 , 17 , 18 , "0xFFF0F0F0" , "0xFF000000" , 1 , 1 ) , Gdip_FillEllipse( G , Brush , 867 , 76 , 20 , 20 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( ( Master.Active = 8 ) ? ( "0xFF3399FF" ) : ( "0xFF222222" ) ) , Gdip_FillEllipse( G , Brush , 869 , 78 , 16 , 16 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 870 , 81 , 13 , 11 , "0xFF777777" , "0xFF222222" , 1 , 1 ) , Gdip_FillEllipse( G , Brush , 870 , 79 , 14 , 14 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( ( Master.Active = 8 ) ? ( "0xFF3399FF" ) : ( "0xFF000000" ) ) , Gdip_TextToGraphics( G , "4" , "s12 Center vCenter Bold c" Brush " x868 y78" , "webdings" , 20 , 20 ) , Gdip_DeleteBrush( Brush )
;Right side slider button 2
Brush := Gdip_BrushCreateSolid( "0x66000000" ) , Gdip_FillRoundedRectangle( G , Brush , 836 , 78 , 30 , 20 , 5 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 835 , 78 , 29 , 20 , "0xFFF0F0F0" , "0xFF000000" , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 834 , 76 , 30 , 20 , 5 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( ( Master.Active = 9 ) ? ( "0xFF3399FF" ) : ( "0xFF222222" ) ) , Gdip_FillRoundedRectangle( G , Brush , 836 , 78 , 26 , 16 , 5 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 838 , 81 , 23 , 13 , "0xFF777777" , "0xFF222222" , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 837 , 79 , 24 , 14 , 5 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( ( Master.Active = 9 ) ? ( "0xFF3399FF" ) : ( "0xFF000000" ) ) , Gdip_TextToGraphics( G , "8" , "s12 Center vCenter Bold c" Brush " x840 y78" , "webdings" , 20 , 20 ) , Gdip_DeleteBrush( Brush )
;DDL
Brush := Gdip_BrushCreateSolid( "0xFF999999" ) , Gdip_FillRoundedRectangle( G , Brush , 21 , 10 , 150 , 20 , 5 ) , Gdip_DeleteBrush( Brush )
Pen := Gdip_CreatePen( "0x66222222" , 1 ) , Gdip_DrawRoundedRectangle( G , Pen , 21 , 10 , 150 , 20 , 5 ) , Gdip_DeletePen( Pen )
SplitPath, % Master.FullPath[ Master.SelectedImage ] ,,,, name
;~ path := Master.FullPath[ Master.SelectedImage ]
;~ Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_TextToGraphics( G , "Picture 123456" , "s12 Center vCenter Bold c" Brush " x11 y11" , "Segoe ui" , 130 , 20 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_TextToGraphics( G , name , "s12 nowrap vCenter Bold c" Brush " x25 y11" , "Segoe ui" , 110 , 20 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 146 , 16 , 20 , 12 , "0x99F0F0F0" , "0x99000000" , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 145 , 13 , 22 , 14 , 5 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFF222222" ) , Gdip_TextToGraphics( G , "6" , "s12 Center vCenter Bold c" Brush " x146 y14" , "Webdings" , 22 , 14 ) , Gdip_DeleteBrush( Brush )
;Button 1
Brush := Gdip_CreateLineBrushFromRect( 21 , 33 , 153 , 12 , "0x99F0F0F0" , "0x99000000" , 1 , 1 ) , Gdip_FillRectangle( G , Brush , 31 , 33 , 130 , 19 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 22 , 32 , 149 , 20 , "0xFF777777" , ( Master.Active = 3 ) ? ("0xFF3399FF"):( "0xFF000000") , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRectangle( G , Pen , 31 , 33 , 130 , 19 ) , Gdip_DeletePen( Pen )
Brush := Gdip_BrushCreateSolid( ( Master.Active = 3 ) ? ("0x663399FF" ) : ( "0x66F0F0F0" ) ) , Gdip_FillEllipse( G , Brush , 50 , 35 , 90 , 7 ) , Gdip_DeleteBrush( Brush )
if( Master.Active = 3 )
Brush := Gdip_BrushCreateSolid( "0xFF3399FF" )
Else
Brush := Gdip_BrushCreateSolid( "0xFFDDDDDD" )
Gdip_TextToGraphics( G , "Change Folder" , "s12 Center vCenter Bold c" Brush " x20 y33" , "Segoe ui" , 150 , 19 )
Gdip_TextToGraphics( G , "Change Folder" , "s12 Center vCenter Bold c" Brush " x21 y33" , "Segoe ui" , 150 , 19 )
Gdip_TextToGraphics( G , "Change Folder" , "s12 Center vCenter Bold c" Brush " x22 y34" , "Segoe ui" , 150 , 19 )
Gdip_TextToGraphics( G , "Change Folder" , "s12 Center vCenter Bold c" Brush " x22 y35" , "Segoe ui" , 150 , 19 )
Gdip_TextToGraphics( G , "Change Folder" , "s12 Center vCenter Bold c" Brush " x21 y35" , "Segoe ui" , 150 , 19 )
Gdip_TextToGraphics( G , "Change Folder" , "s12 Center vCenter Bold c" Brush " x20 y35" , "Segoe ui" , 150 , 19 )
Gdip_TextToGraphics( G , "Change Folder" , "s12 Center vCenter Bold c" Brush " x20 y34" , "Segoe ui" , 150 , 19 )
Gdip_TextToGraphics( G , "Change Folder" , "s12 Center vCenter Bold c" Brush " x22 y33" , "Segoe ui" , 150 , 19 )
Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_TextToGraphics( G , "Change Folder" , "s12 Center vCenter Bold c" Brush " x21 y34" , "Segoe ui" , 150 , 19 ) , Gdip_DeleteBrush( Brush )
Pen := Gdip_CreatePen( ( Master.Active = 3 ) ? ("0xFF3399FF" ) : ( "0xFFF0F0F0" ) , 1 ) , Gdip_DrawLine( G , Pen , 33 , 35 , 158 , 35 ) , Gdip_DeletePen( Pen )
Pen := Gdip_CreatePen( ( Master.Active = 3 ) ? ("0xFF3399FF" ) : ( "0xFF222222" ) , 1 ) , Gdip_DrawLine( G , Pen , 43 , 50 , 148 , 50 ) , Gdip_DeletePen( Pen )
;Button 2
Brush := Gdip_CreateLineBrushFromRect( 30 , 56 , 131 , 12 , "0x99F0F0F0" , "0x99000000" , 1 , 1 ) , Gdip_FillRectangle( G , Brush , 31 , 56 , 130 , 19 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 21 , 50 , 150 , 18 , "0xFF777777" , ( Master.Active = 4 ) ? ("0xFF3399FF"):( "0xFF000000") , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRectangle( G , Pen , 31 , 56 , 130 , 19 ) , Gdip_DeletePen( Pen )
Brush := Gdip_BrushCreateSolid( ( Master.Active = 4 ) ? ("0x663399FF" ) : ( "0x66F0F0F0" ) ) , Gdip_FillEllipse( G , Brush , 50 , 58 , 90 , 7 ) , Gdip_DeleteBrush( Brush )
if( Master.Active = 4 )
Brush := Gdip_BrushCreateSolid( "0xFF3399FF" )
Else
Brush := Gdip_BrushCreateSolid( "0xFFDDDDDD" )
Gdip_TextToGraphics( G , "Use Image" , "s12 Center vCenter Bold c" Brush " x20 y56" , "Segoe ui" , 150 , 19 )
Gdip_TextToGraphics( G , "Use Image" , "s12 Center vCenter Bold c" Brush " x22 y57" , "Segoe ui" , 150 , 19 )
Gdip_TextToGraphics( G , "Use Image" , "s12 Center vCenter Bold c" Brush " x22 y58" , "Segoe ui" , 150 , 19 )
Gdip_TextToGraphics( G , "Use Image" , "s12 Center vCenter Bold c" Brush " x21 y58" , "Segoe ui" , 150 , 19 )
Gdip_TextToGraphics( G , "Use Image" , "s12 Center vCenter Bold c" Brush " x20 y58" , "Segoe ui" , 150 , 19 )
Gdip_TextToGraphics( G , "Use Image" , "s12 Center vCenter Bold c" Brush " x20 y57" , "Segoe ui" , 150 , 19 )
Gdip_TextToGraphics( G , "Use Image" , "s12 Center vCenter Bold c" Brush " x22 y56" , "Segoe ui" , 150 , 19 )
Gdip_TextToGraphics( G , "Use Image" , "s12 Center vCenter Bold c" Brush " x21 y56" , "Segoe ui" , 150 , 19 )
Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_TextToGraphics( G , "Use Image" , "s12 Center vCenter Bold c" Brush " x21 y57" , "Segoe ui" , 150 , 19 ) , Gdip_DeleteBrush( Brush )
Pen := Gdip_CreatePen( ( Master.Active = 4 ) ? ( "0xFF3399FF" ) : ( "0xFFF0F0F0" ) , 1 ) , Gdip_DrawLine( G , Pen , 33 , 58 , 158 , 58 ) , Gdip_DeletePen( Pen )
Pen := Gdip_CreatePen( ( Master.Active = 4 ) ? ( "0xFF3399FF" ) : ( "0xFF222222" ) , 1 ) , Gdip_DrawLine( G , Pen , 43 , 73 , 148 , 73 ) , Gdip_DeletePen( Pen )
;files
Brush := Gdip_BrushCreateSolid( "0xFFF0F0F0" )
;files , Gdip_TextToGraphics( G , "104 / 165" , "s16 Center vCenter Bold c" Brush " x20 y80" , "Segoe ui" , 150 , 19 ) , Gdip_DeleteBrush( Brush )
; Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_TextToGraphics( G , "104 / 165" , "s16 Center vCenter Bold c" Brush " x21 y81" , "Segoe ui" , 150 , 19 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_TextToGraphics( G , obj.Index " / " obj.FullPath.Length() , "s16 Center vCenter Bold c" Brush " x22 y82" , "Segoe ui" , 150 , 19 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFF3399FF" ) , Gdip_TextToGraphics( G , obj.Index " / " obj.FullPath.Length() , "s16 Center vCenter Bold c" Brush " x21 y81" , "Segoe ui" , 150 , 19 ) , Gdip_DeleteBrush( Brush )
;Move Window
Brush := Gdip_BrushCreateSolid( ( Master.Active = 1 ) ? ( "0x663399FF" ):( "0x66000000" ) ) , Gdip_FillEllipse( G , Brush , 5 , 33 , 22 , 58 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( ( Master.Active = 1 ) ? ( "0xFF000000" ) : ( "0xFFF0F0F0" ) ) , Gdip_TextToGraphics( G , "8" , "s18 Center vCenter c" Brush " x6 y37" , "Wingdings" , 20 , 58 ) , Gdip_DeleteBrush( Brush )
;close button
Brush := Gdip_BrushCreateSolid( ( Master.Active = 5 ) ? ( "0x663399FF" ) : ( "0x66000000" ) ) , Gdip_FillRoundedRectangle( G , Brush , 885 , 11 , 10 , 57 , 3 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( ( Master.Active = 5 ) ? ( "0xFF000000" ) : ( "0xFFF0F0F0" ) ) , Gdip_TextToGraphics( G , "CLOSE" , "s8 Center vCenter Bold c" Brush " x885 y11" , "Segoe ui" , 10 , 57 ) , Gdip_DeleteBrush( Brush )
Gdip_DeleteGraphics( G )
return pBitmap
}
ImageViewerDisplayPanel(){
;Bitmap Created Using: HB Bitmap Maker
pBitmap := Gdip_CreateBitmap( 900 , 310 ) , G := Gdip_GraphicsFromImage( pBitmap ) , Gdip_SetSmoothingMode( G , 2 )
;left panel
Brush := Gdip_CreateLineBrushFromRect( 1 , 88 , 220 , 220 , "0x99F0F0F0" , "0x99000000" , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 1 , 88 , 220 , 220 , 5 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 1 , 88 , 220 , 220 , "0x99F0F0F0" , "0x99000000" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( G , Pen , 1 , 88 , 220 , 220 , 5 ) , Gdip_DeletePen( Pen )
Brush := Gdip_CreateLineBrushFromRect( 2 , -1 , 897 , 310 , "0x993399FF" , "0x33000000" , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 5 , 95 , 210 , 210 , 5 ) , Gdip_DeleteBrush( Brush )
;Active Panel
Brush := Gdip_CreateLineBrushFromRect( 222 , 1 , 307 , 307 , "0x99F0F0F0" , "0x99000000" , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 222 , 1 , 307 , 307 , 5 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 222 , 1 , 307 , 307 , "0x99F0F0F0" , "0x99000000" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( G , Pen , 222 , 1 , 307 , 307 , 5 ) , Gdip_DeletePen( Pen )
Brush := Gdip_CreateLineBrushFromRect( -1 , 0 , 899 , 308 , "0x993399FF" , "0x33000000" , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 223 , 3 , 304 , 304 , 5 ) , Gdip_DeleteBrush( Brush )
;right panel
Brush := Gdip_CreateLineBrushFromRect( 530 , 88 , 220 , 220 , "0x99F0F0F0" , "0x99000000" , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 530 , 88 , 220 , 220 , 5 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 530 , 88 , 220 , 220 , "0x99F0F0F0" , "0x99000000" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( G , Pen , 530 , 88 , 220 , 220 , 5 ) , Gdip_DeletePen( Pen )
Brush := Gdip_CreateLineBrushFromRect( -1 , 0 , 900 , 310 , "0x993399FF" , "0x33000000" , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 535 , 95 , 210 , 210 , 5 ) , Gdip_DeleteBrush( Brush )
Gdip_DeleteGraphics( G )
return pBitmap
}
DDLGraphics(){
;Bitmap Created Using: HB Bitmap Maker
pBitmap := Gdip_CreateBitmap( 330 , 280 ) , G := Gdip_GraphicsFromImage( pBitmap ) , Gdip_SetSmoothingMode( G , 2 )
Brush := Gdip_BrushCreateSolid( "0xFF999999" ) , Gdip_FillRoundedRectangle( G , Brush , 0 , 0 , 330 , 280 , 5 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 302 , 7 , 23 , 229 , "0xFFC5C5C5" , "0xFF444444" , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 300 , 5 , 25 , 230 , 5 ) , Gdip_DeleteBrush( Brush )
;ok button
Brush := Gdip_CreateLineBrushFromRect( 302 , 241 , 23 , 36 , "0xFFC5C5C5" , "0xFF444444" , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 300 , 239 , 25 , 36 , 5 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFFF0F0F0" ) , Gdip_TextToGraphics( G , "OK" , "s12 Center vCenter Bold c" Brush " x300 y239" , "Segoe ui" , 25 , 36 ) , Gdip_DeleteBrush( Brush )
;List cells
;***********************************************************
Brushes := {}
Brushes.BG1 := Gdip_BrushCreateSolid( "0xFF333333" )
Brushes.BG2 := Gdip_BrushCreateSolid( "0xFF444444" )
Brushes.Selected := Gdip_BrushCreateSolid( "0xff3399ff" )
Brushes.Hover := Gdip_BrushCreateSolid( "0x66336699" )
Brushes.MainTextB := Gdip_BrushCreateSolid( "0xFFF0F0F0" )
Brushes.SelTextB := Gdip_BrushCreateSolid( "0xFF000000" )
;~ Master.DDL.Value := Master.SelectedImage
y := 5
Loop, % 13 {
SplitPath, % Master.FullPath[ A_Index + Master.Index - 1 ] ,,,, name
if( ( A_Index + Master.Index - 1 ) != Master.SelectedImage ){
Gdip_FillRoundedRectangle( G , ( tog := !tog ) ? ( Brushes.BG1 ) : ( Brushes.BG2 ) , 5 , y , 290 , 20 , 5 )
}else{
Gdip_FillRoundedRectangle( G , Brushes.Selected , 5 , y , 290 , 20 , 5 )
;Highlighted Cell
Brush := Gdip_CreateLineBrushFromRect( 5 , y , 290 , 20 , "0xFF336699" , "0xFF222222" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 2 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( G , Pen , 5 , y , 290 , 20 , 5 ) , Gdip_DeletePen( Pen )
}
if( Master.DDL.HoverActive = A_Index && ( A_Index + Master.Index - 1 ) != Master.SelectedImage ){
Gdip_FillRoundedRectangle( G , Brushes.Hover , 5 , y , 290 , 20 , 5 )
}
Brush := Gdip_BrushCreateSolid( ( ( A_Index + Master.Index - 1 ) = Master.SelectedImage ) ? ( "0xFF000000" ) : ( "0xFFF0F0F0" ) ) , Gdip_TextToGraphics( G , Name , "s12 left nowrap vCenter Bold c" Brush " x14 y" y + 1 , "Segoe ui" , 270 , 20 ) , Gdip_DeleteBrush( Brush )
;~ if( ( A_Index + Master.Index - 1 ) = Master.SelectedImage ){
;~ Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_TextToGraphics( G , name , "s12 left vCenter Bold nowrap c" Brush " x15 y" y + 1 , "Segoe ui" , 270 , 20 ) , Gdip_DeleteBrush( Brush )
;~ }
y += 21
}
for k, v in Brushes
Gdip_DeleteBrush( Brushes[ k ] )
;slider button
Brush := Gdip_CreateLineBrushFromRect( 301 , Master.DDL.SliderButtonY , 22 , 86 , "0xFF777777" , "0xFF333333" , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 302 , Master.DDL.SliderButtonY , 21 , 90 , 5 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFF333333" ) , Gdip_FillRectangle( G , Brush , 305 , Master.DDL.SliderButtonY + 44 , 15 , 3 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFF333333" ) , Gdip_FillRectangle( G , Brush , 305 , Master.DDL.SliderButtonY + 55 - 7 , 15 , 3 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFF333333" ) , Gdip_FillRectangle( G , Brush , 305 , Master.DDL.SliderButtonY + 59 - 7 , 15 , 3 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFF333333" ) , Gdip_FillRectangle( G , Brush , 305 , Master.DDL.SliderButtonY + 47 - 7 , 15 , 3 ) , Gdip_DeleteBrush( Brush )
Gdip_DeleteGraphics( G )
return pBitmap
}
_CreateWindows( obj ){
obj.Gui1 := New PopUpWindow( { WindowName: "1" , WindowOptions: " -DPIScale +AlwaysOnTop " , WindowSmoothing: 2 , X: 300 , Y: 410 , W: 900 , H: 100 } )
obj.Gui1.ShowWindow()
obj.Gui1.DrawBitmap( ImageViewerMain( obj ) , { X: 0 , Y: 0 , W: 900 , H: 100 } , dispose := 1 )
Loop, % obj.BitMaps.Length()
obj.Gui1.DrawBitmap( obj.BitMaps[ A_Index ].Bitmap , { X: obj.BitMaps[ A_Index ].X , Y: obj.BitMaps[ A_Index ].Y , W: obj.BitMaps[ A_Index ].Width , H: obj.BitMaps[ A_Index ].Height } , dispose := 0 )
obj.Gui1.UpdateWindow()
}
ResizeIt( PB , ByRef tWidth , ByRef tHeight , InputValue ){
Gdip_GetDimensions( PB , tWidth , tHeight )
if( tWidth > InputValue && tWidth >= tHeight )
Ratio := tHeight / tWidth , tWidth := InputValue , tHeight := InputValue * Ratio
else if( tHeight > InputValue && tHeight >= tWidth )
Ratio := tWidth / tHeight , tHeight := InputValue , tWidth := InputValue * Ratio
else if( tWidth > InputValue && tWidth <= tHeight )
Ratio := tWidth / tHeight , tHeight := InputValue , tWidth := InputValue * Ratio
}
;************************************************************************************************************************************************************************************************
;************************************************************************************************************************************************************************************************
;************************************************************************************************************************************************************************************************
;************************************************************************************************************************************************************************************************
;************************************************************************************************************************************************************************************************
class PopUpWindow {
;Class By: Hellbent
;Apr 2021
static Index := 0 , Windows := [] , Handles := [] , HelpHandles := [] , HelperEditHwnd
__New( obj := "" ){
This._SetDefaults()
if( isObject( obj ) )
This.SetWindowProperties( obj )
This._SetupWindowGraphics()
}
_SetDefaults(){
PopUpWindow.Index++
This.WindowName := "HBLayeredWindow" PopUpWindow.Index
This.WindowSmoothing := 2
This.WindowOptions := " -DPIScale +AlwaysOnTop "
This.X := 10
This.Y := 10
This.W := 10
This.H := 10
}
PaintBackground( color := "0xFF000000" ){
Brush := Gdip_BrushCreateSolid( color )
Gdip_FillRectangle( This.G , Brush , -1 , -1 , This.W + 2 , This.H + 2 )
Gdip_DeleteBrush( Brush )
}
_SetupWindowGraphics(){
This.Hwnd := This._CreateGUI()
This.hbm := CreateDIBSection( This.W , This.H )
This.hdc := CreateCompatibleDC()
This.obm := SelectObject( This.hdc , This.hbm )
This.G := Gdip_GraphicsFromHDC( This.hdc )
Gdip_SetSmoothingMode( This.G , This.WindowSmoothing )
PopUpWindow.Handles[ This.Hwnd ] := PopUpWindow.Index
PopUpWindow.Windows[ PopUpWindow.Index ] := This
}
SetWindowProperties( obj ){
local k , v
for k , v in obj
if( k != "hwnd" )
This[k] := v
}
ShowWindow( Title := "" ){
Gui , % This.WindowName ":Show", % "x" This.X " y" This.Y " w" This.W " h" This.H " NA", % Title
}
HideWindow(){
Gui , % This.WindowName ":Hide",
}
UpdateWindow(){
UpdateLayeredWindow( This.hwnd , This.hdc , This.X , This.Y , This.W , This.H )
}
ClearWindow(){
Gdip_GraphicsClear( This.G )
}
DrawBitmap( pBitmap , obj , dispose := 1 ){
Gdip_DrawImage( This.G , pBitmap , obj.X , obj.Y , obj.W , obj.H )
if( dispose )
Gdip_DisposeImage( pBitmap )
}
DeleteWindow(){
Gui, % This.WindowName ":Destroy"
SelectObject( This.hdc , This.obm )
DeleteObject( This.hbm )
DeleteDC( This.hdc )
Gdip_DeleteGraphics( This.G )
hwnd := This.Hwnd
for k, v in PopUpWindow.Windows[ Hwnd ]
This[k] := ""
PopUpWindow.Windows[ Hwnd ] := ""
}
_CreateGUI(){
local hwnd
Gui , % This.WindowName ":New" , % " +E0x80000 hwndhwnd -Caption " This.WindowOptions
return hwnd
}
Helper(){
local List := ["New Window","SetWindowProperties","ShowWindow","HideWindow","UpdateWindow","ClearWindow","DrawBitmap","PaintBackground","DeleteWindow"]
local hwnd, bd
Gui, HBLWHelperGui:New, +AlwaysOnTop
Gui, HBLWHelperGui:Color, 62666a, 24282c
Gui, HBLWHelperGui:Font, cWhite s10 , Segoe UI
Gui, HBLWHelperGui:Margin, 5 , 5
Gui, HBLWHelperGui:Add, Edit, xm ym w200 r1 Center hwndHwnd, Gui1
PopUpWindow.HelperEditHwnd := Hwnd
Gui, HBLWHelperGui:Margin, 5 , 1
Loop, % List.Length() {
Gui, HBLWHelperGui:Add, Button, xm wp h23 -Theme hwndhwnd, % List[ A_Index ]
PopUpWindow.HelpHandles[hwnd] := List[ A_Index ]
bd := PopUpWindow._ClipIt.Bind( PopUpWindow )
GuiControl , HBLWHelperGui: +G , % Hwnd , % bd
}
Gui, HBLWHelperGui:Show,
}
_ClipIt(){
local List := ["New Window","SetWindowProperties","ShowWindow","HideWindow","UpdateWindow","ClearWindow","DrawBitmap","PaintBackground","DeleteWindow"]
local Output , FQ := 400
GuiControlGet, Output , HBLWHelperGui: , % PopUpWindow.HelperEditHwnd
Switch A_GuiControl
{
case List[1]:
Clipboard := Output " := New PopUpWindow( { WindowName: ""1"" , WindowOptions: "" -DPIScale +AlwaysOnTop "" , WindowSmoothing: 2 , X: ""Center"" , Y: ""Center"" , W: 100 , H: 100 } )"
loop 2
SoundBeep, FQ
return
case List[2]:
Clipboard := Output ".SetWindowProperties( { X: """" , Y: """" , W: """" , H: """" } )"
loop 2
SoundBeep, FQ
return
case List[3]:
Clipboard := Output ".ShowWindow( MyWindowTitle := """" )"
loop 2
SoundBeep, FQ
return
case List[4]:
Clipboard := Output ".HideWindow()"
loop 2
SoundBeep, FQ
return
case List[5]:
Clipboard := Output ".UpdateWindow()"
loop 2
SoundBeep, FQ
return
case List[6]:
Clipboard := Output ".ClearWindow()"
loop 2
SoundBeep, FQ
return
case List[7]:
Clipboard := Output ".DrawBitmap( pBitmap := """" , { X: """" , Y: """" , W: """" , H: """" } , dispose := 1 )"
loop 2
SoundBeep, FQ
return
case List[8]:
Clipboard := Output ".PaintBackground( color := ""0xFF000000"" )"
loop 2
SoundBeep, FQ
return
case List[9]:
Clipboard := Output ".DeleteWindow()"
loop 2
SoundBeep, FQ
return
Default:
ToolTip, Looks like a new case needs to be added
return
}
}
}