Skip to content

Commit

Permalink
xrECore/WindowLog: adjust colours
Browse files Browse the repository at this point in the history
Autoscroll to newly added text
Fix autoresize
  • Loading branch information
Xottab-DUTY committed Mar 24, 2018
1 parent 0626572 commit 9abf32b
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 10 deletions.
26 changes: 25 additions & 1 deletion src/editors/xrECore/Core/ELog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,20 @@ XRECORE_API void ELogCallback(void* context, pcstr message)
return;

bool isDialog = false;
MessageType type = MessageType::Information;

MessageType type;
switch (message[0])
{
case '*':
type = MessageType::Information;
message++;
break;

case '~':
type = MessageType::Warning;
message++;
break;

case '!':
type = MessageType::Error;
message++;
Expand All @@ -26,6 +36,20 @@ XRECORE_API void ELogCallback(void* context, pcstr message)
type = MessageType::Confirmation;
message++;
break;

case '@':
type = MessageType::UserInput;
message++;
break;

case '-':
type = MessageType::Confirmation;
message++;
break;

default:
type = MessageType::Custom;
break;
}

auto windowLog = safe_cast<WindowLog^>(Form::FromHandle(IntPtr(context)));
Expand Down
9 changes: 5 additions & 4 deletions src/editors/xrECore/Core/ELog.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

enum class MessageType
{
Information,
Warning,
Error,
Confirmation,
Information, // *
Warning, // ~
Error, // !
Confirmation, // #, -
UserInput, // @
Custom
};

Expand Down
13 changes: 9 additions & 4 deletions src/editors/xrECore/Windows/WindowLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ void WindowLog::AddMessage(MessageType type, System::String^ message)

switch (type)
{
case MessageType::Information:
newMessage->BackColor = Color::LightGray;
break;

case MessageType::Warning:
newMessage->BackColor = Color::Yellow;
newMessage->BackColor = Color::LightGoldenrodYellow;
break;

case MessageType::Error:
Expand All @@ -30,12 +34,13 @@ void WindowLog::AddMessage(MessageType type, System::String^ message)
newMessage->BackColor = Color::LightGreen;
break;

case MessageType::Custom:
newMessage->BackColor = Color::LightYellow;
case MessageType::UserInput:
newMessage->BackColor = Color::LightBlue;
break;
}

logList->Items->Add(newMessage);
newMessage->EnsureVisible();

if (type == MessageType::Error)
Focus();
Expand Down Expand Up @@ -64,7 +69,7 @@ System::Void WindowLog::buttonClearSelected_Click(System::Object^ sender, System

System::Void WindowLog::logList_Resize(System::Object^ sender, System::EventArgs^ e)
{
columnHeader1->Width = logList->Size.Width;
columnHeader1->AutoResize(ColumnHeaderAutoResizeStyle::HeaderSize);
}

System::Void WindowLog::LogForm_Closing(System::Object^ sender, System::Windows::Forms::FormClosingEventArgs^ e)
Expand Down
2 changes: 1 addition & 1 deletion src/editors/xrECore/Windows/WindowLog.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private: System::Windows::Forms::Button^ buttonFlush;
this->logList->UseCompatibleStateImageBehavior = false;
this->logList->View = System::Windows::Forms::View::Details;
this->logList->Resize += gcnew System::EventHandler(this, &WindowLog::logList_Resize);
this->columnHeader1->Width = 121;
this->columnHeader1->Width = 333;
this->buttonClose->Location = System::Drawing::Point(0, 0);
this->buttonClose->Name = L"buttonClose";
this->buttonClose->Size = System::Drawing::Size(85, 23);
Expand Down

0 comments on commit 9abf32b

Please sign in to comment.