Called when an item is focused, moves the item into the viewport

        :param view:
        :param StateView | ConnectionView | PortView focused_item: The focused item
492879
def _move_focused_item_into_viewport(self, view, focused_item):
        
        self.view.editor.handler_block(self.drag_motion_handler_id)
        self.move_item_into_viewport(focused_item)
        self.view.editor.handler_unblock(self.drag_motion_handler_id)
1199645
def _filter_hovered_items(self, items, event):
        
        items = self._filter_library_state(items)
        if not items:
            return items
        top_most_item = items[0]
        second_top_most_item = items[1] if len(items) > 1 else None

        # States/Names take precedence over connections if the connections are on the same hierarchy and if there is
        # a port beneath the cursor
        first_state_v = next(filter(lambda item: isinstance(item, (NameView, StateView)), items))
        first_state_v = first_state_v.parent if isinstance(first_state_v, NameView) else first_state_v
        if first_state_v:
            # There can be several connections above the state/name skip those and find the first non-connection-item
            for item in items:
                if isinstance(item, ConnectionView):
                    # connection is on the same hierarchy level as the state/name, thus we dismiss it
                    if self.view.canvas.get_parent(top_most_item) is not first_state_v:
                        continue
                break

            # Connections are only dismissed, if there is a port beneath the cursor. Search for ports here:
            port_beneath_cursor = False
            state_ports = first_state_v.get_all_ports()
            position = self.view.get_matrix_v2i(first_state_v).transform_point(event.x, event.y)
            i2v_matrix = self.view.get_matrix_i2v(first_state_v)
            for port_v in state_ports:
                item_distance = port_v.port.glue(position)[1]
                view_distance = i2v_matrix.transform_distance(item_distance, 0)[0]
                if view_distance == 0:
                    port_beneath_cursor = True
                    break

            if port_beneath_cursor:
                items = self.dismiss_upper_items(items, item)
                top_most_item = items[0]
                second_top_most_item = items[1] if len(items) > 1 else None

        # NameView can only be hovered if it or its parent state is selected
        if isinstance(top_most_item, NameView):
            state_v = second_top_most_item  # second item in the list must be the parent state of the NameView
            if state_v not in self.view.selected_items and top_most_item not in self.view.selected_items:
                items = items[1:]

        return items
421379
def on_button_press(self, event):
        
        if event.get_button()[1] not in self._buttons:
            return False  # Only handle events for registered buttons (left mouse clicks)

        if event.get_state()[1] & constants.RUBBERBAND_MODIFIER:
            return False  # Mouse clicks with pressed shift key are handled in another tool

        # Special case: moving the NameView
        # This is only allowed, if the hovered item is a NameView and the Ctrl-key is pressed and the only selected
        # item is the parental StateView. In this case, the selection and _item will no longer be looked at,
        # but only _move_name_v
        self._item = self.get_item()
        if isinstance(self._item, NameView):
            selected_items = self.view.selected_items
            if event.get_state()[1] & Gdk.ModifierType.CONTROL_MASK and len(selected_items) == 1 and next(iter(selected_items)) is \
                    self._item.parent:
                self._move_name_v = True
            else:
                self._item = self._item.parent

        if not self._move_name_v:
            self._old_selection = self.view.selected_items
            if self._item not in self.view.selected_items:
                # When items are to be moved, a button-press should not cause any deselection.
                # However, the selection is stored, in case no move operation is performed.
                self.view.handle_new_selection(self._item)

        if not self.view.is_focus():
            self.view.grab_focus()

        return True
228293
@Override
    public void addFocusables(ArrayList<View> views, int direction, int focusableMode) {
        final int focusableCount = views.size();

        final int descendantFocusability = getDescendantFocusability();

        if (descendantFocusability != FOCUS_BLOCK_DESCENDANTS) {
            for (int i = 0; i < getChildCount(); i++) {
                final View child = getChildAt(i);
                if (child.getVisibility() == VISIBLE) {
                    ItemInfo ii = infoForChild(child);
                    if (ii != null && ii.position == mCurItem) {
                        child.addFocusables(views, direction, focusableMode);
                    }
                }
            }
        }

        // we add ourselves (if focusable) in all cases except for when we are
        // FOCUS_AFTER_DESCENDANTS and there are some descendants focusable.  this is
        // to avoid the focus search finding layouts when a more precise search
        // among the focusable children would be more interesting.
        if (
                descendantFocusability != FOCUS_AFTER_DESCENDANTS ||
                        // No focusable descendants
                        (focusableCount == views.size())) {
            // Note that we can't call the superclass here, because it will
            // add all views in.  So we need to do the same thing View does.
            if (!isFocusable()) {
                return;
            }
            if ((focusableMode & FOCUSABLES_TOUCH_MODE) == FOCUSABLES_TOUCH_MODE &&
                    isInTouchMode() && !isFocusableInTouchMode()) {
                return;
            }
            if (views != null) {
                views.add(this);
            }
        }
    }
763415
def movable_items(self):
        
        view = self.view

        if self._move_name_v:
            yield InMotion(self._item, view)
        else:
            selected_items = set(view.selected_items)
            for item in selected_items:
                if not isinstance(item, Item):
                    continue
                yield InMotion(item, view)
159303
def register_view(self, view):
        """"""
        super(GraphicalEditorController, self).register_view(view)

        self.view.connect('meta_data_changed', self._meta_data_changed)
        self.focus_changed_handler_id = self.view.editor.connect('focus-changed', self._move_focused_item_into_viewport)
        self.view.editor.connect("drag-data-received", self.on_drag_data_received)
        self.drag_motion_handler_id = self.view.editor.connect("drag-motion", self.on_drag_motion)

        self.setup_canvas()
451676
def set_items(self, items):
        
        self._pending_view_refreshes +=1
        timed_call(self._pending_timeout, self._refresh_layout)
1049219
protected boolean onDrawItem(final Canvas canvas, final Item item, final Point curScreenCoords,
			final Projection pProjection) {

		

		final int state = (mDrawFocusedItem && (mFocusedItem == item) ? OverlayItem.ITEM_STATE_FOCUSED_MASK
				: 0);
		final Drawable marker = (item.getMarker(state) == null) ? getDefaultMarker(state) : item
				.getMarker(state);
		final HotspotPlace hotspot = item.getMarkerHotspot();

		boundToHotspot(marker, hotspot);

		int x = mCurScreenCoords.x;
		int y = mCurScreenCoords.y;

		marker.copyBounds(mRect);
		mRect.offset(x, y);
		RectL.getBounds(mRect, x, y, pProjection.getOrientation(), mOrientedMarkerRect);
		final boolean displayed = Rect.intersects(mOrientedMarkerRect, canvas.getClipBounds());
		if (displayed) {
			if (pProjection.getOrientation() != 0) { // optimization: step 1/2
				canvas.save();
				canvas.rotate(-pProjection.getOrientation(), x, y);
			}
			marker.setBounds(mRect);
			marker.draw(canvas);
			if (pProjection.getOrientation() != 0) { // optimization: step 2/2
				canvas.restore();
			}
		}

		return displayed;
	}
219362
@Override public void onViewPositionChanged(View changedView, int left, int top, int dx, int dy) {
    if (draggableView.isDragViewAtBottom()) {
      draggableView.changeDragViewViewAlpha();
    } else {
      draggableView.restoreAlpha();
      draggableView.changeDragViewScale();
      draggableView.changeDragViewPosition();
      draggableView.changeSecondViewAlpha();
      draggableView.changeSecondViewPosition();
      draggableView.changeBackgroundAlpha();
    }
  }
723126
def _get_focused_item(self):
        
        focused_model = self._selection.focus
        if not focused_model:
            return None
        return self.canvas.get_view_for_model(focused_model)
38474
private void onNavDrawerItemClicked(final int itemId) {
        if (itemId == mSelectedItem) {
            mDrawerLayout.closeDrawer(GravityCompat.START);
            return;
        }

        if (isSpecialItem(itemId)) {
            goToNavDrawerItem(itemId);
        } else {
            // launch the target Activity after a short delay, to allow the close animation to play
            mHandler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    goToNavDrawerItem(itemId);
                }
            }, mConfig.getLaunchDelay());

            // change the active item on the list so the user can see the item changed
            setSelectedNavDrawerItem(itemId);

            // fade out the main content
//            if (mMainContent != null && mConfig.getFadeOutDuration() != -1) {
//                mMainContent.animate().alpha(0).setDuration(mConfig.getFadeOutDuration());
//            }
        }

        mDrawerLayout.closeDrawer(GravityCompat.START);
    }
307388
def move_cursor(row = nil)
      if row
        if (prev_item = items[current_row])
          main.draw_item prev_item
        end
        page = row / max_items
        switch_page page if page != current_page
        main.activate_pane row / maxy
        @current_row = row
      else
        @current_row = 0
      end

      item = items[current_row]
      main.draw_item item, current: true
      main.display current_page

      header_l.draw_current_file_info item
      @current_row
    end
662256
def focusInEvent(self, event):
        """"""
        self.focus_changed.emit()
        return super(PageControlWidget, self).focusInEvent(event)
516525
protected void handleStateOnResult(LayoutChunkResult result, View[] views) {
        if (views == null) return;

        for (int i = 0; i < views.length; i++) {
            View view = views[i];
            if (view == null) {
                continue;
            }
            RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) view.getLayoutParams();

            // Consume the available space if the view is not removed OR changed
            if (params.isItemRemoved() || params.isItemChanged()) {
                result.mIgnoreConsumed = true;
            }

            // used when search a focusable view
            result.mFocusable = result.mFocusable || view.isFocusable();

            if (result.mFocusable && result.mIgnoreConsumed) {
                break;
            }
        }
    }
444639
@Override
    public final void onEnterFocus(FocusChangeDirection direction, Interactable previouslyInFocus) {
        inFocus = true;
        afterEnterFocus(direction, previouslyInFocus);
    }
629977
def focusInEvent(self, event):
        
        widget = self.widget
        type(widget).focusInEvent(widget, event)
        self.declaration.focus_gained()
217252
def link_view(self, view):
        
        if view is self._linked_view:
            return
        if self._linked_view is not None:
            self._linked_view.scene.transform.changed.disconnect(
                self._view_changed)
        self._linked_view = view
        view.scene.transform.changed.connect(self._view_changed)
        self._view_changed()