Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
etorth committed Nov 11, 2024
1 parent 16cae69 commit a6f842e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
36 changes: 27 additions & 9 deletions client/src/gui/friendchatboard/friendchatboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,7 @@ bool FriendChatBoard::processEventDefault(const SDL_Event &event, bool valid)
}
case SDL_MOUSEMOTION:
{
if((event.motion.state & SDL_BUTTON_LMASK) && (in(event.motion.x, event.motion.y) || focus())){
if((event.motion.state & SDL_BUTTON_LMASK) && (in(event.motion.x, event.motion.y) || m_dragIndex.has_value())){
// ->|w0|<----w1------->|w2|<- |
// x0 x1 x2 v
// +--+---------------+--+ y0 -
Expand Down Expand Up @@ -991,15 +991,28 @@ bool FriendChatBoard::processEventDefault(const SDL_Event &event, bool valid)
}
};

if (mathf::pointInRectangle<int>(event.motion.x, event.motion.y, x0, y0, w0, h0)){ fnAdjustW(-event.motion.xrel, 1); fnAdjustH(-event.motion.yrel, 1); }
else if(mathf::pointInRectangle<int>(event.motion.x, event.motion.y, x1, y0, w1, h0)){ fnAdjustH(-event.motion.yrel, 1); }
else if(mathf::pointInRectangle<int>(event.motion.x, event.motion.y, x2, y0, w2, h0)){ fnAdjustW( event.motion.xrel, 0); fnAdjustH(-event.motion.yrel, 1); }
else if(mathf::pointInRectangle<int>(event.motion.x, event.motion.y, x0, y1, w0, h1)){ fnAdjustW(-event.motion.xrel, 1); }
else if(mathf::pointInRectangle<int>(event.motion.x, event.motion.y, x2, y1, w2, h1)){ fnAdjustW( event.motion.xrel, 0); }
else if(mathf::pointInRectangle<int>(event.motion.x, event.motion.y, x0, y2, w0, h2)){ fnAdjustW(-event.motion.xrel, 1); fnAdjustH( event.motion.yrel, 0); }
else if(mathf::pointInRectangle<int>(event.motion.x, event.motion.y, x1, y2, w1, h2)){ fnAdjustH( event.motion.yrel, 0); }
else if(mathf::pointInRectangle<int>(event.motion.x, event.motion.y, x2, y2, w2, h2)){ fnAdjustW( event.motion.xrel, 0); fnAdjustH( event.motion.yrel, 0); }
if(!m_dragIndex.has_value()){
if (mathf::pointInRectangle<int>(event.motion.x, event.motion.y, x0, y0, w0, h0)){ m_dragIndex = 0; }
else if(mathf::pointInRectangle<int>(event.motion.x, event.motion.y, x1, y0, w1, h0)){ m_dragIndex = 1; }
else if(mathf::pointInRectangle<int>(event.motion.x, event.motion.y, x2, y0, w2, h0)){ m_dragIndex = 2; }
else if(mathf::pointInRectangle<int>(event.motion.x, event.motion.y, x0, y1, w0, h1)){ m_dragIndex = 3; }
else if(mathf::pointInRectangle<int>(event.motion.x, event.motion.y, x2, y1, w2, h1)){ m_dragIndex = 4; }
else if(mathf::pointInRectangle<int>(event.motion.x, event.motion.y, x0, y2, w0, h2)){ m_dragIndex = 5; }
else if(mathf::pointInRectangle<int>(event.motion.x, event.motion.y, x1, y2, w1, h2)){ m_dragIndex = 6; }
else if(mathf::pointInRectangle<int>(event.motion.x, event.motion.y, x2, y2, w2, h2)){ m_dragIndex = 7; }
else { m_dragIndex.reset(); }
}

if(m_dragIndex.has_value()){
if (m_dragIndex.value() == 0){ fnAdjustW(-event.motion.xrel, 1); fnAdjustH(-event.motion.yrel, 1); }
else if(m_dragIndex.value() == 1){ fnAdjustH(-event.motion.yrel, 1); }
else if(m_dragIndex.value() == 2){ fnAdjustW( event.motion.xrel, 0); fnAdjustH(-event.motion.yrel, 1); }
else if(m_dragIndex.value() == 3){ fnAdjustW(-event.motion.xrel, 1); }
else if(m_dragIndex.value() == 4){ fnAdjustW( event.motion.xrel, 0); }
else if(m_dragIndex.value() == 5){ fnAdjustW(-event.motion.xrel, 1); fnAdjustH( event.motion.yrel, 0); }
else if(m_dragIndex.value() == 6){ fnAdjustH( event.motion.yrel, 0); }
else { fnAdjustW( event.motion.xrel, 0); fnAdjustH( event.motion.yrel, 0); }
}
else{
const int maxX = rendererW - w();
const int maxY = rendererH - h();
Expand All @@ -1012,6 +1025,11 @@ bool FriendChatBoard::processEventDefault(const SDL_Event &event, bool valid)
}
return consumeFocus(false);
}
case SDL_MOUSEBUTTONUP:
{
m_dragIndex.reset();
return consumeFocus(in(event.button.x, event.button.y));
}
case SDL_MOUSEBUTTONDOWN:
{
if(m_uiPageList[m_uiPage].page->in(event.button.x, event.button.y)){
Expand Down
4 changes: 4 additions & 0 deletions client/src/gui/friendchatboard/friendchatboard.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once
#include <array>
#include <string>
#include <optional>
#include <unordered_map>
#include "serdesmsg.hpp"
#include "widget.hpp"
Expand Down Expand Up @@ -44,6 +45,9 @@ class FriendChatBoard: public Widget
private:
ProcessRun *m_processRun;

private:
std::optional<int> m_dragIndex;

private:
ImageBoard m_frame;
GfxCropDupBoard m_frameCropDup;
Expand Down

0 comments on commit a6f842e

Please sign in to comment.