void RenderNode::issueDrawShadowOperation(const Matrix4& transformFromParent, T& handler) {
    if (properties().getAlpha() <= 0.0f
            || properties().getOutline().getAlpha() <= 0.0f
            || !properties().getOutline().getPath()
            || properties().getScaleX() == 0
            || properties().getScaleY() == 0) {
        // no shadow to draw
        return;
    }

    mat4 shadowMatrixXY(transformFromParent);
    applyViewPropertyTransforms(shadowMatrixXY);

    // Z matrix needs actual 3d transformation, so mapped z values will be correct
    mat4 shadowMatrixZ(transformFromParent);
    applyViewPropertyTransforms(shadowMatrixZ, true);

    const SkPath* casterOutlinePath = properties().getOutline().getPath();
    const SkPath* revealClipPath = properties().getRevealClip().getPath();
    if (revealClipPath && revealClipPath->isEmpty()) return;

    float casterAlpha = properties().getAlpha() * properties().getOutline().getAlpha();


    // holds temporary SkPath to store the result of intersections
    SkPath* frameAllocatedPath = nullptr;
    const SkPath* outlinePath = casterOutlinePath;

    // intersect the outline with the reveal clip, if present
    if (revealClipPath) {
        frameAllocatedPath = handler.allocPathForFrame();

        Op(*outlinePath, *revealClipPath, kIntersect_SkPathOp, frameAllocatedPath);
        outlinePath = frameAllocatedPath;
    }

    // intersect the outline with the clipBounds, if present
    if (properties().getClippingFlags() & CLIP_TO_CLIP_BOUNDS) {
        if (!frameAllocatedPath) {
            frameAllocatedPath = handler.allocPathForFrame();
        }

        Rect clipBounds;
        properties().getClippingRectForFlags(CLIP_TO_CLIP_BOUNDS, &clipBounds);
        SkPath clipBoundsPath;
        clipBoundsPath.addRect(clipBounds.left, clipBounds.top,
                clipBounds.right, clipBounds.bottom);

        Op(*outlinePath, clipBoundsPath, kIntersect_SkPathOp, frameAllocatedPath);
        outlinePath = frameAllocatedPath;
    }

    DisplayListOp* shadowOp  = new (handler.allocator()) DrawShadowOp(
            shadowMatrixXY, shadowMatrixZ, casterAlpha, outlinePath);
    handler(shadowOp, PROPERTY_SAVECOUNT, properties().getClipToBounds());
}
void RenderNode::issueOperationsOf3dChildren(ChildrenSelectMode mode,
        const Matrix4& initialTransform, const std::vector<ZDrawRenderNodeOpPair>& zTranslatedNodes,
        OpenGLRenderer& renderer, T& handler) {
    const int size = zTranslatedNodes.size();
    if (size == 0
            || (mode == ChildrenSelectMode::NegativeZChildren && zTranslatedNodes[0].key > 0.0f)
            || (mode == ChildrenSelectMode::PositiveZChildren && zTranslatedNodes[size - 1].key < 0.0f)) {
        // no 3d children to draw
        return;
    }

    // Apply the base transform of the parent of the 3d children. This isolates
    // 3d children of the current chunk from transformations made in previous chunks.
    int rootRestoreTo = renderer.save(SaveFlags::Matrix);
    renderer.setGlobalMatrix(initialTransform);

    /**
     * Draw shadows and (potential) casters mostly in order, but allow the shadows of casters
     * with very similar Z heights to draw together.
     *
     * This way, if Views A & B have the same Z height and are both casting shadows, the shadows are
     * underneath both, and neither's shadow is drawn on top of the other.
     */
    const size_t nonNegativeIndex = findNonNegativeIndex(zTranslatedNodes);
    size_t drawIndex, shadowIndex, endIndex;
    if (mode == ChildrenSelectMode::NegativeZChildren) {
        drawIndex = 0;
        endIndex = nonNegativeIndex;
        shadowIndex = endIndex; // draw no shadows
    } else {
        drawIndex = nonNegativeIndex;
        endIndex = size;
        shadowIndex = drawIndex; // potentially draw shadow for each pos Z child
    }

    DISPLAY_LIST_LOGD("%*s%d %s 3d children:", (handler.level() + 1) * 2, "",
            endIndex - drawIndex, mode == kNegativeZChildren ? "negative" : "positive");

    float lastCasterZ = 0.0f;
    while (shadowIndex < endIndex || drawIndex < endIndex) {
        if (shadowIndex < endIndex) {
            DrawRenderNodeOp* casterOp = zTranslatedNodes[shadowIndex].value;
            RenderNode* caster = casterOp->renderNode;
            const float casterZ = zTranslatedNodes[shadowIndex].key;
            // attempt to render the shadow if the caster about to be drawn is its caster,
            // OR if its caster's Z value is similar to the previous potential caster
            if (shadowIndex == drawIndex || casterZ - lastCasterZ < SHADOW_DELTA) {
                caster->issueDrawShadowOperation(casterOp->localMatrix, handler);

                lastCasterZ = casterZ; // must do this even if current caster not casting a shadow
                shadowIndex++;
                continue;
            }
        }

        // only the actual child DL draw needs to be in save/restore,
        // since it modifies the renderer's matrix
        int restoreTo = renderer.save(SaveFlags::Matrix);

        DrawRenderNodeOp* childOp = zTranslatedNodes[drawIndex].value;

        renderer.concatMatrix(childOp->localMatrix);
        childOp->skipInOrderDraw = false; // this is horrible, I'm so sorry everyone
        handler(childOp, renderer.getSaveCount() - 1, properties().getClipToBounds());
        childOp->skipInOrderDraw = true;

        renderer.restoreToCount(restoreTo);
        drawIndex++;
    }
    renderer.restoreToCount(rootRestoreTo);
}
void RenderNode::setViewProperties(OpenGLRenderer& renderer, T& handler) {
#if DEBUG_DISPLAY_LIST
    properties().debugOutputProperties(handler.level() + 1);
#endif
    if (properties().getLeft() != 0 || properties().getTop() != 0) {
        renderer.translate(properties().getLeft(), properties().getTop());
    }
    if (properties().getStaticMatrix()) {
        renderer.concatMatrix(*properties().getStaticMatrix());
    } else if (properties().getAnimationMatrix()) {
        renderer.concatMatrix(*properties().getAnimationMatrix());
    }
    if (properties().hasTransformMatrix()) {
        if (properties().isTransformTranslateOnly()) {
            renderer.translate(properties().getTranslationX(), properties().getTranslationY());
        } else {
            renderer.concatMatrix(*properties().getTransformMatrix());
        }
    }
    const bool isLayer = properties().effectiveLayerType() != LayerType::None;
    int clipFlags = properties().getClippingFlags();
    if (properties().getAlpha() < 1) {
        if (isLayer) {
            clipFlags &= ~CLIP_TO_BOUNDS; // bounds clipping done by layer
        }
        if (CC_LIKELY(isLayer || !properties().getHasOverlappingRendering())) {
            // simply scale rendering content's alpha
            renderer.scaleAlpha(properties().getAlpha());
        } else {
            // savelayer needed to create an offscreen buffer
            Rect layerBounds(0, 0, getWidth(), getHeight());
            if (clipFlags) {
                properties().getClippingRectForFlags(clipFlags, &layerBounds);
                clipFlags = 0; // all clipping done by savelayer
            }
            SaveLayerOp* op = new (handler.allocator()) SaveLayerOp(
                    layerBounds.left, layerBounds.top,
                    layerBounds.right, layerBounds.bottom,
                    (int) (properties().getAlpha() * 255),
                    SaveFlags::HasAlphaLayer | SaveFlags::ClipToLayer);
            handler(op, PROPERTY_SAVECOUNT, properties().getClipToBounds());
        }

        if (CC_UNLIKELY(ATRACE_ENABLED() && properties().promotedToLayer())) {
            // pretend alpha always causes savelayer to warn about
            // performance problem affecting old versions
            ATRACE_FORMAT("%s alpha caused saveLayer %dx%d", getName(),
                    static_cast<int>(getWidth()),
                    static_cast<int>(getHeight()));
        }
    }
    if (clipFlags) {
        Rect clipRect;
        properties().getClippingRectForFlags(clipFlags, &clipRect);
        ClipRectOp* op = new (handler.allocator()) ClipRectOp(
                clipRect.left, clipRect.top, clipRect.right, clipRect.bottom,
                SkRegion::kIntersect_Op);
        handler(op, PROPERTY_SAVECOUNT, properties().getClipToBounds());
    }

    // TODO: support nesting round rect clips
    if (mProperties.getRevealClip().willClip()) {
        Rect bounds;
        mProperties.getRevealClip().getBounds(&bounds);
        renderer.setClippingRoundRect(handler.allocator(), bounds, mProperties.getRevealClip().getRadius());
    } else if (mProperties.getOutline().willClip()) {
        renderer.setClippingOutline(handler.allocator(), &(mProperties.getOutline()));
    }
}
/**
 * Apply property-based transformations to input matrix
 *
 * If true3dTransform is set to true, the transform applied to the input matrix will use true 4x4
 * matrix computation instead of the Skia 3x3 matrix + camera hackery.
 */
void RenderNode::applyViewPropertyTransforms(mat4& matrix, bool true3dTransform) const {
    if (properties().getLeft() != 0 || properties().getTop() != 0) {
        matrix.translate(properties().getLeft(), properties().getTop());
    }
    if (properties().getStaticMatrix()) {
        mat4 stat(*properties().getStaticMatrix());
        matrix.multiply(stat);
    } else if (properties().getAnimationMatrix()) {
        mat4 anim(*properties().getAnimationMatrix());
        matrix.multiply(anim);
    }

    bool applyTranslationZ = true3dTransform && !MathUtils::isZero(properties().getZ());
    if (properties().hasTransformMatrix() || applyTranslationZ) {
        if (properties().isTransformTranslateOnly()) {
            matrix.translate(properties().getTranslationX(), properties().getTranslationY(),
                    true3dTransform ? properties().getZ() : 0.0f);
        } else {
            if (!true3dTransform) {
                matrix.multiply(*properties().getTransformMatrix());
            } else {
                mat4 true3dMat;
                true3dMat.loadTranslate(
                        properties().getPivotX() + properties().getTranslationX(),
                        properties().getPivotY() + properties().getTranslationY(),
                        properties().getZ());
                true3dMat.rotate(properties().getRotationX(), 1, 0, 0);
                true3dMat.rotate(properties().getRotationY(), 0, 1, 0);
                true3dMat.rotate(properties().getRotation(), 0, 0, 1);
                true3dMat.scale(properties().getScaleX(), properties().getScaleY(), 1);
                true3dMat.translate(-properties().getPivotX(), -properties().getPivotY());

                matrix.multiply(true3dMat);
            }
        }
    }
}
void RenderNode::copyTo(proto::RenderNode *pnode) {
    pnode->set_id(static_cast<uint64_t>(
            reinterpret_cast<uintptr_t>(this)));
    pnode->set_name(mName.string(), mName.length());

    proto::RenderProperties* pprops = pnode->mutable_properties();
    pprops->set_left(properties().getLeft());
    pprops->set_top(properties().getTop());
    pprops->set_right(properties().getRight());
    pprops->set_bottom(properties().getBottom());
    pprops->set_clip_flags(properties().getClippingFlags());
    pprops->set_alpha(properties().getAlpha());
    pprops->set_translation_x(properties().getTranslationX());
    pprops->set_translation_y(properties().getTranslationY());
    pprops->set_translation_z(properties().getTranslationZ());
    pprops->set_elevation(properties().getElevation());
    pprops->set_rotation(properties().getRotation());
    pprops->set_rotation_x(properties().getRotationX());
    pprops->set_rotation_y(properties().getRotationY());
    pprops->set_scale_x(properties().getScaleX());
    pprops->set_scale_y(properties().getScaleY());
    pprops->set_pivot_x(properties().getPivotX());
    pprops->set_pivot_y(properties().getPivotY());
    pprops->set_has_overlapping_rendering(properties().getHasOverlappingRendering());
    pprops->set_pivot_explicitly_set(properties().isPivotExplicitlySet());
    pprops->set_project_backwards(properties().getProjectBackwards());
    pprops->set_projection_receiver(properties().isProjectionReceiver());
    set(pprops->mutable_clip_bounds(), properties().getClipBounds());

    const Outline& outline = properties().getOutline();
    if (outline.getType() != Outline::Type::None) {
        proto::Outline* poutline = pprops->mutable_outline();
        poutline->clear_path();
        if (outline.getType() == Outline::Type::Empty) {
            poutline->set_type(proto::Outline_Type_Empty);
        } else if (outline.getType() == Outline::Type::ConvexPath) {
            poutline->set_type(proto::Outline_Type_ConvexPath);
            if (const SkPath* path = outline.getPath()) {
                set(poutline->mutable_path(), *path);
            }
        } else if (outline.getType() == Outline::Type::RoundRect) {
            poutline->set_type(proto::Outline_Type_RoundRect);
        } else {
            ALOGW("Uknown outline type! %d", static_cast<int>(outline.getType()));
            poutline->set_type(proto::Outline_Type_None);
        }
        poutline->set_should_clip(outline.getShouldClip());
        poutline->set_alpha(outline.getAlpha());
        poutline->set_radius(outline.getRadius());
        set(poutline->mutable_bounds(), outline.getBounds());
    } else {
        pprops->clear_outline();
    }

    const RevealClip& revealClip = properties().getRevealClip();
    if (revealClip.willClip()) {
        proto::RevealClip* prevealClip = pprops->mutable_reveal_clip();
        prevealClip->set_x(revealClip.getX());
        prevealClip->set_y(revealClip.getY());
        prevealClip->set_radius(revealClip.getRadius());
    } else {
        pprops->clear_reveal_clip();
    }

    pnode->clear_children();
    if (mDisplayList) {
        for (auto&& child : mDisplayList->getChildren()) {
            child->renderNode->copyTo(pnode->add_children());
        }
    }
}
void RenderNode::pushLayerUpdate(TreeInfo& info) {
    LayerType layerType = properties().effectiveLayerType();
    // If we are not a layer OR we cannot be rendered (eg, view was detached)
    // we need to destroy any Layers we may have had previously
    if (CC_LIKELY(layerType != LayerType::RenderLayer) || CC_UNLIKELY(!isRenderable())) {
        if (CC_UNLIKELY(mLayer)) {
            destroyLayer(mLayer);
            mLayer = nullptr;
        }
        return;
    }

    bool transformUpdateNeeded = false;
    if (!mLayer) {
        mLayer = createLayer(info.canvasContext.getRenderState(), getWidth(), getHeight());
#if !HWUI_NEW_OPS
        applyLayerPropertiesToLayer(info);
#endif
        damageSelf(info);
        transformUpdateNeeded = true;
    } else if (!layerMatchesWidthAndHeight(mLayer, getWidth(), getHeight())) {
#if HWUI_NEW_OPS
        // TODO: remove now irrelevant, currently enqueued damage (respecting damage ordering)
        // Or, ideally, maintain damage between frames on node/layer so ordering is always correct
        RenderState& renderState = mLayer->renderState;
        if (properties().fitsOnLayer()) {
            mLayer = renderState.layerPool().resize(mLayer, getWidth(), getHeight());
        } else {
#else
        if (!LayerRenderer::resizeLayer(mLayer, getWidth(), getHeight())) {
#endif
            destroyLayer(mLayer);
            mLayer = nullptr;
        }
        damageSelf(info);
        transformUpdateNeeded = true;
    }

    SkRect dirty;
    info.damageAccumulator->peekAtDirty(&dirty);

    if (!mLayer) {
        Caches::getInstance().dumpMemoryUsage();
        if (info.errorHandler) {
            std::ostringstream err;
            err << "Unable to create layer for " << getName();
            const int maxTextureSize = Caches::getInstance().maxTextureSize;
            if (getWidth() > maxTextureSize || getHeight() > maxTextureSize) {
                err << ", size " << getWidth() << "x" << getHeight()
                        << " exceeds max size " << maxTextureSize;
            } else {
                err << ", see logcat for more info";
            }
            info.errorHandler->onError(err.str());
        }
        return;
    }

    if (transformUpdateNeeded && mLayer) {
        // update the transform in window of the layer to reset its origin wrt light source position
        Matrix4 windowTransform;
        info.damageAccumulator->computeCurrentTransform(&windowTransform);
        mLayer->setWindowTransform(windowTransform);
    }

#if HWUI_NEW_OPS
    info.layerUpdateQueue->enqueueLayerWithDamage(this, dirty);
#else
    if (dirty.intersect(0, 0, getWidth(), getHeight())) {
        dirty.roundOut(&dirty);
        mLayer->updateDeferred(this, dirty.fLeft, dirty.fTop, dirty.fRight, dirty.fBottom);
    }
    // This is not inside the above if because we may have called
    // updateDeferred on a previous prepare pass that didn't have a renderer
    if (info.renderer && mLayer->deferredUpdateScheduled) {
        info.renderer->pushLayerUpdate(mLayer);
    }
#endif

    // There might be prefetched layers that need to be accounted for.
    // That might be us, so tell CanvasContext that this layer is in the
    // tree and should not be destroyed.
    info.canvasContext.markLayerInUse(this);
}

/**
 * Traverse down the the draw tree to prepare for a frame.
 *
 * MODE_FULL = UI Thread-driven (thus properties must be synced), otherwise RT driven
 *
 * While traversing down the tree, functorsNeedLayer flag is set to true if anything that uses the
 * stencil buffer may be needed. Views that use a functor to draw will be forced onto a layer.
 */
void RenderNode::prepareTreeImpl(TreeInfo& info, bool functorsNeedLayer) {
    info.damageAccumulator->pushTransform(this);

    if (info.mode == TreeInfo::MODE_FULL) {
        pushStagingPropertiesChanges(info);
    }
    uint32_t animatorDirtyMask = 0;
    if (CC_LIKELY(info.runAnimations)) {
        animatorDirtyMask = mAnimatorManager.animate(info);
    }

    bool willHaveFunctor = false;
    if (info.mode == TreeInfo::MODE_FULL && mStagingDisplayList) {
        willHaveFunctor = !mStagingDisplayList->getFunctors().empty();
    } else if (mDisplayList) {
        willHaveFunctor = !mDisplayList->getFunctors().empty();
    }
    bool childFunctorsNeedLayer = mProperties.prepareForFunctorPresence(
            willHaveFunctor, functorsNeedLayer);

    if (CC_UNLIKELY(mPositionListener.get())) {
        mPositionListener->onPositionUpdated(*this, info);
    }

    prepareLayer(info, animatorDirtyMask);
    if (info.mode == TreeInfo::MODE_FULL) {
        pushStagingDisplayListChanges(info);
    }
    prepareSubTree(info, childFunctorsNeedLayer, mDisplayList);
    pushLayerUpdate(info);

    info.damageAccumulator->popTransform();
}
示例#7
0
mainWidget::mainWidget(const char *name) : KTMainWindow(name) {
  md = new mainDlg(this);
  md->init();

  QPopupMenu *file = new QPopupMenu;
  CHECK_PTR( file );
  file->insertItem(i18n("&Save"),  md, SLOT(save()) );
  file->insertSeparator();
  file->insertItem(i18n("&Preferences..."),  md, SLOT(properties()) );
  file->insertSeparator();
  file->insertItem(i18n("&Quit"),  md, SLOT(quit()) );

  QPopupMenu *user = new QPopupMenu;
  CHECK_PTR(user);
  user->insertItem(i18n("&Edit..."), md, SLOT(useredit()) );
  user->insertItem(i18n("&Delete..."), md, SLOT(userdel()) );
  user->insertItem(i18n("&Add..."), md, SLOT(useradd()) );
  user->insertItem(i18n("&Set password..."), md, SLOT(setpwd()) );

  QPopupMenu *group = new QPopupMenu;
  CHECK_PTR(group);
  group->insertItem(i18n("&Edit..."), md, SLOT(grpedit()) );
  group->insertItem(i18n("&Delete..."), md, SLOT(grpdel()) );
  group->insertItem(i18n("&Add..."), md, SLOT(grpadd()) );

  QString tmp;
  tmp.sprintf(i18n("KUser version %s\n"
		"KDE project\n"
		"This program was created by\n"
		"Denis Pershin\n"
		"[email protected]\n"
		"Copyright 1997(c)"), _KU_VERSION);
  QPopupMenu *help = kapp->getHelpMenu(true, tmp);

  menubar = new KMenuBar( this );
  CHECK_PTR( menubar );
  menubar->insertItem(i18n("&File"), file );
  menubar->insertItem(i18n("&User"), user );
  menubar->insertItem(i18n("&Group"), group );
  menubar->insertSeparator();
  menubar->insertItem(i18n("&Help"), help );

  setMenu(menubar);

  toolbar = new KToolBar(this, "toolbar");
  QPixmap pix;

  pix = kapp->getIconLoader()->loadIcon("useradd.xpm");
  toolbar->insertButton(pix, 0, SIGNAL(clicked()), md, SLOT(useradd()), TRUE, i18n("Add user"));
  pix = kapp->getIconLoader()->loadIcon("userdel.xpm");
  toolbar->insertButton(pix, 0, SIGNAL(clicked()), md, SLOT(userdel()), TRUE, i18n("Delete user"));
  pix = kapp->getIconLoader()->loadIcon("useredit.xpm");
  toolbar->insertButton(pix, 0, SIGNAL(clicked()), md, SLOT(useredit()), TRUE, i18n("Edit user"));
  
  toolbar->insertSeparator();
  
  pix = kapp->getIconLoader()->loadIcon("grpadd.xpm");
  toolbar->insertButton(pix, 0, SIGNAL(clicked()), md, SLOT(grpadd()), TRUE, i18n("Add group"));
  pix = kapp->getIconLoader()->loadIcon("grpdel.xpm");
  toolbar->insertButton(pix, 0, SIGNAL(clicked()), md, SLOT(grpdel()), TRUE, i18n("Delete group"));
  pix = kapp->getIconLoader()->loadIcon("grpedit.xpm");
  toolbar->insertButton(pix, 0, SIGNAL(clicked()), md, SLOT(grpedit()), TRUE, i18n("Edit group"));
  toolbar->setBarPos(KToolBar::Top);

  addToolBar(toolbar);
  
  sbar = new KStatusBar(this);
  sbar->insertItem("Reading config", 0);
  
  setStatusBar(sbar);

  setView(md);

  resize(500, 400);

  // restore geometry settings
  KConfig *config = KApplication::getKApplication()->getConfig();
  config->setGroup( "Appearance" );
  QString geom = config->readEntry( "Geometry" );
  if (!geom.isEmpty()) {
    int width, height;
    sscanf( geom, "%dx%d", &width, &height );
    resize( width, height );
  }
  sbar->changeItem(i18n("Ready"), 0);
}
void RenderNode::issueOperations(OpenGLRenderer& renderer, T& handler) {
    if (mDisplayList->isEmpty()) {
        DISPLAY_LIST_LOGD("%*sEmpty display list (%p, %s)", handler.level() * 2, "",
                this, getName());
        return;
    }

#if HWUI_NEW_OPS
    const bool drawLayer = false;
#else
    const bool drawLayer = (mLayer && (&renderer != mLayer->renderer.get()));
#endif
    // If we are updating the contents of mLayer, we don't want to apply any of
    // the RenderNode's properties to this issueOperations pass. Those will all
    // be applied when the layer is drawn, aka when this is true.
    const bool useViewProperties = (!mLayer || drawLayer);
    if (useViewProperties) {
        const Outline& outline = properties().getOutline();
        if (properties().getAlpha() <= 0
                || (outline.getShouldClip() && outline.isEmpty())
                || properties().getScaleX() == 0
                || properties().getScaleY() == 0) {
            DISPLAY_LIST_LOGD("%*sRejected display list (%p, %s)", handler.level() * 2, "",
                    this, getName());
            return;
        }
    }

    handler.startMark(getName());

#if DEBUG_DISPLAY_LIST
    const Rect& clipRect = renderer.getLocalClipBounds();
    DISPLAY_LIST_LOGD("%*sStart display list (%p, %s), localClipBounds: %.0f, %.0f, %.0f, %.0f",
            handler.level() * 2, "", this, getName(),
            clipRect.left, clipRect.top, clipRect.right, clipRect.bottom);
#endif

    LinearAllocator& alloc = handler.allocator();
    int restoreTo = renderer.getSaveCount();
    handler(new (alloc) SaveOp(SaveFlags::MatrixClip),
            PROPERTY_SAVECOUNT, properties().getClipToBounds());

    DISPLAY_LIST_LOGD("%*sSave %d %d", (handler.level() + 1) * 2, "",
            SaveFlags::MatrixClip, restoreTo);

    if (useViewProperties) {
        setViewProperties<T>(renderer, handler);
    }

#if HWUI_NEW_OPS
    LOG_ALWAYS_FATAL("legacy op traversal not supported");
#else
    bool quickRejected = properties().getClipToBounds()
            && renderer.quickRejectConservative(0, 0, properties().getWidth(), properties().getHeight());
    if (!quickRejected) {
        Matrix4 initialTransform(*(renderer.currentTransform()));
        renderer.setBaseTransform(initialTransform);

        if (drawLayer) {
            handler(new (alloc) DrawLayerOp(mLayer),
                    renderer.getSaveCount() - 1, properties().getClipToBounds());
        } else {
            const int saveCountOffset = renderer.getSaveCount() - 1;
            const int projectionReceiveIndex = mDisplayList->projectionReceiveIndex;
            for (size_t chunkIndex = 0; chunkIndex < mDisplayList->getChunks().size(); chunkIndex++) {
                const DisplayList::Chunk& chunk = mDisplayList->getChunks()[chunkIndex];

                std::vector<ZDrawRenderNodeOpPair> zTranslatedNodes;
                buildZSortedChildList(chunk, zTranslatedNodes);

                issueOperationsOf3dChildren(ChildrenSelectMode::NegativeZChildren,
                        initialTransform, zTranslatedNodes, renderer, handler);

                for (size_t opIndex = chunk.beginOpIndex; opIndex < chunk.endOpIndex; opIndex++) {
                    DisplayListOp *op = mDisplayList->getOps()[opIndex];
#if DEBUG_DISPLAY_LIST
                    op->output(handler.level() + 1);
#endif
                    handler(op, saveCountOffset, properties().getClipToBounds());

                    if (CC_UNLIKELY(!mProjectedNodes.empty() && projectionReceiveIndex >= 0 &&
                        opIndex == static_cast<size_t>(projectionReceiveIndex))) {
                        issueOperationsOfProjectedChildren(renderer, handler);
                    }
                }

                issueOperationsOf3dChildren(ChildrenSelectMode::PositiveZChildren,
                        initialTransform, zTranslatedNodes, renderer, handler);
            }
        }
    }
#endif

    DISPLAY_LIST_LOGD("%*sRestoreToCount %d", (handler.level() + 1) * 2, "", restoreTo);
    handler(new (alloc) RestoreToCountOp(restoreTo),
            PROPERTY_SAVECOUNT, properties().getClipToBounds());

    DISPLAY_LIST_LOGD("%*sDone (%p, %s)", handler.level() * 2, "", this, getName());
    handler.endMark();
}
PaintLayerPainter::PaintResult PaintLayerPainter::paintLayerContents(GraphicsContext& context, const PaintLayerPaintingInfo& paintingInfoArg, PaintLayerFlags paintFlags, FragmentPolicy fragmentPolicy)
{
    ASSERT(m_paintLayer.isSelfPaintingLayer() || m_paintLayer.hasSelfPaintingLayerDescendant());
    ASSERT(!(paintFlags & PaintLayerAppliedTransform));

    bool isSelfPaintingLayer = m_paintLayer.isSelfPaintingLayer();
    bool isPaintingOverlayScrollbars = paintFlags & PaintLayerPaintingOverlayScrollbars;
    bool isPaintingScrollingContent = paintFlags & PaintLayerPaintingCompositingScrollingPhase;
    bool isPaintingCompositedForeground = paintFlags & PaintLayerPaintingCompositingForegroundPhase;
    bool isPaintingCompositedBackground = paintFlags & PaintLayerPaintingCompositingBackgroundPhase;
    bool isPaintingOverflowContents = paintFlags & PaintLayerPaintingOverflowContents;
    // Outline always needs to be painted even if we have no visible content. Also,
    // the outline is painted in the background phase during composited scrolling.
    // If it were painted in the foreground phase, it would move with the scrolled
    // content. When not composited scrolling, the outline is painted in the
    // foreground phase. Since scrolled contents are moved by paint invalidation in this
    // case, the outline won't get 'dragged along'.
    bool shouldPaintSelfOutline = isSelfPaintingLayer && !isPaintingOverlayScrollbars
        && ((isPaintingScrollingContent && isPaintingCompositedBackground)
            || (!isPaintingScrollingContent && isPaintingCompositedForeground))
        && m_paintLayer.layoutObject()->styleRef().hasOutline();
    bool shouldPaintContent = m_paintLayer.hasVisibleContent() && isSelfPaintingLayer && !isPaintingOverlayScrollbars;

    PaintResult result = FullyPainted;

    if (paintFlags & PaintLayerPaintingRootBackgroundOnly && !m_paintLayer.layoutObject()->isLayoutView() && !m_paintLayer.layoutObject()->isDocumentElement())
        return result;

    if (m_paintLayer.layoutObject()->isLayoutView() && toLayoutView(m_paintLayer.layoutObject())->frameView()->shouldThrottleRendering())
        return result;

    // Ensure our lists are up-to-date.
    m_paintLayer.stackingNode()->updateLayerListsIfNeeded();

    LayoutSize subpixelAccumulation = m_paintLayer.compositingState() == PaintsIntoOwnBacking ? m_paintLayer.subpixelAccumulation() : paintingInfoArg.subPixelAccumulation;
    ShouldRespectOverflowClip respectOverflowClip = shouldRespectOverflowClip(paintFlags, m_paintLayer.layoutObject());

    Optional<SubsequenceRecorder> subsequenceRecorder;
    if (shouldCreateSubsequence(m_paintLayer, context, paintingInfoArg, paintFlags)) {
        if (!shouldRepaintSubsequence(m_paintLayer, paintingInfoArg, respectOverflowClip, subpixelAccumulation)
            && SubsequenceRecorder::useCachedSubsequenceIfPossible(context, m_paintLayer))
            return result;
        subsequenceRecorder.emplace(context, m_paintLayer);
    }

    PaintLayerPaintingInfo paintingInfo = paintingInfoArg;

    LayoutPoint offsetFromRoot;
    m_paintLayer.convertToLayerCoords(paintingInfo.rootLayer, offsetFromRoot);
    offsetFromRoot.move(subpixelAccumulation);

    LayoutRect bounds = m_paintLayer.physicalBoundingBox(offsetFromRoot);
    if (!paintingInfo.paintDirtyRect.contains(bounds))
        result = MayBeClippedByPaintDirtyRect;

    LayoutRect rootRelativeBounds;
    bool rootRelativeBoundsComputed = false;

    if (paintingInfo.ancestorHasClipPathClipping && m_paintLayer.layoutObject()->isPositioned())
        UseCounter::count(m_paintLayer.layoutObject()->document(), UseCounter::ClipPathOfPositionedElement);

    // These helpers output clip and compositing operations using a RAII pattern. Stack-allocated-varibles are destructed in the reverse order of construction,
    // so they are nested properly.
    ClipPathHelper clipPathHelper(context, m_paintLayer, paintingInfo, rootRelativeBounds, rootRelativeBoundsComputed, offsetFromRoot, paintFlags);

    Optional<CompositingRecorder> compositingRecorder;
    // Blending operations must be performed only with the nearest ancestor stacking context.
    // Note that there is no need to composite if we're painting the root.
    // FIXME: this should be unified further into PaintLayer::paintsWithTransparency().
    bool shouldCompositeForBlendMode = (!m_paintLayer.layoutObject()->isDocumentElement() || m_paintLayer.layoutObject()->isSVGRoot()) && m_paintLayer.stackingNode()->isStackingContext() && m_paintLayer.hasNonIsolatedDescendantWithBlendMode();
    if (shouldCompositeForBlendMode || m_paintLayer.paintsWithTransparency(paintingInfo.globalPaintFlags())) {
        FloatRect compositingBounds = FloatRect(m_paintLayer.paintingExtent(paintingInfo.rootLayer, paintingInfo.subPixelAccumulation, paintingInfo.globalPaintFlags()));
        compositingRecorder.emplace(context, *m_paintLayer.layoutObject(),
            WebCoreCompositeToSkiaComposite(CompositeSourceOver, m_paintLayer.layoutObject()->style()->blendMode()),
            m_paintLayer.layoutObject()->opacity(), &compositingBounds);
    }

    PaintLayerPaintingInfo localPaintingInfo(paintingInfo);
    localPaintingInfo.subPixelAccumulation = subpixelAccumulation;

    PaintLayerFragments layerFragments;
    if (shouldPaintContent || shouldPaintSelfOutline || isPaintingOverlayScrollbars) {
        // Collect the fragments. This will compute the clip rectangles and paint offsets for each layer fragment.
        ClipRectsCacheSlot cacheSlot = (paintFlags & PaintLayerUncachedClipRects) ? UncachedClipRects : PaintingClipRects;
        if (fragmentPolicy == ForceSingleFragment)
            m_paintLayer.appendSingleFragmentIgnoringPagination(layerFragments, localPaintingInfo.rootLayer, localPaintingInfo.paintDirtyRect, cacheSlot, IgnoreOverlayScrollbarSize, respectOverflowClip, &offsetFromRoot, localPaintingInfo.subPixelAccumulation);
        else
            m_paintLayer.collectFragments(layerFragments, localPaintingInfo.rootLayer, localPaintingInfo.paintDirtyRect, cacheSlot, IgnoreOverlayScrollbarSize, respectOverflowClip, &offsetFromRoot, localPaintingInfo.subPixelAccumulation);
        if (shouldPaintContent) {
            // TODO(wangxianzhu): This is for old slow scrolling. Implement similar optimization for slimming paint v2.
            shouldPaintContent = atLeastOneFragmentIntersectsDamageRect(layerFragments, localPaintingInfo, paintFlags, offsetFromRoot);
            if (!shouldPaintContent)
                result = MayBeClippedByPaintDirtyRect;
        }
    }

    bool selectionOnly = localPaintingInfo.globalPaintFlags() & GlobalPaintSelectionOnly;

    { // Begin block for the lifetime of any filter.
        FilterPainter filterPainter(m_paintLayer, context, offsetFromRoot, layerFragments.isEmpty() ? ClipRect() : layerFragments[0].backgroundRect, localPaintingInfo, paintFlags,
            rootRelativeBounds, rootRelativeBoundsComputed);

        Optional<ScopedPaintChunkProperties> scopedPaintChunkProperties;
        if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
            if (const auto* objectProperties = m_paintLayer.layoutObject()->objectPaintProperties()) {
                PaintChunkProperties properties(context.paintController().currentPaintChunkProperties());
                if (TransformPaintPropertyNode* transform = objectProperties->transformForLayerContents())
                    properties.transform = transform;
                if (EffectPaintPropertyNode* effect = objectProperties->effect())
                    properties.effect = effect;
                scopedPaintChunkProperties.emplace(context.paintController(), properties);
            }
        }

        bool shouldPaintBackground = isPaintingCompositedBackground && shouldPaintContent && !selectionOnly;
        bool shouldPaintNegZOrderList = (isPaintingScrollingContent && isPaintingOverflowContents) || (!isPaintingScrollingContent && isPaintingCompositedBackground);
        bool shouldPaintOwnContents = isPaintingCompositedForeground && shouldPaintContent;
        bool shouldPaintNormalFlowAndPosZOrderLists = isPaintingCompositedForeground;
        bool shouldPaintOverlayScrollbars = isPaintingOverlayScrollbars;

        if (shouldPaintBackground) {
            paintBackgroundForFragments(layerFragments, context, paintingInfo.paintDirtyRect,
                localPaintingInfo, paintFlags);
        }

        if (shouldPaintNegZOrderList) {
            if (paintChildren(NegativeZOrderChildren, context, paintingInfo, paintFlags) == MayBeClippedByPaintDirtyRect)
                result = MayBeClippedByPaintDirtyRect;
        }

        if (shouldPaintOwnContents) {
            paintForegroundForFragments(layerFragments, context, paintingInfo.paintDirtyRect,
                localPaintingInfo, selectionOnly, paintFlags);
        }

        if (shouldPaintSelfOutline)
            paintSelfOutlineForFragments(layerFragments, context, localPaintingInfo, paintFlags);

        if (shouldPaintNormalFlowAndPosZOrderLists) {
            if (paintChildren(NormalFlowChildren | PositiveZOrderChildren, context, paintingInfo, paintFlags) == MayBeClippedByPaintDirtyRect)
                result = MayBeClippedByPaintDirtyRect;
        }

        if (shouldPaintOverlayScrollbars)
            paintOverflowControlsForFragments(layerFragments, context, localPaintingInfo, paintFlags);
    } // FilterPainter block

    bool shouldPaintMask = (paintFlags & PaintLayerPaintingCompositingMaskPhase) && shouldPaintContent && m_paintLayer.layoutObject()->hasMask() && !selectionOnly;
    bool shouldPaintClippingMask = (paintFlags & PaintLayerPaintingChildClippingMaskPhase) && shouldPaintContent && !selectionOnly;

    if (shouldPaintMask)
        paintMaskForFragments(layerFragments, context, localPaintingInfo, paintFlags);
    if (shouldPaintClippingMask) {
        // Paint the border radius mask for the fragments.
        paintChildClippingMaskForFragments(layerFragments, context, localPaintingInfo, paintFlags);
    }

    if (subsequenceRecorder)
        m_paintLayer.setPreviousPaintResult(result);
    return result;
}
示例#10
0
bool AkVCam::PluginInterface::createDevice(const std::string &deviceId,
                                           const std::wstring &description,
                                           const std::vector<VideoFormat> &formats)
{
    AkLoggerLog("AkVCam::PluginInterface::createDevice");

    StreamPtr stream;

    // Create one device.
    auto pluginRef = reinterpret_cast<CMIOHardwarePlugInRef>(this->d);
    auto device = std::make_shared<Device>(pluginRef);
    device->setDeviceId(deviceId);
    device->connectAddListener(this, &PluginInterface::addListener);
    device->connectRemoveListener(this, &PluginInterface::removeListener);
    this->m_devices.push_back(device);

    // Define device properties.
    device->properties().setProperty(kCMIOObjectPropertyName,
                                     description.c_str());
    device->properties().setProperty(kCMIOObjectPropertyManufacturer,
                                     CMIO_PLUGIN_VENDOR);
    device->properties().setProperty(kCMIODevicePropertyModelUID,
                                     CMIO_PLUGIN_PRODUCT);
    device->properties().setProperty(kCMIODevicePropertyLinkedCoreAudioDeviceUID,
                                     "");
    device->properties().setProperty(kCMIODevicePropertyLinkedAndSyncedCoreAudioDeviceUID,
                                     "");
    device->properties().setProperty(kCMIODevicePropertySuspendedByUser,
                                     UInt32(0));
    device->properties().setProperty(kCMIODevicePropertyHogMode,
                                     pid_t(-1),
                                     false);
    device->properties().setProperty(kCMIODevicePropertyDeviceMaster,
                                     pid_t(-1));
    device->properties().setProperty(kCMIODevicePropertyExcludeNonDALAccess,
                                     UInt32(0));
    device->properties().setProperty(kCMIODevicePropertyDeviceIsAlive,
                                     UInt32(1));
    device->properties().setProperty(kCMIODevicePropertyDeviceUID,
                                     deviceId.c_str());
    device->properties().setProperty(kCMIODevicePropertyTransportType,
                                     UInt32(kIOAudioDeviceTransportTypePCI));
    device->properties().setProperty(kCMIODevicePropertyDeviceIsRunningSomewhere,
                                     UInt32(0));

    if (device->createObject() != kCMIOHardwareNoError)
        goto createDevice_failed;

    stream = device->addStream();

    // Register one stream for this device.
    if (!stream)
        goto createDevice_failed;

    stream->setFormats(formats);
    stream->properties().setProperty(kCMIOStreamPropertyDirection, UInt32(0));

    if (device->registerStreams() != kCMIOHardwareNoError) {
        device->registerStreams(false);

        goto createDevice_failed;
    }

    // Register the device.
    if (device->registerObject() != kCMIOHardwareNoError) {
        device->registerObject(false);
        device->registerStreams(false);

        goto createDevice_failed;
    }

    device->setBroadcasting(this->d->m_ipcBridge.broadcaster(deviceId));
    device->setMirror(this->d->m_ipcBridge.isHorizontalMirrored(deviceId),
                      this->d->m_ipcBridge.isVerticalMirrored(deviceId));
    device->setScaling(this->d->m_ipcBridge.scalingMode(deviceId));
    device->setAspectRatio(this->d->m_ipcBridge.aspectRatioMode(deviceId));
    device->setSwapRgb(this->d->m_ipcBridge.swapRgb(deviceId));

    return true;

createDevice_failed:
    this->m_devices.erase(std::prev(this->m_devices.end()));

    return false;
}
示例#11
0
void KoPageLayout::loadOdf(const KoXmlElement &style)
{
    KoXmlElement  properties(KoXml::namedItemNS(style, KoXmlNS::style,
                                                "page-layout-properties"));

    if (!properties.isNull()) {
        KoPageLayout standard;

        // Page dimension -- width / height
        width = KoUnit::parseValue(properties.attributeNS(KoXmlNS::fo, "page-width"),
                                   standard.width);
        height = KoUnit::parseValue(properties.attributeNS(KoXmlNS::fo, "page-height"),
                                    standard.height);

        // Page orientation
        if (properties.attributeNS(KoXmlNS::style, "print-orientation", QString()) == "portrait")
            orientation = KoPageFormat::Portrait;
        else
            orientation = KoPageFormat::Landscape;

        // Margins.  Check if there is one "margin" attribute and use it for all
        // margins if there is.  Otherwise load the individual margins.
        if (properties.hasAttributeNS(KoXmlNS::fo, "margin")) {
            leftMargin  = KoUnit::parseValue(properties.attributeNS(KoXmlNS::fo, "margin"));
            topMargin = leftMargin;
            rightMargin = leftMargin;
            bottomMargin = leftMargin;
        } else {
            /*
                If one of the individual margins is specified then the default for the others is zero.
                Otherwise all of them are set to 20mm.
            */
            qreal defaultValue = 0;
            if (!(properties.hasAttributeNS(KoXmlNS::fo, "margin-left")
                    || properties.hasAttributeNS(KoXmlNS::fo, "margin-top")
                    || properties.hasAttributeNS(KoXmlNS::fo, "margin-right")
                    || properties.hasAttributeNS(KoXmlNS::fo, "margin-bottom")))
                defaultValue = MM_TO_POINT(20.0); // no margin specified at all, lets make it 20mm

            leftMargin   = KoUnit::parseValue(properties.attributeNS(KoXmlNS::fo, "margin-left"), defaultValue);
            topMargin    = KoUnit::parseValue(properties.attributeNS(KoXmlNS::fo, "margin-top"), defaultValue);
            rightMargin  = KoUnit::parseValue(properties.attributeNS(KoXmlNS::fo, "margin-right"), defaultValue);
            bottomMargin = KoUnit::parseValue(properties.attributeNS(KoXmlNS::fo, "margin-bottom"), defaultValue);
        }

        // Padding.  Same reasoning as for margins
        if (properties.hasAttributeNS(KoXmlNS::fo, "padding")) {
            leftPadding  = KoUnit::parseValue(properties.attributeNS(KoXmlNS::fo, "padding"));
            topPadding = leftPadding;
            rightPadding = leftPadding;
            bottomPadding = leftPadding;
        }
        else {
            leftPadding   = KoUnit::parseValue(properties.attributeNS(KoXmlNS::fo, "padding-left"));
            topPadding    = KoUnit::parseValue(properties.attributeNS(KoXmlNS::fo, "padding-top"));
            rightPadding  = KoUnit::parseValue(properties.attributeNS(KoXmlNS::fo, "padding-right"));
            bottomPadding = KoUnit::parseValue(properties.attributeNS(KoXmlNS::fo, "padding-bottom"));
        }

        // Parse border properties if there are any.
        border.loadOdf(properties);

        // guessFormat takes millimeters
        if (orientation == KoPageFormat::Landscape)
            format = KoPageFormat::guessFormat(POINT_TO_MM(height), POINT_TO_MM(width));
        else
            format = KoPageFormat::guessFormat(POINT_TO_MM(width), POINT_TO_MM(height));
    }
}
示例#12
0
WorkoutWindow::WorkoutWindow(Context *context) :
    GcWindow(context), draw(true), context(context), active(false), recording(false)
{
    setContentsMargins(0,0,0,0);
    setProperty("color", GColor(CTRAINPLOTBACKGROUND));

    setControls(NULL);
    ergFile = NULL;

    QVBoxLayout *main = new QVBoxLayout(this);
    QHBoxLayout *layout = new QHBoxLayout;
    QVBoxLayout *editor = new QVBoxLayout;

    connect(context, SIGNAL(configChanged(qint32)), this, SLOT(configChanged(qint32)));

    // the workout scene
    workout = new WorkoutWidget(this, context);

    // paint the TTE curve
    mmp = new WWMMPCurve(workout);

    // add a line between the dots
    line = new WWLine(workout);

    // block cursos
    bcursor = new WWBlockCursor(workout);

    // block selection
    brect = new WWBlockSelection(workout);

    // paint the W'bal curve
    wbline = new WWWBLine(workout, context);

    // telemetry
    telemetry = new WWTelemetry(workout, context);

    // add the power, W'bal scale
    powerscale = new WWPowerScale(workout, context);
    wbalscale = new WWWBalScale(workout, context);

    // lap markers
    lap = new WWLap(workout);

    // tte warning bar at bottom
    tte = new WWTTE(workout);

    // selection tool
    rect = new WWRect(workout);

    // guides always on top!
    guide = new WWSmartGuide(workout);

    // recording ...
    now = new WWNow(workout, context);

    // scroller, hidden until needed
    scroll = new QScrollBar(Qt::Horizontal, this);
    scroll->hide();

    // setup the toolbar
    toolbar = new QToolBar(this);
    toolbar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
    toolbar->setFloatable(true);
    toolbar->setIconSize(QSize(18,18));

    QIcon newIcon(":images/toolbar/new doc.png");
    newAct = new QAction(newIcon, tr("New"), this);
    connect(newAct, SIGNAL(triggered()), this, SLOT(newFile()));
    toolbar->addAction(newAct);

    QIcon saveIcon(":images/toolbar/save.png");
    saveAct = new QAction(saveIcon, tr("Save"), this);
    connect(saveAct, SIGNAL(triggered()), this, SLOT(saveFile()));
    toolbar->addAction(saveAct);

    QIcon saveAsIcon(":images/toolbar/saveas.png");
    saveAsAct = new QAction(saveAsIcon, tr("Save As"), this);
    connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs()));
    toolbar->addAction(saveAsAct);

    toolbar->addSeparator();

    //XXX TODO
    //XXXHelpWhatsThis *helpToolbar = new HelpWhatsThis(toolbar);
    //XXXtoolbar->setWhatsThis(helpToolbar->getWhatsThisText(HelpWhatsThis::ChartRides_Editor));

    // undo and redo deliberately at a distance from the
    // save icon, since accidentally hitting the wrong
    // icon in that instance would be horrible
    QIcon undoIcon(":images/toolbar/undo.png");
    undoAct = new QAction(undoIcon, tr("Undo"), this);
    connect(undoAct, SIGNAL(triggered()), workout, SLOT(undo()));
    toolbar->addAction(undoAct);

    QIcon redoIcon(":images/toolbar/redo.png");
    redoAct = new QAction(redoIcon, tr("Redo"), this);
    connect(redoAct, SIGNAL(triggered()), workout, SLOT(redo()));
    toolbar->addAction(redoAct);
    
    toolbar->addSeparator();

    QIcon drawIcon(":images/toolbar/edit.png");
    drawAct = new QAction(drawIcon, tr("Draw"), this);
    connect(drawAct, SIGNAL(triggered()), this, SLOT(drawMode()));
    toolbar->addAction(drawAct);

    QIcon selectIcon(":images/toolbar/select.png");
    selectAct = new QAction(selectIcon, tr("Select"), this);
    connect(selectAct, SIGNAL(triggered()), this, SLOT(selectMode()));
    toolbar->addAction(selectAct);

    selectAct->setEnabled(true);
    drawAct->setEnabled(false);

    toolbar->addSeparator();

    QIcon cutIcon(":images/toolbar/cut.png");
    cutAct = new QAction(cutIcon, tr("Cut"), this);
    cutAct->setEnabled(true);
    toolbar->addAction(cutAct);
    connect(cutAct, SIGNAL(triggered()), workout, SLOT(cut()));

    QIcon copyIcon(":images/toolbar/copy.png");
    copyAct = new QAction(copyIcon, tr("Copy"), this);
    copyAct->setEnabled(true);
    toolbar->addAction(copyAct);
    connect(copyAct, SIGNAL(triggered()), workout, SLOT(copy()));

    QIcon pasteIcon(":images/toolbar/paste.png");
    pasteAct = new QAction(pasteIcon, tr("Paste"), this);
    pasteAct->setEnabled(false);
    toolbar->addAction(pasteAct);
    connect(pasteAct, SIGNAL(triggered()), workout, SLOT(paste()));

    toolbar->addSeparator();

    QIcon propertiesIcon(":images/toolbar/properties.png");
    propertiesAct = new QAction(propertiesIcon, tr("Properties"), this);
    connect(propertiesAct, SIGNAL(triggered()), this, SLOT(properties()));
    toolbar->addAction(propertiesAct);

    QIcon zoomInIcon(":images/toolbar/zoom in.png");
    zoomInAct = new QAction(zoomInIcon, tr("Zoom In"), this);
    connect(zoomInAct, SIGNAL(triggered()), this, SLOT(zoomIn()));
    toolbar->addAction(zoomInAct);

    QIcon zoomOutIcon(":images/toolbar/zoom out.png");
    zoomOutAct = new QAction(zoomOutIcon, tr("Zoom Out"), this);
    connect(zoomOutAct, SIGNAL(triggered()), this, SLOT(zoomOut()));
    toolbar->addAction(zoomOutAct);

    // stretch the labels to the right hand side
    QWidget *empty = new QWidget(this);
    empty->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
    toolbar->addWidget(empty);


    xlabel = new QLabel("00:00");
    toolbar->addWidget(xlabel);

    ylabel = new QLabel("150w");
    toolbar->addWidget(ylabel);

    IFlabel = new QLabel("0 IF");
    toolbar->addWidget(IFlabel);

    TSSlabel = new QLabel("0 TSS");
    toolbar->addWidget(TSSlabel);

#if 0 // not yet!
    // get updates..
    connect(context, SIGNAL(telemetryUpdate(RealtimeData)), this, SLOT(telemetryUpdate(RealtimeData)));
    telemetryUpdate(RealtimeData());
#endif

    // editing the code...
    code = new CodeEditor(this);
    code->setContextMenuPolicy(Qt::NoContextMenu); // no context menu
    code->installEventFilter(this); // filter the undo/redo stuff
    code->hide();

    // WATTS and Duration for the cursor
    main->addWidget(toolbar);
    editor->addWidget(workout);
    editor->addWidget(scroll);
    layout->addLayout(editor);
    layout->addWidget(code);
    main->addLayout(layout);

    // make it look right
    saveAct->setEnabled(false);
    undoAct->setEnabled(false);
    redoAct->setEnabled(false);

    // watch for erg file selection
    connect(context, SIGNAL(ergFileSelected(ErgFile*)), this, SLOT(ergFileSelected(ErgFile*)));

    // watch for erg run/stop
    connect(context, SIGNAL(start()), this, SLOT(start()));
    connect(context, SIGNAL(stop()), this, SLOT(stop()));

    // text changed
    connect(code, SIGNAL(textChanged()), this, SLOT(qwkcodeChanged()));
    connect(code, SIGNAL(cursorPositionChanged()), workout, SLOT(hoverQwkcode()));

    // scrollbar
    connect(scroll, SIGNAL(sliderMoved(int)), this, SLOT(scrollMoved()));

    // set the widgets etc
    configChanged(CONFIG_APPEARANCE);
}
示例#13
0
文件: srv-prop.c 项目: IR4T4/xqf
static GtkWidget *server_info_page (struct server *s) {
	GtkWidget *page_vbox;
	GtkWidget *table;
	GtkWidget *frame;
	GtkWidget *hbox;
	GtkWidget *vbox;
	GtkWidget *label;
	GSList *sources;
	GSList *list;

	struct master *m;
	struct server_props *props;
	char buf[32];
	GList *cfgs;
	int slots_buffer;
	guint row = 0;



	props = properties (s);

	page_vbox = gtk_vbox_new (FALSE, 8);
	gtk_container_set_border_width (GTK_CONTAINER (page_vbox), 8);

	/* Address */

	table = gtk_table_new (6, 4, FALSE);
	gtk_table_set_row_spacings (GTK_TABLE (table), 4);
	gtk_table_set_col_spacings (GTK_TABLE (table), 8);
	gtk_box_pack_start (GTK_BOX (page_vbox), table, FALSE, FALSE, 0);

	gtk_table_set_col_spacing (GTK_TABLE (table), 1, 16);

	label = gtk_label_new (_("IP Address:"));
	gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
	gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, row, row+1);
	gtk_widget_show (label);

	label = gtk_label_new (inet_ntoa (s->host->ip));
	gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
	gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 2, row, row+1);
	gtk_widget_show (label);

	label = gtk_label_new (_("Port:"));
	gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
	gtk_table_attach_defaults (GTK_TABLE (table), label, 2, 3, row, row+1);
	gtk_widget_show (label);

	g_snprintf (buf, 32, "%d", s->port);

	label = gtk_label_new (buf);
	gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
	gtk_table_attach_defaults (GTK_TABLE (table), label, 3, 4, row, row+1);
	gtk_widget_show (label);

	row++;

	label = gtk_label_new (_("Host Name:"));
	gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
	gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, row, row+1);
	gtk_widget_show (label);

	if (s->host->name) {
		label = gtk_label_new (s->host->name);
		gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
		gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 4, row, row+1);
		gtk_widget_show (label);
	}

	row++;

	label = gtk_label_new (_("Country:"));
	gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
	gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, row, row+1);
	gtk_widget_show (label);

#ifdef USE_GEOIP
	if (geoip_name_by_id(s->country_id)) {
		GtkWidget* hbox = gtk_hbox_new (FALSE, 4);
		struct pixmap* pix = get_pixmap_for_country(s->country_id);
		if (pix) {
			GtkWidget *pixmap = gtk_pixmap_new(pix->pix,pix->mask);
			gtk_box_pack_start (GTK_BOX (hbox), pixmap, FALSE, FALSE, 0);
			gtk_widget_show (pixmap);
		}

		label = gtk_label_new (geoip_name_by_id(s->country_id));
		gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
		gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
		gtk_widget_show (label);

		gtk_table_attach_defaults (GTK_TABLE (table), hbox, 1, 4, row, row+1);
		gtk_widget_show (hbox);
	}
#endif

	row++;

	label = gtk_label_new (_("Refreshed:"));
	gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
	gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, row, row+1);
	gtk_widget_show (label);

	if (s->refreshed) {
		char* str = timet2string(&s->refreshed);

		label = gtk_label_new (str);
		g_free(str);
		gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
		gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 4, row, row+1);
		gtk_widget_show (label);
	}

	row++;

	// translator: last time and date the server answered the query
	label = gtk_label_new (_("Last answer:"));
	gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
	gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, row, row+1);
	gtk_widget_show (label);

	if (s->last_answer) {
		GtkStyle *style;
		GdkColor color;
		time_t max_days = 3; // XXX: hardcoded, has to be configurable some time
		char* str = timet2string(&s->last_answer);

		label = gtk_label_new (str);
		g_free(str);
		gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
		gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 4, row, row+1);

		if (s->last_answer + max_days*24*60*60 < s->refreshed) {
			// XXX: I don't know if that is the correct way, it's undocumented :-(
			style = gtk_widget_get_style(label);
			gdk_color_parse("red",&color);

			style->fg [GTK_STATE_NORMAL]   = color;
			style->fg [GTK_STATE_ACTIVE]   = color;
			style->fg [GTK_STATE_PRELIGHT] = color;
			style->fg [GTK_STATE_SELECTED] = color;
			style->fg [GTK_STATE_INSENSITIVE] = color;

			gtk_widget_set_style (label, style);
		}

		gtk_widget_show (label);
	}

	row++;

	/*pulp*/ /*Reserved Slots spin widget*/


	if (props) {
		if (props->reserved_slots) {


			slots_buffer=props->reserved_slots;
		}

		else {
			slots_buffer=0;
		}
	}

	else {
		slots_buffer=0;
	}



	label = gtk_label_new (_("Reserved Slots:"));
	gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
	gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, row, row+1);
	gtk_widget_show (label);


	adj = (GtkAdjustment *) gtk_adjustment_new (slots_buffer, 0, 9, 1, 2,0);
	spinner = gtk_spin_button_new (adj, 0, 0);
	gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinner), TRUE);
	gtk_spin_button_set_update_policy(GTK_SPIN_BUTTON (spinner), GTK_UPDATE_IF_VALID);
	gtk_table_attach_defaults (GTK_TABLE (table), spinner, 1, 2, row, row+1);
	gtk_widget_show (spinner);



	gtk_widget_show (table);

	/* Sources */

	frame = gtk_frame_new (_("Sources"));
	gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN);
	gtk_box_pack_start (GTK_BOX (page_vbox), frame, FALSE, FALSE, 0);

	vbox = gtk_vbox_new (FALSE, 4);
	gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
	gtk_container_add (GTK_CONTAINER (frame), vbox);

	sources = references_to_server (s);

	for (list = sources; list; list = list->next) {
		m = (struct master *) list->data;

		label = gtk_label_new (_(m->name));
		gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
		gtk_widget_show (label);
	}

	g_slist_free (sources);

	gtk_widget_show (vbox);
	gtk_widget_show (frame);

	/* Custom CFG */

	hbox = gtk_hbox_new (FALSE, 8);
	gtk_box_pack_start (GTK_BOX (page_vbox), hbox, FALSE, FALSE, 0);

	customcfg_combo = gtk_combo_new ();
	gtk_entry_set_max_length (GTK_ENTRY (GTK_COMBO (customcfg_combo)->entry), 
			256);
	gtk_widget_set_usize (GTK_COMBO (customcfg_combo)->entry, 112, -1);

	if ((games[s->type].flags & GAME_CONNECT) != 0 && 
			games[s->type].custom_cfgs) {

		cfgs = (*games[s->type].custom_cfgs) (&games[s->type], NULL, s->game);

		combo_set_vals (customcfg_combo, cfgs, 
				(props && props->custom_cfg)? props->custom_cfg : NULL);
		if (cfgs) {
			g_list_foreach (cfgs, (GFunc) g_free, NULL);
			g_list_free (cfgs);
		}
	}
	else {
		gtk_widget_set_sensitive (customcfg_combo, FALSE);
	}

	gtk_box_pack_end (GTK_BOX (hbox), customcfg_combo, FALSE, FALSE, 0);
	gtk_widget_show (customcfg_combo);

	label = gtk_label_new (_("Custom CFG:"));
	gtk_box_pack_end (GTK_BOX (hbox), label, FALSE, FALSE, 0);
	gtk_widget_show (label);

	gtk_widget_show (hbox);

	gtk_widget_show (page_vbox);

	return page_vbox;
}
示例#14
0
文件: srv-prop.c 项目: IR4T4/xqf
static void set_new_properties (GtkWidget *widget, struct server *s) {
	struct server_props *props;
	char *customcfg;
	char *srvpwd;
	char *spectpwd;
	char *rconpwd;
	int   reserved;
	int   sucks;
	char* comment = NULL;

	customcfg = strdup_strip (gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (customcfg_combo)->entry)));

	srvpwd = strdup_strip (gtk_entry_get_text (GTK_ENTRY (password_entry)));
	spectpwd = strdup_strip (gtk_entry_get_text (GTK_ENTRY (spectator_entry)));
	rconpwd = strdup_strip (gtk_entry_get_text (GTK_ENTRY (rcon_entry)));
	reserved = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spinner));
	sucks = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (sucks_check_button));
	comment = gtk_editable_get_chars (GTK_EDITABLE (comment_text), 0, -1);

	props = properties (s);

	if (props) {
		if (customcfg || srvpwd || spectpwd || rconpwd || reserved || sucks || comment) {
			g_free (props->custom_cfg);
			props->custom_cfg = customcfg;

			g_free (props->server_password);
			props->server_password = srvpwd;

			g_free (props->spectator_password);
			props->spectator_password = spectpwd;

			g_free (props->rcon_password);
			props->rcon_password = rconpwd;

			props->reserved_slots = reserved;

			props->sucks = sucks;

			g_free(props->comment);
			props->comment = comment;
		}
		else {
			props_list = g_slist_remove (props_list, props);
			props_free (props);
		}
	}
	else {
		if (customcfg || srvpwd || spectpwd || rconpwd || reserved || sucks || comment) {
			props = properties_new (s->host, s->port);
			props->custom_cfg = customcfg;
			props->server_password = srvpwd;
			props->spectator_password = spectpwd;
			props->rcon_password = rconpwd;
			props->reserved_slots = reserved;
			props->sucks = sucks;
			props->comment = comment;
		}
	}

	props_save ();
}
示例#15
0
/*! MyWindow constructor
 * \param w - window width
 * \param h - window hight
 */
MyWindow::MyWindow(int w, int h) : num_of_colors(18)
{
    myBar = new QTabWidget(this);
    setCentralWidget(myBar);
    m_width = w;
    m_height = h;
    tab_number = 0;
    number_of_tabs = 0;
    testlayer = new Qt_layer( myBar );
    colors_flag = true;
    statusBar();

    m_scailing_factor = 2;

    // Traits Group
    QActionGroup *traitsGroup = new QActionGroup( this ); // Connected later
    traitsGroup->setExclusive( TRUE );

    setSegmentTraits = new QAction("Segment Traits",
                                   QPixmap( (const char**)line_xpm ),
                                   "&Segment Traits", 0 ,traitsGroup,
                                   "Segment Traits" );
    setSegmentTraits->setToggleAction( TRUE );

    setPolylineTraits = new QAction("Polyline Traits",
                                    QPixmap( (const char**)polyline_xpm ),
                                    "&Polyline Traits", 0 , traitsGroup,
                                    "Polyline Traits" );
    setPolylineTraits->setToggleAction( TRUE );

#ifdef CGAL_USE_CORE
    setConicTraits = new QAction("Conic Traits",
                                 QPixmap( (const char**)conic_xpm ),
                                 "&Conic Traits", 0 , traitsGroup,
                                 "Conic Traits" );
    setConicTraits->setToggleAction( TRUE );
#endif

    // Snap Mode Group

    setSnapMode = new QAction("Snap Mode", QPixmap( (const char**)snapvertex_xpm ),
                              "&Snap Mode", 0 , this, "Snap Mode" );
    setSnapMode->setToggleAction( TRUE );

    setGridSnapMode = new QAction("Grid Snap Mode",
                                  QPixmap( (const char**)snapgrid_xpm ),
                                  "&Grid Snap Mode", 0 , this,
                                  "Grid Snap Mode" );
    setGridSnapMode->setToggleAction( TRUE );

    // insert - delete - point_location Mode Group
    QActionGroup *modeGroup = new QActionGroup( this ); // Connected later
    modeGroup->setExclusive( TRUE );

    insertMode = new QAction("Insert", QPixmap( (const char**)insert_xpm ),
                             "&Insert", 0 , modeGroup, "Insert" );
    insertMode->setToggleAction( TRUE );

    deleteMode = new QAction("Delete", QPixmap( (const char**)delete_xpm ),
                             "&Delete", 0 , modeGroup, "Delete" );
    deleteMode->setToggleAction( TRUE );

    pointLocationMode = new QAction("PointLocation",
                                    QPixmap( (const char**)pointlocation_xpm ),
                                    "&Point Location", 0 , modeGroup,
                                    "Point Location" );
    pointLocationMode->setToggleAction( TRUE );

    rayShootingUpMode = new QAction("RayShootingUp",
                                    QPixmap( (const char**)demo_rayshoot_up_xpm ),
                                    "&Ray Shooting Up", 0 , modeGroup,
                                    "Ray Shooting Up" );
    rayShootingUpMode->setToggleAction( TRUE );

    rayShootingDownMode = new QAction("RayShootingDown",
                                      QPixmap( (const char**)demo_rayshoot_down_xpm ),
                                      "&Ray Shooting Down", 0 , modeGroup,
                                      "Ray Shooting Down" );
    rayShootingDownMode->setToggleAction( TRUE );

    dragMode = new QAction("Drag", QPixmap( (const char**)hand_xpm ),
                           "&Drag", 0 , modeGroup, "Drag" );
    dragMode->setToggleAction( TRUE );

    mergeMode = new QAction("Merge", QPixmap( (const char**)merge_xpm ),
                            "&Merge", 0 , modeGroup, "Merge" );
    mergeMode->setToggleAction( TRUE );

    splitMode = new QAction("Split", QPixmap( (const char**)split_xpm ),
                            "&Split", 0 , modeGroup, "Split" );
    splitMode->setToggleAction( TRUE );

    fillfaceMode = new QAction("Fill", QPixmap( (const char**)demo_fill_xpm ),
                               "&Fill", 0 , modeGroup, "Fill" );
    fillfaceMode->setToggleAction( TRUE );



    // zoom in
    zoominBt = new QAction("Zoom in", QPixmap( (const char**)zoomin_xpm ),
                           "&Zoom in", 0 , this, "Zoom in" );
    // zoom out
    zoomoutBt = new QAction("Zoom out", QPixmap( (const char**)zoomout_xpm ),
                            "&Zoom out", 0 , this, "Zoom out" );

    // color dialog
    color_dialog_bt = new QAction("Choose color", QPixmap( (const char**)demo_colors_xpm ),
                                  "&choose color", 0 , this, "choose color" );

    lower_env_dialog_bt = new QAction("Lower envelope", QPixmap( (const char**)lower_env_xpm ),
                                      "&lower envelope", 0, this, "Lower envelop" );
    lower_env_dialog_bt->setToggleAction( TRUE );

    upper_env_dialog_bt = new QAction("Upper envelope", QPixmap( (const char**)upper_env_xpm ),
                                      "&upper envelope", 0, this, "Upper envelop" );
    upper_env_dialog_bt->setToggleAction( TRUE );

#ifdef CGAL_USE_CORE
    // Conic Type Group
    QActionGroup *conicTypeGroup = new QActionGroup( this ); // Connected later
    conicTypeGroup->setExclusive( TRUE );

    setCircle = new QAction("Circle",
                            QPixmap( (const char**)demo_conic_circle_xpm ),
                            "&Circle", 0 ,conicTypeGroup,
                            "Circle" );
    setCircle->setToggleAction( TRUE );
    setSegment = new QAction("Segment",
                             QPixmap( (const char**)demo_conic_segment_xpm ),
                             "&Segment", 0 ,conicTypeGroup,
                             "Segment" );
    setSegment->setToggleAction( TRUE );
    setEllipse = new QAction("Ellipse",
                             QPixmap( (const char**)demo_conic_ellipse_xpm ),
                             "&Ellipse", 0 ,conicTypeGroup,
                             "Ellipse" );
    setEllipse->setToggleAction( TRUE );
    setParabola = new QAction("3 Points Arc",
                              QPixmap( (const char**)demo_conic_3points_xpm ),
                              "&3 Points Arc", 0 ,conicTypeGroup,
                              "3 Points Arc" );
    setParabola->setToggleAction( TRUE );
    setHyperbola = new QAction("5 Points Arc",
                               QPixmap( (const char**)demo_conic_5points_xpm ),
                               "&5 Points Arc", 0 ,conicTypeGroup,
                               "5 Points Arc" );
    setHyperbola->setToggleAction( TRUE );
#endif

    //create a timer for checking if somthing changed
    QTimer *timer = new QTimer( this );
    connect( timer, SIGNAL(timeout()),
             this, SLOT(timer_done()) );
    timer->start( 200, FALSE );

    // file menu
    QPopupMenu * file = new QPopupMenu( this );
    menuBar()->insertItem( "&File", file );
    file->insertItem("&Open Segment File...", this, SLOT(fileOpenSegment()));
    file->insertItem("&Open Polyline File...", this, SLOT(fileOpenPolyline()));
    \

#ifdef CGAL_USE_CORE
    file->insertItem("&Open Conic File...", this, SLOT(fileOpenConic()));
#endif

    file->insertItem("&Open Segment Arr File...", this, SLOT(fileOpenSegmentPm()));
    file->insertItem("&Open Polyline Arr File...", this, SLOT(fileOpenPolylinePm()));
    //file->insertItem("&Open Conic Pm File", this, SLOT(fileOpenConicPm()));
    file->insertItem("&Save...", this, SLOT(fileSave()));
    file->insertItem("&Save As...", this, SLOT(fileSaveAs()));
    //file->insertItem("&Save to ps...", this, SLOT(fileSave_ps()));
    file->insertSeparator();
    file->insertItem("&Print...", this , SLOT(print()));
    file->insertSeparator();
    file->insertItem( "&Close", this, SLOT(close()), CTRL+Key_X );
    file->insertItem( "&Quit", qApp, SLOT( closeAllWindows() ), CTRL+Key_Q );
    menuBar()->insertSeparator();

    // tab menu
    QPopupMenu * tab = new QPopupMenu( this );
    menuBar()->insertItem( "&Tab", tab );
    tab->insertItem("Add &Segment Tab", this, SLOT(add_segment_tab()));
    tab->insertItem("Add &Polyline Tab", this, SLOT(add_polyline_tab()));

#ifdef CGAL_USE_CORE
    tab->insertItem("Add &Conic Tab", this, SLOT(add_conic_tab()));
    tab->insertSeparator();
#endif

    tab->insertItem("Remove &Tab", this, SLOT(remove_tab()));
    menuBar()->insertSeparator();

    // mode menu
    QPopupMenu * mode = new QPopupMenu( this );
    menuBar()->insertItem( "&Mode", mode );
    insertMode->addTo( mode );
    deleteMode->addTo( mode );
    pointLocationMode->addTo( mode );
    rayShootingUpMode->addTo( mode );
    rayShootingDownMode->addTo( mode );
    dragMode->addTo( mode );
    mergeMode->addTo( mode );
    splitMode->addTo( mode );
    fillfaceMode->addTo( mode );
    menuBar()->insertSeparator();

    // snap mode menu
    QPopupMenu * snap_mode = new QPopupMenu( this );
    menuBar()->insertItem( "&Snap mode", snap_mode );
    setSnapMode->addTo(snap_mode);
    setGridSnapMode->addTo(snap_mode);
    menuBar()->insertSeparator();

    // traits menu
    QPopupMenu * traits = new QPopupMenu( this );
    menuBar()->insertItem( "&Traits Type", traits );
    setSegmentTraits->addTo(traits);
    setPolylineTraits->addTo(traits);
#ifdef CGAL_USE_CORE
    setConicTraits->addTo(traits);
#endif

    // options menu
    QPopupMenu * options = new QPopupMenu( this );
    menuBar()->insertItem( "&Options", options );
    options->insertSeparator();
    options->insertItem("Overlay...", this, SLOT(overlay_pm()));
    options->insertSeparator();
    options->insertItem("Properties...", this, SLOT(properties()));
    options->insertSeparator();
    options->insertItem("Show Grid", this, SLOT(showGrid()));
    options->insertItem("Hide Grid", this, SLOT(hideGrid()));
    options->insertSeparator();
    //options->insertItem("Conic Type", this, SLOT(conicType()));
    //options->insertSeparator();
    options->insertItem("Unbounded Face Color...", this, SLOT(backGroundColor()));
    options->insertSeparator();
    options->insertItem("Edge Color...", this, SLOT(changeEdgeColor()));
    options->insertSeparator();
    options->insertItem("Vertex Color...", this, SLOT(changeVertexColor()));
    options->insertSeparator();
    options->insertItem("Point-Locaiton Strategy....", this ,
                        SLOT(pointLocationStrategy()));


    // help menu
    QPopupMenu * help = new QPopupMenu( this );
    menuBar()->insertItem( "&Help", help );
    help->insertItem("How To...", this, SLOT(howto()), Key_F1);
    help->insertSeparator();
    help->insertItem("&About...", this, SLOT(about()), CTRL+Key_A );
    help->insertItem("About &Qt...", this, SLOT(aboutQt()) );

    QToolBar *modeTools = new QToolBar( this, "mode operations" );
    modeTools->setLabel( "Mode Operations" );
    insertMode->addTo( modeTools );
    deleteMode->addTo( modeTools );
    dragMode->addTo( modeTools );
    pointLocationMode->addTo( modeTools );
    rayShootingUpMode->addTo( modeTools );
    rayShootingDownMode->addTo( modeTools );
    mergeMode->addTo( modeTools );
    splitMode->addTo( modeTools );
    fillfaceMode->addTo( modeTools );
    modeTools->addSeparator();

    QToolBar *snapModeTools = new QToolBar( this, "snapMode operations" );
    snapModeTools->setLabel( "Snap Mode Operations" );
    snapModeTools->addSeparator();
    setSnapMode->addTo( snapModeTools );
    setGridSnapMode->addTo( snapModeTools );
    snapModeTools->addSeparator();

    QToolBar *traitsTool = new QToolBar( this, "traits type" );
    traitsTool->setLabel( "Traits Type" );
    traitsTool->addSeparator();
    setSegmentTraits->addTo( traitsTool );
    setPolylineTraits->addTo( traitsTool );
#ifdef CGAL_USE_CORE
    setConicTraits->addTo( traitsTool );
#endif
    traitsTool->addSeparator();

    QToolBar *zoomTool = new QToolBar( this, "zoom" );
    zoomTool->setLabel( "Zoom" );
    zoomTool->addSeparator();
    zoomoutBt->addTo( zoomTool );
    zoominBt->addTo( zoomTool );
    zoomTool->addSeparator();

    QToolBar *colorTool = new QToolBar( this, "color" );
    colorTool->addSeparator();
    colorTool->setLabel("Choose color");
    color_dialog_bt->addTo(colorTool);
    colorTool->addSeparator();

    QToolBar *envelopeTool = new QToolBar( this, "envelopes" );
    envelopeTool->addSeparator();
    envelopeTool->setLabel("Envelopes");
    lower_env_dialog_bt->addTo(envelopeTool);
    upper_env_dialog_bt->addTo(envelopeTool);
    envelopeTool->addSeparator();


#ifdef CGAL_USE_CORE
    conicTypeTool = new QToolBar( this, "conic type" );
    conicTypeTool->setLabel( "Conic Type" );
    conicTypeTool->addSeparator();
    setSegment->addTo( conicTypeTool );
    setCircle->addTo( conicTypeTool );
    setEllipse->addTo( conicTypeTool );
    setParabola->addTo( conicTypeTool );
    setHyperbola->addTo( conicTypeTool );
#endif

    connect( zoomoutBt, SIGNAL( activated () ) ,
             this, SLOT( zoomout() ) );

    connect( zoominBt, SIGNAL( activated () ) ,
             this, SLOT( zoomin() ) );

    connect (color_dialog_bt , SIGNAL( activated()) ,
             this , SLOT(openColorDialog() ) );

    connect (lower_env_dialog_bt, SIGNAL(toggled(bool)) ,
             this, SLOT(lowerEnvelope(bool) ));

    connect (upper_env_dialog_bt, SIGNAL(toggled(bool)) ,
             this, SLOT(upperEnvelope(bool) ));
    // connect mode group
    connect( modeGroup, SIGNAL( selected(QAction*) ),
             this, SLOT( updateMode(QAction*) ) );

    // connect Traits Group
    connect( traitsGroup, SIGNAL( selected(QAction*) ),
             this, SLOT( updateTraitsType(QAction*) ) );

#ifdef CGAL_USE_CORE
    // connect Conic Type Group
    connect( conicTypeGroup, SIGNAL( selected(QAction*) ),
             this, SLOT( updateConicType(QAction*) ) );
#endif

    // connect Snap Mode

    connect( setSnapMode, SIGNAL( toggled( bool ) ) ,
             this, SLOT( updateSnapMode( bool ) ) );

    connect( setGridSnapMode, SIGNAL( toggled( bool ) ) ,
             this, SLOT( updateGridSnapMode( bool ) ) );

    // connect the change of current tab
    connect( myBar, SIGNAL( currentChanged(QWidget * )  ),
             this, SLOT( update() ) );

    colors = new QColor[num_of_colors];
    colors[0]  =  Qt::blue;
    colors[1]  =  Qt::gray;
    colors[2]  =  Qt::green;
    colors[3]  =  Qt::cyan;
    colors[4]  =  Qt::magenta;
    colors[5]  =  Qt::darkRed;
    colors[6]  =  Qt::darkGreen;
    colors[7]  =  Qt::darkBlue;
    colors[8]  =  Qt::darkMagenta;
    colors[9]  =  Qt::darkCyan;
    colors[10] =  Qt::yellow;
    colors[11] =  Qt::white;
    colors[12] =  Qt::darkGray;
    colors[13] =  Qt::gray;
    colors[14] =  Qt::red;
    colors[15] =  Qt::cyan;
    colors[16] =  Qt::darkYellow;
    colors[17] =  Qt::lightGray;

    //state flag
    old_state = 0;
    add_segment_tab();
    resize(m_width,m_height);
}