-display/emulate_touchscreen now really emulates a touchscreen

-icons to show node menus
This commit is contained in:
Juan Linietsky 2015-08-29 17:16:11 -03:00
parent 1fecba6b5b
commit b4acd18f32
11 changed files with 77 additions and 6 deletions

View File

@ -1477,7 +1477,6 @@ Globals::Globals() {
custom_prop_info["render/mipmap_policy"]=PropertyInfo(Variant::INT,"render/mipmap_policy",PROPERTY_HINT_ENUM,"Allow,Allow For Po2,Disallow");
custom_prop_info["render/thread_model"]=PropertyInfo(Variant::INT,"render/thread_model",PROPERTY_HINT_ENUM,"Single-Unsafe,Single-Safe,Multi-Threaded");
custom_prop_info["physics_2d/thread_model"]=PropertyInfo(Variant::INT,"physics_2d/thread_model",PROPERTY_HINT_ENUM,"Single-Unsafe,Single-Safe,Multi-Threaded");
set("display/emulate_touchscreen",false);
using_datapack=false;
}

View File

@ -271,6 +271,38 @@ void InputDefault::parse_input_event(const InputEvent& p_event) {
mouse_button_mask|=(1<<p_event.mouse_button.button_index);
else
mouse_button_mask&=~(1<<p_event.mouse_button.button_index);
if (main_loop && emulate_touch && p_event.mouse_button.button_index==1) {
InputEventScreenTouch touch_event;
touch_event.index=0;
touch_event.pressed=p_event.mouse_button.pressed;
touch_event.x=p_event.mouse_button.x;
touch_event.y=p_event.mouse_button.y;
InputEvent ev;
ev.type=InputEvent::SCREEN_TOUCH;
ev.screen_touch=touch_event;
main_loop->input_event(ev);
}
} break;
case InputEvent::MOUSE_MOTION: {
if (main_loop && emulate_touch && p_event.mouse_motion.button_mask&1) {
InputEventScreenDrag drag_event;
drag_event.index=0;
drag_event.x=p_event.mouse_motion.x;
drag_event.y=p_event.mouse_motion.y;
drag_event.relative_x=p_event.mouse_motion.relative_x;
drag_event.relative_y=p_event.mouse_motion.relative_y;
drag_event.speed_x=p_event.mouse_motion.speed_x;
drag_event.speed_y=p_event.mouse_motion.speed_y;
InputEvent ev;
ev.type=InputEvent::SCREEN_DRAG;
ev.screen_drag=drag_event;
main_loop->input_event(ev);
}
} break;
case InputEvent::JOYSTICK_BUTTON: {
@ -362,8 +394,19 @@ void InputDefault::action_release(const StringName& p_action){
}
}
void InputDefault::set_emulate_touch(bool p_emulate) {
emulate_touch=p_emulate;
}
bool InputDefault::is_emulating_touchscreen() const {
return emulate_touch;
}
InputDefault::InputDefault() {
mouse_button_mask=0;
emulate_touch=false;
main_loop=NULL;
}

View File

@ -78,6 +78,8 @@ public:
void get_argument_options(const StringName& p_function,int p_idx,List<String>*r_options) const;
virtual bool is_emulating_touchscreen() const=0;
Input();
};
@ -99,6 +101,8 @@ class InputDefault : public Input {
Vector2 mouse_pos;
MainLoop *main_loop;
bool emulate_touch;
struct SpeedTrack {
uint64_t last_tick;
@ -147,6 +151,9 @@ public:
void iteration(float p_step);
void set_emulate_touch(bool p_emulate);
virtual bool is_emulating_touchscreen() const;
InputDefault();
};

View File

@ -31,7 +31,7 @@
#include <stdarg.h>
#include "dir_access.h"
#include "globals.h"
#include "input.h"
OS* OS::singleton=NULL;
@ -363,7 +363,7 @@ Error OS::set_cwd(const String& p_cwd) {
bool OS::has_touchscreen_ui_hint() const {
//return false;
return GLOBAL_DEF("display/emulate_touchscreen",false);
return Input::get_singleton() && Input::get_singleton()->is_emulating_touchscreen();
}
int OS::get_free_static_memory() const {

View File

@ -75,7 +75,7 @@
#include "core/io/file_access_zip.h"
#include "translation.h"
#include "version.h"
#include "os/input.h"
#include "performance.h"
static Globals *globals=NULL;
@ -847,6 +847,14 @@ Error Main::setup2() {
GLOBAL_DEF("application/icon",String());
Globals::get_singleton()->set_custom_property_info("application/icon",PropertyInfo(Variant::STRING,"application/icon",PROPERTY_HINT_FILE,"*.png,*.webp"));
if (bool(GLOBAL_DEF("display/emulate_touchscreen",false))) {
if (!OS::get_singleton()->has_touchscreen_ui_hint() && Input::get_singleton()) {
//only if no touchscreen ui hint, set emulation
InputDefault *id = Input::get_singleton()->cast_to<InputDefault>();
if (id)
id->set_emulate_touch(true);
}
}
MAIN_PRINT("Main: Load Remaps");
path_remap->load_remaps();

View File

@ -297,7 +297,7 @@ void make_default_theme() {
t->set_color("font_color_hover","MenuButton", control_font_color_hover );
t->set_color("font_color_disabled","MenuButton", Color(1,1,1,0.3) );
t->set_constant("hseparation","MenuButton", 0 );
t->set_constant("hseparation","MenuButton", 3 );
// CheckBox

View File

@ -93,7 +93,7 @@
#include "plugins/light_occluder_2d_editor_plugin.h"
#include "plugins/color_ramp_editor_plugin.h"
#include "plugins/collision_shape_2d_editor_plugin.h"
#include "os/input.h"
// end
#include "tools/editor/io_plugins/editor_texture_import_plugin.h"
#include "tools/editor/io_plugins/editor_scene_import_plugin.h"
@ -4163,6 +4163,14 @@ EditorNode::EditorNode() {
EditorHelp::generate_doc(); //before any editor classes are crated
if (!OS::get_singleton()->has_touchscreen_ui_hint() && Input::get_singleton()) {
//only if no touchscreen ui hint, set emulation
InputDefault *id = Input::get_singleton()->cast_to<InputDefault>();
if (id)
id->set_emulate_touch(false); //just disable just in case
}
singleton=this;
last_checked_version=0;
changing_scene=false;

View File

@ -216,6 +216,8 @@ MeshInstanceEditor::MeshInstanceEditor() {
SpatialEditor::get_singleton()->add_control_to_menu_panel(options);
options->set_text("Mesh");
options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("MeshInstance","EditorIcons"));
options->get_popup()->add_item("Create Trimesh Static Body",MENU_OPTION_CREATE_STATIC_TRIMESH_BODY);
options->get_popup()->add_item("Create Convex Static Body",MENU_OPTION_CREATE_STATIC_CONVEX_BODY);
options->get_popup()->add_separator();

View File

@ -330,6 +330,8 @@ MultiMeshEditor::MultiMeshEditor() {
options->set_area_as_parent_rect();
options->set_text("MultiMesh");
options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("MultiMeshInstance","EditorIcons"));
options->get_popup()->add_item("Populate Surface");
options->get_popup()->connect("item_pressed", this,"_menu_option");

View File

@ -146,6 +146,7 @@ void Particles2DEditorPlugin::_notification(int p_what) {
if (p_what==NOTIFICATION_ENTER_TREE) {
menu->get_popup()->connect("item_pressed",this,"_menu_callback");
menu->set_icon(menu->get_popup()->get_icon("Particles2D","EditorIcons"));
file->connect("file_selected",this,"_file_selected");
}
}

View File

@ -111,6 +111,7 @@ void ParticlesEditor::_populate() {
void ParticlesEditor::_notification(int p_notification) {
if (p_notification==NOTIFICATION_ENTER_TREE) {
options->set_icon(options->get_popup()->get_icon("Particles","EditorIcons"));
}
}