Move back mouse stuff to window
This commit is contained in:
@@ -94,7 +94,7 @@ bool GlobalCommand(Event event) {
|
||||
static SDL_Cursor *SDL_MouseCursor;
|
||||
if (SDL_MouseCursor) SDL_DestroyCursor(SDL_MouseCursor);
|
||||
|
||||
if (view->mouse_selecting || mouse_in_document) {
|
||||
if (window->mouse_selecting || mouse_in_document) {
|
||||
SDL_MouseCursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_TEXT);
|
||||
SDL_SetCursor(SDL_MouseCursor);
|
||||
} else if (mouse_in_scrollbar || window->mouse_selecting_scrollbar || mouse_in_line_numbers) {
|
||||
|
||||
@@ -882,7 +882,7 @@ void WindowCommand(Event event, Window *window, View *view) {
|
||||
bool document_action = false;
|
||||
{
|
||||
bool a = mouse_in_document && IsMouseEvent(event.kind);
|
||||
bool b = view->mouse_selecting && !mouse_in_document;
|
||||
bool b = window->mouse_selecting && !mouse_in_document;
|
||||
document_action = a || b;
|
||||
}
|
||||
|
||||
@@ -913,12 +913,12 @@ void WindowCommand(Event event, Window *window, View *view) {
|
||||
}
|
||||
|
||||
if (mouse_in_document && Mouse(LEFT)) {
|
||||
view->mouse_selecting = true;
|
||||
window->mouse_selecting = true;
|
||||
}
|
||||
|
||||
if (view->mouse_selecting) {
|
||||
if (window->mouse_selecting) {
|
||||
if (Mouse(LEFT_UP)) {
|
||||
view->mouse_selecting = false;
|
||||
window->mouse_selecting = false;
|
||||
}
|
||||
|
||||
MergeCarets(view, &view->selection_anchor);
|
||||
@@ -932,7 +932,7 @@ void WindowCommand(Event event, Window *window, View *view) {
|
||||
}
|
||||
MergeCarets(view, &view->selection_anchor);
|
||||
}
|
||||
} else if (!(mouse_in_document || view->mouse_selecting) && mouse_in_scrollbar || window->mouse_selecting_scrollbar) {
|
||||
} else if (!(mouse_in_document || window->mouse_selecting) && mouse_in_scrollbar || window->mouse_selecting_scrollbar) {
|
||||
Vec2 mouse_vec2 = MouseVec2();
|
||||
Scroller s = ComputeScrollerRect(window);
|
||||
double size_y = (double)GetSize(window->scrollbar_rect).y;
|
||||
|
||||
@@ -169,7 +169,7 @@ void Update(Event event) {
|
||||
window->mouse_selecting_scrollbar = false;
|
||||
View *view = GetView(window->active_view);
|
||||
view->underline_count = 0;
|
||||
view->mouse_selecting = false;
|
||||
window->mouse_selecting = false;
|
||||
ActiveWindow = NextActiveWindow;
|
||||
{
|
||||
Window *w = GetWindow(ActiveWindow);
|
||||
@@ -184,6 +184,9 @@ void Update(Event event) {
|
||||
// because it seems to be buggy and problematic
|
||||
}
|
||||
}
|
||||
if (Mouse(LEFT_UP)) {
|
||||
For(Windows) it.mouse_selecting = false;
|
||||
}
|
||||
|
||||
ReloadLuaConfig();
|
||||
ReplaceDebugData();
|
||||
@@ -327,7 +330,7 @@ int main()
|
||||
WaitForEvents = true;
|
||||
Window *window = GetActiveWindow();
|
||||
View *view = GetView(window->active_view);
|
||||
if (view->mouse_selecting || window->mouse_selecting_scrollbar) {
|
||||
if (window->mouse_selecting || window->mouse_selecting_scrollbar) {
|
||||
WaitForEvents = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,6 @@ struct View {
|
||||
|
||||
struct {
|
||||
bool fuzzy_search : 1;
|
||||
bool mouse_selecting : 1;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -79,6 +78,7 @@ struct Window {
|
||||
struct {
|
||||
bool mouse_selecting_scrollbar : 1;
|
||||
bool mouse_in_scrollbar : 1;
|
||||
bool mouse_selecting : 1;
|
||||
|
||||
bool draw_scrollbar : 1;
|
||||
bool draw_line_numbers : 1;
|
||||
|
||||
@@ -42,6 +42,7 @@ void ReplaceDebugData() {
|
||||
float xmouse, ymouse;
|
||||
SDL_GetMouseState(&xmouse, &ymouse);
|
||||
Appendf(buffer, "mouse: [%f, %f]", xmouse, ymouse);
|
||||
Appendf(buffer, "C:/Work/text_editor/src/text_editor/text_editor.cpp");
|
||||
|
||||
// String view_list = DebugViewList(scratch);
|
||||
// Append(buffer, ToString16(scratch, view_list));
|
||||
|
||||
@@ -240,7 +240,7 @@ void DrawWindow(Window *window) {
|
||||
Scroller scroller = ComputeScrollerRect(window);
|
||||
Rect2 rect = Shrink(scroller.rect, 2);
|
||||
Color color = ColorScrollbarScroller;
|
||||
if (!view->mouse_selecting && (window->mouse_selecting_scrollbar || window->mouse_in_scrollbar)) {
|
||||
if (!window->mouse_selecting && (window->mouse_selecting_scrollbar || window->mouse_in_scrollbar)) {
|
||||
if (is_active) color = ColorScrollbarScrollerSelected;
|
||||
}
|
||||
DrawRect(rect, color);
|
||||
|
||||
Reference in New Issue
Block a user