Exemple #1
0
  AbstractWidget* AbstractNode::RecursiveDispatchHoverEvent (AbstractWidget* widget,
                                                             AbstractWindow* context)
  {
    AbstractWidget* retval = widget;
    Point offset = widget->GetOffset();
    context->set_local_cursor_position(
        context->local_cursor_position().x() - widget->position().x()
            - offset.x(),
        context->local_cursor_position().y() - widget->position().y()
            - offset.y());

    for (AbstractView* p = widget->GetLastSubView(); p;
        p = widget->GetPreviousSubView(p)) {

      if (is_widget(p)) {
        if (p->Contain(context->local_cursor_position())) {
          retval = dynamic_cast<AbstractWidget*>(p);
          dispatch_mouse_hover_in(retval, context);
          retval = RecursiveDispatchHoverEvent(retval, context);

          break;
        }
      } else {
        break;
      }

    }

    return retval;
  }
Exemple #2
0
  AbstractWidget* AbstractNode::FindWidgetUnderCursor (AbstractWindow* context)
  {
    AbstractWidget* result = 0;
    Point offset = GetOffset();

    context->set_local_cursor_position(
        context->local_cursor_position().x() - position().x() - offset.x(),
        context->local_cursor_position().y() - position().y() - offset.y());

    for (AbstractView* p = GetLastSubView(); p; p = GetPreviousSubView(p)) {

      if (is_widget(p)) {
        result = dynamic_cast<AbstractWidget*>(p);
        if (p->Contain(context->local_cursor_position())) {
          dispatch_mouse_hover_in(result, context);
          break;
        }
      } else {
        break;
      }

    }

    if (result) {
      result = RecursiveDispatchHoverEvent(result, context);
    }

    return result;
  }
Exemple #3
0
// Generate a descriptive text for this item, to put in browser & window
// titles. Warning: the buffer used is overwritten each time!
const char* Fl_Type::title() {
#define MAXLABEL 128
  static char buffer[MAXLABEL];
  const char* t1 = type_name();
  const char* type = 0;
  if (is_widget()) type = t1 = ((Fl_Widget_Type*)this)->subclass();
  const char* name = this->name();
  bool quoted = false;
  if (!name || !*name) {
    name = label();
    if (!name || !*name) return t1;
    quoted = true;
  }
  // copy but stop at any newline or when the buffer fills up:
  char* e = buffer+MAXLABEL-1; if (quoted) e--;
  char* p = buffer;
  if (type) {
    while (p < e && *type) *p++ = *type++;
    if (p >= e-4) return name;
    *p++ = ' ';
  }
  if (quoted) *p++ = '"';
  while (p < e && (*name&~31)) *p++ = *name++;
  if (*name) {
    if (p > e-3) p = e-3;
    strcpy(p, quoted ? "...\"" : "...");
  } else {
    if (quoted) *p++ = '"';
    *p++ = 0;
  }
  return buffer;
}
Exemple #4
0
void StagePanel::LoadFromFile(const char* filename)
{
	Json::Value value;
	Json::Reader reader;
	std::locale::global(std::locale(""));
	std::ifstream fin(filename);
	std::locale::global(std::locale("C"));
	reader.parse(fin, value);
	fin.close();

	std::string type = value["type"].asString();
	if (!type.empty() && !is_widget(type, ID_WRAPPER)) {
		return;
	}

	std::string user_type = value["user type"].asString();
	m_toolbar->SetType(user_type);

	std::string tag = value["tag"].asString();
	m_toolbar->SetTag(tag);

	const Json::Value& cb_val = value["clipbox"];
	m_clipbox.xmin = cb_val["x"].asDouble();
	m_clipbox.ymax = cb_val["y"].asDouble();
	m_clipbox.xmax = m_clipbox.xmin + cb_val["w"].asDouble();
	m_clipbox.ymin = m_clipbox.ymax - cb_val["h"].asDouble();

	std::string items_filepath = value["items filepath"].asString();
	items_filepath = ee::FileHelper::GetAbsolutePathFromFile(filename, items_filepath);
	ecomplex::Symbol items_complex;
	items_complex.LoadFromFile(items_filepath);
	auto& children = items_complex.GetAllChildren();
	for (int i = 0, n = children.size(); i < n; ++i) {
		auto spr = std::dynamic_pointer_cast<ee::Sprite>(children[i]);
		ee::InsertSpriteSJ::Instance()->Insert(spr);
	}
}
Exemple #5
0
  AbstractWidget* AbstractNode::RecheckWidgetUnderCursor (AbstractWidget* orig,
                                                          AbstractWindow* context)
  {
    DBG_ASSERT(orig);
    DBG_ASSERT(orig->super() && orig->super() != this);

    AbstractWidget* result = orig;
    AbstractView* parent = result->super();
    Point offset;

    Rect rect(GetRelativePosition(parent) + position() + GetOffset(),
              parent->size());

    bool cursor_in_superview = rect.contains(context->local_cursor_position());

    if (cursor_in_superview) {

      offset = parent->GetOffset();
      context->set_local_cursor_position(
          context->local_cursor_position().x() - rect.x() - offset.x(),
          context->local_cursor_position().y() - rect.y() - offset.y());

      if (result->Contain(context->local_cursor_position())) {
        result = RecursiveDispatchHoverEvent(result, context);
      } else {

        dispatch_mouse_hover_out(result, context);

        // find which contianer contains cursor position
        while (parent) {

          if (parent == this) {
            parent = 0;
            break;
          }

          offset = parent->GetOffset();
          context->set_local_cursor_position(
              context->local_cursor_position().x() + parent->position().x()
                  + offset.x(),
              context->local_cursor_position().y() + parent->position().y()
                  + offset.y());

          if (parent->Contain(context->local_cursor_position())) break;

          parent = parent->super();
        }

        result = dynamic_cast<AbstractWidget*>(parent);

        if (result) {
          result = RecursiveDispatchHoverEvent(result, context);
        }

      }

    } else {

      dispatch_mouse_hover_out(result, context);

      // find which contianer contains cursor position
      parent = parent->super();
      while (parent != nullptr) {

        if (parent == this) {
          parent = nullptr;
          break;
        }

        if (is_widget(parent)) {
          rect.set_position(GetRelativePosition(parent));
          rect.set_size(parent->size());
        } else {
          DBG_ASSERT(parent == this);
          rect.set_position(position());
          rect.set_size(size());
        }

        offset = parent->GetOffset();
        context->set_local_cursor_position(
            context->local_cursor_position().x() - rect.x() - offset.x(),
            context->local_cursor_position().y() - rect.y() - offset.y());

        if (rect.contains(context->local_cursor_position())) break;

        parent = parent->super();
      }

      result = dynamic_cast<AbstractWidget*>(parent);
      if (result) {

        for (AbstractView* p = parent->GetLastSubView(); p;
            p = parent->GetPreviousSubView(p)) {

          if (is_widget(p)) {
            if (p->Contain(context->local_cursor_position())) {
              result = dynamic_cast<AbstractWidget*>(p);

              dispatch_mouse_hover_in(result, context);
              result = RecursiveDispatchHoverEvent(result, context);

              break;
            }
          } else {
            break;
          }
        }
      }

    }

    return result;
  }