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