Info bar
This commit is contained in:
@@ -18,6 +18,9 @@
|
|||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
#include "raylib_utils.cpp"
|
#include "raylib_utils.cpp"
|
||||||
|
|
||||||
|
float MenuFontSize = 19.f;
|
||||||
|
Font MenuFont;
|
||||||
|
|
||||||
#include "commands.cpp"
|
#include "commands.cpp"
|
||||||
#include "colors.cpp"
|
#include "colors.cpp"
|
||||||
|
|
||||||
@@ -29,7 +32,6 @@
|
|||||||
/*
|
/*
|
||||||
- Ctrl + D - create new cursor at next occurence of word
|
- Ctrl + D - create new cursor at next occurence of word
|
||||||
- Line numbers
|
- Line numbers
|
||||||
- file info bar at bottom (line, column, line endings)
|
|
||||||
- Colored strings
|
- Colored strings
|
||||||
|
|
||||||
- file dock on left side
|
- file dock on left side
|
||||||
@@ -59,6 +61,8 @@ int main(void) {
|
|||||||
SetWindowIcon(window_icon_image);
|
SetWindowIcon(window_icon_image);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MenuFont = LoadFontEx("c:\\Windows\\Fonts\\Segoeui.ttf", (int)MenuFontSize, NULL, 500);
|
||||||
|
|
||||||
View view = {};
|
View view = {};
|
||||||
{
|
{
|
||||||
Int font_size = 16;
|
Int font_size = 16;
|
||||||
@@ -85,6 +89,7 @@ int main(void) {
|
|||||||
ProfileScope(game_loop);
|
ProfileScope(game_loop);
|
||||||
view.rect = GetScreenRect();
|
view.rect = GetScreenRect();
|
||||||
view.scrollbar_rect = CutRight(&view.rect, 10);
|
view.scrollbar_rect = CutRight(&view.rect, 10);
|
||||||
|
view.infobar_rect = CutBottom(&view.rect, (int)MenuFontSize);
|
||||||
|
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
ClearBackground(ColorBackground);
|
ClearBackground(ColorBackground);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
struct View {
|
struct View {
|
||||||
|
// @todo: some of this data probably should go to window
|
||||||
Font font;
|
Font font;
|
||||||
Int font_size;
|
Int font_size;
|
||||||
Int font_spacing;
|
Int font_spacing;
|
||||||
@@ -7,6 +8,7 @@ struct View {
|
|||||||
|
|
||||||
Rect2I rect;
|
Rect2I rect;
|
||||||
Rect2I scrollbar_rect;
|
Rect2I scrollbar_rect;
|
||||||
|
Rect2I infobar_rect;
|
||||||
Vec2I scroll;
|
Vec2I scroll;
|
||||||
|
|
||||||
int mouse_selecting_scrollbar;
|
int mouse_selecting_scrollbar;
|
||||||
|
|||||||
@@ -299,6 +299,8 @@ void HandleKeybindings(View *_view) {
|
|||||||
bool mouse_in_scrollbar = CheckCollisionPointRec(_mouse, ToRectangle(view.scrollbar_rect));
|
bool mouse_in_scrollbar = CheckCollisionPointRec(_mouse, ToRectangle(view.scrollbar_rect));
|
||||||
Vec2I mouse = ToVec2I(_mouse);
|
Vec2I mouse = ToVec2I(_mouse);
|
||||||
|
|
||||||
|
if (!mouse_in_view) SetMouseCursor(MOUSE_CURSOR_DEFAULT);
|
||||||
|
|
||||||
if (!(mouse_in_scrollbar || view.mouse_selecting_scrollbar) && (mouse_in_view || view.mouse_selecting)) {
|
if (!(mouse_in_scrollbar || view.mouse_selecting_scrollbar) && (mouse_in_view || view.mouse_selecting)) {
|
||||||
if (!view.mouse_selecting) {
|
if (!view.mouse_selecting) {
|
||||||
if (mouse_in_view) {
|
if (mouse_in_view) {
|
||||||
@@ -345,7 +347,6 @@ void HandleKeybindings(View *_view) {
|
|||||||
MergeCarets(&view.carets, &view.selection_anchor);
|
MergeCarets(&view.carets, &view.selection_anchor);
|
||||||
}
|
}
|
||||||
} else if (!(mouse_in_view || view.mouse_selecting) && mouse_in_scrollbar || view.mouse_selecting_scrollbar) {
|
} else if (!(mouse_in_view || view.mouse_selecting) && mouse_in_scrollbar || view.mouse_selecting_scrollbar) {
|
||||||
SetMouseCursor(MOUSE_CURSOR_DEFAULT);
|
|
||||||
Scroller s = ComputeScrollerRect(view);
|
Scroller s = ComputeScrollerRect(view);
|
||||||
double size_y = (double)GetSize(view.scrollbar_rect).y;
|
double size_y = (double)GetSize(view.scrollbar_rect).y;
|
||||||
double p = _mouse.y - view.scrollbar_rect.min.y;
|
double p = _mouse.y - view.scrollbar_rect.min.y;
|
||||||
|
|||||||
@@ -173,4 +173,19 @@ void DrawView(View &view) {
|
|||||||
}
|
}
|
||||||
DrawRectangleRec(ToRectangle(rect), color);
|
DrawRectangleRec(ToRectangle(rect), color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
DrawRectangleRec(ToRectangle(view.infobar_rect), ColorScrollbarBackground);
|
||||||
|
|
||||||
|
{
|
||||||
|
Vec2 p = ToVec2(view.infobar_rect.min);
|
||||||
|
// p.y += 0.f * MenuFontSize;
|
||||||
|
Scratch scratch;
|
||||||
|
Caret caret = view.carets[0];
|
||||||
|
XY xy = PosToXY(*view.buffer, GetFront(caret));
|
||||||
|
String s = Format(scratch, "-- line: %lld col: %lld", (long long)xy.line + 1ll, (long long)xy.col + 1ll);
|
||||||
|
String16 string = ToString16(scratch, s);
|
||||||
|
DrawString(MenuFont, string, p, MenuFontSize, 1, ColorText);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user