Added Variant "String" support.

Added panel location configuration (left or right).
Added default key modifier (CTRL on Linux and windows, META on macOS, ALT on Haiku).
Optimized GlobalSearchController.
Allow using $FILENAME in linter warning pattern.
Optimized ProjectSearch.
Added TextDocument delete on close option (default for temporal files downloaded from the Internet).
This commit is contained in:
Martín Lucas Golini
2022-03-20 15:04:07 -03:00
parent a0a3674312
commit 375d1e66e8
36 changed files with 374 additions and 198 deletions

View File

@@ -398,6 +398,10 @@ class EE_API TextDocument {
bool isLoading() const;
bool isDeleteOnClose() const;
void setDeleteOnClose( bool deleteOnClose );
protected:
friend class UndoStack;
UndoStack mUndoStack;
@@ -416,6 +420,7 @@ class EE_API TextDocument {
bool mAutoCloseBrackets{ false };
bool mDirtyOnFileSystem{ false };
bool mSaving{ false };
bool mDeleteOnClose{ false };
std::vector<std::pair<String::StringBaseType, String::StringBaseType>> mAutoCloseBracketsPairs;
Uint32 mIndentWidth{ 4 };
IndentType mIndentType{ IndentType::IndentTabs };

View File

@@ -24,9 +24,9 @@ class EE_API KeyBindings {
Shortcut() {}
Shortcut( Keycode key, Uint32 mod ) : key( key ), mod( mod ) {}
Shortcut( const Uint64& code ) :
key( ( Keycode )( code & 0xFFFFFFFF ) ), mod( ( code >> 32 ) & 0xFFFFFFFF ) {}
Keycode key{KEY_UNKNOWN};
Uint32 mod{0};
key( (Keycode)( code & 0xFFFFFFFF ) ), mod( ( code >> 32 ) & 0xFFFFFFFF ) {}
Keycode key{ KEY_UNKNOWN };
Uint32 mod{ 0 };
Uint64 toUint64() const { return (Uint64)mod << 32 | (Uint64)key; }
operator Uint64() const { return toUint64(); }
bool empty() const { return 0 == mod && 0 == key; }
@@ -66,6 +66,10 @@ class EE_API KeyBindings {
std::string getShortcutString( Shortcut shortcut );
Uint32 getDefaultModifier() const;
void setDefaultModifier( Uint32 newDefaultModifier );
protected:
const Window::Input* mInput;
ShortcutMap mShortcuts;

View File

@@ -19,6 +19,7 @@ class EE_API Variant {
Invalid,
DataPtr,
String,
StdString,
Bool,
Float,
Int,
@@ -32,8 +33,11 @@ class EE_API Variant {
cstr
};
Variant() : mType( Type::Invalid ) {}
explicit Variant( const std::string& string ) : mType( Type::String ) {
mValue.asString = eeNew( std::string, ( string ) );
explicit Variant( const std::string& string ) : mType( Type::StdString ) {
mValue.asStdString = eeNew( std::string, ( string ) );
}
explicit Variant( const String& string ) : mType( Type::String ) {
mValue.asString = eeNew( String, ( string ) );
}
Variant( Drawable* drawable, bool ownDrawable = false ) : mType( Type::Drawable ) {
mValue.asDrawable = drawable;
@@ -53,7 +57,8 @@ class EE_API Variant {
Variant( const Uint64& val ) : mType( Type::Uint64 ) { mValue.asUint64 = val; }
explicit Variant( const char* data ) : mType( Type::cstr ) { mValue.asCStr = data; }
~Variant() { reset(); }
const std::string& asString() const { return *mValue.asString; }
const std::string& asStdString() const { return *mValue.asStdString; }
const String& asString() const { return *mValue.asString; }
Drawable* asDrawable() const { return mValue.asDrawable; }
const bool& asBool() const { return mValue.asBool; }
const Float& asFloat() const { return mValue.asFloat; }
@@ -69,8 +74,11 @@ class EE_API Variant {
bool is( const Type& type ) const { return type == mType; }
void reset() {
switch ( mType ) {
case Type::StdString:
eeSAFE_DELETE( mValue.asStdString );
break;
case Type::String:
eeSAFE_DELETE( mValue.asString );
eeSAFE_DELETE( mValue.asStdString );
break;
case Type::Drawable:
if ( mOwnsObject )
@@ -103,6 +111,8 @@ class EE_API Variant {
return String::toString( asUint64() );
case Type::Float:
return String::toString( asFloat() );
case Type::StdString:
return asStdString();
case Type::String:
return asString();
case Type::Drawable:
@@ -142,6 +152,8 @@ class EE_API Variant {
return asUint64() < other.asUint64();
case Type::Float:
return asFloat() < other.asFloat();
case Type::StdString:
return asStdString() < other.asStdString();
case Type::String:
return asString() < other.asString();
case Type::Drawable:
@@ -178,6 +190,8 @@ class EE_API Variant {
return asUint64() == other.asUint64();
case Type::Float:
return asFloat() == other.asFloat();
case Type::StdString:
return asStdString() == other.asStdString();
case Type::String:
return asString() == other.asString();
case Type::Drawable:
@@ -203,7 +217,8 @@ class EE_API Variant {
void* asDataPtr;
Drawable* asDrawable;
UIIcon* asIcon;
std::string* asString;
std::string* asStdString;
String* asString;
bool asBool;
Float asFloat;
int asInt;
@@ -215,7 +230,7 @@ class EE_API Variant {
const char* asCStr;
} mValue;
Type mType;
bool mOwnsObject{false};
bool mOwnsObject{ false };
};
}}} // namespace EE::UI::Models

View File

@@ -135,7 +135,7 @@ class EE_API UIFileDialog : public UIWindow {
UIDropDownList* mFiletype;
Uint32 mDialogFlags;
KeyBindings::Shortcut mCloseShortcut;
KeyBindings::Shortcut mOpenShortut{ KEY_RETURN, KEYMOD_CTRL };
KeyBindings::Shortcut mOpenShortut{ KEY_RETURN, KEYMOD_DEFAULT_MODIFIER };
std::shared_ptr<FileSystemModel> mModel;
virtual void onWindowReady();

View File

@@ -27,7 +27,7 @@ class EE_API UISplitter : public UILayout {
void setSplitPartition( const StyleSheetLength& divisionSplit );
void swap();
void swap( bool swapSplitPartition = false );
bool isEmpty();

View File

@@ -1,6 +1,8 @@
#ifndef EE_INPUT_KEYKODES_HPP
#define EE_INPUT_KEYKODES_HPP
#include <eepp/config.hpp>
namespace EE { namespace Window {
// This is a exact copy from the SDL_keycode and SDL_scancode.
@@ -685,6 +687,14 @@ enum KeyModTable {
#define KEYMOD_META ( KEYMOD_LMETA | KEYMOD_RMETA )
#define KEYMOD_CTRL_SHIFT_ALT_META ( KEYMOD_CTRL | KEYMOD_SHIFT | KEYMOD_ALT | KEYMOD_META )
#if EE_PLATFORM == EE_PLATFORM_MACOSX
#define KEYMOD_DEFAULT_MODIFIER KEYMOD_META
#elif EE_PLATFORM == EE_PLATFORM_HAIKU
#define KEYMOD_DEFAULT_MODIFIER KEYMOD_ALT
#else
#define KEYMOD_DEFAULT_MODIFIER KEYMOD_CTRL
#endif
/** @enum MouseButton Mouse buttons */
enum MouseButton {
EE_BUTTON_LEFT = 1,