Skip to content

Commit

Permalink
Merge pull request #16 from ruchuby/develop
Browse files Browse the repository at this point in the history
Starter v0.3.3
  • Loading branch information
AkiChase authored Apr 6, 2023
2 parents 0ce8768 + fd1ac0b commit 2fdee9e
Show file tree
Hide file tree
Showing 20 changed files with 926 additions and 127 deletions.
Binary file added resource/img/copy.ico
Binary file not shown.
Binary file added resource/img/link.ico
Binary file not shown.
Binary file added resource/img/setting.ico
Binary file not shown.
4 changes: 2 additions & 2 deletions src/Gui/AboutGui.ah2
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
* @Version: 0.0.3
* @Author: ruchuby
* @LastEditors: ruchuby
* @LastEditTime: 2023-04-04
* @LastEditTime: 2023-04-06
* @Description: 关于界面显示版本信息、项目主页、检查更新
*/
class AboutGui {
static version := "0.3.2"
static version := "0.3.3"
; static gui:=unset

static init() {
Expand Down
38 changes: 26 additions & 12 deletions src/Gui/SearchGui/IntelligentMode.ah2
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ class IntelligentMode {
; static listView := unset
; static menu := unset
static imgListID := 0
static rowHeight := 0
static imgPathToImgListIndex := Map()
static hotkeyHandlerMap := Map()

Expand All @@ -15,11 +16,13 @@ class IntelligentMode {
{
get => this.listView.GetNext()
set {
if (value > GlobalData.intelligentSearchResult.Length + this.pluginSearchResult.Length)
value := 1
else if (value == 0)
value := GlobalData.startupSearchResult.Length + this.pluginSearchResult.Length
this.listView.Modify(value, "Select Focus Vis")
if (GlobalData.intelligentSearchResult.Length || this.pluginSearchResult.Length) { ; 有内容才可修改
if (value > GlobalData.intelligentSearchResult.Length + this.pluginSearchResult.Length)
value := 1
else if (value == 0)
value := GlobalData.startupSearchResult.Length + this.pluginSearchResult.Length
this.listView.Modify(value, "Select Focus Vis")
}
}
}
;#endregion
Expand All @@ -40,7 +43,7 @@ class IntelligentMode {

static init() {
; 本列表默认隐藏
this.listView := SearchGui.gui.Add("ListView", "x10 y50 w510 r8 -Multi -hdr -E0x200 Hidden Count" 3, [""])
this.listView := SearchGui.gui.Add("ListView", "x10 y52 w560 r10 -Multi -hdr -E0x200 Hidden Count" 3, [""])
this.listView.SetFont("s14 w700 c444444")

this.loadImgs()
Expand Down Expand Up @@ -246,14 +249,25 @@ class IntelligentMode {
this.listView.Add("Icon" this.imgPathToImgListIndex[GlobalData.imgDir "\noImg.png"], " " item["title"])
}

;重置listView和gui高度
this.resizeGui()
}

;重置listView和gui高度
static resizeGui() {
len := GlobalData.intelligentSearchResult.Length + this.pluginSearchResult.Length
LVHeight := Round((len >= 8 ? 8 : len) * 26.4) ; 此处不需要DPI缩放计算
this.listView.Move(, , , LVHeight)
this.listView.ModifyCol(1, "480")
this.listView.Modify(1, "Select Focus Vis") ;聚焦第一行
if (len && this.rowHeight == 0) {
LV_XYstruct := Buffer(16, 0)
SendMessage(0x1038, 1, LV_XYstruct.Ptr, , this.listView)
if (rowH := NumGet(LV_XYstruct, 12, "UInt") - NumGet(LV_XYstruct, 4, "UInt"))
this.rowHeight := rowH
}

LVHeight := len > 0 ? Ceil((len >= 8 ? 8 : len) * this.rowHeight) : 0
ControlMove(, , , LVHeight, this.listView) ; 使用ControlMove避免DPI 缩放
this.listView.ModifyCol(1, "530")
this.focusedRow := 1 ;聚焦第一行
this.listView.Opt("Redraw")
WinMove(, , 500 * (A_ScreenDPI / 96), Round((LVHeight + 55) * (A_ScreenDPI / 96)), SearchGui.gui)
WinMove(, , 550 * (A_ScreenDPI / 96), LVHeight + Ceil(55 * (A_ScreenDPI / 96)), SearchGui.gui)
}

; 载入插件图片
Expand Down
76 changes: 55 additions & 21 deletions src/Gui/SearchGui/PluginMode.ah2
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @Version: 0.0.1
* @Author: ruchuby
* @LastEditors: ruchuby
* @LastEditTime: 2023-04-04
* @LastEditTime: 2023-04-06
* @Description: 插件模式
*/

Expand All @@ -21,9 +21,11 @@ class PluginMode {
static runHandler := (*) => 0
static doubleLeftHandler := (*) => 0
static loadImgsHandler := (*) => 0
static toBottomHandler := (*) => 0

static pluginSearchData := []
static pluginSearchResult := []
static pluginOtherData := 0 ; 可自定义此数据

static _default_thumb := 0
static _thumb := 0
Expand All @@ -39,11 +41,14 @@ class PluginMode {
{
get => this.listView.GetNext()
set {
if (value > this.pluginSearchResult.Length)
value := 1
else if (value == 0)
value := this.pluginSearchResult.Length
this.listView.Modify(value, "Select Focus Vis")
if (this.pluginSearchResult.Length) { ; 有内容才可修改
if (value > this.pluginSearchResult.Length)
value := 1
else if (value == 0)
value := this.pluginSearchResult.Length
this.listView.Modify(value, "Select Focus Vis")
this.toBottomNotify() ; 触发检测
}
}
}
;#endregion
Expand All @@ -64,29 +69,53 @@ class PluginMode {

; 初始化
static init() {
this.listView := SearchGui.gui.Add("ListView", "x10 y50 w510 r8 -Multi -hdr -E0x200", [""])
this.listView := SearchGui.gui.Add("ListView", "x10 y52 w560 r10 -Multi -hdr -E0x200", [""])
this.listView.SetFont("s14 w700 c444444")

; 鼠标双击运行
this.listView.OnEvent("DoubleClick", (_lv, rowNum) => rowNum ? this.pluginRun(rowNum) : 0)
this.listView.OnEvent("DoubleClick", (_, rowNum) => rowNum ? this.pluginRun(rowNum) : 0)
; 菜单栏
this.listView.OnEvent("ContextMenu", (_lv, rowNum, *) => rowNum ? this.showMenu() : 0)
this.listView.OnEvent("ContextMenu", (_, rowNum, *) => rowNum ? this.showMenu() : 0)

LVN_ENDSCROLL := -181
this.listView.OnNotify(LVN_ENDSCROLL, this.toBottomNotify) ;滚动结束时检测是否触底

; 插件模式热键处理函数
this.hotkeyHandlerMap["~Esc"] := () => StrLen(SearchGui.searchText) ?
SearchGui.searchText := SearchGui.edit.Value := "" : SearchGui.mode := this.oldMode ;切回原来的模式

this.hotkeyHandlerMap["~Left Up"] := () => (A_ThisHotkey == A_PriorHotkey && A_TimeSincePriorHotkey < 250) ? this.pluginRun(, true) : 0
rightUpHandler() {
static lastEndFlag := false
EditCtrlFunc.getSelection(&s, &e, SearchGui.edit)
if (s == e && e == StrLen(SearchGui.searchText)) { ; 选区是否位于最后
if ((A_ThisHotkey == A_PriorHotkey && A_TimeSincePriorHotkey < 250) && (rowNum := this.focusedRow) && lastEndFlag) {
this.pluginRun(, true)
}
lastEndFlag := true
} else
lastEndFlag := false
}
this.hotkeyHandlerMap["~Right Up"] := rightUpHandler

this.hotkeyHandlerMap["Down"] := () => this.focusedRow++
this.hotkeyHandlerMap["Up"] := () => this.focusedRow--

this._default_thumb := LoadPicture(GlobalData.imgDir "\plugin.png", "w64")
}

; 重新加载搜索列表图标资源
static reloadIL(ILFlag) {
SearchGui.placeholder := "正在加载插件模式搜索列表..."
; 检测是否触底并发出通知
static toBottomNotify(*) {
static LVM_ISITEMVISIBLE := 0x10B6
index := PluginMode.pluginSearchResult.Length
if (index) {
res := SendMessage(LVM_ISITEMVISIBLE, index - 1, 0, PluginMode.listView)
if (res)
PluginMode.toBottomHandler() ;调用触底处理函数
}
}

; 重置列表和图标资源
static reloadLVIL(ILFlag) {
this.listView.Opt("-Redraw")
this.listView.Delete() ;清空搜索列表

Expand All @@ -110,27 +139,32 @@ class PluginMode {
}


static showPluginMode(pluginSearchData, searchHandler, runHandler, doubleLeftHandler?, loadImgsHandler?, menuInitHandler?, searchText := "", placeholder := "", thumb?) {
static showPluginMode(pluginSearchData, searchHandler, runHandler, doubleLeftHandler?, loadImgsHandler?, toBottomHandler?, initHandler?, searchText := "", placeholder := "", thumb?) {
this.oldMode := SearchGui.mode

this.pluginSearchData := pluginSearchData
this.searchHandler := searchHandler
this.runHandler := runHandler
this.doubleLeftHandler := IsSet(doubleLeftHandler) ? doubleLeftHandler : (*) => 0
this.loadImgsHandler := IsSet(loadImgsHandler) ? loadImgsHandler : (*) => 0
this.toBottomHandler := IsSet(toBottomHandler) ? toBottomHandler : (*) => 0

this.pluginOtherData := 0
this.rowHeight := 0
this.menu := 0
if (IsSet(menuInitHandler))
menuInitHandler(this)

this.reloadIL(IsSet(loadImgsHandler))
if (IsSet(initHandler))
initHandler(this)

this.thumb := IsSet(thumb) ? thumb : 0
SearchGui.mode := -1
SearchGui.placeholder := placeholder
; 隐藏多余部分
WinMove(, , 550 * (A_ScreenDPI / 96), Ceil(55 * (A_ScreenDPI / 96)), SearchGui.gui)
this.reloadLVIL(IsSet(loadImgsHandler))

SearchGui.edit.Value := SearchGui.searchText := searchText ;同时触发搜索
EditCtrlFunc.editSelect(SearchGui.edit, StrLen(searchText), -1) ; 指示器移动到最后


if (!WinActive(SearchGui.gui)) { ; 窗口未激活
SearchGui.gui.Show()
Expand All @@ -149,12 +183,12 @@ class PluginMode {
this.rowHeight := rowH
}

LVHeight := len > 0 ? Round((len >= 8 ? 8 : len) * this.rowHeight) : 0
LVHeight := len > 0 ? Ceil((len >= 8 ? 8 : len) * this.rowHeight) : 0
ControlMove(, , , LVHeight, this.listView) ; 使用ControlMove避免DPI 缩放
this.listView.ModifyCol(1, "480")
this.listView.ModifyCol(1, "530")
this.focusedRow := 1 ;聚焦第一行
this.listView.Opt("Redraw")
WinMove(, , 500 * (A_ScreenDPI / 96), LVHeight + Round(55 * (A_ScreenDPI / 96)), SearchGui.gui)
WinMove(, , 550 * (A_ScreenDPI / 96), LVHeight + Ceil(55 * (A_ScreenDPI / 96)), SearchGui.gui)
}

static pluginRun(rowNum?, doubleLeft := false) {
Expand Down
14 changes: 8 additions & 6 deletions src/Gui/SearchGui/SearchGui.ah2
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class SearchGui {

;#region 设置搜索框占位符
static placeholder {
set => DllCall("User32.dll\SendMessageW", "Ptr", SearchGui.edit.Hwnd, "Uint", (0x1500 + 1), "Ptr", True, "WStr", value)
set => EditCtrlFunc.setPlaceholder(SearchGui.edit, value)
}
;#endregion

Expand Down Expand Up @@ -87,7 +87,7 @@ class SearchGui {
this.gui.SetFont(, "雅痞-简") ;优先使用更好看的字体
this.gui.MarginY := 0

this.edit := this.gui.AddEdit("x10 y10 h30 w445 -E0x200")
this.edit := this.gui.AddEdit("x10 y10 h30 w495 -E0x200")
this.placeholder := "Hi, Starter"
this.edit.Focus()

Expand All @@ -101,14 +101,14 @@ class SearchGui {


this.thumbList := [LoadPicture(GlobalData.imgDir "\Starter.png", "w64"), LoadPicture(GlobalData.imgDir "\AI.png", "w64")]
this.thumb := this.gui.AddPicture("x460 y10 w30 h30", "hBitmap:*" this.thumbList[1])
this.thumb := this.gui.AddPicture("x510 y10 w30 h30", "hBitmap:*" this.thumbList[1])

; 回车触发
this.gui.AddButton("Default Hidden").OnEvent("Click", (*) => this.mode == 0 ?
StartupMode.startupRun() : this.mode == 1 ?
IntelligentMode.intelligentRun() : PluginMode.pluginRun())

this.gui.Show("Hide y" Round(A_ScreenHeight / 5))
this.gui.Show("w550 Hide y" Ceil(A_ScreenHeight / 5))
StartupMode.init()
IntelligentMode.init()
PluginMode.init()
Expand Down Expand Up @@ -169,7 +169,7 @@ class SearchGui {
; 清空、隐藏
Hotkey("~Esc", hotkeyHandler)
; 文件夹中显示
Hotkey("~Left Up", hotkeyHandler)
Hotkey("~Right Up", hotkeyHandler)
; 上下移动焦点行
Hotkey("Down", hotkeyHandler)
Hotkey("Up", hotkeyHandler)
Expand All @@ -195,13 +195,15 @@ class SearchGui {
}

; 根据模式隐藏主界面
static hideGui() {
static hideGui(recordHideTime := false) {
if (this.mode == 0) {
StartupMode.hideGui()
} else if (this.mode == 1) {
IntelligentMode.hideGui()
} else {
PluginMode.hideGui()
}
if (recordHideTime) ;记录关闭时间,15s内可恢复
SearchGui.hideTime := A_Now
}
}
Loading

0 comments on commit 2fdee9e

Please sign in to comment.