mirror of
https://github.com/clangen/musikcube.git
synced 2025-03-14 13:21:13 +00:00
Add musik::cube::windowutil::WasHeaderClicked()
This commit is contained in:
parent
18e6f154b8
commit
2d96ddcfd7
@ -39,6 +39,7 @@ set (CUBE_SRCS
|
||||
./app/util/Rating.cpp
|
||||
./app/util/TrackRowRenderers.cpp
|
||||
./app/util/UpdateCheck.cpp
|
||||
./app/util/WindowUtil.cpp
|
||||
./app/window/CategoryListView.cpp
|
||||
./app/window/TrackListView.cpp
|
||||
./app/window/TransportWindow.cpp
|
||||
|
@ -49,6 +49,7 @@
|
||||
#include <app/util/Playback.h>
|
||||
#include <app/util/PreferenceKeys.h>
|
||||
#include <app/util/Messages.h>
|
||||
#include <app/util/WindowUtil.h>
|
||||
#include <app/overlay/PlayQueueOverlays.h>
|
||||
#include <app/overlay/TrackOverlays.h>
|
||||
|
||||
@ -273,19 +274,15 @@ void BrowseLayout::RequeryTrackList(ListWindow *view) {
|
||||
}
|
||||
|
||||
void BrowseLayout::OnWindowMouseEvent(Window* window, const IMouseHandler::Event* mouseEvent) {
|
||||
if (mouseEvent->y == -1) {
|
||||
auto title = window->GetFrameTitle();
|
||||
/* the title will be in the format "- title -". this check is kludgy. */
|
||||
if (mouseEvent->x > 0 && mouseEvent->x < u8cols(title) + 3) {
|
||||
if (window == this->categoryList.get()) {
|
||||
if (this->categoryListHeaderClickHandler) {
|
||||
this->categoryListHeaderClickHandler();
|
||||
}
|
||||
}
|
||||
else if (window == this->trackList.get()) {
|
||||
this->ShowTrackSortOverlay();
|
||||
if (windowutil::WasHeaderClicked(window, mouseEvent)) {
|
||||
if (window == this->categoryList.get()) {
|
||||
if (this->categoryListHeaderClickHandler) {
|
||||
this->categoryListHeaderClickHandler();
|
||||
}
|
||||
}
|
||||
else if (window == this->trackList.get()) {
|
||||
this->ShowTrackSortOverlay();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include <app/util/Messages.h>
|
||||
#include <app/util/Playback.h>
|
||||
#include <app/util/PreferenceKeys.h>
|
||||
#include <app/util/WindowUtil.h>
|
||||
#include <app/overlay/PlayQueueOverlays.h>
|
||||
#include <app/overlay/TrackOverlays.h>
|
||||
|
||||
@ -207,12 +208,8 @@ void TrackSearchLayout::OnEnterPressed(cursespp::TextInput* sender) {
|
||||
}
|
||||
|
||||
void TrackSearchLayout::OnWindowMouseEvent(Window* window, const IMouseHandler::Event* mouseEvent) {
|
||||
if (window == this->trackList.get() && mouseEvent->y == -1) {
|
||||
auto title = window->GetFrameTitle();
|
||||
/* the title will be in the format "- title -". this check is kludgy. */
|
||||
if (mouseEvent->x > 0 && mouseEvent->x < u8cols(title) + 3) {
|
||||
this->ShowTrackSortOverlay();
|
||||
}
|
||||
if (windowutil::WasHeaderClicked(window, mouseEvent)) {
|
||||
this->ShowTrackSortOverlay();
|
||||
}
|
||||
}
|
||||
|
||||
|
55
src/musikcube/app/util/WindowUtil.cpp
Normal file
55
src/musikcube/app/util/WindowUtil.cpp
Normal file
@ -0,0 +1,55 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004-2021 musikcube team
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// * Neither the name of the author nor the names of other contributors may
|
||||
// be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdafx.h>
|
||||
#include "WindowUtil.h"
|
||||
|
||||
using namespace cursespp;
|
||||
|
||||
namespace musik { namespace cube { namespace windowutil {
|
||||
|
||||
bool WasHeaderClicked(Window* window, const IMouseHandler::Event* mouseEvent) noexcept {
|
||||
if (window && mouseEvent->y == -1) {
|
||||
auto title = window->GetFrameTitle();
|
||||
/* the title will be in the format "- title -". this check is kludgy. */
|
||||
if (mouseEvent->x > 0 && mouseEvent->x < u8cols(title) + 3) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} } }
|
45
src/musikcube/app/util/WindowUtil.h
Normal file
45
src/musikcube/app/util/WindowUtil.h
Normal file
@ -0,0 +1,45 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004-2021 musikcube team
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// * Neither the name of the author nor the names of other contributors may
|
||||
// be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cursespp/Window.h>
|
||||
|
||||
namespace musik { namespace cube { namespace windowutil {
|
||||
|
||||
extern bool WasHeaderClicked(
|
||||
cursespp::Window* window,
|
||||
const cursespp::IMouseHandler::Event* mouseEvent) noexcept;
|
||||
|
||||
} } }
|
@ -895,6 +895,7 @@ xcopy "$(SolutionDir)src\3rdparty\bin\win\font\*.ttf" "$(TargetDir)fonts\" /Y /e
|
||||
<ClCompile Include="app\util\Rating.cpp" />
|
||||
<ClCompile Include="app\util\TrackRowRenderers.cpp" />
|
||||
<ClCompile Include="app\util\UpdateCheck.cpp" />
|
||||
<ClCompile Include="app\util\WindowUtil.cpp" />
|
||||
<ClCompile Include="app\window\CategoryListView.cpp" />
|
||||
<ClCompile Include="app\window\TrackListView.cpp" />
|
||||
<ClCompile Include="app\window\TransportWindow.cpp" />
|
||||
@ -980,6 +981,7 @@ xcopy "$(SolutionDir)src\3rdparty\bin\win\font\*.ttf" "$(TargetDir)fonts\" /Y /e
|
||||
<ClInclude Include="app\util\Rating.h" />
|
||||
<ClInclude Include="app\util\TrackRowRenderers.h" />
|
||||
<ClInclude Include="app\util\UpdateCheck.h" />
|
||||
<ClInclude Include="app\util\WindowUtil.h" />
|
||||
<ClInclude Include="app\window\CategoryListView.h" />
|
||||
<ClInclude Include="app\window\TrackListView.h" />
|
||||
<ClInclude Include="app\window\TransportWindow.h" />
|
||||
|
@ -204,6 +204,9 @@
|
||||
<ClCompile Include="app\layout\RemoteLibrarySettingsLayout.cpp">
|
||||
<Filter>app\layout</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="app\util\WindowUtil.cpp">
|
||||
<Filter>app\util</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="stdafx.h" />
|
||||
@ -460,6 +463,9 @@
|
||||
<ClInclude Include="app\layout\RemoteLibrarySettingsLayout.h">
|
||||
<Filter>app\layout</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="app\util\WindowUtil.h">
|
||||
<Filter>app\util</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="cursespp">
|
||||
|
Loading…
x
Reference in New Issue
Block a user