Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ドラッグ操作でタブの並び替え、最後のタブより右の位置にドラッグした場合に最後のタブの位置にする #1099

Merged
merged 1 commit into from
Nov 24, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions sakura_core/window/CTabWnd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
#include "util/module.h"
#include "util/string_ex2.h"
#include "sakura_rc.h"
#include <windowsx.h>

//#if(WINVER >= 0x0500)
#ifndef SPI_GETFOREGROUNDLOCKTIMEOUT
Expand Down Expand Up @@ -312,11 +313,22 @@ LRESULT CTabWnd::OnTabMouseMove( WPARAM wParam, LPARAM lParam )
{
TCHITTESTINFO hitinfo;
int i;
int nTabCount;
hitinfo.pt.x = LOWORD( (DWORD)lParam );
hitinfo.pt.y = HIWORD( (DWORD)lParam );
int nTabCount = TabCtrl_GetItemCount(m_hwndTab);
hitinfo.pt.x = GET_X_LPARAM( lParam );
hitinfo.pt.y = GET_Y_LPARAM( lParam );
int nDstTab = TabCtrl_HitTest( m_hwndTab, (LPARAM)&hitinfo );

// 最後のタブより右の位置にドラッグした場合に最後のタブの位置にする
if (nDstTab == -1 && m_nTabBorderArray) {
if (hitinfo.pt.x >= m_nTabBorderArray[nTabCount - 1]) {
RECT rc;
GetClientRect(m_hwndTab, &rc);
if (hitinfo.pt.y >= rc.top && hitinfo.pt.y < rc.bottom) {
nDstTab = nTabCount - 1;
}
}
}

// 各タブの閉じるボタン描画用処理
EDispTabClose bDispTabClose = m_pShareData->m_Common.m_sTabBar.m_bDispTabClose;
if( bDispTabClose && ::GetCapture() != m_hwndTab ){
Expand Down Expand Up @@ -393,8 +405,8 @@ LRESULT CTabWnd::OnTabMouseMove( WPARAM wParam, LPARAM lParam )
if( m_nTabBorderArray ){
delete[] m_nTabBorderArray;
}
m_nTabBorderArray = new LONG[nTabCount];
for (i = 0 ; i < nTabCount-1; i++) {
m_nTabBorderArray = new LONG[nTabCount + 1];
for (i = 0 ; i < nTabCount; i++) {
RECT rc;
TabCtrl_GetItemRect(m_hwndTab, i, &rc);
m_nTabBorderArray[ i ] = rc.right;
Expand All @@ -418,6 +430,8 @@ LRESULT CTabWnd::OnTabMouseMove( WPARAM wParam, LPARAM lParam )
break;
}
}
if (nDstTab >= nTabCount)
nDstTab = nTabCount - 1;

// ドラッグ中に即時移動
if( m_nSrcTab != nDstTab )
Expand Down