mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-05-28 17:16:29 +03:00
Minor code editor fixes.
Improved touch dragging. Minor API change in UIMenu::add*. Updated the README.md. Added TODO.md (to keep track on the things I want to improve/implement).
This commit is contained in:
69
README.md
69
README.md
@@ -184,12 +184,33 @@ its submodules, in order to achieve this easily you can simply clone with:
|
||||
|
||||
## UI Screenshots
|
||||
|
||||
### ecode - Text Editor
|
||||
|
||||
Text editor inspired in [lite](https://github.com/rxi/lite) (in development, already fully functional).
|
||||
It's using the newest pure CSS theme based on the default [Plasma](https://kde.org/plasma-desktop)
|
||||
dark theme: Breeze Dark.
|
||||
|
||||

|
||||
|
||||
### UI Editor
|
||||
|
||||
Editor that displays in real-time the changes on any layout and CSS to help speed up the development
|
||||
of user interfaces. In the screenshot is displaying some of the default widgets available in eepp.
|
||||
|
||||

|
||||
|
||||
### Texture Atlas Editor
|
||||
|
||||
Small tool, used to create and edit texture atlases.
|
||||
|
||||

|
||||
|
||||
### Map Editor
|
||||
|
||||
2D map editor using the default skinned theme (using a single texture atlas with 9-patch images).
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
## UI Layout XML example
|
||||
|
||||
It should look really familiar to any Android developer. This is a window with
|
||||
@@ -215,6 +236,8 @@ the most basic controls in a vertical linear layout display.
|
||||
</window>
|
||||
```
|
||||
|
||||
**UI introduction can be found [here](https://eepp.ensoft.dev/page_uiintroduction.html)**.
|
||||
|
||||
## UI Widgets with C++ example
|
||||
|
||||
How does it look with real code?
|
||||
@@ -311,6 +334,36 @@ Here is a small example on how the CSS looks like:
|
||||
}
|
||||
```
|
||||
|
||||
**The complete CSS specification can be found in the docs: [here](https://eepp.ensoft.dev/page_cssspecification.html).**
|
||||
|
||||
**You can also check how a pure CSS theme looks like in eepp: [here](https://github.com/SpartanJ/eepp/blob/develop/bin/assets/ui/breeze.css).**
|
||||
|
||||
## Live demos (using emscripten)
|
||||
|
||||
Since eepp supports emscripten you can take a quick look on some of the examples, demos and tools that
|
||||
the library currently provides. Please be aware that you'll find some differences based on the limitations
|
||||
that emscripten have at the moment (no threads, no access to the file system, no custom cursors, etc).
|
||||
Note: please wait some seconds until the resources are loaded, currently there is no loading indicator.
|
||||
Also please use a modern browser with WebGL and WASM support.
|
||||
|
||||
* **[ecode - Text Editor](https://web.ensoft.dev/eepp/demo-fs.html?run=eepp-CodeEditor-debug.js)**
|
||||
|
||||
* **[Texture Atlas Editor](https://web.ensoft.dev/eepp/demo-fs.html?run=eepp-TextureAtlasEditor-debug.js)**
|
||||
|
||||
* **[Map Editor](https://web.ensoft.dev/eepp/demo-fs.html?run=eepp-MapEditor-debug.js)**
|
||||
|
||||
* **[UI Hello World](https://web.ensoft.dev/eepp/demo-fs.html?run=eepp-ui-hello-world-debug.js)**
|
||||
|
||||
* **[UI Editor running some tests](https://web.ensoft.dev/eepp/demo-fs.html?run=eepp-UIEditor-debug.js)**
|
||||
|
||||
* **[Fonts example](http://localhost/eepp/emscripten-fs.html?run=eepp-fonts-debug.js)**
|
||||
|
||||
* **[Physics module demo](https://web.ensoft.dev/eepp/demo-fs.html?run=eepp-physics-debug.js)**
|
||||
|
||||
* **[Sprites example](https://web.ensoft.dev/eepp/demo-fs.html?run=eepp-sprites-debug.js)**
|
||||
|
||||
* **[Full Test](https://web.ensoft.dev/eepp/demo-fs.html?run=eepp-test-debug.js)**
|
||||
|
||||
## How to build it
|
||||
|
||||
The library has very few external dependencies. Most of the time you will only
|
||||
@@ -517,7 +570,7 @@ oriented to desktop apps.
|
||||
Audio and Network modules were based the modules in SFML with several important
|
||||
differences mentioned above.
|
||||
|
||||
I like to use what's well done and fit my needs, but since I have my personal
|
||||
I like to use what's well done and fits my needs, but since I have my personal
|
||||
views on how to implement some things I prefer to take the code, to have full
|
||||
control over it.
|
||||
|
||||
@@ -547,9 +600,9 @@ of similar alternatives.
|
||||
Regarding the code quality: this project started very long time ago and suffered
|
||||
many modifications over time. A good chunk of the code base still uses old C++
|
||||
practices (for example: raw pointers, own implementation of thread, mutex, etc).
|
||||
Some of these things can be "modernized" others don't make much sense or
|
||||
Some of these things can be "modernized", but, others don't make much sense or
|
||||
overhauling them would take too much time to justify the effort. I'm working on
|
||||
"modernizing" some parts of the code, and new code usually tend to look more
|
||||
"modernizing" some parts of the code, and new code usually tends to look more
|
||||
modern.
|
||||
|
||||
### Plans/ideas for the future
|
||||
@@ -562,7 +615,7 @@ Improve/create documentation for the UI module.
|
||||
|
||||
Add more examples and some tools.
|
||||
|
||||
Add Scripting support ( first I would like to stabilize the library, but I'm getting there ).
|
||||
Add scripting support, but first I would like to stabilize the library, but I'm getting there.
|
||||
|
||||
Add 2D skeletal animations support ( probably Spine2D, shouldn't be much work to implement ).
|
||||
|
||||
|
||||
61
TODO.md
Normal file
61
TODO.md
Normal file
@@ -0,0 +1,61 @@
|
||||
|
||||
# TODO - Short and mid term plans.
|
||||
|
||||
## UIMenuRadioButton
|
||||
|
||||
Implement support for radio buttons in menues.
|
||||
|
||||
## UIMenuItem
|
||||
|
||||
* Support displaying the keyboard shortcuts for the menu items.
|
||||
|
||||
## UIWidget
|
||||
|
||||
* Add onDrop( UIWidget* ) API. In order to be able to drop widgets onto other widgets.
|
||||
|
||||
## UITabWidget
|
||||
|
||||
* Add support to move Tabs from one UITabWidget to another using the onDrop API.
|
||||
|
||||
## UIIconTheme and UIIconThemeManager
|
||||
|
||||
Implement icon themes separated from the UITheme and customizable from a CSS file.
|
||||
|
||||
## UICodeEditor
|
||||
|
||||
* Add show white spaces.
|
||||
|
||||
## TextDocument
|
||||
|
||||
* Add indentation type auto-detection.
|
||||
|
||||
* Add multi-line search and replace.
|
||||
|
||||
* Add auto-close brackets.
|
||||
|
||||
* Add XML tags auto-close.
|
||||
|
||||
* Add command to comment selected lines.
|
||||
|
||||
* On Save: trim white spaces.
|
||||
|
||||
* On Save: Ensure new line at end of file option.
|
||||
|
||||
* On Save: Allow to select line endings type.
|
||||
|
||||
## GlyphDrawable
|
||||
|
||||
Implement a `GlyphDrawable`. This should render any glyph as a drawable type.
|
||||
It should be very useful to use font icons in buttons and menues.
|
||||
|
||||
## UITreeView
|
||||
|
||||
Implement a simple tree view widget, to at least cover the most common use cases.
|
||||
|
||||
## Code Editor
|
||||
|
||||
Keep improving it:
|
||||
|
||||
* Add more menues ( Edit, Window ).
|
||||
|
||||
* Save user configuration.
|
||||
@@ -4,6 +4,7 @@
|
||||
--back: #31363b;
|
||||
--font: #eff0f1;
|
||||
--font-hint: #898b8d;
|
||||
--menu-font-disabled: #6e7275;
|
||||
--button-back: #30353a;
|
||||
--button-border: #6b6f73;
|
||||
--button-radius: 2dp;
|
||||
@@ -624,6 +625,13 @@ Menu::SubMenu::text {
|
||||
color: var(--menu-font);
|
||||
}
|
||||
|
||||
|
||||
Menu::Item:disabled > Menu::Item::text,
|
||||
Menu::CheckBox:disabled > Menu::CheckBox::text,
|
||||
Menu::SubMenu:disabled > Menu::SubMenu::text {
|
||||
color: var(--menu-font-disabled);
|
||||
}
|
||||
|
||||
Menu::SubMenu::arrow {
|
||||
margin-right: 1dp;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define EE_UI_DOC_DEFINITION_HPP
|
||||
|
||||
#include <eepp/config.hpp>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
|
||||
@@ -428,6 +428,8 @@ class EE_API UICodeEditor : public UIWidget, public TextDocument::Client {
|
||||
|
||||
virtual void onFontChanged();
|
||||
|
||||
virtual Uint32 onMessage( const NodeMessage* msg );
|
||||
|
||||
void disableEditorFeatures();
|
||||
|
||||
Float getViewportWidth( const bool& forceVScroll = false ) const;
|
||||
|
||||
@@ -25,15 +25,15 @@ class EE_API UIMenu : public UIWidget {
|
||||
|
||||
virtual bool isType( const Uint32& type ) const;
|
||||
|
||||
Uint32 add( const String& Text, Drawable* Icon = NULL );
|
||||
UIMenuItem* add( const String& Text, Drawable* Icon = NULL );
|
||||
|
||||
Uint32 add( UIWidget* widget );
|
||||
UIWidget* add( UIWidget* widget );
|
||||
|
||||
Uint32 addSeparator();
|
||||
UIMenuSeparator* addSeparator();
|
||||
|
||||
Uint32 addCheckBox( const String& Text, const bool& Active = false );
|
||||
UIMenuCheckBox* addCheckBox( const String& Text, const bool& Active = false );
|
||||
|
||||
Uint32 addSubMenu( const String& Text, Drawable* Icon = NULL, UIMenu* SubMenu = NULL );
|
||||
UIMenuSubMenu* addSubMenu( const String& Text, Drawable* Icon = NULL, UIMenu* SubMenu = NULL );
|
||||
|
||||
UIWidget* getItem( const Uint32& Index );
|
||||
|
||||
|
||||
@@ -25,8 +25,6 @@ class EE_API UIMenuCheckBox : public UIMenuItem {
|
||||
|
||||
void switchActive();
|
||||
|
||||
virtual bool inheritsFrom( const Uint32 getType );
|
||||
|
||||
protected:
|
||||
bool mActive;
|
||||
UISkin* mSkinActive;
|
||||
|
||||
@@ -46,6 +46,8 @@ class EE_API UITouchDraggableWidget : public UIWidget {
|
||||
virtual bool isTouchOverAllowedChilds();
|
||||
|
||||
virtual void scheduledUpdate( const Time& time );
|
||||
|
||||
virtual Uint32 onMessage( const NodeMessage* msg );
|
||||
};
|
||||
|
||||
}} // namespace EE::UI
|
||||
|
||||
@@ -133,26 +133,20 @@ void MapEditor::createMenuBar() {
|
||||
|
||||
UIPopUpMenu* PU3 = UIPopUpMenu::New();
|
||||
PU3->setParent( mUIContainer );
|
||||
mChkShowGrid = PU3->getItem( PU3->addCheckBox( "Show Grid" ) )->asType<UIMenuCheckBox>();
|
||||
mChkShowGrid = PU3->addCheckBox( "Show Grid" );
|
||||
|
||||
mChkShowGrid->setActive( true );
|
||||
|
||||
mChkMarkTileOver =
|
||||
PU3->getItem( PU3->addCheckBox( "Mark Tile Over" ) )->asType<UIMenuCheckBox>();
|
||||
|
||||
mChkShowBlocked = PU3->getItem( PU3->addCheckBox( "Show Blocked" ) )->asType<UIMenuCheckBox>();
|
||||
mChkMarkTileOver = PU3->addCheckBox( "Mark Tile Over" );
|
||||
mChkShowBlocked = PU3->addCheckBox( "Show Blocked" );
|
||||
|
||||
PU3->addSeparator();
|
||||
|
||||
addShortcut( KEY_KP_PLUS, KEYMOD_CTRL,
|
||||
PU3->getItem( PU3->add( "Zoom In", mTheme->getIconByName( "zoom-in" ) ) )
|
||||
->asType<UIPushButton>() );
|
||||
PU3->add( "Zoom In", mTheme->getIconByName( "zoom-in" ) ) );
|
||||
addShortcut( KEY_KP_MINUS, KEYMOD_CTRL,
|
||||
PU3->getItem( PU3->add( "Zoom Out", mTheme->getIconByName( "zoom-out" ) ) )
|
||||
->asType<UIPushButton>() );
|
||||
PU3->add( "Zoom Out", mTheme->getIconByName( "zoom-out" ) ) );
|
||||
addShortcut( KEY_0, KEYMOD_CTRL,
|
||||
PU3->getItem( PU3->add( "Normal Size", mTheme->getIconByName( "zoom-original" ) ) )
|
||||
->asType<UIPushButton>() );
|
||||
PU3->add( "Normal Size", mTheme->getIconByName( "zoom-original" ) ) );
|
||||
PU3->addSeparator();
|
||||
|
||||
PU3->addEventListener( Event::OnItemClicked, cb::Make1( this, &MapEditor::viewMenuClick ) );
|
||||
@@ -179,13 +173,11 @@ void MapEditor::createMenuBar() {
|
||||
PU5->add( "Layer Properties..." );
|
||||
PU5->addSeparator();
|
||||
|
||||
Uint32 LayerChkBoxIndex = PU5->addCheckBox( "Lights Enabled" );
|
||||
mLayerChkLights = PU5->getItem( LayerChkBoxIndex )->asType<UIMenuCheckBox>();
|
||||
mLayerChkLights = PU5->addCheckBox( "Lights Enabled" );
|
||||
|
||||
PU5->addSeparator();
|
||||
|
||||
LayerChkBoxIndex = PU5->addCheckBox( "Visible" );
|
||||
mLayerChkVisible = PU5->getItem( LayerChkBoxIndex )->asType<UIMenuCheckBox>();
|
||||
mLayerChkVisible = PU5->addCheckBox( "Visible" );
|
||||
|
||||
PU5->addEventListener( Event::OnItemClicked, cb::Make1( this, &MapEditor::layerMenuClick ) );
|
||||
MenuBar->addMenuButton( "Layer", PU5 );
|
||||
|
||||
@@ -69,8 +69,8 @@ SyntaxDefinitionManager::SyntaxDefinitionManager() {
|
||||
{{"\\."}, "normal"},
|
||||
{{"<!%-%-", "%-%->"}, "comment"},
|
||||
{{"```", "```"}, "string"},
|
||||
{{"``", "``", "\\"}, "string"},
|
||||
{{"`", "`", "\\"}, "string"},
|
||||
{{"``", "``"}, "string"},
|
||||
{{"`", "`"}, "string"},
|
||||
{{"~~", "~~", "\\"}, "keyword2"},
|
||||
{{"%-%-%-+"}, "comment"},
|
||||
{{"%*%s+"}, "operator"},
|
||||
@@ -858,10 +858,10 @@ SyntaxDefinitionManager::SyntaxDefinitionManager() {
|
||||
|
||||
// ini / conf
|
||||
add( {"Config File",
|
||||
{"%.ini$", "%.conf$", "%.desktop$"},
|
||||
{"%.ini$", "%.conf$", "%.desktop$", "Doxyfile"},
|
||||
{
|
||||
{{"#[%da-fA-F]+"}, "literal"},
|
||||
{{"#", "\n"}, "comment"},
|
||||
{{"#.-\n"}, "comment"},
|
||||
{{"\"", "\"", "\\"}, "string"},
|
||||
{{"'", "'", "\\"}, "string"},
|
||||
{{"%[", "%]"}, "keyword2"},
|
||||
@@ -1713,6 +1713,12 @@ std::vector<std::string> SyntaxDefinitionManager::getLanguageNames() const {
|
||||
const SyntaxDefinition&
|
||||
SyntaxDefinitionManager::getStyleByExtension( const std::string& filePath ) const {
|
||||
std::string extension( FileSystem::fileExtension( filePath ) );
|
||||
|
||||
// Use the filename instead
|
||||
if ( extension.empty() ) {
|
||||
extension = FileSystem::fileNameFromPath( filePath );
|
||||
}
|
||||
|
||||
if ( !extension.empty() ) {
|
||||
for ( auto style = mStyles.rbegin(); style != mStyles.rend(); ++style ) {
|
||||
for ( auto ext : style->getFiles() ) {
|
||||
|
||||
@@ -262,6 +262,12 @@ UICodeEditor* UICodeEditor::setFont( Font* font ) {
|
||||
|
||||
void UICodeEditor::onFontChanged() {}
|
||||
|
||||
Uint32 UICodeEditor::onMessage( const NodeMessage* msg ) {
|
||||
if ( msg->getMsg() == NodeMessage::MouseDown )
|
||||
return 1;
|
||||
return UIWidget::onMessage( msg );
|
||||
}
|
||||
|
||||
void UICodeEditor::disableEditorFeatures() {
|
||||
mShowLineNumber = false;
|
||||
mShowIndentationGuide = false;
|
||||
@@ -1586,6 +1592,10 @@ void UICodeEditor::registerKeybindings() {
|
||||
{{KEY_DELETE, 0}, "delete-to-next-char"},
|
||||
{{KEY_KP_ENTER, KEYMOD_CTRL | KEYMOD_SHIFT}, "new-line-above"},
|
||||
{{KEY_RETURN, KEYMOD_CTRL | KEYMOD_SHIFT}, "new-line-above"},
|
||||
{{KEY_KP_ENTER, KEYMOD_CTRL}, "new-line"},
|
||||
{{KEY_RETURN, KEYMOD_CTRL}, "new-line"},
|
||||
{{KEY_KP_ENTER, KEYMOD_SHIFT}, "new-line"},
|
||||
{{KEY_RETURN, KEYMOD_SHIFT}, "new-line"},
|
||||
{{KEY_KP_ENTER, 0}, "new-line"},
|
||||
{{KEY_RETURN, 0}, "new-line"},
|
||||
{{KEY_UP, KEYMOD_CTRL | KEYMOD_SHIFT}, "move-lines-up"},
|
||||
|
||||
@@ -71,8 +71,10 @@ UIMenuItem* UIMenu::createMenuItem( const String& Text, Drawable* Icon ) {
|
||||
return tCtrl;
|
||||
}
|
||||
|
||||
Uint32 UIMenu::add( const String& Text, Drawable* Icon ) {
|
||||
return add( createMenuItem( Text, Icon ) );
|
||||
UIMenuItem* UIMenu::add( const String& Text, Drawable* Icon ) {
|
||||
UIMenuItem* menuItem = createMenuItem( Text, Icon );
|
||||
add( menuItem );
|
||||
return menuItem;
|
||||
}
|
||||
|
||||
UIMenuCheckBox* UIMenu::createMenuCheckBox( const String& Text, const bool& Active ) {
|
||||
@@ -88,8 +90,10 @@ UIMenuCheckBox* UIMenu::createMenuCheckBox( const String& Text, const bool& Acti
|
||||
return tCtrl;
|
||||
}
|
||||
|
||||
Uint32 UIMenu::addCheckBox( const String& Text, const bool& Active ) {
|
||||
return add( createMenuCheckBox( Text, Active ) );
|
||||
UIMenuCheckBox* UIMenu::addCheckBox( const String& Text, const bool& Active ) {
|
||||
UIMenuCheckBox* chkBox = createMenuCheckBox( Text, Active );
|
||||
add( chkBox );
|
||||
return chkBox;
|
||||
}
|
||||
|
||||
UIMenuSubMenu* UIMenu::createSubMenu( const String& Text, Drawable* Icon, UIMenu* SubMenu ) {
|
||||
@@ -104,8 +108,10 @@ UIMenuSubMenu* UIMenu::createSubMenu( const String& Text, Drawable* Icon, UIMenu
|
||||
return tCtrl;
|
||||
}
|
||||
|
||||
Uint32 UIMenu::addSubMenu( const String& Text, Drawable* Icon, UIMenu* SubMenu ) {
|
||||
return add( createSubMenu( Text, Icon, SubMenu ) );
|
||||
UIMenuSubMenu* UIMenu::addSubMenu( const String& Text, Drawable* Icon, UIMenu* SubMenu ) {
|
||||
UIMenuSubMenu* subMenu = createSubMenu( Text, Icon, SubMenu );
|
||||
add( subMenu );
|
||||
return subMenu;
|
||||
}
|
||||
|
||||
bool UIMenu::widgetCheckSize( UIWidget* widget, const bool& Resize ) {
|
||||
@@ -137,7 +143,7 @@ bool UIMenu::widgetCheckSize( UIWidget* widget, const bool& Resize ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Uint32 UIMenu::add( UIWidget* widget ) {
|
||||
UIWidget* UIMenu::add( UIWidget* widget ) {
|
||||
if ( this != widget->getParent() )
|
||||
widget->setParent( this );
|
||||
|
||||
@@ -160,7 +166,7 @@ Uint32 UIMenu::add( UIWidget* widget ) {
|
||||
|
||||
resizeMe();
|
||||
|
||||
return mItems.size() - 1;
|
||||
return widget;
|
||||
}
|
||||
|
||||
void UIMenu::setWidgetSize( UIWidget* widget ) {
|
||||
@@ -169,7 +175,7 @@ void UIMenu::setWidgetSize( UIWidget* widget ) {
|
||||
mResizing = false;
|
||||
}
|
||||
|
||||
Uint32 UIMenu::addSeparator() {
|
||||
UIMenuSeparator* UIMenu::addSeparator() {
|
||||
UIMenuSeparator* separator = UIMenuSeparator::New();
|
||||
separator->setParent( this );
|
||||
separator->setPixelsPosition( mRealPadding.Left, mRealPadding.Top + mNextPosY );
|
||||
@@ -189,7 +195,7 @@ Uint32 UIMenu::addSeparator() {
|
||||
}
|
||||
} );
|
||||
|
||||
return mItems.size() - 1;
|
||||
return separator;
|
||||
}
|
||||
|
||||
UIWidget* UIMenu::getItem( const Uint32& Index ) {
|
||||
|
||||
@@ -11,6 +11,7 @@ UIMenuCheckBox* UIMenuCheckBox::New() {
|
||||
UIMenuCheckBox::UIMenuCheckBox() :
|
||||
UIMenuItem( "menu::checkbox" ), mActive( false ), mSkinActive( NULL ), mSkinInactive( NULL ) {
|
||||
mIcon->setElementTag( mTag + "::icon" );
|
||||
mTextBox->setElementTag( mTag + "::text" );
|
||||
applyDefaultTheme();
|
||||
mIcon->setFlags( UI_SKIN_KEEP_SIZE_ON_DRAW );
|
||||
}
|
||||
@@ -117,11 +118,4 @@ void UIMenuCheckBox::onStateChange() {
|
||||
setActive( mActive );
|
||||
}
|
||||
|
||||
bool UIMenuCheckBox::inheritsFrom( const Uint32 Type ) {
|
||||
if ( Type == UI_TYPE_MENUITEM )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}} // namespace EE::UI
|
||||
|
||||
@@ -349,8 +349,7 @@ Uint32 UIScrollView::onMessage( const NodeMessage* Msg ) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return UITouchDraggableWidget::onMessage( Msg );
|
||||
}
|
||||
|
||||
}} // namespace EE::UI
|
||||
|
||||
@@ -255,7 +255,8 @@ Uint32 UITab::onMessage( const NodeMessage* message ) {
|
||||
|
||||
switch ( message->getMsg() ) {
|
||||
case NodeMessage::MouseDown: {
|
||||
if ( flags & EE_BUTTON_LMASK && message->getSender() != mCloseButton ) {
|
||||
if ( flags & EE_BUTTON_LMASK && message->getSender() != mCloseButton &&
|
||||
getEventDispatcher()->getMouseDownNode() == this ) {
|
||||
tTabW->setTabSelected( this );
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -63,88 +63,85 @@ bool UITouchDraggableWidget::isTouchOverAllowedChilds() {
|
||||
}
|
||||
|
||||
void UITouchDraggableWidget::scheduledUpdate( const Time& time ) {
|
||||
if ( mEnabled && mVisible && NULL != getEventDispatcher() ) {
|
||||
if ( isTouchDragEnabled() ) {
|
||||
EventDispatcher* eventDispatcher = getEventDispatcher();
|
||||
Uint32 Press = eventDispatcher->getPressTrigger();
|
||||
if ( mEnabled && mVisible && isTouchDragEnabled() && NULL != getEventDispatcher() ) {
|
||||
if ( isTouchDragging() ) {
|
||||
// Mouse Not Down
|
||||
if ( !( getEventDispatcher()->getPressTrigger() & EE_BUTTON_LMASK ) ) {
|
||||
setTouchDragging( false );
|
||||
getEventDispatcher()->setNodeDragging( NULL );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( isTouchDragging() ) {
|
||||
// Mouse Not Down
|
||||
if ( !( Press & EE_BUTTON_LMASK ) ) {
|
||||
setTouchDragging( false );
|
||||
eventDispatcher->setNodeDragging( NULL );
|
||||
return;
|
||||
}
|
||||
Float ms = time.asSeconds();
|
||||
Vector2f elapsed( ms, ms );
|
||||
Vector2f Pos( getEventDispatcher()->getMousePosf() );
|
||||
|
||||
Float ms = time.asSeconds();
|
||||
Vector2f elapsed( ms, ms );
|
||||
Vector2f Pos( eventDispatcher->getMousePosf() );
|
||||
if ( mTouchDragPoint != Pos ) {
|
||||
Vector2f diff = -( mTouchDragPoint - Pos );
|
||||
|
||||
if ( mTouchDragPoint != Pos ) {
|
||||
Vector2f diff = -( mTouchDragPoint - Pos );
|
||||
onTouchDragValueChange( diff );
|
||||
|
||||
onTouchDragValueChange( diff );
|
||||
mTouchDragAcceleration += elapsed * diff;
|
||||
|
||||
mTouchDragAcceleration += elapsed * diff;
|
||||
mTouchDragPoint = Pos;
|
||||
|
||||
mTouchDragPoint = Pos;
|
||||
|
||||
eventDispatcher->setNodeDragging( this );
|
||||
} else {
|
||||
mTouchDragAcceleration -= elapsed * mTouchDragDeceleration;
|
||||
}
|
||||
getEventDispatcher()->setNodeDragging( this );
|
||||
} else {
|
||||
// Mouse Down
|
||||
if ( Press & EE_BUTTON_LMASK ) {
|
||||
if ( isTouchOverAllowedChilds() && !eventDispatcher->isNodeDragging() ) {
|
||||
setTouchDragging( true );
|
||||
eventDispatcher->setNodeDragging( this );
|
||||
mTouchDragAcceleration -= elapsed * mTouchDragDeceleration;
|
||||
}
|
||||
} else {
|
||||
// Deaccelerate
|
||||
if ( mTouchDragAcceleration.x != 0 || mTouchDragAcceleration.y != 0 ) {
|
||||
Float ms = getEventDispatcher()->getLastFrameTime().asSeconds();
|
||||
|
||||
mTouchDragPoint = Vector2f( eventDispatcher->getMousePos().x,
|
||||
eventDispatcher->getMousePos().y );
|
||||
mTouchDragAcceleration = Vector2f( 0, 0 );
|
||||
}
|
||||
if ( 0 != mTouchDragAcceleration.x ) {
|
||||
bool wasPositiveX = mTouchDragAcceleration.x >= 0;
|
||||
|
||||
if ( mTouchDragAcceleration.x > 0 )
|
||||
mTouchDragAcceleration.x -= mTouchDragDeceleration.x * ms;
|
||||
else
|
||||
mTouchDragAcceleration.x += mTouchDragDeceleration.x * ms;
|
||||
|
||||
if ( wasPositiveX && mTouchDragAcceleration.x < 0 )
|
||||
mTouchDragAcceleration.x = 0;
|
||||
else if ( !wasPositiveX && mTouchDragAcceleration.x > 0 )
|
||||
mTouchDragAcceleration.x = 0;
|
||||
}
|
||||
|
||||
// Deaccelerate
|
||||
if ( mTouchDragAcceleration.x != 0 || mTouchDragAcceleration.y != 0 ) {
|
||||
Float ms = eventDispatcher->getLastFrameTime().asSeconds();
|
||||
if ( 0 != mTouchDragAcceleration.y ) {
|
||||
bool wasPositiveY = mTouchDragAcceleration.y >= 0;
|
||||
|
||||
if ( 0 != mTouchDragAcceleration.x ) {
|
||||
bool wasPositiveX = mTouchDragAcceleration.x >= 0;
|
||||
if ( mTouchDragAcceleration.y > 0 )
|
||||
mTouchDragAcceleration.y -= mTouchDragDeceleration.y * ms;
|
||||
else
|
||||
mTouchDragAcceleration.y += mTouchDragDeceleration.y * ms;
|
||||
|
||||
if ( mTouchDragAcceleration.x > 0 )
|
||||
mTouchDragAcceleration.x -= mTouchDragDeceleration.x * ms;
|
||||
else
|
||||
mTouchDragAcceleration.x += mTouchDragDeceleration.x * ms;
|
||||
|
||||
if ( wasPositiveX && mTouchDragAcceleration.x < 0 )
|
||||
mTouchDragAcceleration.x = 0;
|
||||
else if ( !wasPositiveX && mTouchDragAcceleration.x > 0 )
|
||||
mTouchDragAcceleration.x = 0;
|
||||
}
|
||||
|
||||
if ( 0 != mTouchDragAcceleration.y ) {
|
||||
bool wasPositiveY = mTouchDragAcceleration.y >= 0;
|
||||
|
||||
if ( mTouchDragAcceleration.y > 0 )
|
||||
mTouchDragAcceleration.y -= mTouchDragDeceleration.y * ms;
|
||||
else
|
||||
mTouchDragAcceleration.y += mTouchDragDeceleration.y * ms;
|
||||
|
||||
if ( wasPositiveY && mTouchDragAcceleration.y < 0 )
|
||||
mTouchDragAcceleration.y = 0;
|
||||
else if ( !wasPositiveY && mTouchDragAcceleration.y > 0 )
|
||||
mTouchDragAcceleration.y = 0;
|
||||
}
|
||||
|
||||
onTouchDragValueChange( mTouchDragAcceleration );
|
||||
if ( wasPositiveY && mTouchDragAcceleration.y < 0 )
|
||||
mTouchDragAcceleration.y = 0;
|
||||
else if ( !wasPositiveY && mTouchDragAcceleration.y > 0 )
|
||||
mTouchDragAcceleration.y = 0;
|
||||
}
|
||||
|
||||
onTouchDragValueChange( mTouchDragAcceleration );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Uint32 UITouchDraggableWidget::onMessage( const NodeMessage* msg ) {
|
||||
if ( msg->getMsg() == NodeMessage::MouseDown && ( msg->getFlags() & EE_BUTTON_LMASK ) &&
|
||||
!isTouchDragging() && isTouchOverAllowedChilds() &&
|
||||
!getEventDispatcher()->isNodeDragging() ) {
|
||||
setTouchDragging( true );
|
||||
getEventDispatcher()->setNodeDragging( this );
|
||||
mTouchDragPoint = Vector2f( getEventDispatcher()->getMousePos().x,
|
||||
getEventDispatcher()->getMousePos().y );
|
||||
mTouchDragAcceleration = Vector2f( 0, 0 );
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string UITouchDraggableWidget::getPropertyString( const PropertyDefinition* propertyDef,
|
||||
const Uint32& propertyIndex ) {
|
||||
if ( NULL == propertyDef )
|
||||
|
||||
@@ -663,15 +663,18 @@ void App::initSearchBar() {
|
||||
UITextInput* findInput = mSearchBarLayout->find<UITextInput>( "search_find" );
|
||||
UITextInput* replaceInput = mSearchBarLayout->find<UITextInput>( "search_replace" );
|
||||
UICheckBox* caseSensitiveChk = mSearchBarLayout->find<UICheckBox>( "case_sensitive" );
|
||||
findInput->addEventListener(
|
||||
Event::OnTextChanged, [&, findInput, caseSensitiveChk]( const Event* ) {
|
||||
findInput->addEventListener( Event::OnTextChanged, [&, findInput,
|
||||
caseSensitiveChk]( const Event* ) {
|
||||
if ( mCurEditor ) {
|
||||
if ( !findInput->getText().empty() ) {
|
||||
mCurEditor->getDocument().setSelection( mCurEditor->getDocument().startOfDoc() );
|
||||
findNextText( findInput->getText(), caseSensitiveChk->isChecked() );
|
||||
} else if ( mCurEditor ) {
|
||||
} else {
|
||||
mCurEditor->getDocument().setSelection(
|
||||
mCurEditor->getDocument().getSelection().start() );
|
||||
}
|
||||
} );
|
||||
}
|
||||
} );
|
||||
mSearchBarLayout->addCommand( "close-searchbar", [&] {
|
||||
mSearchBarLayout->setEnabled( false )->setVisible( false );
|
||||
mCurEditor->setFocus();
|
||||
|
||||
@@ -496,10 +496,7 @@ void refreshLayoutList() {
|
||||
uiLayoutsMenu->removeAll();
|
||||
|
||||
for ( auto it = layouts.begin(); it != layouts.end(); ++it ) {
|
||||
Uint32 idx = uiLayoutsMenu->addCheckBox( it->first );
|
||||
UIMenuCheckBox* chk = static_cast<UIMenuCheckBox*>( uiLayoutsMenu->getItem( idx ) );
|
||||
|
||||
chk->setActive( currentLayout == it->second );
|
||||
uiLayoutsMenu->addCheckBox( it->first )->setActive( currentLayout == it->second );
|
||||
}
|
||||
} else if ( uiMenuBar->getButton( "Layouts" ) != NULL ) {
|
||||
uiMenuBar->removeMenuButton( "Layouts" );
|
||||
|
||||
Reference in New Issue
Block a user